summaryrefslogtreecommitdiff
path: root/controller.cxx
diff options
context:
space:
mode:
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();