Changeset View
Standalone View
libtaskmanager/taskgroupingproxymodel.cpp
Show First 20 Lines • Show All 665 Lines • ▼ Show 20 Line(s) | 663 | if (role == Qt::DisplayRole) { | |||
---|---|---|---|---|---|
666 | // Groups are formed by app id or launcher URL; neither requires | 666 | // Groups are formed by app id or launcher URL; neither requires | ||
667 | // AppName to be available. If it's not, fall back to the app id | 667 | // AppName to be available. If it's not, fall back to the app id | ||
668 | /// rather than an empty string. | 668 | /// rather than an empty string. | ||
669 | if (appName.isEmpty()) { | 669 | if (appName.isEmpty()) { | ||
670 | return sourceIndex.data(AbstractTasksModel::AppId); | 670 | return sourceIndex.data(AbstractTasksModel::AppId); | ||
671 | } | 671 | } | ||
672 | 672 | | |||
673 | return appName; | 673 | return appName; | ||
674 | } else if (role == AbstractTasksModel::LegacyWinIdList) { | 674 | } else if (role == AbstractTasksModel::WinIdList) { | ||
675 | QVariantList winIds; | 675 | QVariantList winIds; | ||
676 | 676 | | |||
677 | for (int i = 0; i < rowCount(proxyIndex); ++i) { | 677 | for (int i = 0; i < rowCount(proxyIndex); ++i) { | ||
678 | winIds.append(proxyIndex.child(i, 0).data(AbstractTasksModel::LegacyWinIdList).toList()); | 678 | winIds.append(proxyIndex.child(i, 0).data(AbstractTasksModel::WinIdList).toList()); | ||
679 | } | 679 | } | ||
680 | 680 | | |||
681 | return winIds; | 681 | return winIds; | ||
682 | } else if (role == AbstractTasksModel::MimeType) { | 682 | } else if (role == AbstractTasksModel::MimeType) { | ||
683 | // FIXME: Legacy X11 stuff, but it's what we have for now. | 683 | // FIXME: Legacy X11 stuff, but it's what we have for now. | ||
684 | return QStringLiteral("windowsystem/multiple-winids"); | 684 | return QStringLiteral("windowsystem/multiple-winids"); | ||
685 | } else if (role == AbstractTasksModel::MimeData) { | 685 | } else if (role == AbstractTasksModel::MimeData) { | ||
686 | // FIXME TODO: Implement. | 686 | // FIXME TODO: Implement. | ||
Show All 27 Lines | |||||
714 | } else if (role == AbstractTasksModel::IsFullScreenable) { | 714 | } else if (role == AbstractTasksModel::IsFullScreenable) { | ||
715 | return d->all(proxyIndex, AbstractTasksModel::IsFullScreenable); | 715 | return d->all(proxyIndex, AbstractTasksModel::IsFullScreenable); | ||
716 | } else if (role == AbstractTasksModel::IsFullScreen) { | 716 | } else if (role == AbstractTasksModel::IsFullScreen) { | ||
717 | return d->all(proxyIndex, AbstractTasksModel::IsFullScreen); | 717 | return d->all(proxyIndex, AbstractTasksModel::IsFullScreen); | ||
718 | } else if (role == AbstractTasksModel::IsShadeable) { | 718 | } else if (role == AbstractTasksModel::IsShadeable) { | ||
719 | return d->all(proxyIndex, AbstractTasksModel::IsShadeable); | 719 | return d->all(proxyIndex, AbstractTasksModel::IsShadeable); | ||
720 | } else if (role == AbstractTasksModel::IsShaded) { | 720 | } else if (role == AbstractTasksModel::IsShaded) { | ||
721 | return d->all(proxyIndex, AbstractTasksModel::IsShaded); | 721 | return d->all(proxyIndex, AbstractTasksModel::IsShaded); | ||
722 | } else if (role == AbstractTasksModel::IsVirtualDesktopChangeable) { | 722 | } else if (role == AbstractTasksModel::IsVirtualDesktopsChangeable) { | ||
723 | return d->all(proxyIndex, AbstractTasksModel::IsVirtualDesktopChangeable); | 723 | return d->all(proxyIndex, AbstractTasksModel::IsVirtualDesktopsChangeable); | ||
724 | } else if (role == AbstractTasksModel::VirtualDesktop) { | 724 | } else if (role == AbstractTasksModel::VirtualDesktops) { | ||
725 | // Returns the lowest virtual desktop id among all children of the | 725 | // FIXME WAYLAND Similar to activities | ||
davidedmundson: should be mostly a copy/paste right? Anything holding this up? | |||||
The sorting code will look at the first desktop in practice, which is why it should be the lowest desktop. I wasn't sure if I can rely on PlasmaWindow::plasmaVirtualDesktops() to return the desktops in position-sorting order. Something for @mart to answer. hein: The sorting code will look at the first desktop in practice, which is why it should be the… | |||||
no, the desktops in plasmawindow are just in order of "last added last" mart: no, the desktops in plasmawindow are just in order of "last added last"
if is needed they… | |||||
mart: what's the rationale of this dead code? | |||||
726 | // group. | 726 | // // Returns the lowest virtual desktop id among all children of the | ||
727 | int virtualDesktop = INT_MAX; | 727 | // // group. | ||
728 | 728 | // int virtualDesktop = INT_MAX; | |||
729 | for (int i = 0; i < rowCount(proxyIndex); ++i) { | 729 | // | ||
730 | const int childVirtualDesktop = proxyIndex.child(i, 0).data(AbstractTasksModel::VirtualDesktop).toInt(); | 730 | // for (int i = 0; i < rowCount(proxyIndex); ++i) { | ||
731 | 731 | // const int childVirtualDesktop = proxyIndex.child(i, 0).data(AbstractTasksModel::VirtualDesktop).toInt(); | |||
732 | if (childVirtualDesktop < virtualDesktop) { | 732 | // | ||
733 | virtualDesktop = childVirtualDesktop; | 733 | // if (childVirtualDesktop < virtualDesktop) { | ||
734 | } | 734 | // virtualDesktop = childVirtualDesktop; | ||
735 | } | 735 | // } | ||
736 | 736 | // } | |||
737 | return virtualDesktop; | 737 | // | ||
738 | // return virtualDesktop; | ||||
738 | } else if (role == AbstractTasksModel::ScreenGeometry) { | 739 | } else if (role == AbstractTasksModel::ScreenGeometry) { | ||
739 | // TODO: Nothing needs this for now and it would add complexity to | 740 | // TODO: Nothing needs this for now and it would add complexity to | ||
740 | // make it a list; skip it until needed. Once it is, do it similarly | 741 | // make it a list; skip it until needed. Once it is, do it similarly | ||
741 | // to the AbstractTasksModel::VirtualDesktop case. | 742 | // to the AbstractTasksModel::VirtualDesktop case. | ||
742 | return QVariant(); | 743 | return QVariant(); | ||
743 | } else if (role == AbstractTasksModel::Activities) { | 744 | } else if (role == AbstractTasksModel::Activities) { | ||
744 | QStringList activities; | 745 | QStringList activities; | ||
745 | 746 | | |||
▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Line(s) | 1103 | for (int i = 0; i < rowCount(index); ++i) { | |||
1104 | 1105 | | |||
1105 | if (child.data(AbstractTasksModel::IsShaded).toBool() != goalState) { | 1106 | if (child.data(AbstractTasksModel::IsShaded).toBool() != goalState) { | ||
1106 | d->abstractTasksSourceModel->requestToggleShaded(mapToSource(child)); | 1107 | d->abstractTasksSourceModel->requestToggleShaded(mapToSource(child)); | ||
1107 | } | 1108 | } | ||
1108 | } | 1109 | } | ||
1109 | } | 1110 | } | ||
1110 | } | 1111 | } | ||
1111 | 1112 | | |||
1112 | void TaskGroupingProxyModel::requestVirtualDesktop(const QModelIndex &index, qint32 desktop) | 1113 | void TaskGroupingProxyModel::requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) | ||
1113 | { | 1114 | { | ||
1114 | if (!d->abstractTasksSourceModel || !index.isValid() || index.model() != this) { | 1115 | if (!d->abstractTasksSourceModel || !index.isValid() || index.model() != this) { | ||
1115 | return; | 1116 | return; | ||
1116 | } | 1117 | } | ||
1117 | 1118 | | |||
1118 | if (index.parent().isValid() || !d->isGroup(index.row())) { | 1119 | if (index.parent().isValid() || !d->isGroup(index.row())) { | ||
1119 | d->abstractTasksSourceModel->requestVirtualDesktop(mapToSource(index), desktop); | 1120 | d->abstractTasksSourceModel->requestVirtualDesktops(mapToSource(index), desktops); | ||
1120 | } else { | 1121 | } else { | ||
1121 | const int row = index.row(); | 1122 | const int row = index.row(); | ||
1122 | 1123 | | |||
1123 | for (int i = (rowCount(index) - 1); i >= 1; --i) { | 1124 | for (int i = (rowCount(index) - 1); i >= 1; --i) { | ||
1124 | const QModelIndex &sourceChild = mapToSource(index.child(i, 0)); | 1125 | const QModelIndex &sourceChild = mapToSource(index.child(i, 0)); | ||
1125 | d->abstractTasksSourceModel->requestVirtualDesktop(sourceChild, desktop); | 1126 | d->abstractTasksSourceModel->requestVirtualDesktops(sourceChild, desktops); | ||
1126 | } | 1127 | } | ||
1127 | 1128 | | |||
1128 | d->abstractTasksSourceModel->requestVirtualDesktop(mapToSource(TaskGroupingProxyModel::index(row, 0)), | 1129 | d->abstractTasksSourceModel->requestVirtualDesktops(mapToSource(TaskGroupingProxyModel::index(row, 0)), | ||
Am I reading this right? We iterate backwards from N -> 1 because moving the desktop /might/ filter them. I would expect this to not work if a user is sorting by virtual desktops. Would it work to generate a list of sourceIndexes from all children one loop, then go over those indexes requesting the desktops? davidedmundson: Am I reading this right?
We iterate backwards from N -> 1 because moving the desktop /might/… | |||||
Can you explain how sorting comes into this? (Sorting is done a level up in TasksModel.) hein: Can you explain how sorting comes into this? (Sorting is done a level up in TasksModel.) | |||||
1129 | desktop); | 1130 | desktops); | ||
1130 | } | 1131 | } | ||
1131 | } | 1132 | } | ||
1132 | 1133 | | |||
1133 | void TaskGroupingProxyModel::requestActivities(const QModelIndex &index, const QStringList &activities) | 1134 | void TaskGroupingProxyModel::requestActivities(const QModelIndex &index, const QStringList &activities) | ||
1134 | { | 1135 | { | ||
1135 | if (!d->abstractTasksSourceModel || !index.isValid() || index.model() != this) { | 1136 | if (!d->abstractTasksSourceModel || !index.isValid() || index.model() != this) { | ||
1136 | return; | 1137 | return; | ||
1137 | } | 1138 | } | ||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |
should be mostly a copy/paste right? Anything holding this up?