File indexing completed on 2024-05-05 17:44:53
0001 /* 0002 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QQmlParserStatus> 0010 #include <QSortFilterProxyModel> 0011 0012 #include "abstracttasksmodeliface.h" 0013 0014 #include "taskmanager_export.h" 0015 0016 namespace TaskManager 0017 { 0018 /** 0019 * @short A unified tasks model. 0020 * 0021 * This model presents tasks sourced from supplied launcher URLs, startup 0022 * notification data and window data retrieved from the windowing server 0023 * the host process is connected to. The underlying windowing system is 0024 * abstracted away. 0025 * 0026 * The source data is abstracted into a unified lifecycle for tasks 0027 * suitable for presentation in a user interface. 0028 * 0029 * Matching startup and window tasks replace launcher tasks. Startup 0030 * tasks are omitted when matching window tasks exist. Tasks that desire 0031 * not to be shown in a user interface are omitted. 0032 * 0033 * Tasks may be filtered, sorted or grouped by setting properties on the 0034 * model. 0035 * 0036 * Tasks may be interacted with by calling methods on the model. 0037 * 0038 * @author Eike Hein <hein@kde.org> 0039 **/ 0040 0041 class TASKMANAGER_EXPORT TasksModel : public QSortFilterProxyModel, public AbstractTasksModelIface, public QQmlParserStatus 0042 { 0043 Q_OBJECT 0044 Q_INTERFACES(QQmlParserStatus) 0045 0046 Q_PROPERTY(int count READ rowCount NOTIFY countChanged) 0047 Q_PROPERTY(int launcherCount READ launcherCount NOTIFY launcherCountChanged) 0048 0049 Q_PROPERTY(QStringList launcherList READ launcherList WRITE setLauncherList NOTIFY launcherListChanged) 0050 0051 Q_PROPERTY(bool anyTaskDemandsAttention READ anyTaskDemandsAttention NOTIFY anyTaskDemandsAttentionChanged) 0052 0053 Q_PROPERTY(QVariant virtualDesktop READ virtualDesktop WRITE setVirtualDesktop NOTIFY virtualDesktopChanged) 0054 Q_PROPERTY(QRect screenGeometry READ screenGeometry WRITE setScreenGeometry NOTIFY screenGeometryChanged) 0055 Q_PROPERTY(QString activity READ activity WRITE setActivity NOTIFY activityChanged) 0056 0057 Q_PROPERTY(bool filterByVirtualDesktop READ filterByVirtualDesktop WRITE setFilterByVirtualDesktop NOTIFY filterByVirtualDesktopChanged) 0058 Q_PROPERTY(bool filterByScreen READ filterByScreen WRITE setFilterByScreen NOTIFY filterByScreenChanged) 0059 Q_PROPERTY(bool filterByActivity READ filterByActivity WRITE setFilterByActivity NOTIFY filterByActivityChanged) 0060 Q_PROPERTY(bool filterMinimized READ filterMinimized WRITE setFilterMinimized NOTIFY filterMinimizedChanged) 0061 Q_PROPERTY(bool filterNotMinimized READ filterNotMinimized WRITE setFilterNotMinimized NOTIFY filterNotMinimizedChanged) 0062 Q_PROPERTY(bool filterNotMaximized READ filterNotMaximized WRITE setFilterNotMaximized NOTIFY filterNotMaximizedChanged) 0063 Q_PROPERTY(bool filterHidden READ filterHidden WRITE setFilterHidden NOTIFY filterHiddenChanged) 0064 0065 Q_PROPERTY(SortMode sortMode READ sortMode WRITE setSortMode NOTIFY sortModeChanged) 0066 Q_PROPERTY(bool separateLaunchers READ separateLaunchers WRITE setSeparateLaunchers NOTIFY separateLaunchersChanged) 0067 Q_PROPERTY(bool launchInPlace READ launchInPlace WRITE setLaunchInPlace NOTIFY launchInPlaceChanged) 0068 0069 Q_PROPERTY(GroupMode groupMode READ groupMode WRITE setGroupMode NOTIFY groupModeChanged) 0070 Q_PROPERTY(bool groupInline READ groupInline WRITE setGroupInline NOTIFY groupInlineChanged) 0071 Q_PROPERTY( 0072 int groupingWindowTasksThreshold READ groupingWindowTasksThreshold WRITE setGroupingWindowTasksThreshold NOTIFY groupingWindowTasksThresholdChanged) 0073 Q_PROPERTY(QStringList groupingAppIdBlacklist READ groupingAppIdBlacklist WRITE setGroupingAppIdBlacklist NOTIFY groupingAppIdBlacklistChanged) 0074 Q_PROPERTY(QStringList groupingLauncherUrlBlacklist READ groupingLauncherUrlBlacklist WRITE setGroupingLauncherUrlBlacklist NOTIFY 0075 groupingLauncherUrlBlacklistChanged) 0076 Q_PROPERTY(bool taskReorderingEnabled READ taskReorderingEnabled WRITE setTaskReorderingEnabled NOTIFY taskReorderingEnabledChanged) 0077 Q_PROPERTY(QModelIndex activeTask READ activeTask NOTIFY activeTaskChanged) 0078 0079 public: 0080 enum SortMode { 0081 SortDisabled = 0, /**< No sorting is done. */ 0082 SortManual, /**< Tasks can be moved with move() and syncLaunchers(). */ 0083 SortAlpha, /**< Tasks are sorted alphabetically, by AbstractTasksModel::AppName and Qt::DisplayRole. */ 0084 SortVirtualDesktop, /**< Tasks are sorted by the virtual desktop they are on. */ 0085 SortActivity, /**< Tasks are sorted by the number of tasks on the activities they're on. */ 0086 SortLastActivated, /**< Tasks are sorted by the last time they were active. */ 0087 }; 0088 Q_ENUM(SortMode) 0089 0090 enum GroupMode { 0091 GroupDisabled = 0, /**< No grouping is done. */ 0092 GroupApplications, /**< Tasks are grouped by the application backing them. */ 0093 }; 0094 Q_ENUM(GroupMode) 0095 0096 explicit TasksModel(QObject *parent = nullptr); 0097 ~TasksModel() override; 0098 0099 QHash<int, QByteArray> roleNames() const override; 0100 0101 Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override; // Invokable. 0102 0103 QVariant data(const QModelIndex &proxyIndex, int role) const override; 0104 0105 /** 0106 * The number of launcher tasks in the tast list. 0107 * 0108 * @returns the number of launcher tasks in the task list. 0109 **/ 0110 int launcherCount() const; 0111 0112 /** 0113 * The list of launcher URLs serialized to strings along with 0114 * the activities they belong to. 0115 * 0116 * @see setLauncherList 0117 * @returns the list of launcher URLs serialized to strings. 0118 **/ 0119 QStringList launcherList() const; 0120 0121 /** 0122 * Replace the list of launcher URL strings. 0123 * 0124 * Invalid or empty URLs will be rejected. Duplicate URLs will be 0125 * collapsed. 0126 * 0127 * @see launcherList 0128 * @param launchers A list of launcher URL strings. 0129 **/ 0130 void setLauncherList(const QStringList &launchers); 0131 0132 /** 0133 * Returns whether any task in the model currently demands attention 0134 * (AbstractTasksModel::IsDemandingAttention). 0135 * 0136 * @returns whether any task in the model currently demands attention. 0137 **/ 0138 bool anyTaskDemandsAttention() const; 0139 0140 /** 0141 * The id of the virtual desktop used in filtering by virtual 0142 * desktop. Usually set to the id of the current virtual desktop. 0143 * Defaults to empty. 0144 * 0145 * @see setVirtualDesktop 0146 * @returns the number of the virtual desktop used in filtering. 0147 **/ 0148 QVariant virtualDesktop() const; 0149 0150 /** 0151 * Set the id of the virtual desktop to use in filtering by virtual 0152 * desktop. 0153 * 0154 * If set to an empty id, filtering by virtual desktop is disabled. 0155 * 0156 * @see virtualDesktop 0157 * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11). 0158 **/ 0159 void setVirtualDesktop(const QVariant &desktop = QVariant()); 0160 0161 /** 0162 * The geometry of the screen used in filtering by screen. Defaults 0163 * to a null QRect. 0164 * 0165 * @see setGeometryScreen 0166 * @returns the geometry of the screen used in filtering. 0167 **/ 0168 QRect screenGeometry() const; 0169 0170 /** 0171 * Set the geometry of the screen to use in filtering by screen. 0172 * 0173 * If set to an invalid QRect, filtering by screen is disabled. 0174 * 0175 * @see screenGeometry 0176 * @param geometry A screen geometry. 0177 **/ 0178 void setScreenGeometry(const QRect &geometry); 0179 0180 /** 0181 * The id of the activity used in filtering by activity. Usually 0182 * set to the id of the current activity. Defaults to an empty id. 0183 * 0184 * @see setActivity 0185 * @returns the id of the activity used in filtering. 0186 **/ 0187 QString activity() const; 0188 0189 /** 0190 * Set the id of the activity to use in filtering by activity. 0191 * 0192 * @see activity 0193 * @param activity An activity id. 0194 **/ 0195 void setActivity(const QString &activity); 0196 0197 /** 0198 * Whether tasks should be filtered by virtual desktop. Defaults to 0199 * @c false. 0200 * 0201 * Filtering by virtual desktop only happens if a virtual desktop 0202 * number is set, even if this returns @c true. 0203 * 0204 * @see setFilterByVirtualDesktop 0205 * @see setVirtualDesktop 0206 * @returns @c true if tasks should be filtered by virtual desktop. 0207 **/ 0208 bool filterByVirtualDesktop() const; 0209 0210 /** 0211 * Set whether tasks should be filtered by virtual desktop. 0212 * 0213 * Filtering by virtual desktop only happens if a virtual desktop 0214 * number is set, even if this is set to @c true. 0215 * 0216 * @see filterByVirtualDesktop 0217 * @see setVirtualDesktop 0218 * @param filter Whether tasks should be filtered by virtual desktop. 0219 **/ 0220 void setFilterByVirtualDesktop(bool filter); 0221 0222 /** 0223 * Whether tasks should be filtered by screen. Defaults to @c false. 0224 * 0225 * Filtering by screen only happens if a screen number is set, even 0226 * if this returns @c true. 0227 * 0228 * @see setFilterByScreen 0229 * @see setScreenGeometry 0230 * @returns @c true if tasks should be filtered by screen. 0231 **/ 0232 bool filterByScreen() const; 0233 0234 /** 0235 * Set whether tasks should be filtered by screen. 0236 * 0237 * Filtering by screen only happens if a screen number is set, even 0238 * if this is set to @c true. 0239 * 0240 * @see filterByScreen 0241 * @see setScreenGeometry 0242 * @param filter Whether tasks should be filtered by screen. 0243 **/ 0244 void setFilterByScreen(bool filter); 0245 0246 /** 0247 * Whether tasks should be filtered by activity. Defaults to @c false. 0248 * 0249 * Filtering by activity only happens if an activity id is set, even 0250 * if this returns @c true. 0251 * 0252 * @see setFilterByActivity 0253 * @see setActivity 0254 * @returns @c true if tasks should be filtered by activity. 0255 **/ 0256 bool filterByActivity() const; 0257 0258 /** 0259 * Set whether tasks should be filtered by activity. Defaults to 0260 * @c false. 0261 * 0262 * Filtering by activity only happens if an activity id is set, 0263 * even if this is set to @c true. 0264 * 0265 * @see filterByActivity 0266 * @see setActivity 0267 * @param filter Whether tasks should be filtered by activity. 0268 **/ 0269 void setFilterByActivity(bool filter); 0270 0271 /** 0272 * Whether minimized tasks should be filtered out. Defaults to 0273 * @c false. 0274 * 0275 * @returns @c true if minimized tasks should be filtered out. 0276 * @see setFilterMinimized 0277 * @since 5.27 0278 **/ 0279 bool filterMinimized() const; 0280 0281 /** 0282 * Sets whether non-minimized tasks should be filtered out. 0283 * 0284 * @param filter Whether minimized tasks should be filtered out. 0285 * @see filterMinimized 0286 * @since 5.27 0287 **/ 0288 void setFilterMinimized(bool filter); 0289 0290 /** 0291 * Whether non-minimized tasks should be filtered. Defaults to 0292 * @c false. 0293 * 0294 * @see setFilterNotMinimized 0295 * @returns @c true if non-minimized tasks should be filtered. 0296 **/ 0297 bool filterNotMinimized() const; 0298 0299 /** 0300 * Set whether non-minimized tasks should be filtered. 0301 * 0302 * @see filterNotMinimized 0303 * @param filter Whether non-minimized tasks should be filtered. 0304 **/ 0305 void setFilterNotMinimized(bool filter); 0306 0307 /** 0308 * Whether non-maximized tasks should be filtered. Defaults to 0309 * @c false. 0310 * 0311 * @see setFilterNotMaximized 0312 * @returns @c true if non-maximized tasks should be filtered. 0313 **/ 0314 bool filterNotMaximized() const; 0315 0316 /** 0317 * Set whether non-maximized tasks should be filtered. 0318 * 0319 * @see filterNotMaximized 0320 * @param filter Whether non-maximized tasks should be filtered. 0321 **/ 0322 void setFilterNotMaximized(bool filter); 0323 0324 /** 0325 * Whether hidden tasks should be filtered. Defaults to 0326 * @c false. 0327 * 0328 * @see setFilterHidden 0329 * @returns @c true if hidden tasks should be filtered. 0330 **/ 0331 bool filterHidden() const; 0332 0333 /** 0334 * Set whether hidden tasks should be filtered. 0335 * 0336 * @see filterHidden 0337 * @param filter Whether hidden tasks should be filtered. 0338 **/ 0339 void setFilterHidden(bool filter); 0340 0341 /** 0342 * The sort mode used in sorting tasks. Defaults to SortAlpha. 0343 * 0344 * @see setSortMode 0345 * @returns the current sort mode. 0346 **/ 0347 SortMode sortMode() const; 0348 0349 /** 0350 * Sets the sort mode used in sorting tasks. 0351 * 0352 * @see sortMode 0353 * @param mode A sort mode. 0354 **/ 0355 void setSortMode(SortMode mode); 0356 0357 /** 0358 * Whether launchers are kept separate from other kinds of tasks. 0359 * Defaults to @c true. 0360 * 0361 * When enabled, launcher tasks are sorted first in the tasks model 0362 * and move() disallows moving them below the last launcher task, 0363 * or moving a different kind of task above the first launcher. New 0364 * launcher tasks are inserted after the last launcher task. When 0365 * disabled, move() allows mixing, and new launcher tasks are 0366 * appended to the model. 0367 * 0368 * Further, when disabled, the model always behaves as if 0369 * launchInPlace is enabled: A window task takes the place of the 0370 * first matching launcher task. 0371 * 0372 * @see LauncherTasksModel 0373 * @see move 0374 * @see launchInPlace 0375 * @see setSeparateLaunchers 0376 * @return whether launcher tasks are kept separate. 0377 */ 0378 bool separateLaunchers() const; 0379 0380 /** 0381 * Sets whether launchers are kept separate from other kinds of tasks. 0382 * 0383 * When enabled, launcher tasks are sorted first in the tasks model 0384 * and move() disallows moving them below the last launcher task, 0385 * or moving a different kind of task above the first launcher. New 0386 * launcher tasks are inserted after the last launcher task. When 0387 * disabled, move() allows mixing, and new launcher tasks are 0388 * appended to the model. 0389 * 0390 * Further, when disabled, the model always behaves as if 0391 * launchInPlace is enabled: A window task takes the place of the 0392 * first matching launcher task. 0393 * 0394 * @see LauncherTasksModel 0395 * @see move 0396 * @see launchInPlace 0397 * @see separateLaunchers 0398 * @param separate Whether to keep launcher tasks separate. 0399 */ 0400 void setSeparateLaunchers(bool separate); 0401 0402 /** 0403 * Whether window tasks should be sorted as their associated launcher 0404 * tasks or separately. Defaults to @c false. 0405 * 0406 * @see setLaunchInPlace 0407 * @returns whether window tasks should be sorted as their associated 0408 * launcher tasks. 0409 **/ 0410 bool launchInPlace() const; 0411 0412 /** 0413 * Sets whether window tasks should be sorted as their associated launcher 0414 * tasks or separately. 0415 * 0416 * @see launchInPlace 0417 * @param launchInPlace Whether window tasks should be sorted as their 0418 * associated launcher tasks. 0419 **/ 0420 void setLaunchInPlace(bool launchInPlace); 0421 0422 /** 0423 * Returns the current group mode, i.e. the criteria by which tasks should 0424 * be grouped. 0425 * 0426 * Defaults to TasksModel::GroupApplication, which groups tasks backed by 0427 * the same application. 0428 * 0429 * If the group mode is TasksModel::GroupDisabled, no grouping is done. 0430 * 0431 * @see setGroupMode 0432 * @returns the current group mode. 0433 **/ 0434 TasksModel::GroupMode groupMode() const; 0435 0436 /** 0437 * Sets the group mode, i.e. the criteria by which tasks should be grouped. 0438 * 0439 * The group mode can be set to TasksModel::GroupDisabled to disable grouping 0440 * entirely, breaking apart any existing groups. 0441 * 0442 * @see groupMode 0443 * @param mode A group mode. 0444 **/ 0445 void setGroupMode(TasksModel::GroupMode mode); 0446 0447 /** 0448 * Returns whether grouping is done "inline" or not, i.e. whether groups 0449 * are maintained inside the flat, top-level list, or by forming a tree. 0450 * In inline grouping mode, move() on a group member will move all siblings 0451 * as well, and sorting is first done among groups, then group members. 0452 * 0453 * Further, in inline grouping mode, the groupingWindowTasksThreshold 0454 * setting is ignored: Grouping is always done. 0455 * 0456 * @see setGroupInline 0457 * @see move 0458 * @see groupingWindowTasksThreshold 0459 * @returns whether grouping is done inline or not. 0460 **/ 0461 bool groupInline() const; 0462 0463 /** 0464 * Sets whether grouping is done "inline" or not, i.e. whether groups 0465 * are maintained inside the flat, top-level list, or by forming a tree. 0466 * In inline grouping mode, move() on a group member will move all siblings 0467 * as well, and sorting is first done among groups, then group members. 0468 * 0469 * @see groupInline 0470 * @see move 0471 * @see groupingWindowTasksThreshold 0472 * @param inline Whether to do grouping inline or not. 0473 **/ 0474 void setGroupInline(bool groupInline); 0475 0476 /** 0477 * As window tasks (AbstractTasksModel::IsWindow) come and go, groups will 0478 * be formed when this threshold value is exceeded, and broken apart when 0479 * it matches or falls below. 0480 * 0481 * Defaults to @c -1, which means grouping is done regardless of the number 0482 * of window tasks. 0483 * 0484 * When the groupInline property is set to @c true, the threshold is ignored: 0485 * Grouping is always done. 0486 * 0487 * @see setGroupingWindowTasksThreshold 0488 * @see groupInline 0489 * @return the threshold number of window tasks used in grouping decisions. 0490 **/ 0491 int groupingWindowTasksThreshold() const; 0492 0493 /** 0494 * Sets the number of window tasks (AbstractTasksModel::IsWindow) above which 0495 * groups will be formed, and at or below which groups will be broken apart. 0496 * 0497 * If set to -1, grouping will be done regardless of the number of window tasks 0498 * in the source model. 0499 * 0500 * When the groupInline property is set to @c true, the threshold is ignored: 0501 * Grouping is always done. 0502 * 0503 * @see groupingWindowTasksThreshold 0504 * @see groupInline 0505 * @param threshold A threshold number of window tasks used in grouping 0506 * decisions. 0507 **/ 0508 void setGroupingWindowTasksThreshold(int threshold); 0509 0510 /** 0511 * A blacklist of app ids (AbstractTasksModel::AppId) that is consulted before 0512 * grouping a task. If a task's app id is found on the blacklist, it is not 0513 * grouped. 0514 * 0515 * The default app id blacklist is empty. 0516 * 0517 * @see setGroupingAppIdBlacklist 0518 * @returns the blacklist of app ids consulted before grouping a task. 0519 **/ 0520 QStringList groupingAppIdBlacklist() const; 0521 0522 /** 0523 * Sets the blacklist of app ids (AbstractTasksModel::AppId) that is consulted 0524 * before grouping a task. If a task's app id is found on the blacklist, it is 0525 * not grouped. 0526 * 0527 * When set, groups will be formed and broken apart as necessary. 0528 * 0529 * @see groupingAppIdBlacklist 0530 * @param list a blacklist of app ids to be consulted before grouping a task. 0531 **/ 0532 void setGroupingAppIdBlacklist(const QStringList &list); 0533 0534 /** 0535 * A blacklist of launcher URLs (AbstractTasksModel::LauncherUrl) that is 0536 * consulted before grouping a task. If a task's launcher URL is found on the 0537 * blacklist, it is not grouped. 0538 * 0539 * The default launcher URL blacklist is empty. 0540 * 0541 * @see setGroupingLauncherUrlBlacklist 0542 * @returns the blacklist of launcher URLs consulted before grouping a task. 0543 **/ 0544 QStringList groupingLauncherUrlBlacklist() const; 0545 0546 /** 0547 * Sets the blacklist of launcher URLs (AbstractTasksModel::LauncherUrl) that 0548 * is consulted before grouping a task. If a task's launcher URL is found on 0549 * the blacklist, it is not grouped. 0550 * 0551 * When set, groups will be formed and broken apart as necessary. 0552 * 0553 * @see groupingLauncherUrlBlacklist 0554 * @param list a blacklist of launcher URLs to be consulted before grouping a task. 0555 **/ 0556 void setGroupingLauncherUrlBlacklist(const QStringList &list); 0557 0558 /** 0559 * Enables or disables tasks reordering. 0560 * 0561 * @param enabled enables tasks reordering if @c true; disables it otherwise. 0562 */ 0563 void setTaskReorderingEnabled(bool enabled); 0564 0565 /** 0566 * Returns whether tasks reordering is enabled or not. 0567 * 0568 * @returns whether tasks reordering is enabled or not. 0569 */ 0570 bool taskReorderingEnabled() const; 0571 0572 /** 0573 * Finds the first active (AbstractTasksModel::IsActive) task in the model 0574 * and returns its QModelIndex, or a null QModelIndex if no active task is 0575 * found. 0576 * 0577 * @returns the model index for the first active task, if any. 0578 */ 0579 QModelIndex activeTask() const; 0580 0581 /** 0582 * Request adding a launcher with the given URL. 0583 * 0584 * If this URL is already in the list, the request will fail. URLs are 0585 * compared for equality after removing the query string used to hold 0586 * metadata. 0587 * 0588 * @see launcherUrlsMatch 0589 * @param url A launcher URL. 0590 * @returns @c true if a launcher was added. 0591 */ 0592 Q_INVOKABLE bool requestAddLauncher(const QUrl &url); 0593 0594 /** 0595 * Request removing the launcher with the given URL. 0596 * 0597 * If this URL is already in the list, the request will fail. URLs are 0598 * compared for equality after removing the query string used to hold 0599 * metadata. 0600 * 0601 * @see launcherUrlsMatch 0602 * @param url A launcher URL. 0603 * @returns @c true if the launcher was removed. 0604 */ 0605 Q_INVOKABLE bool requestRemoveLauncher(const QUrl &url); 0606 0607 /** 0608 * Request adding a launcher with the given URL to current activity. 0609 * 0610 * If this URL is already in the list, the request will fail. URLs are 0611 * compared for equality after removing the query string used to hold 0612 * metadata. 0613 * 0614 * @see launcherUrlsMatch 0615 * @param url A launcher URL. 0616 * @returns @c true if a launcher was added. 0617 */ 0618 Q_INVOKABLE bool requestAddLauncherToActivity(const QUrl &url, const QString &activity); 0619 0620 /** 0621 * Request removing the launcher with the given URL from the current activity. 0622 * 0623 * If this URL is already in the list, the request will fail. URLs are 0624 * compared for equality after removing the query string used to hold 0625 * metadata. 0626 * 0627 * @see launcherUrlsMatch 0628 * @param url A launcher URL. 0629 * @returns @c true if the launcher was removed. 0630 */ 0631 Q_INVOKABLE bool requestRemoveLauncherFromActivity(const QUrl &url, const QString &activity); 0632 0633 /** 0634 * Return the list of activities the launcher belongs to. 0635 * If there is no launcher with that url, the list will be empty, 0636 * while if the launcher is on all activities, it will contain a 0637 * null uuid. 0638 * 0639 * URLs are compared for equality after removing the query string used 0640 * to hold metadata. 0641 */ 0642 Q_INVOKABLE QStringList launcherActivities(const QUrl &url); 0643 0644 /** 0645 * Return the position of the launcher with the given URL. 0646 * 0647 * URLs are compared for equality after removing the query string used 0648 * to hold metadata. 0649 * 0650 * @see launcherUrlsMatch 0651 * @param url A launcher URL. 0652 * @returns @c -1 if no launcher exists for the given URL. 0653 */ 0654 Q_INVOKABLE int launcherPosition(const QUrl &url) const; 0655 0656 /** 0657 * Request activation of the task at the given index. Derived classes are 0658 * free to interpret the meaning of "activate" themselves depending on 0659 * the nature and state of the task, e.g. launch or raise a window task. 0660 * 0661 * @param index An index in this tasks model. 0662 **/ 0663 Q_INVOKABLE void requestActivate(const QModelIndex &index) override; 0664 0665 /** 0666 * Request an additional instance of the application backing the task 0667 * at the given index. 0668 * 0669 * @param index An index in this tasks model. 0670 **/ 0671 Q_INVOKABLE void requestNewInstance(const QModelIndex &index) override; 0672 0673 /** 0674 * Requests to open the given URLs with the application backing the task 0675 * at the given index. 0676 * 0677 * @param index An index in this tasks model. 0678 * @param urls The URLs to be passed to the application. 0679 **/ 0680 Q_INVOKABLE void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) override; 0681 0682 /** 0683 * Request the task at the given index be closed. 0684 * 0685 * @param index An index in this tasks model. 0686 **/ 0687 Q_INVOKABLE void requestClose(const QModelIndex &index) override; 0688 0689 /** 0690 * Request starting an interactive move for the task at the given index. 0691 * 0692 * This is meant for tasks that have an associated window, and may be 0693 * a no-op when there is no window. 0694 * 0695 * @param index An index in this tasks model. 0696 **/ 0697 Q_INVOKABLE void requestMove(const QModelIndex &index) override; 0698 0699 /** 0700 * Request starting an interactive resize for the task at the given index. 0701 * 0702 * This is meant for tasks that have an associated window, and may be a 0703 * no-op when there is no window. 0704 * 0705 * @param index An index in this tasks model. 0706 **/ 0707 Q_INVOKABLE void requestResize(const QModelIndex &index) override; 0708 0709 /** 0710 * Request toggling the minimized state of the task at the given index. 0711 * 0712 * This is meant for tasks that have an associated window, and may be 0713 * a no-op when there is no window. 0714 * 0715 * @param index An index in this tasks model. 0716 **/ 0717 Q_INVOKABLE void requestToggleMinimized(const QModelIndex &index) override; 0718 0719 /** 0720 * Request toggling the maximized state of the task at the given index. 0721 * 0722 * This is meant for tasks that have an associated window, and may be 0723 * a no-op when there is no window. 0724 * 0725 * @param index An index in this tasks model. 0726 **/ 0727 Q_INVOKABLE void requestToggleMaximized(const QModelIndex &index) override; 0728 0729 /** 0730 * Request toggling the keep-above state of the task at the given index. 0731 * 0732 * This is meant for tasks that have an associated window, and may be 0733 * a no-op when there is no window. 0734 * 0735 * @param index An index in this tasks model. 0736 **/ 0737 Q_INVOKABLE void requestToggleKeepAbove(const QModelIndex &index) override; 0738 0739 /** 0740 * Request toggling the keep-below state of the task at the given index. 0741 * 0742 * This is meant for tasks that have an associated window, and may be 0743 * a no-op when there is no window. 0744 * 0745 * @param index An index in this tasks model. 0746 **/ 0747 Q_INVOKABLE void requestToggleKeepBelow(const QModelIndex &index) override; 0748 0749 /** 0750 * Request toggling the fullscreen state of the task at the given index. 0751 * 0752 * This is meant for tasks that have an associated window, and may be 0753 * a no-op when there is no window. 0754 * 0755 * @param index An index in this tasks model. 0756 **/ 0757 Q_INVOKABLE void requestToggleFullScreen(const QModelIndex &index) override; 0758 0759 /** 0760 * Request toggling the shaded state of the task at the given index. 0761 * 0762 * This is meant for tasks that have an associated window, and may be 0763 * a no-op when there is no window. 0764 * 0765 * @param index An index in this tasks model. 0766 **/ 0767 Q_INVOKABLE void requestToggleShaded(const QModelIndex &index) override; 0768 0769 /** 0770 * Request entering the window at the given index on the specified virtual desktops. 0771 * 0772 * On Wayland, virtual desktop ids are QStrings. On X11, they are uint >0. 0773 * 0774 * An empty list has a special meaning: The window is entered on all virtual desktops 0775 * in the session. 0776 * 0777 * On X11, a window can only be on one or all virtual desktops. Therefore, only the 0778 * first list entry is actually used. 0779 * 0780 * On X11, the id 0 has a special meaning: The window is entered on all virtual 0781 * desktops in the session. 0782 * 0783 * @param index An index in this window tasks model. 0784 * @param desktops A list of virtual desktop ids. 0785 **/ 0786 Q_INVOKABLE void requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) override; 0787 0788 /** 0789 * Request entering the window at the given index on a new virtual desktop, 0790 * which is created in response to this request. 0791 * 0792 * @param index An index in this window tasks model. 0793 **/ 0794 Q_INVOKABLE void requestNewVirtualDesktop(const QModelIndex &index) override; 0795 0796 /** 0797 * Request moving the task at the given index to the specified activities. 0798 * 0799 * This is meant for tasks that have an associated window, and may be 0800 * a no-op when there is no window. 0801 * 0802 * This base implementation does nothing. 0803 * 0804 * @param index An index in this tasks model. 0805 * @param activities The new list of activities. 0806 **/ 0807 Q_INVOKABLE void requestActivities(const QModelIndex &index, const QStringList &activities) override; 0808 0809 /** 0810 * Request informing the window manager of new geometry for a visual 0811 * delegate for the task at the given index. The geometry should be in 0812 * screen coordinates. 0813 * 0814 * If the task at the given index is a group parent, the geometry is 0815 * set for all of its children. If the task at the given index is a 0816 * group member, the geometry is set for all of its siblings. 0817 * 0818 * @param index An index in this tasks model. 0819 * @param geometry Visual delegate geometry in screen coordinates. 0820 * @param delegate The delegate. Implementations are on their own with 0821 * regard to extracting information from this, and should take care to 0822 * reject invalid objects. 0823 **/ 0824 Q_INVOKABLE void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) override; 0825 0826 /** 0827 * Request toggling whether the task at the given index, along with any 0828 * tasks matching its kind, should be grouped or not. Task groups will be 0829 * formed or broken apart as needed, along with affecting future grouping 0830 * decisions as new tasks appear. 0831 * 0832 * As grouping is toggled for a task, updates are made to the 0833 * grouping*Blacklist properties of the model instance. 0834 * 0835 * @see groupingAppIdBlacklist 0836 * @see groupingLauncherUrlBlacklist 0837 * 0838 * @param index An index in this tasks model. 0839 **/ 0840 Q_INVOKABLE void requestToggleGrouping(const QModelIndex &index); 0841 0842 /** 0843 * Moves a task to a new position in the list. The insert position is 0844 * is bounded to the list start and end. 0845 * 0846 * syncLaunchers() should be called after a set of move operations to 0847 * update the launcherList property to reflect the new order. 0848 * 0849 * When the groupInline property is set to @c true, a move request 0850 * for a group member will bring all siblings along. 0851 * 0852 * @see syncLaunchers 0853 * @see launcherList 0854 * @see setGroupInline 0855 * @param index An index in this tasks model. 0856 * @param newPos The new list position to move the task to. 0857 */ 0858 Q_INVOKABLE bool move(int row, int newPos, const QModelIndex &parent = QModelIndex()); 0859 0860 /** 0861 * Updates the launcher list to reflect the new order after calls to 0862 * move(), if needed. 0863 * 0864 * @see move 0865 * @see launcherList 0866 */ 0867 Q_INVOKABLE void syncLaunchers(); 0868 0869 /** 0870 * Given a row in the model, returns a QModelIndex for it. To get an index 0871 * for a child in a task group, an optional child row may be passed as well. 0872 * 0873 * This easier to use from Qt Quick views than QAbstractItemModel::index is. 0874 * 0875 * @param row A row index in the model. 0876 * @param childRow A row index for a child of the task group at the given row. 0877 * @returns a model index for the task at the given row, or for one of its 0878 * child tasks. 0879 */ 0880 Q_INVOKABLE QModelIndex makeModelIndex(int row, int childRow = -1) const; 0881 0882 /** 0883 * Given a row in the model, returns a QPersistentModelIndex for it. To get an index 0884 * for a child in a task group, an optional child row may be passed as well. 0885 * 0886 * @param row A row index in the model. 0887 * @param childRow A row index for a child of the task group at the given row. 0888 * @returns a model index for the task at the given row, or for one of its 0889 * child tasks. 0890 */ 0891 Q_INVOKABLE QPersistentModelIndex makePersistentModelIndex(int row, int childRow = -1) const; 0892 0893 void classBegin() override; 0894 void componentComplete() override; 0895 0896 Q_SIGNALS: 0897 void countChanged() const; 0898 void launcherCountChanged() const; 0899 void launcherListChanged() const; 0900 void anyTaskDemandsAttentionChanged() const; 0901 void virtualDesktopChanged() const; 0902 void screenGeometryChanged() const; 0903 void activityChanged() const; 0904 void filterByVirtualDesktopChanged() const; 0905 void filterByScreenChanged() const; 0906 void filterByActivityChanged() const; 0907 void filterMinimizedChanged(); 0908 void filterNotMinimizedChanged() const; 0909 void filterNotMaximizedChanged() const; 0910 void filterHiddenChanged() const; 0911 void sortModeChanged() const; 0912 void separateLaunchersChanged() const; 0913 void launchInPlaceChanged() const; 0914 void groupModeChanged() const; 0915 void groupInlineChanged() const; 0916 void groupingWindowTasksThresholdChanged() const; 0917 void groupingAppIdBlacklistChanged() const; 0918 void groupingLauncherUrlBlacklistChanged() const; 0919 void taskReorderingEnabledChanged() const; 0920 void activeTaskChanged() const; 0921 0922 protected: 0923 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 0924 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 0925 0926 private: 0927 Q_INVOKABLE void updateLauncherCount(); 0928 0929 class Private; 0930 class TasksModelLessThan; 0931 friend class TasksModelLessThan; 0932 QScopedPointer<Private> d; 0933 }; 0934 0935 }