7#include "taskgroupingproxymodel.h"
8#include "abstracttasksmodel.h"
16class Q_DECL_HIDDEN TaskGroupingProxyModel::Private
19 Private(TaskGroupingProxyModel *q);
22 AbstractTasksModelIface *abstractTasksSourceModel =
nullptr;
24 TasksModel::GroupMode groupMode = TasksModel::GroupApplications;
25 bool groupDemandingAttention =
false;
26 int windowTasksThreshold = -1;
33 bool isGroup(
int row);
37 void sourceRowsAboutToBeInserted(
const QModelIndex &parent,
int first,
int last);
39 void sourceRowsAboutToBeRemoved(
const QModelIndex &parent,
int first,
int last);
41 void sourceModelAboutToBeReset();
42 void sourceModelReset();
44 void adjustMap(
int anchor,
int delta);
47 bool shouldGroupTasks();
48 void checkGrouping(
bool silent =
false);
50 bool tryToGroup(
const QModelIndex &sourceIndex,
bool silent =
false);
52 void breakGroupFor(
const QModelIndex &index,
bool silent =
false);
55 TaskGroupingProxyModel *q;
58TaskGroupingProxyModel::Private::Private(TaskGroupingProxyModel *q)
63TaskGroupingProxyModel::Private::~Private()
68bool TaskGroupingProxyModel::Private::isGroup(
int row)
70 if (row < 0 || row >= rowMap.
count()) {
74 return (rowMap.
at(row)->count() > 1);
77bool TaskGroupingProxyModel::Private::any(
const QModelIndex &parent,
int role)
81 for (
int i = 0; i < q->rowCount(parent); ++i) {
82 if (q->index(i, 0, parent).data(role).toBool()) {
90bool TaskGroupingProxyModel::Private::all(
const QModelIndex &parent,
int role)
94 for (
int i = 0; i < q->rowCount(parent); ++i) {
95 if (!q->index(i, 0, parent).data(role).toBool()) {
103void TaskGroupingProxyModel::Private::sourceRowsAboutToBeInserted(
const QModelIndex &parent,
int first,
int last)
110void TaskGroupingProxyModel::Private::sourceRowsInserted(
const QModelIndex &parent,
int start,
int end)
119 bool shouldGroup = shouldGroupTasks();
121 for (
int i =
start; i <=
end; ++i) {
122 if (!shouldGroup || !tryToGroup(q->sourceModel()->index(i, 0))) {
132void TaskGroupingProxyModel::Private::sourceRowsAboutToBeRemoved(
const QModelIndex &parent,
int first,
int last)
139 for (
int i = first; i <= last; ++i) {
140 for (
int j = 0; j < rowMap.
count(); ++j) {
142 const int mapIndex = sourceRows->
indexOf(i);
144 if (mapIndex != -1) {
146 if (sourceRows->
count() == 1) {
151 }
else if (sourceRows->
count() == 2) {
153 q->beginRemoveRows(parent, 0, 1);
154 rowMap[j]->
remove(mapIndex);
158 Q_EMIT q->dataChanged(parent, parent);
162 q->beginRemoveRows(parent, mapIndex, mapIndex);
163 rowMap[j]->
remove(mapIndex);
168 Q_EMIT q->dataChanged(parent, parent);
177void TaskGroupingProxyModel::Private::sourceRowsRemoved(
const QModelIndex &parent,
int start,
int end)
189void TaskGroupingProxyModel::Private::sourceModelAboutToBeReset()
191 q->beginResetModel();
194void TaskGroupingProxyModel::Private::sourceModelReset()
203 for (
int i = topLeft.
row(); i <= bottomRight.
row(); ++i) {
204 const QModelIndex &sourceIndex = q->sourceModel()->index(i, 0);
205 QModelIndex proxyIndex = q->mapFromSource(sourceIndex);
218 Q_EMIT q->dataChanged(parent, parent, roles);
224 if (!parent.
isValid() && !groupDemandingAttention && roles.
contains(AbstractTasksModel::IsDemandingAttention)
225 && !sourceIndex.
data(AbstractTasksModel::IsDemandingAttention).
toBool()) {
226 if (shouldGroupTasks() && tryToGroup(sourceIndex)) {
231 Q_EMIT q->dataChanged(proxyIndex, proxyIndex, roles);
234 Q_EMIT q->dataChanged(proxyIndex, proxyIndex, roles);
239void TaskGroupingProxyModel::Private::adjustMap(
int anchor,
int delta)
241 for (
int i = 0; i < rowMap.
count(); ++i) {
243 for (
auto it = sourceRows->
begin(); it != sourceRows->
end(); ++it) {
244 if ((*it) >= anchor) {
251void TaskGroupingProxyModel::Private::rebuildMap()
256 const int rows = q->sourceModel()->rowCount();
260 for (
int i = 0; i < rows; ++i) {
264 checkGrouping(
true );
267bool TaskGroupingProxyModel::Private::shouldGroupTasks()
269 if (groupMode == TasksModel::GroupDisabled) {
273 if (windowTasksThreshold != -1) {
280 int windowTasksCount = 0;
282 for (
int i = 0; i < q->sourceModel()->rowCount(); ++i) {
283 const QModelIndex &idx = q->sourceModel()->index(i, 0);
285 if (idx.
data(AbstractTasksModel::IsWindow).
toBool()) {
290 return (windowTasksCount > windowTasksThreshold);
296void TaskGroupingProxyModel::Private::checkGrouping(
bool silent)
298 if (shouldGroupTasks()) {
299 for (
int i = (rowMap.
count()) - 1; i >= 0; --i) {
304 if (tryToGroup(q->sourceModel()->index(rowMap.
at(i)->constFirst(), 0), silent)) {
311 for (
int i = (rowMap.
count()) - 1; i >= 0; --i) {
312 breakGroupFor(q->index(i, 0), silent);
317bool TaskGroupingProxyModel::Private::isBlacklisted(
const QModelIndex &sourceIndex)
325 if (blacklistedLauncherUrls.
count()) {
326 const QUrl &launcherUrl = sourceIndex.
data(AbstractTasksModel::LauncherUrlWithoutIcon).
toUrl();
329 if (blacklistedLauncherUrls.
contains(launcherUrlString)) {
337bool TaskGroupingProxyModel::Private::tryToGroup(
const QModelIndex &sourceIndex,
bool silent)
343 if (!sourceIndex.
data(AbstractTasksModel::IsWindow).
toBool()) {
350 if (!groupDemandingAttention && sourceIndex.
data(AbstractTasksModel::IsDemandingAttention).
toBool()) {
355 if (isBlacklisted(sourceIndex)) {
361 for (
int i = 0; i < rowMap.
count(); ++i) {
362 const QModelIndex &groupRep = q->sourceModel()->index(rowMap.
at(i)->constFirst(), 0);
365 if (sourceIndex == groupRep) {
370 if (!groupRep.
data(AbstractTasksModel::IsWindow).
toBool()) {
374 if (appsMatch(sourceIndex, groupRep)) {
378 const int newIndex = rowMap.
at(i)->count();
381 q->beginInsertRows(parent, 0, 1);
383 q->beginInsertRows(parent, newIndex, newIndex);
392 Q_EMIT q->dataChanged(parent, parent);
402void TaskGroupingProxyModel::Private::formGroupFor(
const QModelIndex &index)
411 const QModelIndex &sourceTarget = q->mapToSource(index);
413 for (
int i = (rowMap.
count() - 1); i >= 0; --i) {
414 const QModelIndex &sourceIndex = q->sourceModel()->index(rowMap.
at(i)->constFirst(), 0);
416 if (!appsMatch(sourceTarget, sourceIndex)) {
420 if (tryToGroup(sourceIndex)) {
428void TaskGroupingProxyModel::Private::breakGroupFor(
const QModelIndex &index,
bool silent)
430 const int row = index.
row();
445 q->beginRemoveRows(index, 0, extraChildren.
count());
454 Q_EMIT q->dataChanged(index, index);
459 for (
int i = 0; i < extraChildren.
count(); ++i) {
468TaskGroupingProxyModel::TaskGroupingProxyModel(
QObject *parent)
470 , d(new Private(this))
474TaskGroupingProxyModel::~TaskGroupingProxyModel()
480 if (row < 0 || column != 0) {
484 if (parent.
isValid() && row < d->rowMap.
at(parent.
row())->count()) {
485 return createIndex(row, column, d->rowMap.at(parent.
row()));
488 if (row < d->rowMap.
count()) {
489 return createIndex(row, column,
nullptr);
502 if (parentRow != -1) {
503 return index(parentRow, 0);
508 Q_ASSERT(parentRow != -1);
516 if (!sourceIndex.
isValid() || sourceIndex.
model() != sourceModel()) {
520 for (
int i = 0; i < d->rowMap.count(); ++i) {
522 const int childIndex = sourceRows->
indexOf(sourceIndex.
row());
525 if (childIndex == 0) {
531 return index(0, 0, parent);
536 }
else if (childIndex != -1) {
537 return index(childIndex, 0, parent);
546 if (!proxyIndex.
isValid() || proxyIndex.
model() !=
this || !sourceModel()) {
553 if (parent.
row() < 0 || parent.
row() >= d->rowMap.count()) {
557 return sourceModel()->index(d->rowMap.at(parent.
row())->at(proxyIndex.
row()), 0);
565 return sourceModel()->index(d->rowMap.at(proxyIndex.
row())->at(0), 0);
571int TaskGroupingProxyModel::rowCount(
const QModelIndex &parent)
const
573 if (!sourceModel()) {
584 if (parent.
row() < 0 || parent.
row() >= d->rowMap.count()) {
588 const uint rowCount = d->rowMap.at(parent.
row())->count();
599 return d->rowMap.count();
602bool TaskGroupingProxyModel::hasChildren(
const QModelIndex &parent)
const
604 if ((parent.
model() && parent.
model() !=
this) || !sourceModel()) {
608 return rowCount(parent);
611int TaskGroupingProxyModel::columnCount(
const QModelIndex &parent)
const
620 if (!proxyIndex.
isValid() || proxyIndex.
model() !=
this || !sourceModel()) {
625 const bool isWindowGroup = (!parent.
isValid() && d->isGroup(proxyIndex.
row()));
628 const QModelIndex &sourceIndex = mapToSource(proxyIndex);
634 if (role == AbstractTasksModel::IsGroupable) {
635 return !d->isBlacklisted(sourceIndex);
647 return sourceIndex.
data(AbstractTasksModel::AppId);
651 }
else if (role == AbstractTasksModel::WinIdList) {
654 for (
int i = 0; i < rowCount(proxyIndex); ++i) {
655 winIds.append(index(i, 0, proxyIndex).data(AbstractTasksModel::WinIdList).toList());
659 }
else if (role == AbstractTasksModel::MimeType) {
660 return QStringLiteral(
"windowsystem/multiple-winids");
661 }
else if (role == AbstractTasksModel::MimeData) {
664 }
else if (role == AbstractTasksModel::IsGroupParent) {
666 }
else if (role == AbstractTasksModel::ChildCount) {
667 return rowCount(proxyIndex);
668 }
else if (role == AbstractTasksModel::IsActive) {
669 return d->any(proxyIndex, AbstractTasksModel::IsActive);
670 }
else if (role == AbstractTasksModel::IsClosable) {
671 return d->all(proxyIndex, AbstractTasksModel::IsClosable);
672 }
else if (role == AbstractTasksModel::IsMovable) {
675 }
else if (role == AbstractTasksModel::IsResizable) {
678 }
else if (role == AbstractTasksModel::IsMaximizable) {
679 return d->all(proxyIndex, AbstractTasksModel::IsMaximizable);
680 }
else if (role == AbstractTasksModel::IsMaximized) {
681 return d->all(proxyIndex, AbstractTasksModel::IsMaximized);
682 }
else if (role == AbstractTasksModel::IsMinimizable) {
683 return d->all(proxyIndex, AbstractTasksModel::IsMinimizable);
684 }
else if (role == AbstractTasksModel::IsMinimized) {
685 return d->all(proxyIndex, AbstractTasksModel::IsMinimized);
686 }
else if (role == AbstractTasksModel::IsKeepAbove) {
687 return d->all(proxyIndex, AbstractTasksModel::IsKeepAbove);
688 }
else if (role == AbstractTasksModel::IsKeepBelow) {
689 return d->all(proxyIndex, AbstractTasksModel::IsKeepBelow);
690 }
else if (role == AbstractTasksModel::IsFullScreenable) {
691 return d->all(proxyIndex, AbstractTasksModel::IsFullScreenable);
692 }
else if (role == AbstractTasksModel::IsFullScreen) {
693 return d->all(proxyIndex, AbstractTasksModel::IsFullScreen);
694 }
else if (role == AbstractTasksModel::IsShadeable) {
695 return d->all(proxyIndex, AbstractTasksModel::IsShadeable);
696 }
else if (role == AbstractTasksModel::IsShaded) {
697 return d->all(proxyIndex, AbstractTasksModel::IsShaded);
698 }
else if (role == AbstractTasksModel::IsVirtualDesktopsChangeable) {
699 return d->all(proxyIndex, AbstractTasksModel::IsVirtualDesktopsChangeable);
700 }
else if (role == AbstractTasksModel::VirtualDesktops) {
703 for (
int i = 0; i < rowCount(proxyIndex); ++i) {
704 desktops.
append(index(i, 0, proxyIndex).data(AbstractTasksModel::VirtualDesktops).toStringList());
709 }
else if (role == AbstractTasksModel::ScreenGeometry) {
714 }
else if (role == AbstractTasksModel::Activities) {
717 for (
int i = 0; i < rowCount(proxyIndex); ++i) {
718 activities.
append(index(i, 0, proxyIndex).data(AbstractTasksModel::Activities).toStringList());
723 }
else if (role == AbstractTasksModel::IsDemandingAttention) {
724 return d->any(proxyIndex, AbstractTasksModel::IsDemandingAttention);
725 }
else if (role == AbstractTasksModel::SkipTaskbar) {
726 return d->all(proxyIndex, AbstractTasksModel::SkipTaskbar);
727 }
else if (role == AbstractTasksModel::LastActivated) {
729 const int groupSize = d->rowMap.at(proxyIndex.
row())->size();
730 QTime lastActivated = mapToSource(index(0, 0, proxyIndex)).data(AbstractTasksModel::LastActivated).toTime();
732 for (
int i = 1; i < groupSize; i++) {
733 const QTime activated = mapToSource(index(i, 0, proxyIndex)).data(AbstractTasksModel::LastActivated).toTime();
735 if (lastActivated < activated) {
736 lastActivated = activated;
740 return lastActivated;
744 return sourceIndex.
data(role);
760 d->abstractTasksSourceModel =
dynamic_cast<AbstractTasksModelIface *
>(sourceModel);
765 using namespace std::placeholders;
770 std::bind(&TaskGroupingProxyModel::Private::sourceRowsAboutToBeInserted, dd, _1, _2, _3));
775 std::bind(&TaskGroupingProxyModel::Private::sourceRowsAboutToBeRemoved, dd, _1, _2, _3));
781 qDeleteAll(d->rowMap);
795 if (d->groupMode != mode) {
800 Q_EMIT groupModeChanged();
804bool TaskGroupingProxyModel::groupDemandingAttention()
const
806 return d->groupDemandingAttention;
809void TaskGroupingProxyModel::setGroupDemandingAttention(
bool group)
811 if (d->groupDemandingAttention != group) {
812 d->groupDemandingAttention = group;
816 Q_EMIT groupDemandingAttentionChanged();
820int TaskGroupingProxyModel::windowTasksThreshold()
const
822 return d->windowTasksThreshold;
825void TaskGroupingProxyModel::setWindowTasksThreshold(
int threshold)
827 if (d->windowTasksThreshold != threshold) {
828 d->windowTasksThreshold = threshold;
832 Q_EMIT windowTasksThresholdChanged();
838 return d->blacklistedAppIds.values();
841void TaskGroupingProxyModel::setBlacklistedAppIds(
const QStringList &list)
845 if (d->blacklistedAppIds != set) {
846 d->blacklistedAppIds = set;
853 for (
int i = (d->rowMap.count() - 1); i >= 0; --i) {
858 d->breakGroupFor(groupRep);
863 Q_EMIT blacklistedAppIdsChanged();
867QStringList TaskGroupingProxyModel::blacklistedLauncherUrls()
const
869 return d->blacklistedLauncherUrls.values();
872void TaskGroupingProxyModel::setBlacklistedLauncherUrls(
const QStringList &list)
876 if (d->blacklistedLauncherUrls != set) {
877 d->blacklistedLauncherUrls = set;
884 for (
int i = (d->rowMap.count() - 1); i >= 0; --i) {
887 const QUrl &launcherUrl = groupRep.
data(AbstractTasksModel::LauncherUrlWithoutIcon).
toUrl();
890 if (set.
contains(launcherUrlString)) {
891 d->breakGroupFor(groupRep);
896 Q_EMIT blacklistedLauncherUrlsChanged();
900void TaskGroupingProxyModel::requestActivate(
const QModelIndex &index)
902 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
907 d->abstractTasksSourceModel->requestActivate(mapToSource(index));
911void TaskGroupingProxyModel::requestNewInstance(
const QModelIndex &index)
913 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
917 d->abstractTasksSourceModel->requestNewInstance(mapToSource(index));
922 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
926 d->abstractTasksSourceModel->requestOpenUrls(mapToSource(index), urls);
929void TaskGroupingProxyModel::requestClose(
const QModelIndex &index)
931 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
936 d->abstractTasksSourceModel->requestClose(mapToSource(index));
938 const int row = index.
row();
940 for (
int i = (rowCount(index) - 1); i >= 1; --i) {
941 const QModelIndex &sourceChild = mapToSource(this->index(i, 0, index));
942 d->abstractTasksSourceModel->requestClose(sourceChild);
945 d->abstractTasksSourceModel->requestClose(mapToSource(TaskGroupingProxyModel::index(row, 0)));
951 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
956 d->abstractTasksSourceModel->requestMove(mapToSource(index));
960void TaskGroupingProxyModel::requestResize(
const QModelIndex &index)
962 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
967 d->abstractTasksSourceModel->requestResize(mapToSource(index));
971void TaskGroupingProxyModel::requestToggleMinimized(
const QModelIndex &index)
973 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
978 d->abstractTasksSourceModel->requestToggleMinimized(mapToSource(index));
980 const bool goalState = !index.
data(AbstractTasksModel::IsHidden).
toBool();
982 for (
int i = 0; i < rowCount(index); ++i) {
983 const QModelIndex &child = this->index(i, 0, index);
985 if (child.
data(AbstractTasksModel::IsHidden).
toBool() != goalState) {
986 d->abstractTasksSourceModel->requestToggleMinimized(mapToSource(child));
992void TaskGroupingProxyModel::requestToggleMaximized(
const QModelIndex &index)
994 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
999 d->abstractTasksSourceModel->requestToggleMaximized(mapToSource(index));
1001 const bool goalState = !index.
data(AbstractTasksModel::IsMaximized).
toBool();
1003 QModelIndexList inStackingOrder;
1005 for (
int i = 0; i < rowCount(index); ++i) {
1006 const QModelIndex &child = this->index(i, 0, index);
1008 if (child.
data(AbstractTasksModel::IsMaximized).
toBool() != goalState) {
1009 inStackingOrder << mapToSource(child);
1013 std::sort(inStackingOrder.begin(), inStackingOrder.end(), [](
const QModelIndex &a,
const QModelIndex &b) {
1014 return (a.data(AbstractTasksModel::StackingOrder).toInt() < b.data(AbstractTasksModel::StackingOrder).toInt());
1017 for (
const QModelIndex &sourceChild : std::as_const(inStackingOrder)) {
1018 d->abstractTasksSourceModel->requestToggleMaximized(sourceChild);
1023void TaskGroupingProxyModel::requestToggleKeepAbove(
const QModelIndex &index)
1025 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1030 d->abstractTasksSourceModel->requestToggleKeepAbove(mapToSource(index));
1032 const bool goalState = !index.
data(AbstractTasksModel::IsKeepAbove).
toBool();
1034 for (
int i = 0; i < rowCount(index); ++i) {
1035 const QModelIndex &child = this->index(i, 0, index);
1037 if (child.
data(AbstractTasksModel::IsKeepAbove).
toBool() != goalState) {
1038 d->abstractTasksSourceModel->requestToggleKeepAbove(mapToSource(child));
1044void TaskGroupingProxyModel::requestToggleKeepBelow(
const QModelIndex &index)
1046 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1051 d->abstractTasksSourceModel->requestToggleKeepBelow(mapToSource(index));
1053 const bool goalState = !index.
data(AbstractTasksModel::IsKeepBelow).
toBool();
1055 for (
int i = 0; i < rowCount(index); ++i) {
1056 const QModelIndex &child = this->index(i, 0, index);
1058 if (child.
data(AbstractTasksModel::IsKeepBelow).
toBool() != goalState) {
1059 d->abstractTasksSourceModel->requestToggleKeepBelow(mapToSource(child));
1065void TaskGroupingProxyModel::requestToggleFullScreen(
const QModelIndex &index)
1067 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1072 d->abstractTasksSourceModel->requestToggleFullScreen(mapToSource(index));
1074 const bool goalState = !index.
data(AbstractTasksModel::IsFullScreen).
toBool();
1076 for (
int i = 0; i < rowCount(index); ++i) {
1077 const QModelIndex &child = this->index(i, 0, index);
1079 if (child.
data(AbstractTasksModel::IsFullScreen).
toBool() != goalState) {
1080 d->abstractTasksSourceModel->requestToggleFullScreen(mapToSource(child));
1086void TaskGroupingProxyModel::requestToggleShaded(
const QModelIndex &index)
1088 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1093 d->abstractTasksSourceModel->requestToggleShaded(mapToSource(index));
1095 const bool goalState = !index.
data(AbstractTasksModel::IsShaded).
toBool();
1097 for (
int i = 0; i < rowCount(index); ++i) {
1098 const QModelIndex &child = this->index(i, 0, index);
1100 if (child.
data(AbstractTasksModel::IsShaded).
toBool() != goalState) {
1101 d->abstractTasksSourceModel->requestToggleShaded(mapToSource(child));
1107void TaskGroupingProxyModel::requestVirtualDesktops(
const QModelIndex &index,
const QVariantList &desktops)
1109 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1114 d->abstractTasksSourceModel->requestVirtualDesktops(mapToSource(index), desktops);
1118 const int childCount = rowCount(index);
1120 groupChildren.
reserve(childCount);
1122 for (
int i = (childCount - 1); i >= 0; --i) {
1123 groupChildren.
append(mapToSource(this->index(i, 0, index)));
1127 d->abstractTasksSourceModel->requestVirtualDesktops(idx, desktops);
1132void TaskGroupingProxyModel::requestNewVirtualDesktop(
const QModelIndex &index)
1134 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1139 d->abstractTasksSourceModel->requestNewVirtualDesktop(mapToSource(index));
1143 const int childCount = rowCount(index);
1145 groupChildren.
reserve(childCount);
1147 for (
int i = (childCount - 1); i >= 0; --i) {
1148 groupChildren.
append(mapToSource(this->index(i, 0, index)));
1152 d->abstractTasksSourceModel->requestNewVirtualDesktop(idx);
1159 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1164 d->abstractTasksSourceModel->requestActivities(mapToSource(index), activities);
1168 const int childCount = rowCount(index);
1170 groupChildren.
reserve(childCount);
1172 for (
int i = (childCount - 1); i >= 0; --i) {
1173 groupChildren.
append(mapToSource(this->index(i, 0, index)));
1177 d->abstractTasksSourceModel->requestActivities(idx, activities);
1184 if (!d->abstractTasksSourceModel || !index.
isValid() || index.
model() !=
this) {
1189 d->abstractTasksSourceModel->requestPublishDelegateGeometry(mapToSource(index), geometry, delegate);
1191 for (
int i = 0; i < rowCount(index); ++i) {
1192 d->abstractTasksSourceModel->requestPublishDelegateGeometry(mapToSource(this->index(i, 0, index)), geometry, delegate);
1197void TaskGroupingProxyModel::requestToggleGrouping(
const QModelIndex &index)
1200 const QUrl &launcherUrl = index.
data(AbstractTasksModel::LauncherUrlWithoutIcon).
toUrl();
1203 if (d->blacklistedAppIds.contains(appId) || d->blacklistedLauncherUrls.contains(launcherUrlString)) {
1204 d->blacklistedAppIds.remove(appId);
1205 d->blacklistedLauncherUrls.remove(launcherUrlString);
1207 if (d->groupMode != TasksModel::GroupDisabled) {
1211 d->blacklistedAppIds.insert(appId);
1212 d->blacklistedLauncherUrls.insert(launcherUrlString);
1214 if (d->groupMode != TasksModel::GroupDisabled) {
1222 for (
int i = 0; i < d->rowMap.count(); ++i) {
1223 if (!d->isGroup(i)) {
1224 const QModelIndex &idx = TaskGroupingProxyModel::index(i, 0);
1226 if (idx.
data(AbstractTasksModel::AppId).
toString() == appId
1227 || launcherUrlsMatch(idx.
data(AbstractTasksModel::LauncherUrlWithoutIcon).
toUrl(), launcherUrl, IgnoreQueryItems)) {
1228 Q_EMIT dataChanged(idx, idx,
QList<int>{AbstractTasksModel::IsGroupable});
1233 Q_EMIT blacklistedAppIdsChanged();
1234 Q_EMIT blacklistedLauncherUrlsChanged();
1239#include "moc_taskgroupingproxymodel.cpp"
Q_SCRIPTABLE Q_NOREPLY void start()
const QList< QKeySequence > & end()
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void modelAboutToBeReset()
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)
virtual void setSourceModel(QAbstractItemModel *sourceModel)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
const_iterator cbegin() const const
const_iterator cend() const const
bool contains(const AT &value) const const
qsizetype count() const const
qsizetype indexOf(const AT &value, qsizetype from) const const
void remove(qsizetype i, qsizetype n)
void reserve(qsizetype size)
void resize(qsizetype size)
QVariant data(int role) const const
void * internalPointer() const const
bool isValid() const const
const QAbstractItemModel * model() const const
QModelIndex parent() const const
bool contains(const QSet< T > &other) const const
qsizetype count() const const
bool isEmpty() const const
qsizetype removeDuplicates()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString toString(FormattingOptions options) const const
bool toBool() const const
QString toString() const const