diff options
-rw-r--r-- | Home.qml | 10 | ||||
-rw-r--r-- | TicketHistory.qml | 2 | ||||
-rw-r--r-- | TicketList.qml | 5 | ||||
-rw-r--r-- | controller.cxx | 56 | ||||
-rw-r--r-- | controller.hxx | 7 | ||||
m--------- | larva | 0 | ||||
-rw-r--r-- | main.qml | 11 |
7 files changed, 51 insertions, 40 deletions
@@ -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 <QDebug> #ifdef ANDROID #include <QStringBuilder> #endif @@ -7,7 +8,9 @@ #include <qrtclient/user.hxx> #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<QObject*>("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<QObject*>("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 <QThread> #include <qrtclient/ticket.hxx> -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 -Subproject ed24552f650521b2a299c8340d97ae4df6a9948 +Subproject da62a4a4d2320866966b95a71539c52ebe1e466 @@ -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 |