diff options
author | Richard Maudsley <richard.maudsley@isode.com> | 2013-12-16 09:45:40 (GMT) |
---|---|---|
committer | Richard Maudsley <richard.maudsley@isode.com> | 2013-12-18 14:48:12 (GMT) |
commit | 26994474c1ebfe874c2cd62ededf9a82b0496136 (patch) | |
tree | 20feb19c35f438b7789fe0c5113412c87b27b235 /Swift/Controllers/Roster/ContactRosterItem.cpp | |
parent | 503a8077c8811c2e9f65a619c33690a36eb5c153 (diff) | |
download | swift-26994474c1ebfe874c2cd62ededf9a82b0496136.zip swift-26994474c1ebfe874c2cd62ededf9a82b0496136.tar.bz2 |
Add affiliations to tooltips for MUC occupant lists.
Also extracts MUC into an interface and MUCImpl the existing implementation, adds a MockMUC for using in unit tests, and adds unit tests for the MUCController changes.
Change-Id: I25034384f59d3c274c46ffc37b2d1ae60ec660f4
Diffstat (limited to 'Swift/Controllers/Roster/ContactRosterItem.cpp')
-rw-r--r-- | Swift/Controllers/Roster/ContactRosterItem.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp index 622b6ae..fde4c97 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.cpp +++ b/Swift/Controllers/Roster/ContactRosterItem.cpp @@ -11,13 +11,15 @@ #include <Swiften/Base/foreach.h> #include <Swiften/Base/DateTime.h> #include <Swiften/Elements/Idle.h> - +#include <Swift/Controllers/Intl.h> #include <Swift/Controllers/Roster/GroupRosterItem.h> namespace Swift { -ContactRosterItem::ContactRosterItem(const JID& jid, const JID& displayJID, const std::string& name, GroupRosterItem* parent) : RosterItem(name, parent), jid_(jid), displayJID_(displayJID), blockState_(BlockingNotSupported) { +ContactRosterItem::ContactRosterItem(const JID& jid, const JID& displayJID, const std::string& name, GroupRosterItem* parent) +: RosterItem(name, parent), jid_(jid), displayJID_(displayJID), mucRole_(MUCOccupant::NoRole), mucAffiliation_(MUCOccupant::NoAffiliation), blockState_(BlockingNotSupported) +{ } ContactRosterItem::~ContactRosterItem() { @@ -137,6 +139,40 @@ void ContactRosterItem::removeGroup(const std::string& group) { groups_.erase(std::remove(groups_.begin(), groups_.end(), group), groups_.end()); } +MUCOccupant::Role ContactRosterItem::getMUCRole() const +{ + return mucRole_; +} + +void ContactRosterItem::setMUCRole(const MUCOccupant::Role& role) +{ + mucRole_ = role; +} + +MUCOccupant::Affiliation ContactRosterItem::getMUCAffiliation() const +{ + return mucAffiliation_; +} + +void ContactRosterItem::setMUCAffiliation(const MUCOccupant::Affiliation& affiliation) +{ + mucAffiliation_ = affiliation; +} + +std::string ContactRosterItem::getMUCAffiliationText() const +{ + std::string affiliationString; + switch (mucAffiliation_) { + case MUCOccupant::Owner: affiliationString = QT_TRANSLATE_NOOP("", "Owner"); break; + case MUCOccupant::Admin: affiliationString = QT_TRANSLATE_NOOP("", "Admin"); break; + case MUCOccupant::Member: affiliationString = QT_TRANSLATE_NOOP("", "Member"); break; + case MUCOccupant::Outcast: affiliationString = QT_TRANSLATE_NOOP("", "Outcast"); break; + case MUCOccupant::NoAffiliation: affiliationString = ""; break; + } + + return affiliationString; +} + void ContactRosterItem::setSupportedFeatures(const std::set<Feature>& features) { features_ = features; onDataChanged(); |