From 66136b7dfa06a150089fdddd0705aef60aeada4a 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: Sat, 21 Sep 2019 07:56:19 +0800 Subject: User show slot result gets checked first by controller and only if the result is not null, implying the login is successful, then it will do a ticket search based on the logged in user's name. --- controller.cxx | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'controller.cxx') diff --git a/controller.cxx b/controller.cxx index 8e832b7..5ffe31f 100644 --- a/controller.cxx +++ b/controller.cxx @@ -13,38 +13,53 @@ Controller::Controller(QObject* parent) : QObject{parent} auto engine = static_cast(parent); auto rootObjects = engine->rootObjects(); auto appWindow = rootObjects[0]; - auto onboardingView = appWindow->findChild("onboarding"); - connect(onboardingView, SIGNAL(logIn(QString, QString)) - , client, SLOT(logIn(QString, QString))); - connect(client, SIGNAL(loggedIn(QString)) - , client, SLOT(userShow(QString))); - connect(onboardingView, SIGNAL(ticketNew(QString, QString)) - , client, SLOT(ticketNew(QString, QString))); - connect(onboardingView, SIGNAL(ticketSearch(QString)) - , client, SLOT(ticketSearch(QString))); - using RTClient::User; auto typeId = qmlRegisterSingletonType("KelakonUser", 0, 1, "User" - , [](QQmlEngine *engine, - QJSEngine *scriptEngine) -> QObject* { + , [](QQmlEngine *engine + , QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new User; }); auto user = engine->singletonInstance(typeId); + taskList = new RTClient::TicketList; + engine->rootContext()->setContextProperty("taskList", taskList); + + connect(onboardingView, SIGNAL(logIn(QString, QString)) + , client, SLOT(logIn(QString, QString))); + + connect(client, SIGNAL(loggedIn(QString)) + , client, SLOT(userShow(QString))); + connect(client, SIGNAL(userShown(rtclient_user*)) + , this, SLOT(check(rtclient_user*))); + + connect(this, SIGNAL(checked(rtclient_user*)) , user, SLOT(update(rtclient_user*))); - taskList = new RTClient::TicketList; - engine->rootContext()->setContextProperty("taskList", taskList); + connect(this, SIGNAL(checked(QString)) + , client, SLOT(ticketSearch(QString))); + connect(client, SIGNAL(ticketSearched(rtclient_ticketlist*)) , taskList, SLOT(update(rtclient_ticketlist*))); + + connect(onboardingView, SIGNAL(ticketNew(QString, QString)) + , client, SLOT(ticketNew(QString, QString))); + connect(taskList, SIGNAL(updated()), onboardingView, SLOT(pushHome())); thread.start(); } +void Controller::check(rtclient_user* user) +{ + if (user) { + emit checked(QString{user->name}); + emit checked(user); + } +} + Controller::~Controller() { thread.quit(); -- cgit v1.2.3