From 47b72e1b1dd45b496f096262c919e8a730ab5a00 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: Mon, 30 Sep 2019 22:32:18 +0800 Subject: Ticket history is ready with subject, description, content, and creator --- Home.qml | 10 ---------- TicketHistory.qml | 2 +- TicketList.qml | 5 ++++- controller.cxx | 56 +++++++++++++++++++++++++++++-------------------------- controller.hxx | 7 ++++++- larva | 2 +- main.qml | 11 ++++++++++- 7 files changed, 52 insertions(+), 41 deletions(-) diff --git a/Home.qml b/Home.qml index bf1db86..2a8d1a3 100644 --- a/Home.qml +++ b/Home.qml @@ -3,16 +3,6 @@ import QtQuick.Controls 2.12 import "larva/features" HomeForm { - objectName: "home" - function ticketHistory(description, content, creator) { - pageView.push("TicketHistory.qml", { - "subject": subject - , "description": description - , "content": content - , "creator": creator - }) - } - menuButton.onClicked: drawer.open() profileButton.onClicked: pageView.push("Profile.qml") diff --git a/TicketHistory.qml b/TicketHistory.qml index 991b643..7fe07a5 100644 --- a/TicketHistory.qml +++ b/TicketHistory.qml @@ -51,7 +51,7 @@ TaskDetailForm { anchors.leftMargin: 0 anchors.top: separator.bottom anchors.topMargin: 8 - creator.text: creator + creatorText.text: creator ticketDescription.text: content } } diff --git a/TicketList.qml b/TicketList.qml index d253aa8..cb095d9 100644 --- a/TicketList.qml +++ b/TicketList.qml @@ -8,7 +8,10 @@ TaskListForm { width: parent.width height: task.height taskTitle.text: subject - itemDelegate.onClicked: window.ticketHistory(id) + itemDelegate.onClicked: { + window.ticketId(id) + window.ticketSubject(subject) + } } } } diff --git a/controller.cxx b/controller.cxx index 5a1d786..ddbd325 100644 --- a/controller.cxx +++ b/controller.cxx @@ -1,3 +1,4 @@ +#include #ifdef ANDROID #include #endif @@ -7,7 +8,9 @@ #include #include "controller.hxx" -Controller::Controller(QObject* parent) : QObject{parent} +Controller::Controller(QObject* parent) + : QObject{parent} + , m_ticketSubject{""} { #ifdef ANDROID QDir location{QStandardPaths::writableLocation(QStandardPaths @@ -63,44 +66,45 @@ Controller::Controller(QObject* parent) : QObject{parent} connect(client, &Client::searchedTicket, ticketList, &TicketList::update); - auto ticketHistory = [appWindow,this,&client]() { - auto homeView = appWindow->findChild("home"); - connect(client, &Client::gotTicketHistory, [homeView] - (rtclient_ticket_history_list* list) { - auto history = list->histories[list->length - 1]; - QMetaObject::invokeMethod(homeView - , "ticketHistory" - , Q_ARG(QString - , QString{history - ->description}) - , Q_ARG(QString - , QString{history - ->content}) - , Q_ARG(QString - , QString{history - ->creator})); - }); - }; - - connect(client, &Client::loggedIn, [appWindow,this,ticketHistory]() { + connect(client, &Client::loggedIn, [appWindow,this]() { auto loginView = appWindow->findChild("login"); - connect(ticketList, &TicketList::updated - , [loginView,this,ticketHistory]() { + connect(ticketList, &TicketList::updated, [loginView]() { QMetaObject::invokeMethod(loginView , "pushHome"); - ticketHistory(); - }); + }); }); - connect(appWindow, SIGNAL(ticketHistory(int)) + connect(appWindow, SIGNAL(ticketId(int)) , client, SLOT(ticketHistory(int))); + connect(appWindow, SIGNAL(ticketSubject(QString)) + , this, SLOT(setTicketSubject(QString))); + + connect(client, &Client::gotTicketHistory + , [appWindow,this](rtclient_ticket_history_list* list) { + auto history = list->histories[list->length - 1]; + QMetaObject::invokeMethod(appWindow, "ticketHistory" + , Q_ARG(QVariant, m_ticketSubject) + , Q_ARG(QVariant + , QString{history->description}) + , Q_ARG(QVariant + , QString{history->content}) + , Q_ARG(QVariant + , QString{history->creator})); + }); + connect(appWindow, SIGNAL(ticketNew(QString, QString)) , client, SLOT(ticketNew(QString, QString))); thread.start(); } +void Controller::setTicketSubject(QString const& subject) +{ + qDebug() << "Subject: " << subject; + if (m_ticketSubject != subject) m_ticketSubject = subject; +} + Controller::~Controller() { thread.quit(); diff --git a/controller.hxx b/controller.hxx index 04db899..1e9c7f8 100644 --- a/controller.hxx +++ b/controller.hxx @@ -4,7 +4,7 @@ #include #include -struct rtclient_user; +struct rtclient_ticket_history_list; class Controller : public QObject { @@ -16,10 +16,15 @@ class Controller : public QObject signals: void checked(QString const& name); + void gotTicketHistory(rtclient_ticket_history_list* list); + + private slots: + void setTicketSubject(QString const& subject); private: QThread thread; RTClient::TicketList* ticketList; + QString m_ticketSubject; }; #endif // CONTROLLER_HXX diff --git a/larva b/larva index ed24552..da62a4a 160000 --- a/larva +++ b/larva @@ -1 +1 @@ -Subproject commit ed24552f650521b2a299c8340d97ae4df6a9948b +Subproject commit da62a4a4d2320866966b95a71539c52ebe1e466d diff --git a/main.qml b/main.qml index 83eb694..26010e2 100644 --- a/main.qml +++ b/main.qml @@ -4,8 +4,17 @@ import "larva/features" ApplicationWindow { signal logIn(string name, string password) - signal ticketHistory(int id) + signal ticketId(int id) + signal ticketSubject(string subject) signal ticketNew(string queue, string requestor) + function ticketHistory(subject, description, content, creator) { + pageView.push("TicketHistory.qml", { + "subject": subject + , "description": description + , "content": content + , "creator": creator + }) + } id: window visible: true -- cgit v1.2.3