[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:04:39 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=751cf71
The following commit has been merged in the master branch:
commit 751cf71a63996deff524573c9f46ab68371c809a
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date: Fri Oct 28 18:13:05 2011 +0200
Fix KPresence operator< ineffectivness by splitting the priority checking to a separate method with switch()
BUG: 284907
---
kpresence.cpp | 47 ++++++++++++++++++++++++++++++-----------------
kpresence.h | 3 +++
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/kpresence.cpp b/kpresence.cpp
index 3ec484e..7ae9736 100644
--- a/kpresence.cpp
+++ b/kpresence.cpp
@@ -53,24 +53,9 @@ KIcon KPresence::icon() const
bool KPresence::operator <(const KPresence &other) const
{
- /// Sets the sorting order of presences
- QHash<uint, int> m_presenceSorting;
-
- m_presenceSorting[Tp::ConnectionPresenceTypeAvailable] = 0;
- m_presenceSorting[Tp::ConnectionPresenceTypeBusy] = 1;
- m_presenceSorting[Tp::ConnectionPresenceTypeHidden] = 2;
- m_presenceSorting[Tp::ConnectionPresenceTypeAway] = 3;
- m_presenceSorting[Tp::ConnectionPresenceTypeExtendedAway] = 4;
- m_presenceSorting[Tp::ConnectionPresenceTypeHidden] = 5;
- //don't distinguish between the following three presences
- m_presenceSorting[Tp::ConnectionPresenceTypeError] = 6;
- m_presenceSorting[Tp::ConnectionPresenceTypeUnknown] = 6;
- m_presenceSorting[Tp::ConnectionPresenceTypeUnset] = 6;
- m_presenceSorting[Tp::ConnectionPresenceTypeOffline] = 7;
-
- if (m_presenceSorting[type()] < m_presenceSorting[other.type()]) {
+ if (sortPriority(type()) < sortPriority(other.type())) {
return true;
- } else if (m_presenceSorting[type()] == m_presenceSorting[other.type()]) {
+ } else if (sortPriority(type()) == sortPriority(other.type())) {
return (statusMessage() < other.statusMessage());
} else {
return false;
@@ -96,3 +81,31 @@ QString KPresence::displayString() const
return QString();
}
}
+
+int KPresence::sortPriority(const Tp::ConnectionPresenceType &type)
+{
+ switch(type) {
+ case Tp::ConnectionPresenceTypeAvailable:
+ return 0;
+ case Tp::ConnectionPresenceTypeBusy:
+ return 1;
+ case Tp::ConnectionPresenceTypeHidden:
+ return 2;
+ case Tp::ConnectionPresenceTypeAway:
+ return 3;
+ case Tp::ConnectionPresenceTypeExtendedAway:
+ return 4;
+ case Tp::ConnectionPresenceTypeHidden:
+ return 5;
+ //don't distinguish between the following three presences
+ case Tp::ConnectionPresenceTypeError:
+ case Tp::ConnectionPresenceTypeUnknown:
+ case Tp::ConnectionPresenceTypeUnset:
+ return 6;
+ case Tp::ConnectionPresenceTypeOffline:
+ default:
+ return 7;
+ }
+
+ return -1;
+}
diff --git a/kpresence.h b/kpresence.h
index 2321816..1746a2d 100644
--- a/kpresence.h
+++ b/kpresence.h
@@ -36,6 +36,9 @@ public:
bool operator <(const KPresence &other) const;
QString displayString() const;
+
+ /** Returns an int representation of the presence type sorted by priority. 0 - most online, 7 - offline */
+ int sortPriority(const Tp::ConnectionPresenceType &type);
};
#endif // KPRESENCE_H
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list