summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controller.cxx46
-rw-r--r--controller.hxx3
m---------larva0
3 files changed, 25 insertions, 24 deletions
diff --git a/controller.cxx b/controller.cxx
index df10b20..40eee0d 100644
--- a/controller.cxx
+++ b/controller.cxx
@@ -16,7 +16,8 @@ Controller::Controller(QObject* parent) : QObject{parent}
QFile file{"assets:/certs/ca-certificates.crt"};
file.copy(path);
#endif
- auto client = new RTClient::Client{"https://darapsa.co.id/rt"
+ using RTClient::Client;
+ auto client = new Client{"https://darapsa.co.id/rt"
#ifdef ANDROID
, path.toLatin1().constData()
#endif
@@ -27,6 +28,7 @@ Controller::Controller(QObject* parent) : QObject{parent}
auto engine = static_cast<QQmlApplicationEngine*>(parent);
auto rootObjects = engine->rootObjects();
auto appWindow = rootObjects[0];
+
using RTClient::User;
auto typeId = qmlRegisterSingletonType<User>("KelakonUser", 0, 1, "User"
, [](QQmlEngine *engine
@@ -36,27 +38,37 @@ Controller::Controller(QObject* parent) : QObject{parent}
return new User;
});
auto user = engine->singletonInstance<User*>(typeId);
- taskList = new RTClient::TicketList;
+
+ using RTClient::TicketList;
+ taskList = new TicketList;
engine->rootContext()->setContextProperty("taskList", taskList);
connect(appWindow, SIGNAL(logIn(QString, QString))
, client, SLOT(logIn(QString, QString)));
- connect(client, SIGNAL(loggedIn(QString))
- , client, SLOT(userShow(QString)));
+ connect(client, &Client::loggedIn
+ , client, static_cast<void (Client::*)(QString const&)>
+ (&Client::userShow));
- connect(client, SIGNAL(userShown(rtclient_user*))
- , this, SLOT(check(rtclient_user*)));
+ connect(client, &Client::userShown, [this](rtclient_user* user) {
+ if (user) {
+ emit checked(QString{user->name});
+ emit checked(user);
+ }
+ });
- connect(this, SIGNAL(checked(rtclient_user*))
- , user, SLOT(update(rtclient_user*)));
- connect(this, SIGNAL(checked(QString))
- , client, SLOT(ticketSearch(QString)));
+ connect(this, static_cast<void (Controller::*)(rtclient_user*)>
+ (&Controller::checked)
+ , user, &User::update);
+ connect(this, static_cast<void (Controller::*)(QString const&)>
+ (&Controller::checked)
+ , client, &Client::ticketSearch);
- connect(client, SIGNAL(ticketSearched(rtclient_ticketlist*))
- , taskList, SLOT(update(rtclient_ticketlist*)));
+ connect(client, &Client::ticketSearched, taskList, &TicketList::update);
- connect(taskList, SIGNAL(updated()), appWindow, SLOT(pushHome()));
+ connect(taskList, &TicketList::updated, [appWindow]() {
+ QMetaObject::invokeMethod(appWindow, "pushHome");
+ });
connect(appWindow, SIGNAL(ticketHistory(int))
, client, SLOT(ticketHistory(int)));
@@ -67,14 +79,6 @@ Controller::Controller(QObject* parent) : QObject{parent}
thread.start();
}
-void Controller::check(rtclient_user* user)
-{
- if (user) {
- emit checked(QString{user->name});
- emit checked(user);
- }
-}
-
Controller::~Controller()
{
thread.quit();
diff --git a/controller.hxx b/controller.hxx
index 8eb4017..1a9935c 100644
--- a/controller.hxx
+++ b/controller.hxx
@@ -18,9 +18,6 @@ class Controller : public QObject
void checked(rtclient_user* user);
void checked(QString const& name);
- private slots:
- void check(rtclient_user* user);
-
private:
QThread thread;
RTClient::TicketList* taskList;
diff --git a/larva b/larva
-Subproject c09d129ea53dfc267a808dd15667453eb9177e5
+Subproject 24bfec230e5ab25a50e5d6876719e538191d0be