Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/tasksmodel.cpp
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 46 | public: | |||
---|---|---|---|---|---|
65 | int screen = -1; | 65 | int screen = -1; | ||
66 | QString activity; | 66 | QString activity; | ||
67 | 67 | | |||
68 | SortMode sortMode = SortAlpha; | 68 | SortMode sortMode = SortAlpha; | ||
69 | bool separateLaunchers = true; | 69 | bool separateLaunchers = true; | ||
70 | bool launchInPlace = false; | 70 | bool launchInPlace = false; | ||
71 | bool launchersEverSet = false; | 71 | bool launchersEverSet = false; | ||
72 | bool launcherSortingDirty = false; | 72 | bool launcherSortingDirty = false; | ||
73 | QSet<QModelIndex> dirtyLaunchers; | ||||
73 | QList<int> sortedPreFilterRows; | 74 | QList<int> sortedPreFilterRows; | ||
74 | QVector<int> sortRowInsertQueue; | 75 | QVector<int> sortRowInsertQueue; | ||
75 | QHash<QString, int> activityTaskCounts; | 76 | QHash<QString, int> activityTaskCounts; | ||
76 | static ActivityInfo* activityInfo; | 77 | static ActivityInfo* activityInfo; | ||
77 | static int activityInfoUsers; | 78 | static int activityInfoUsers; | ||
78 | 79 | | |||
79 | bool groupInline = false; | 80 | bool groupInline = false; | ||
80 | int groupingWindowTasksThreshold = -1; | 81 | int groupingWindowTasksThreshold = -1; | ||
▲ Show 20 Lines • Show All 291 Lines • ▼ Show 20 Line(s) | 371 | if (!launcherTasksModel | |||
372 | || sourceIndex.data(AbstractTasksModel::IsStartup).toBool())) { | 373 | || sourceIndex.data(AbstractTasksModel::IsStartup).toBool())) { | ||
373 | continue; | 374 | continue; | ||
374 | } | 375 | } | ||
375 | 376 | | |||
376 | for (int j = 0; j < launcherTasksModel->rowCount(); ++j) { | 377 | for (int j = 0; j < launcherTasksModel->rowCount(); ++j) { | ||
377 | const QModelIndex &launcherIndex = launcherTasksModel->index(j, 0); | 378 | const QModelIndex &launcherIndex = launcherTasksModel->index(j, 0); | ||
378 | 379 | | |||
379 | if (appsMatch(sourceIndex, launcherIndex)) { | 380 | if (appsMatch(sourceIndex, launcherIndex)) { | ||
380 | QMetaObject::invokeMethod(launcherTasksModel, "dataChanged", Qt::QueuedConnection, | 381 | dirtyLaunchers.insert(launcherIndex); | ||
381 | Q_ARG(QModelIndex, launcherIndex), Q_ARG(QModelIndex, launcherIndex)); | 382 | } | ||
383 | } | ||||
382 | } | 384 | } | ||
383 | } | 385 | } | ||
386 | ); | ||||
387 | | ||||
388 | QObject::connect(filterProxyModel, &QAbstractItemModel::rowsRemoved, q, | ||||
davidedmundson: I think it's a bit weird that we have a pair:
groupingProxyModel::aboutToRemove… | |||||
389 | [this](const QModelIndex &parent, int first, int last) { | ||||
390 | Q_UNUSED(parent) | ||||
391 | Q_UNUSED(first) | ||||
392 | Q_UNUSED(last) | ||||
393 | | ||||
394 | if (launcherTasksModel && !dirtyLaunchers.isEmpty()) { | ||||
395 | foreach(const QModelIndex &launcherIndex, dirtyLaunchers) { | ||||
396 | QMetaObject::invokeMethod(launcherTasksModel, "dataChanged", | ||||
397 | Q_ARG(QModelIndex, launcherIndex), Q_ARG(QModelIndex, launcherIndex)); | ||||
398 | } | ||||
399 | | ||||
400 | dirtyLaunchers.clear(); | ||||
384 | } | 401 | } | ||
385 | } | 402 | } | ||
386 | ); | 403 | ); | ||
387 | 404 | | |||
388 | // Update anyTaskDemandsAttention on source data changes. | 405 | // Update anyTaskDemandsAttention on source data changes. | ||
389 | QObject::connect(groupingProxyModel, &QAbstractItemModel::dataChanged, q, | 406 | QObject::connect(groupingProxyModel, &QAbstractItemModel::dataChanged, q, | ||
390 | [this](const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) { | 407 | [this](const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) { | ||
391 | Q_UNUSED(bottomRight) | 408 | Q_UNUSED(bottomRight) | ||
▲ Show 20 Lines • Show All 1251 Lines • Show Last 20 Lines |
I think it's a bit weird that we have a pair:
groupingProxyModel::aboutToRemove
filterProxyModel:rowsRemoved
As it doesn't match up evenly.
It'll work, but having them both the same will be less confusing long term.
I think changing the first connect to filterProxyModel might result in logic being overall simpler. You'd be processing the launcher every time any window got removed, but that might fix what's in the bug reports.
Other than that, the change looks good.