From 6e3ee14209963c9a7190cc76925cc736fea83218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Wed, 2 Oct 2019 21:30:32 +0800 Subject: Ticket history class --- qrtclient/tickethistory.hxx | 109 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 qrtclient/tickethistory.hxx (limited to 'qrtclient') diff --git a/qrtclient/tickethistory.hxx b/qrtclient/tickethistory.hxx new file mode 100644 index 0000000..7d68652 --- /dev/null +++ b/qrtclient/tickethistory.hxx @@ -0,0 +1,109 @@ +#ifndef QRTCLIENT_TICKET_HISTORY_HXX +#define QRTCLIENT_TICKET_HISTORY_HXX + +#include +#include +#include + +struct rtclient_ticket_history_list; + +namespace RTClient { + + class TicketHistory + { + public: + TicketHistory(struct rtclient_ticket_history* history) + : m_id{history->id} + , m_ticket{history->ticket} + , m_timeTaken{history->time_taken} + , m_type{history->type} + , m_description{history->description} + , m_content{history->content} + , m_creator{history->creator} + { + if (history->field) + m_field = QString{history->field}; + if (history->old_value) + m_oldValue = QString{history->old_value}; + if (history->new_value) + m_newValue = QString{history->new_value}; + if (history->data) + m_data = QString{history->data}; + } + unsigned int id() const { return m_id; } + unsigned int ticket() const { return m_ticket; } + unsigned int timeTaken() const { return m_timeTaken; } +// Q_ENUM(rtclient_ticket_history_type) + rtclient_ticket_history_type type() const { return m_type; } + QString const& field() const { return m_field; } + QString const& oldValue() const { return m_oldValue; } + QString const& newValue() const { return m_newValue; } + QString const& data() const { return m_data; } + QString const& description() const { return m_description; } + QString const& content() const { return m_content; } + QString const& creator() const { return m_creator; } + QDateTime const& created() const { return m_created; } + + private: + unsigned int m_id; + unsigned int m_ticket; + unsigned int m_timeTaken; + rtclient_ticket_history_type m_type; + QString m_field; + QString m_oldValue; + QString m_newValue; + QString m_data; + QString m_description; + QString m_content; + QString m_creator; + QDateTime m_created; +// QList* m_attachments; + }; + + class TicketHistoryList : public QAbstractListModel + { + Q_OBJECT + + public: + enum TicketHistoryRoles { + IdRole = Qt::UserRole + 1, + TicketRole, + TimeTakenRole, + TypeRole, + FieldRole, + OldValueRole, + NewValueRole, + DataRole, + DescriptionRole, + ContentRole, + CreatorRole, + CreatedRole/*, + AttachmentsRole*/ + }; + + explicit TicketHistoryList(QObject* parent = nullptr) + : QAbstractListModel{parent} {} + + int rowCount(QModelIndex const& parent + = QModelIndex()) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex& index + , int role = Qt::DisplayRole + ) const Q_DECL_OVERRIDE; + + public slots: + void update(rtclient_ticket_history_list* list); + + protected: + QHash roleNames() const Q_DECL_OVERRIDE; + + signals: + void updated(); + + private: + QList histories; + void addTicketHistory(TicketHistory const& history); + }; + +} + +#endif // QRTCLIENT_TICKET_HISTORY_HXX -- cgit v1.2.3 From 5567338ace1f591c6a0e7a54da0cf15667e3b462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Wed, 2 Oct 2019 22:47:49 +0800 Subject: Ticket history long format can be set --- qrtclient/client.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qrtclient') diff --git a/qrtclient/client.hxx b/qrtclient/client.hxx index b672620..e9e6b0f 100644 --- a/qrtclient/client.hxx +++ b/qrtclient/client.hxx @@ -63,7 +63,7 @@ namespace RTClient { , QString const& due = nullptr , QString const& text = nullptr); void searchTicket(QString const& owner); - void ticketHistory(int id); + void ticketHistory(int id, bool longFormat = false); signals: void loggedIn(QString const& name); -- cgit v1.2.3