summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-09 07:41:27 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-09 07:41:27 (GMT)
commit89034baf34d913daae0d53d0468885c603762d8a (patch)
tree8a94b6119eae3e1f6970ee53f57118fcbd116af5 /Swiften
parent6f4fa16b1ddb0633771423a8e8d9520864ffb95d (diff)
parentf948f047401021f3afc8a015991fc81e7d69d6ce (diff)
downloadswift-contrib-89034baf34d913daae0d53d0468885c603762d8a.zip
swift-contrib-89034baf34d913daae0d53d0468885c603762d8a.tar.bz2
Replace dummy roster with Qt Model/View driven one.
Merge branch 'roster' * roster: Group expandedness in roster persists between roster changes. Plumbing in place for roster group expansion. \nDoesn't work. Conditional includes to get the QtSoundPlayer to compile on Ubuntu. Roster clicks now open chats again. Roster now includes avatars. Resize avatars to 32pix in Roster, change alignments to be relative, do item hiding. Sort out the alignments in the roster. Render status text italicised, and selection colours. Now render an ugly default icon and default status text in the roster. Use a (boring) delegate for roster rendering. Clear down some of the cruft from RosterItem. Removing RosterItem and including in QtTreeWidgetItem. Removing the dummy title from the roster. The new roster now renders (badly) the contents. Begin to assage Swift model into Qt Model/View.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Avatars/AvatarManager.h2
-rw-r--r--Swiften/Roster/ContactRosterItem.cpp8
-rw-r--r--Swiften/Roster/ContactRosterItem.h2
-rw-r--r--Swiften/Roster/Roster.cpp4
-rw-r--r--Swiften/Roster/SetAvatar.h33
-rw-r--r--Swiften/Roster/SetPresence.h2
-rw-r--r--Swiften/Roster/TreeWidgetItem.h2
7 files changed, 50 insertions, 3 deletions
diff --git a/Swiften/Avatars/AvatarManager.h b/Swiften/Avatars/AvatarManager.h
index 984ce19..3ac4433 100644
--- a/Swiften/Avatars/AvatarManager.h
+++ b/Swiften/Avatars/AvatarManager.h
@@ -32,7 +32,7 @@ namespace Swift {
void handlePresenceReceived(boost::shared_ptr<Presence>);
void handleVCardReceived(const JID& from, const String& hash, boost::shared_ptr<VCard>, const boost::optional<Error>&);
void setAvatarHash(const JID& from, const String& hash);
- JID getAvatarJID(const JID& o) const;
+ JID getAvatarJID(const JID& o) const;
private:
StanzaChannel* stanzaChannel_;
diff --git a/Swiften/Roster/ContactRosterItem.cpp b/Swiften/Roster/ContactRosterItem.cpp
index f38b0f7..2f2f787 100644
--- a/Swiften/Roster/ContactRosterItem.cpp
+++ b/Swiften/Roster/ContactRosterItem.cpp
@@ -34,6 +34,14 @@ void ContactRosterItem::setStatusShow(StatusShow::Type show) {
widget_->setTextColor(colour);
}
+void ContactRosterItem::setStatusText(const String& status) {
+ widget_->setStatusText(status);
+}
+
+void ContactRosterItem::setAvatarPath(const String& path) {
+ widget_->setAvatarPath(path);
+}
+
const JID& ContactRosterItem::getJID() const {
return jid_;
}
diff --git a/Swiften/Roster/ContactRosterItem.h b/Swiften/Roster/ContactRosterItem.h
index 20f9f65..f1810aa 100644
--- a/Swiften/Roster/ContactRosterItem.h
+++ b/Swiften/Roster/ContactRosterItem.h
@@ -23,6 +23,8 @@ class ContactRosterItem : public RosterItem {
StatusShow::Type getStatusShow();
void setStatusShow(StatusShow::Type show);
+ void setStatusText(const String& status);
+ void setAvatarPath(const String& path);
const JID& getJID() const;
void show();
void hide();
diff --git a/Swiften/Roster/Roster.cpp b/Swiften/Roster/Roster.cpp
index 61c0286..b51d8eb 100644
--- a/Swiften/Roster/Roster.cpp
+++ b/Swiften/Roster/Roster.cpp
@@ -39,7 +39,7 @@ GroupRosterItem* Roster::getGroup(const String& groupName) {
}
GroupRosterItem* group = new GroupRosterItem(groupName, treeWidget_, widgetFactory_);
children_.push_back(group);
- items_.push_back(group);
+ items_.push_back(group);
return group;
}
@@ -49,7 +49,7 @@ void Roster::handleUserAction(boost::shared_ptr<UserRosterAction> action) {
void Roster::addContact(const JID& jid, const String& name, const String& group) {
ContactRosterItem *item = new ContactRosterItem(jid, name, getGroup(group), widgetFactory_);
- items_.push_back(item);
+ items_.push_back(item);
item->onUserAction.connect(boost::bind(&Roster::handleUserAction, this, _1));
filterItem(item);
diff --git a/Swiften/Roster/SetAvatar.h b/Swiften/Roster/SetAvatar.h
new file mode 100644
index 0000000..7bc9c37
--- /dev/null
+++ b/Swiften/Roster/SetAvatar.h
@@ -0,0 +1,33 @@
+#ifndef SWIFTEN_SetAvatar_H
+#define SWIFTEN_SetAvatar_H
+
+#include "Swiften/Elements/Presence.h"
+#include "Swiften/JID/JID.h"
+#include "Swiften/Roster/RosterItemOperation.h"
+#include "Swiften/Roster/ContactRosterItem.h"
+
+namespace Swift {
+
+class RosterItem;
+
+class SetAvatar : public RosterItemOperation {
+ public:
+ SetAvatar(const JID& jid, const String& path, JID::CompareType compareType = JID::WithoutResource) : jid_(jid), path_(path), compareType_(compareType) {
+ }
+
+ virtual void operator() (RosterItem* item) const {
+ ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
+ if (contact && contact->getJID().equals(jid_, compareType_)) {
+ contact->setAvatarPath(path_);
+ }
+ }
+
+ private:
+ JID jid_;
+ String path_;
+ JID::CompareType compareType_;
+};
+
+}
+#endif
+
diff --git a/Swiften/Roster/SetPresence.h b/Swiften/Roster/SetPresence.h
index aa36a52..a18ae6d 100644
--- a/Swiften/Roster/SetPresence.h
+++ b/Swiften/Roster/SetPresence.h
@@ -20,8 +20,10 @@ class SetPresence : public RosterItemOperation {
if (contact && contact->getJID().equals(presence_->getFrom(), compareType_)) {
if (presence_->getType() != Presence::Available) {
contact->setStatusShow(StatusShow::None);
+ contact->setStatusText(presence_->getStatus());
} else {
contact->setStatusShow(presence_->getShow());
+ contact->setStatusText(presence_->getStatus());
}
}
}
diff --git a/Swiften/Roster/TreeWidgetItem.h b/Swiften/Roster/TreeWidgetItem.h
index 5a96a41..4e20050 100644
--- a/Swiften/Roster/TreeWidgetItem.h
+++ b/Swiften/Roster/TreeWidgetItem.h
@@ -13,6 +13,8 @@ class TreeWidgetItem {
public:
virtual ~TreeWidgetItem() {}
virtual void setText(const String& text) = 0;
+ virtual void setStatusText(const String& text) = 0;
+ virtual void setAvatarPath(const String& path) = 0;
virtual void setExpanded(bool b) = 0;
virtual void setTextColor(unsigned long color) = 0;
virtual void setBackgroundColor(unsigned long color) = 0;