summaryrefslogtreecommitdiff
path: root/controller.cxx
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-21 07:56:19 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-21 07:56:19 +0800
commit66136b7dfa06a150089fdddd0705aef60aeada4a (patch)
tree9819c772d59762fc710275bdfed410cb60c1b883 /controller.cxx
parenta0653a4b7d95ed0217e7bcb9176b3f950f21fef8 (diff)
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.
Diffstat (limited to 'controller.cxx')
-rw-r--r--controller.cxx43
1 files changed, 29 insertions, 14 deletions
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<QQmlApplicationEngine*>(parent);
auto rootObjects = engine->rootObjects();
auto appWindow = rootObjects[0];
-
auto onboardingView = appWindow->findChild<QObject*>("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<User>("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<User*>(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();