diff options
author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-02 22:55:58 +0800 |
---|---|---|
committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-02 22:55:58 +0800 |
commit | fcf4aea62d1914af4a39f56c0adac37af447c29e (patch) | |
tree | 0d68a1c8a3e55e2fa59f5c8f8bca26744b2d2d56 /tickethistory.cxx | |
parent | 117a8cf40b39d36fe2d5794c20fb6600e92f52e9 (diff) | |
parent | 5567338ace1f591c6a0e7a54da0cf15667e3b462 (diff) |
Merge branch 'master' into cmake
Diffstat (limited to 'tickethistory.cxx')
-rw-r--r-- | tickethistory.cxx | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tickethistory.cxx b/tickethistory.cxx new file mode 100644 index 0000000..4243d7c --- /dev/null +++ b/tickethistory.cxx @@ -0,0 +1,90 @@ +#include <cstddef> +#include "qrtclient/tickethistory.hxx" + +namespace RTClient { + + int TicketHistoryList::rowCount(QModelIndex const& parent) const + { + Q_UNUSED(parent) + return histories.count(); + } + + QVariant TicketHistoryList::data(QModelIndex const& index, int role) const + { + auto row = index.row(); + + if (row < 0 || row >= histories.count()) return QVariant(); + + auto history = histories[row]; + switch (role) { + case IdRole: + return history.id(); + case TicketRole: + return history.ticket(); + case TimeTakenRole: + return history.timeTaken(); + case TypeRole: + return history.type(); + case FieldRole: + return history.field(); + case OldValueRole: + return history.oldValue(); + case NewValueRole: + return history.newValue(); + case DataRole: + return history.data(); + case DescriptionRole: + return history.description(); + case ContentRole: + return history.content(); + case CreatorRole: + return history.creator(); + case CreatedRole: + return history.created(); + /* + case AttachmentsRole: + return history.attachments(); + */ + default: + return QVariant(); + } + } + + QHash<int, QByteArray> TicketHistoryList::roleNames() const + { + return QHash<int, QByteArray>{ + {IdRole, "id"} + , {TicketRole, "ticket"} + , {TimeTakenRole, "timeTaken"} + , {TypeRole, "type"} + , {FieldRole, "field"} + , {OldValueRole, "oldValue"} + , {NewValueRole, "newValue"} + , {DataRole, "data"} + , {DescriptionRole, "description"} + , {ContentRole, "content"} + , {CreatorRole, "creator"} + , {CreatedRole, "created"} +// , {AttachmentsRole, "attachments"} + }; + } + + void TicketHistoryList::addTicketHistory(TicketHistory const& history) + { + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + histories << history; + endInsertRows(); + } + + void TicketHistoryList::update(rtclient_ticket_history_list* list) + { + if (list) { + for (size_t i = 0; i < list->length; i++) + addTicketHistory + (TicketHistory{list->histories[i]}); + rtclient_ticket_history_list_free(list); + } + emit updated(); + } + +} |