From d3b97af431872298f380a195a1d20e9a32af3786 Mon Sep 17 00:00:00 2001 From: "James D. Smith" Date: Mon, 5 Jun 2017 11:33:17 -0600 Subject: [PATCH 2/4] Implement Presence <> operators. --- TelepathyQt/presence.cpp | 23 +++++++++++++++++++++++ TelepathyQt/presence.h | 2 ++ 2 files changed, 25 insertions(+) diff --git TelepathyQt/presence.cpp TelepathyQt/presence.cpp index 823067dc..f0903015 100644 --- TelepathyQt/presence.cpp +++ TelepathyQt/presence.cpp @@ -150,6 +150,29 @@ bool Presence::operator!=(const Presence &other) const return mPriv->sp != other.mPriv->sp; } +bool Presence::operator <(const Presence &other) const +{ + if (!isValid() || !other.isValid()) { + if (!isValid() && !other.isValid()) { + return false; + } + return true; + } + + if (type() < other.type()) { + return true; + } else if (type() == other.type()) { + return (statusMessage() < other.statusMessage()); + } else { + return false; + } +} + +bool Presence::operator >(const Presence &other) const +{ + return (other < *this); +} + ConnectionPresenceType Presence::type() const { if (!isValid()) { diff --git TelepathyQt/presence.h TelepathyQt/presence.h index 31fd056a..ef4e848c 100644 --- TelepathyQt/presence.h +++ TelepathyQt/presence.h @@ -57,6 +57,8 @@ public: Presence &operator=(const Presence &other); bool operator==(const Presence &other) const; bool operator!=(const Presence &other) const; + bool operator <(const Presence &other) const; + bool operator >(const Presence &other) const; ConnectionPresenceType type() const; QString status() const; -- 2.12.3