diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-06-04 22:09:21 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-06-04 22:42:02 (GMT) |
commit | 7bca08eb2829982865f1649483f9aa01b3413b1c (patch) | |
tree | 630b333f0dd9b05478816eae27c6695b1a6bbe35 /Swiften/Roster | |
parent | b3208697addc0492f4ae1f76c75a8810c20e701a (diff) | |
download | swift-contrib-7bca08eb2829982865f1649483f9aa01b3413b1c.zip swift-contrib-7bca08eb2829982865f1649483f9aa01b3413b1c.tar.bz2 |
Starting towards tooltips for the colour-blind.
Putting status show names along with the text in tooltips.
Covers the MeView and roster entries.
Still ToDo: status setter
Resolves: #429
Diffstat (limited to 'Swiften/Roster')
-rw-r--r-- | Swiften/Roster/ContactRosterItem.cpp | 11 | ||||
-rw-r--r-- | Swiften/Roster/ContactRosterItem.h | 5 | ||||
-rw-r--r-- | Swiften/Roster/Roster.cpp | 4 | ||||
-rw-r--r-- | Swiften/Roster/Roster.h | 2 | ||||
-rw-r--r-- | Swiften/Roster/UnitTest/RosterTest.cpp | 24 |
5 files changed, 29 insertions, 17 deletions
diff --git a/Swiften/Roster/ContactRosterItem.cpp b/Swiften/Roster/ContactRosterItem.cpp index 2d5082c..a9591a5 100644 --- a/Swiften/Roster/ContactRosterItem.cpp +++ b/Swiften/Roster/ContactRosterItem.cpp @@ -10,7 +10,7 @@ namespace Swift { -ContactRosterItem::ContactRosterItem(const JID& jid, const String& name, GroupRosterItem* parent) : RosterItem(name, parent), jid_(jid) { +ContactRosterItem::ContactRosterItem(const JID& jid, const JID& displayJID, const String& name, GroupRosterItem* parent) : RosterItem(name, parent), jid_(jid), displayJID_(displayJID) { } ContactRosterItem::~ContactRosterItem() { @@ -48,6 +48,15 @@ const JID& ContactRosterItem::getJID() const { return jid_; } +void ContactRosterItem::setDisplayJID(const JID& jid) { + displayJID_ = jid; +} + +const JID& ContactRosterItem::getDisplayJID() const { + return displayJID_; +} + + typedef std::pair<String, boost::shared_ptr<Presence> > StringPresencePair; void ContactRosterItem::calculateShownPresence() { diff --git a/Swiften/Roster/ContactRosterItem.h b/Swiften/Roster/ContactRosterItem.h index d4c92aa..21f6024 100644 --- a/Swiften/Roster/ContactRosterItem.h +++ b/Swiften/Roster/ContactRosterItem.h @@ -22,7 +22,7 @@ namespace Swift { class GroupRosterItem; class ContactRosterItem : public RosterItem { public: - ContactRosterItem(const JID& jid, const String& name, GroupRosterItem* parent); + ContactRosterItem(const JID& jid, const JID& displayJID, const String& name, GroupRosterItem* parent); virtual ~ContactRosterItem(); StatusShow::Type getStatusShow() const; @@ -31,11 +31,14 @@ class ContactRosterItem : public RosterItem { void setAvatarPath(const String& path); const String& getAvatarPath() const; const JID& getJID() const; + void setDisplayJID(const JID& jid); + const JID& getDisplayJID() const; void applyPresence(const String& resource, boost::shared_ptr<Presence> presence); void clearPresence(); void calculateShownPresence(); private: JID jid_; + JID displayJID_; String avatarPath_; bool hidden_; std::map<String, boost::shared_ptr<Presence> > presences_; diff --git a/Swiften/Roster/Roster.cpp b/Swiften/Roster/Roster.cpp index 9291421..b7ed6c4 100644 --- a/Swiften/Roster/Roster.cpp +++ b/Swiften/Roster/Roster.cpp @@ -67,9 +67,9 @@ void Roster::handleChildrenChanged(GroupRosterItem* item) { onChildrenChanged(item); } -void Roster::addContact(const JID& jid, const String& name, const String& groupName) { +void Roster::addContact(const JID& jid, const JID& displayJID, const String& name, const String& groupName) { GroupRosterItem* group(getGroup(groupName)); - ContactRosterItem *item = new ContactRosterItem(jid, name, group); + ContactRosterItem *item = new ContactRosterItem(jid, displayJID, name, group); group->addChild(item); itemMap_[fullJIDMapping_ ? jid : jid.toBare()].push_back(item); item->onDataChanged.connect(boost::bind(&Roster::handleDataChanged, this, item)); diff --git a/Swiften/Roster/Roster.h b/Swiften/Roster/Roster.h index 78606e8..346157e 100644 --- a/Swiften/Roster/Roster.h +++ b/Swiften/Roster/Roster.h @@ -28,7 +28,7 @@ class Roster { Roster(bool fullJIDMapping = false); ~Roster(); - void addContact(const JID& jid, const String& name, const String& group); + void addContact(const JID& jid, const JID& displayJID, const String& name, const String& group); void removeContact(const JID& jid); void removeContactFromGroup(const JID& jid, const String& group); void applyOnItems(const RosterItemOperation& operation); diff --git a/Swiften/Roster/UnitTest/RosterTest.cpp b/Swiften/Roster/UnitTest/RosterTest.cpp index d170396..13a4ab0 100644 --- a/Swiften/Roster/UnitTest/RosterTest.cpp +++ b/Swiften/Roster/UnitTest/RosterTest.cpp @@ -43,9 +43,9 @@ class RosterTest : public CppUnit::TestFixture } void testGetGroup() { - roster_->addContact(jid1_, "Bert", "group1"); - roster_->addContact(jid2_, "Ernie", "group2"); - roster_->addContact(jid3_, "Cookie", "group1"); + roster_->addContact(jid1_, JID(), "Bert", "group1"); + roster_->addContact(jid2_, JID(), "Ernie", "group2"); + roster_->addContact(jid3_, JID(), "Cookie", "group1"); CPPUNIT_ASSERT_EQUAL(2, (int)roster_->getRoot()->getChildren().size()); CPPUNIT_ASSERT_EQUAL(String("group1"), roster_->getRoot()->getChildren()[0]->getDisplayName()); @@ -57,7 +57,7 @@ class RosterTest : public CppUnit::TestFixture } void testRemoveContact() { - roster_->addContact(jid1_, "Bert", "group1"); + roster_->addContact(jid1_, jid1_, "Bert", "group1"); CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); roster_->removeContact(jid1_); @@ -65,8 +65,8 @@ class RosterTest : public CppUnit::TestFixture } void testRemoveSecondContact() { - roster_->addContact(jid1_, "Bert", "group1"); - roster_->addContact(jid2_, "Cookie", "group1"); + roster_->addContact(jid1_, jid1_, "Bert", "group1"); + roster_->addContact(jid2_, jid2_, "Cookie", "group1"); CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid2_); @@ -77,8 +77,8 @@ class RosterTest : public CppUnit::TestFixture void testRemoveSecondContactSameBare() { JID jid4a("a@b/c"); JID jid4b("a@b/d"); - roster_->addContact(jid4a, "Bert", "group1"); - roster_->addContact(jid4b, "Cookie", "group1"); + roster_->addContact(jid4a, JID(), "Bert", "group1"); + roster_->addContact(jid4b, JID(), "Cookie", "group1"); CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid4b); @@ -90,11 +90,11 @@ class RosterTest : public CppUnit::TestFixture JID jid4a("a@b/c"); JID jid4b("a@b/d"); JID jid4c("a@b/e"); - roster_->addContact(jid4a, "Bird", "group1"); - roster_->addContact(jid4b, "Cookie", "group1"); + roster_->addContact(jid4a, JID(), "Bird", "group1"); + roster_->addContact(jid4b, JID(), "Cookie", "group1"); roster_->removeContact(jid4b); - roster_->addContact(jid4c, "Bert", "group1"); - roster_->addContact(jid4b, "Ernie", "group1"); + roster_->addContact(jid4c, JID(), "Bert", "group1"); + roster_->addContact(jid4b, JID(), "Ernie", "group1"); boost::shared_ptr<Presence> presence(new Presence()); presence->setShow(StatusShow::DND); presence->setFrom(jid4a); |