Plasma-workspace
tasksmodel.cpp
82 bool lessThan(const QModelIndex &left, const QModelIndex &right, bool sortOnlyLaunchers = false) const;
203 QObject::connect(concatProxyModel, &QAbstractItemModel::rowsAboutToBeInserted, q, [this](const QModelIndex &parent, int start, int end) {
232 QObject::connect(concatProxyModel, &QAbstractItemModel::rowsInserted, q, [this](const QModelIndex &parent, int start, int end) {
243 QObject::connect(concatProxyModel, &QAbstractItemModel::rowsRemoved, q, [this](const QModelIndex &parent, int first, int last) {
269 QObject::connect(filterProxyModel, &TaskFilterProxyModel::virtualDesktopChanged, q, &TasksModel::virtualDesktopChanged);
270 QObject::connect(filterProxyModel, &TaskFilterProxyModel::screenGeometryChanged, q, &TasksModel::screenGeometryChanged);
271 QObject::connect(filterProxyModel, &TaskFilterProxyModel::regionGeometryChanged, q, &TasksModel::regionGeometryChanged);
272 QObject::connect(filterProxyModel, &TaskFilterProxyModel::activityChanged, q, &TasksModel::activityChanged);
273 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterByVirtualDesktopChanged, q, &TasksModel::filterByVirtualDesktopChanged);
274 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterByScreenChanged, q, &TasksModel::filterByScreenChanged);
275 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterByActivityChanged, q, &TasksModel::filterByActivityChanged);
276 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterByRegionChanged, q, &TasksModel::filterByRegionChanged);
277 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterMinimizedChanged, q, &TasksModel::filterMinimizedChanged);
278 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterNotMinimizedChanged, q, &TasksModel::filterNotMinimizedChanged);
279 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterNotMaximizedChanged, q, &TasksModel::filterNotMaximizedChanged);
280 QObject::connect(filterProxyModel, &TaskFilterProxyModel::filterHiddenChanged, q, &TasksModel::filterHiddenChanged);
284 QObject::connect(groupingProxyModel, &TaskGroupingProxyModel::groupModeChanged, q, &TasksModel::groupModeChanged);
285 QObject::connect(groupingProxyModel, &TaskGroupingProxyModel::blacklistedAppIdsChanged, q, &TasksModel::groupingAppIdBlacklistChanged);
286 QObject::connect(groupingProxyModel, &TaskGroupingProxyModel::blacklistedLauncherUrlsChanged, q, &TasksModel::groupingLauncherUrlBlacklistChanged);
288 QObject::connect(groupingProxyModel, &QAbstractItemModel::rowsInserted, q, [this](const QModelIndex &parent, int first, int last) {
320 || (!appName.isEmpty() && appName == filterIndex.data(AbstractTasksModel::AppName).toString())) {
326 // When we get a window or startup we have a launcher for, cause the launcher to be re-filtered.
327 if (sourceIndex.data(AbstractTasksModel::IsWindow).toBool() || sourceIndex.data(AbstractTasksModel::IsStartup).toBool()) {
347 QObject::connect(groupingProxyModel, &QAbstractItemModel::rowsAboutToBeRemoved, q, [this](const QModelIndex &parent, int first, int last) {
370 && (sourceIndex.data(AbstractTasksModel::IsWindow).toBool() || sourceIndex.data(AbstractTasksModel::IsStartup).toBool())) {
376 QObject::connect(filterProxyModel, &QAbstractItemModel::rowsRemoved, q, [this](const QModelIndex &parent, int first, int last) {
470 QObject::connect(launcherTasksModel, &LauncherTasksModel::launcherListChanged, q, &TasksModel::launcherListChanged);
471 QObject::connect(launcherTasksModel, &LauncherTasksModel::launcherListChanged, q, &TasksModel::updateLauncherCount);
479 Q_EMIT q->dataChanged(q->index(0, 0), q->index(q->rowCount() - 1, 0), QList<int>{AbstractTasksModel::HasLauncher});
484 QObject::connect(q, &QAbstractItemModel::dataChanged, q, [this](const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles) {
485 if (roles.contains(AbstractTasksModel::AppId) || roles.contains(AbstractTasksModel::LauncherUrlWithoutIcon)) {
550 if (idx.data(AbstractTasksModel::IsWindow).toBool() && idx.data(AbstractTasksModel::SkipTaskbar).toBool()) {
599 || launcherTasksModel->launcherPosition(concatProxyIndex.data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl()) != -1) {
617 && idx.data(AbstractTasksModel::LauncherUrlWithoutIcon) == concatProxyIndex.data(AbstractTasksModel::LauncherUrlWithoutIcon)) {
630void TasksModel::Private::consolidateManualSortMapForGroup(const QModelIndex &groupingProxyIndex)
642 const QModelIndex &preFilterLeader = filterProxyModel->mapToSource(groupingProxyModel->mapToSource(leader));
648 const QModelIndex &preFilterChild = filterProxyModel->mapToSource(groupingProxyModel->mapToSource(child));
709 QObject::connect(q, &QAbstractItemModel::rowsInserted, q, &TasksModel::updateLauncherCount, Qt::UniqueConnection);
710 QObject::connect(q, &QAbstractItemModel::rowsRemoved, q, &TasksModel::updateLauncherCount, Qt::UniqueConnection);
711 QObject::connect(q, &QAbstractItemModel::modelReset, q, &TasksModel::updateLauncherCount, Qt::UniqueConnection);
713 QObject::connect(q, &QAbstractItemModel::rowsInserted, q, &TasksModel::countChanged, Qt::UniqueConnection);
714 QObject::connect(q, &QAbstractItemModel::rowsRemoved, q, &TasksModel::countChanged, Qt::UniqueConnection);
715 QObject::connect(q, &QAbstractItemModel::modelReset, q, &TasksModel::countChanged, Qt::UniqueConnection);
723 return filterProxyModel->mapToSource(groupingProxyModel->mapToSource(flattenGroupsProxyModel->mapToSource(sourceIndex)));
739 for (const auto activities = activityInfo->runningActivities(); const QString &activity : activities) {
745 const QStringList &activities = windowIndex.data(AbstractTasksModel::Activities).toStringList();
770bool TasksModel::Private::lessThan(const QModelIndex &left, const QModelIndex &right, bool sortOnlyLaunchers) const
784 const int leftPos = q->launcherPosition(left.data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl());
785 const int rightPos = q->launcherPosition(right.data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl());
884 return (virtualDesktopInfo->position(leftDesktop) < virtualDesktopInfo->position(rightDesktop));
900 const int score = std::accumulate(activities.cbegin(), activities.cend(), -1, [this](int a, const QString &activity) {
910 const int sumScore = std::accumulate(activityTaskCounts.constBegin(), activityTaskCounts.constEnd(), 0);
1013 if (role == AbstractTasksModel::HasLauncher && proxyIndex.isValid() && proxyIndex.row() < rowCount()) {
1600void TasksModel::requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate)
1602 if (!index.isValid() || index.model() != this || !index.data(AbstractTasksModel::IsWindow).toBool()) {
1605 d->abstractTasksSourceModel->requestPublishDelegateGeometry(mapToSource(index), geometry, delegate);
1611 const QModelIndex &target = (d->flattenGroupsProxyModel ? d->flattenGroupsProxyModel->mapToSource(mapToSource(index)) : mapToSource(index));
1619 * NOTE After doing any modification in TasksModel::move, make sure fixes listed below are not regressed.
1622 * - https://invent.kde.org/plasma/plasma-workspace/-/commit/ea51795e8c571513e1ff583350ab8649bc857fc2
1637 } else if ((d->launchInPlace || !d->separateLaunchers) && idx.data(AbstractTasksModel::IsWindow).toBool()) {
1672 QModelIndex groupingRowIndex = d->flattenGroupsProxyModel->mapToSource(mapToSource(index(row, 0)));
1674 QModelIndex groupingNewPosIndex = d->flattenGroupsProxyModel->mapToSource(mapToSource(index(newPos, 0)));
1678 if (groupingRowIndexParent.isValid() && (groupingRowIndexParent == groupingNewPosIndex || groupingRowIndexParent == groupingNewPosIndexParent)) {
1697 groupingNewPosIndex = groupingNewPosIndexParent.model()->index(extra, 0, groupingNewPosIndexParent);
1704 beginMoveRows(QModelIndex(), (row - offset), (row - offset) + extraChildCount, QModelIndex(), (newPos > row) ? newPos + 1 : newPos);
1706 row = d->sortedPreFilterRows.indexOf(d->filterProxyModel->mapToSource(d->groupingProxyModel->mapToSource(groupingRowIndex)).row());
1707 newPos = d->sortedPreFilterRows.indexOf(d->filterProxyModel->mapToSource(d->groupingProxyModel->mapToSource(groupingNewPosIndex)).row());
1736 newPos = d->sortedPreFilterRows.indexOf(d->preFilterIndex(mapToSource(index(newPos, 0, parent))).row());
1751 if (int childCount = d->groupingProxyModel->rowCount(adjacentGroupingRowIndex); childCount && adjacentGroupingRowIndex.isValid()) {
1755 // After consolidation: [Group parent (not consolidated yet)] [Other task in group] [Task, newPos]
1779 const int sortIndex = d->sortedPreFilterRows.indexOf(d->concatProxyModel->mapFromSource(launcherIndex).row());
1783 const QModelIndex beforeIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(newPos - 1), 0);
1788 const QModelIndex tempIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(afterPos), 0);
1794 const QModelIndex afterIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(afterPos), 0);
1804 const QModelIndex &concatProxyIndex = d->concatProxyModel->index(d->sortedPreFilterRows.at(i), 0);
1806 if (launcherUrl == concatProxyIndex.data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl()) {
1823 const QModelIndex beforeIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(newPos - 1), 0, parent);
1824 const QModelIndex afterIdx = d->concatProxyModel->index(d->sortedPreFilterRows.at(newPos + 1), 0, parent);
1826 const bool hasLauncher = beforeIdx.data(AbstractTasksModel::IsLauncher).toBool() || afterIdx.data(AbstractTasksModel::IsLauncher).toBool();
1861 const QUrl &rowLauncherUrl = index(i, 0).data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl();
1987 if (d->groupInline && d->flattenGroupsProxyModel && sourceIndex.data(AbstractTasksModel::IsGroupParent).toBool()) {
2004 || (!appName.isEmpty() && appName == filterIndex.data(AbstractTasksModel::AppName).toString())) {
2016 if (!filteredIndex.data(AbstractTasksModel::IsWindow).toBool() && !filteredIndex.data(AbstractTasksModel::IsStartup).toBool()) {
2033 return (d->sortedPreFilterRows.indexOf(d->preFilterIndex(left).row()) < d->sortedPreFilterRows.indexOf(d->preFilterIndex(right).row()));
@ LauncherUrlWithoutIcon
Special path to get a launcher URL while skipping fallback icon encoding.
Definition abstracttasksmodel.h:44
@ LastActivated
The timestamp of the last time a task was the active task.
Definition abstracttasksmodel.h:88
A tasks model for startup notifications.
Definition startuptasksmodel.h:33
void setFilterNotMinimized(bool filter)
Set whether non-minimized tasks should be filtered.
Definition tasksmodel.cpp:1168
void setLaunchInPlace(bool launchInPlace)
Sets whether window tasks should be sorted as their associated launcher tasks or separately.
Definition tasksmodel.cpp:1261
Q_INVOKABLE int launcherPosition(const QUrl &url) const
Return the position of the launcher with the given URL.
Definition tasksmodel.cpp:1486
Q_INVOKABLE void requestToggleMinimized(const QModelIndex &index) override
Request toggling the minimized state of the task at the given index.
Definition tasksmodel.cpp:1537
Q_INVOKABLE void requestMove(const QModelIndex &index) override
Request starting an interactive move for the task at the given index.
Definition tasksmodel.cpp:1523
void setFilterByVirtualDesktop(bool filter)
Set whether tasks should be filtered by virtual desktop.
Definition tasksmodel.cpp:1118
void setFilterByActivity(bool filter)
Set whether tasks should be filtered by activity.
Definition tasksmodel.cpp:1138
void setFilterByRegion(RegionFilterMode::Mode mode)
Set whether tasks should be filtered by region.
Definition tasksmodel.cpp:1148
void setRegionGeometry(const QRect &geometry)
Set the geometry of the screen to use in filtering by region.
Definition tasksmodel.cpp:1098
Q_INVOKABLE bool requestAddLauncher(const QUrl &url)
Request adding a launcher with the given URL.
Definition tasksmodel.cpp:1405
void setGroupingWindowTasksThreshold(int threshold)
Sets the number of window tasks (AbstractTasksModel::IsWindow) above which groups will be formed,...
Definition tasksmodel.cpp:1332
Q_INVOKABLE void requestToggleGrouping(const QModelIndex &index)
Request toggling whether the task at the given index, along with any tasks matching its kind,...
Definition tasksmodel.cpp:1608
Q_INVOKABLE bool move(int row, int newPos, const QModelIndex &parent=QModelIndex())
Moves a task to a new position in the list.
Definition tasksmodel.cpp:1616
Q_INVOKABLE void requestToggleKeepBelow(const QModelIndex &index) override
Request toggling the keep-below state of the task at the given index.
Definition tasksmodel.cpp:1558
Q_INVOKABLE bool requestRemoveLauncher(const QUrl &url)
Request removing the launcher with the given URL.
Definition tasksmodel.cpp:1422
Q_INVOKABLE QPersistentModelIndex makePersistentModelIndex(int row, int childRow=-1) const
Given a row in the model, returns a QPersistentModelIndex for it.
Definition tasksmodel.cpp:1958
void setGroupingAppIdBlacklist(const QStringList &list)
Sets the blacklist of app ids (AbstractTasksModel::AppId) that is consulted before grouping a task.
Definition tasksmodel.cpp:1354
void setGroupingLauncherUrlBlacklist(const QStringList &list)
Sets the blacklist of launcher URLs (AbstractTasksModel::LauncherUrl) that is consulted before groupi...
Definition tasksmodel.cpp:1370
Q_INVOKABLE bool requestAddLauncherToActivity(const QUrl &url, const QString &activity)
Request adding a launcher with the given URL to current activity.
Definition tasksmodel.cpp:1441
std::shared_ptr< ActivityInfo > activityInfo() const
Definition tasksmodel.cpp:2050
Q_INVOKABLE void requestActivities(const QModelIndex &index, const QStringList &activities) override
Request moving the task at the given index to the specified activities.
Definition tasksmodel.cpp:1593
Q_INVOKABLE bool requestRemoveLauncherFromActivity(const QUrl &url, const QString &activity)
Request removing the launcher with the given URL from the current activity.
Definition tasksmodel.cpp:1458
void setLauncherList(const QStringList &launchers)
Replace the list of launcher URL strings.
Definition tasksmodel.cpp:1398
Q_INVOKABLE void requestActivate(const QModelIndex &index) override
Request activation of the task at the given index.
Definition tasksmodel.cpp:1495
void setFilterNotMaximized(bool filter)
Set whether non-maximized tasks should be filtered.
Definition tasksmodel.cpp:1178
std::shared_ptr< VirtualDesktopInfo > virtualDesktopInfo() const
Definition tasksmodel.cpp:2039
Q_INVOKABLE void requestToggleFullScreen(const QModelIndex &index) override
Request toggling the fullscreen state of the task at the given index.
Definition tasksmodel.cpp:1565
Q_INVOKABLE void requestToggleKeepAbove(const QModelIndex &index) override
Request toggling the keep-above state of the task at the given index.
Definition tasksmodel.cpp:1551
void setFilterMinimized(bool filter)
Sets whether non-minimized tasks should be filtered out.
Definition tasksmodel.cpp:1158
void setTaskReorderingEnabled(bool enabled)
Enables or disables tasks reordering.
Definition tasksmodel.cpp:1382
Q_INVOKABLE void requestResize(const QModelIndex &index) override
Request starting an interactive resize for the task at the given index.
Definition tasksmodel.cpp:1530
void setGroupInline(bool groupInline)
Sets whether grouping is done "inline" or not, i.e.
Definition tasksmodel.cpp:1316
void setFilterHidden(bool filter)
Set whether hidden tasks should be filtered.
Definition tasksmodel.cpp:1188
Q_INVOKABLE void requestNewInstance(const QModelIndex &index) override
Request an additional instance of the application backing the task at the given index.
Definition tasksmodel.cpp:1502
Q_INVOKABLE void requestNewVirtualDesktop(const QModelIndex &index) override
Request entering the window at the given index on a new virtual desktop, which is created in response...
Definition tasksmodel.cpp:1586
@ SortActivity
Tasks are sorted by the number of tasks on the activities they're on.
Definition tasksmodel.h:95
void setVirtualDesktop(const QVariant &desktop=QVariant())
Set the id of the virtual desktop to use in filtering by virtual desktop.
Definition tasksmodel.cpp:1078
Q_INVOKABLE void requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) override
Request entering the window at the given index on the specified virtual desktops.
Definition tasksmodel.cpp:1579
void setSeparateLaunchers(bool separate)
Sets whether launchers are kept separate from other kinds of tasks.
Definition tasksmodel.cpp:1244
Q_INVOKABLE void requestToggleMaximized(const QModelIndex &index) override
Request toggling the maximized state of the task at the given index.
Definition tasksmodel.cpp:1544
void setHideActivatedLaunchers(bool hideActivatedLaunchers)
Sets whether launchers should be hidden after they have been activated.
Definition tasksmodel.cpp:1286
Q_INVOKABLE void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate=nullptr) override
Request informing the window manager of new geometry for a visual delegate for the task at the given ...
Definition tasksmodel.cpp:1600
void setActivity(const QString &activity)
Set the id of the activity to use in filtering by activity.
Definition tasksmodel.cpp:1108
void setGroupMode(TasksModel::GroupMode mode)
Sets the group mode, i.e.
Definition tasksmodel.cpp:1299
Q_INVOKABLE void syncLaunchers()
Updates the launcher list to reflect the new order after calls to move(), if needed.
Definition tasksmodel.cpp:1841
void setSortMode(SortMode mode)
Sets the sort mode used in sorting tasks.
Definition tasksmodel.cpp:1198
void setFilterByScreen(bool filter)
Set whether tasks should be filtered by screen.
Definition tasksmodel.cpp:1128
Q_INVOKABLE void requestClose(const QModelIndex &index) override
Request the task at the given index be closed.
Definition tasksmodel.cpp:1516
Q_INVOKABLE void requestToggleShaded(const QModelIndex &index) override
Request toggling the shaded state of the task at the given index.
Definition tasksmodel.cpp:1572
Q_INVOKABLE QStringList launcherActivities(const QUrl &url)
Return the list of activities the launcher belongs to.
Definition tasksmodel.cpp:1477
Q_INVOKABLE void requestOpenUrls(const QModelIndex &index, const QList< QUrl > &urls) override
Requests to open the given URLs with the application backing the task at the given index.
Definition tasksmodel.cpp:1509
Q_INVOKABLE QModelIndex makeModelIndex(int row, int childRow=-1) const
Given a row in the model, returns a QModelIndex for it.
Definition tasksmodel.cpp:1939
void setScreenGeometry(const QRect &geometry)
Set the geometry of the screen to use in filtering by screen.
Definition tasksmodel.cpp:1088
Q_SCRIPTABLE QString start(QString train="")
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
QCA_EXPORT QString appName()
QAbstractItemModel(QObject *parent)
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void endMoveRows()
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
void modelReset()
void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
bool isValid() const const
const_reference at(qsizetype i) const const
iterator begin()
const_iterator cbegin() const const
const_iterator cend() const const
bool contains(const AT &value) const const
qsizetype count() const const
pointer data()
iterator end()
qsizetype indexOf(const AT &value, qsizetype from) const const
bool isEmpty() const const
iterator insert(const Key &key, const T &value)
QList< T > values() const const
QVariant data(int role) const const
bool isValid() const const
const QAbstractItemModel * model() const const
QModelIndex parent() const const
int row() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
virtual QVariant data(const QModelIndex &index, int role) const const override
dynamicSortFilter
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
void invalidateFilter()
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const override
virtual QModelIndex parent(const QModelIndex &child) const const override
virtual int rowCount(const QModelIndex &parent) const const override
void setSortRole(int role)
bool isEmpty() const const
int localeAwareCompare(QStringView s1, QStringView s2)
UniqueConnection
DisplayRole
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
singleShot
bool isNull() const const
bool toBool() const const
QDateTime toDateTime() const const
QString toString() const const
QStringList toStringList() const const
QUrl toUrl() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:51:10 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:51:10 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.