From 5632f4c38943b28829ce6013e3dd858b8d9e2a2f Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Sat, 18 Feb 2017 03:20:39 +0900 Subject: [PATCH] Port to QMultiHash. Reviewers: #plasma, fvogt, graesslin Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4654 --- libtaskmanager/xwindowtasksmodel.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/libtaskmanager/xwindowtasksmodel.cpp b/libtaskmanager/xwindowtasksmodel.cpp index 360ac7cbf..f8091be83 100644 --- a/libtaskmanager/xwindowtasksmodel.cpp +++ b/libtaskmanager/xwindowtasksmodel.cpp @@ -62,7 +62,7 @@ public: QVector windows; QSet transients; - QHash transientsDemandingAttention; + QMultiHash transientsDemandingAttention; QHash windowInfoCache; QHash appDataCache; QHash delegateGeometries; @@ -257,22 +257,10 @@ void XWindowTasksModel::Private::removeWindow(WId window) } else { // Could be a transient. // Removing a transient might change the demands attention state of the leader. if (transients.remove(window)) { - QMutableHashIterator i(transientsDemandingAttention); - WId leader = 0; + const WId leader = transientsDemandingAttention.key(window, XCB_WINDOW_NONE); - while (i.hasNext()) { - i.next(); - - if (i.value() == window) { - if (leader == 0) { - leader = i.key(); - } - - i.remove(); - } - } - - if (leader != 0) { + if (leader != XCB_WINDOW_NONE) { + transientsDemandingAttention.remove(leader, window); dataChanged(leader, QVector{IsDemandingAttention}); } } @@ -307,14 +295,13 @@ void XWindowTasksModel::Private::transientChanged(WId window, NET::Properties pr const KWindowInfo info(window, NET::WMState | NET::XAWMState, NET::WM2TransientFor); if (info.hasState(NET::DemandsAttention)) { - QMutableHashIterator i(transientsDemandingAttention); + const WId oldLeader = transientsDemandingAttention.key(window, XCB_WINDOW_NONE); - if (i.findNext(window)) { + if (oldLeader != XCB_WINDOW_NONE) { const WId leader = info.transientFor(); - const WId oldLeader = i.key(); if (leader != oldLeader) { - i.remove(); + transientsDemandingAttention.remove(oldLeader, window); transientsDemandingAttention.insertMulti(leader, window); dataChanged(oldLeader, QVector{IsDemandingAttention}); dataChanged(leader, QVector{IsDemandingAttention});