summaryrefslogtreecommitdiff
path: root/qrtclient
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-15 18:42:35 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-15 18:42:35 +0800
commitcd679da218281c5716001a4e2055451ab9bcc926 (patch)
tree43c1a719690062d4c0f65bbff593b7e5e23b5eb9 /qrtclient
A Qt Core based library that depends on librtclient
and can be used for a Qt based project
Diffstat (limited to 'qrtclient')
-rw-r--r--qrtclient/client.hxx30
-rw-r--r--qrtclient/ticket.hxx56
-rw-r--r--qrtclient/user.hxx165
3 files changed, 251 insertions, 0 deletions
diff --git a/qrtclient/client.hxx b/qrtclient/client.hxx
new file mode 100644
index 0000000..e32e83b
--- /dev/null
+++ b/qrtclient/client.hxx
@@ -0,0 +1,30 @@
+#ifndef QRTCLIENT_HXX
+#define QRTCLIENT_HXX
+
+#include <QObject>
+
+struct rt_user;
+struct rt_ticketlist;
+
+namespace RTClient {
+
+ class Client : public QObject
+ {
+ Q_OBJECT
+
+ public:
+ Client(QString const& url);
+ ~Client();
+
+ public slots:
+ void logIn(QString const& name, QString const& password);
+ void search(QString const& owner);
+
+ signals:
+ void logged(struct rt_user* user);
+ void foundTasks(struct rt_ticketlist* list);
+ };
+
+}
+
+#endif // QRTCLIENT_HXX
diff --git a/qrtclient/ticket.hxx b/qrtclient/ticket.hxx
new file mode 100644
index 0000000..af438ae
--- /dev/null
+++ b/qrtclient/ticket.hxx
@@ -0,0 +1,56 @@
+#ifndef QRTCLIENT_TICKET_HXX
+#define QRTCLIENT_TICKET_HXX
+
+#include <QAbstractListModel>
+
+struct rt_ticketlist;
+
+namespace RTClient {
+
+ class Ticket
+ {
+ public:
+ Ticket(QString subject) : m_subject{subject} {}
+ QString const& subject() const { return m_subject; }
+
+ private:
+ QString m_subject;
+ };
+
+ class TicketList : public QAbstractListModel
+ {
+ Q_OBJECT
+ Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
+
+ public:
+ enum TicketRoles {
+ SubjectRole = Qt::UserRole + 1,
+ };
+
+ explicit TicketList(QObject* parent = nullptr)
+ : QAbstractListModel{parent} {}
+ ~TicketList() {}
+
+ int rowCount(QModelIndex const& parent
+ = QModelIndex()) const Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex& index
+ , int role = Qt::DisplayRole
+ ) const Q_DECL_OVERRIDE;
+
+ protected:
+ QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
+
+ signals:
+ void rowCountChanged();
+
+ private:
+ QList<Ticket> tickets;
+ void addTicket(Ticket const& ticket);
+
+ private slots:
+ void addTickets(struct rt_ticketlist* ticketList);
+ };
+
+}
+
+#endif // QRTCLIENT_TICKET_HXX
diff --git a/qrtclient/user.hxx b/qrtclient/user.hxx
new file mode 100644
index 0000000..06d6a71
--- /dev/null
+++ b/qrtclient/user.hxx
@@ -0,0 +1,165 @@
+#ifndef QRTCLIENT_USER_HXX
+#define QRTCLIENT_USER_HXX
+
+#include <QObject>
+
+struct rt_user;
+
+namespace RTClient {
+
+ class User : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
+ Q_PROPERTY(QString emailAddress READ emailAddress WRITE setEmailAddress NOTIFY emailAddressChanged)
+ Q_PROPERTY(QString realName READ realName WRITE setRealName NOTIFY realNameChanged)
+ Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
+ Q_PROPERTY(QString organization READ organization WRITE setOrganization NOTIFY organizationChanged)
+ Q_PROPERTY(QString address1 READ address1 WRITE setAddress1 NOTIFY address1Changed)
+ Q_PROPERTY(QString address2 READ address2 WRITE setAddress2 NOTIFY address2Changed)
+ Q_PROPERTY(QString city READ city WRITE setCity NOTIFY cityChanged)
+ Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
+ Q_PROPERTY(QString zip READ zip WRITE setZip NOTIFY zipChanged)
+ Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
+ Q_PROPERTY(QString homePhone READ homePhone WRITE setHomePhone NOTIFY homePhoneChanged)
+ Q_PROPERTY(QString workPhone READ workPhone WRITE setWorkPhone NOTIFY workPhoneChanged)
+ Q_PROPERTY(QString mobilePhone READ mobilePhone WRITE setMobilePhone NOTIFY mobilePhoneChanged)
+ Q_PROPERTY(QString pagerPhone READ pagerPhone WRITE setPagerPhone NOTIFY pagerPhoneChanged)
+ Q_PROPERTY(QString lang READ lang WRITE setLang NOTIFY langChanged)
+ Q_PROPERTY(bool privileged READ privileged WRITE setPrivileged NOTIFY privilegedChanged)
+ Q_PROPERTY(bool disabled READ disabled WRITE setDisabled NOTIFY disabledChanged)
+ Q_PROPERTY(bool loggedIn READ loggedIn WRITE setLoggedIn NOTIFY loggedInChanged)
+
+ public:
+ explicit User(QObject* parent = nullptr)
+ : QObject{parent}
+ , m_id{""}
+ , m_name{""}
+ , m_password{""}
+ , m_emailAddress{""}
+ , m_realName{""}
+ , m_nickName{""}
+ , m_organization{""}
+ , m_gecos{""}
+ , m_address1{""}
+ , m_address2{""}
+ , m_city{""}
+ , m_state{""}
+ , m_zip{""}
+ , m_country{""}
+ , m_homePhone{""}
+ , m_workPhone{""}
+ , m_mobilePhone{""}
+ , m_pagerPhone{""}
+ , m_contactInfo{""}
+ , m_comments{""}
+ , m_lang{""}
+ , m_privileged{false}
+ , m_disabled{true}
+ , m_loggedIn{false}
+ {}
+ ~User() {}
+
+ QString const& id() const { return m_id; }
+ QString const& name() const { return m_name; }
+ QString const& password() const { return m_password; }
+ QString const& emailAddress() const { return m_emailAddress; }
+ QString const& realName() const { return m_realName; }
+ QString const& nickName() const { return m_nickName; }
+ QString const& organization() const { return m_organization; }
+ QString const& address1() const { return m_address1; }
+ QString const& address2() const { return m_address2; }
+ QString const& city() const { return m_city; }
+ QString const& state() const { return m_state; }
+ QString const& zip() const { return m_zip; }
+ QString const& country() const { return m_country; }
+ QString const& homePhone() const { return m_homePhone; }
+ QString const& workPhone() const { return m_workPhone; }
+ QString const& mobilePhone() const { return m_mobilePhone; }
+ QString const& pagerPhone() const { return m_pagerPhone; }
+ QString const& lang() const { return m_lang; }
+ bool privileged() const { return m_privileged; }
+ bool disabled() const { return m_disabled; }
+ bool loggedIn() const { return m_loggedIn; }
+
+ void setId(QString const& id);
+ void setName(QString const& name);
+ void setPassword(QString const& password);
+ void setEmailAddress(QString const& emailAddress);
+ void setRealName(QString const& realName);
+ void setNickName(QString const& nickName);
+ void setOrganization(QString const& organization);
+ void setAddress1(QString const& address1);
+ void setAddress2(QString const& address2);
+ void setCity(QString const& city);
+ void setState(QString const& state);
+ void setZip(QString const& zip);
+ void setCountry(QString const& country);
+ void setHomePhone(QString const& homePhone);
+ void setWorkPhone(QString const& workPhone);
+ void setMobilePhone(QString const& mobilePhone);
+ void setPagerPhone(QString const& pagerPhone);
+ void setLang(QString const& lang);
+ void setPrivileged(bool privileged);
+ void setDisabled(bool disabled);
+ void setLoggedIn(bool loggedIn);
+
+ signals:
+ void idChanged();
+ void nameChanged();
+ void passwordChanged();
+ void emailAddressChanged();
+ void realNameChanged();
+ void nickNameChanged();
+ void organizationChanged();
+ void gecosChanged();
+ void address1Changed();
+ void address2Changed();
+ void cityChanged();
+ void stateChanged();
+ void zipChanged();
+ void countryChanged();
+ void homePhoneChanged();
+ void workPhoneChanged();
+ void mobilePhoneChanged();
+ void pagerPhoneChanged();
+ void langChanged();
+ void privilegedChanged();
+ void disabledChanged();
+ void loggedInChanged();
+
+ private slots:
+ void update(struct rt_user* user);
+
+ private:
+ QString m_id;
+ QString m_name;
+ QString m_password;
+ QString m_emailAddress;
+ QString m_realName;
+ QString m_nickName;
+ QString m_organization;
+ QString m_gecos;
+ QString m_address1;
+ QString m_address2;
+ QString m_city;
+ QString m_state;
+ QString m_zip;
+ QString m_country;
+ QString m_homePhone;
+ QString m_workPhone;
+ QString m_mobilePhone;
+ QString m_pagerPhone;
+ QString m_contactInfo;
+ QString m_comments;
+ QString m_lang;
+ bool m_privileged;
+ bool m_disabled;
+ bool m_loggedIn;
+ };
+
+}
+
+#endif // QRTCLIENT_USER_HXX