From b08dea47c7fd0d698b549afd4bcdc6b8b117b4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Mon, 17 Oct 2016 18:00:22 +0200 Subject: [PATCH] Added function to return activities for a specified launcher --- libtaskmanager/launchertasksmodel.cpp | 9 +++++++++ libtaskmanager/launchertasksmodel.h | 11 +++++++++++ libtaskmanager/tasksmodel.cpp | 9 +++++++++ libtaskmanager/tasksmodel.h | 11 +++++++++++ 4 files changed, 40 insertions(+) diff --git a/libtaskmanager/launchertasksmodel.cpp b/libtaskmanager/launchertasksmodel.cpp index 04d1c6e0a..8905d2471 100644 --- a/libtaskmanager/launchertasksmodel.cpp +++ b/libtaskmanager/launchertasksmodel.cpp @@ -455,6 +455,15 @@ bool LauncherTasksModel::requestRemoveLauncherFromActivity(const QUrl &url) return d->requestRemoveLauncherFromActivities(url, { d->activities.currentActivity() }); } +QStringList LauncherTasksModel::launcherActivities(const QUrl &url) const +{ + const auto position = launcherPosition(url); + const auto url = d->launchersOrder.at(position); + + return d->activitiesForLauncher.contains(url) ? d->activitiesForLauncher[url] + : QStringList { NULL_UUID }; +} + int LauncherTasksModel::launcherPosition(const QUrl &url) const { for (int i = 0; i < d->launchersOrder.count(); ++i) { diff --git a/libtaskmanager/launchertasksmodel.h b/libtaskmanager/launchertasksmodel.h index 516c9f9df..4390b7da2 100644 --- a/libtaskmanager/launchertasksmodel.h +++ b/libtaskmanager/launchertasksmodel.h @@ -133,6 +133,17 @@ public: */ bool requestRemoveLauncherFromActivity(const QUrl &url); + /** + * Return the list of activities the launcher belongs to. + * If there is no launcher with that url, the list will be empty, + * while if the launcher is on all activities, it will contain a + * null uuid. + * + * URLs are compared for equality after removing the query string used + * to hold metadata. + */ + QStringList launcherActivities(const QUrl &url) const; + /** * Return the position of the launcher with the given URL. * diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp index 542aee5a7..770085090 100644 --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -1190,6 +1190,15 @@ bool TasksModel::requestRemoveLauncherFromActivity(const QUrl &url) return false; } +QStringList TasksModel::launcherActivities(const QUrl &url) +{ + if (d->launcherTasksModel) { + return d->launcherTasksModel->launcherActivities(url); + } + + return {}; +} + int TasksModel::launcherPosition(const QUrl &url) const { if (d->launcherTasksModel) { diff --git a/libtaskmanager/tasksmodel.h b/libtaskmanager/tasksmodel.h index 4f479499a..75104bbff 100644 --- a/libtaskmanager/tasksmodel.h +++ b/libtaskmanager/tasksmodel.h @@ -573,6 +573,17 @@ public: */ Q_INVOKABLE bool requestRemoveLauncherFromActivity(const QUrl &url); + /** + * Return the list of activities the launcher belongs to. + * If there is no launcher with that url, the list will be empty, + * while if the launcher is on all activities, it will contain a + * null uuid. + * + * URLs are compared for equality after removing the query string used + * to hold metadata. + */ + Q_INVOKABLE QStringList launcherActivities(const QUrl &url); + /** * Return the position of the launcher with the given URL. *