diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-05-06 08:00:44 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-05-06 10:49:49 (GMT) |
commit | 081fc03556708447610e9697a57235fa191a4f0d (patch) | |
tree | 505c8cc9129d2b44968d183a180f0ccddaa08810 /Swift/QtUI/ContextMenus | |
parent | 8c53236875d2ca77f1b463449918458f6b424ab1 (diff) | |
download | swift-081fc03556708447610e9697a57235fa191a4f0d.zip swift-081fc03556708447610e9697a57235fa191a4f0d.tar.bz2 |
Rewrite of large amounts of roster code.
Now keeps widgets out of Swiften, keeps sorting inside Swiften,
and keeps track of presences to show the correct presence per
roster item.
Resolves: #316
Resolves: #81
Resolves: #239
Diffstat (limited to 'Swift/QtUI/ContextMenus')
-rw-r--r-- | Swift/QtUI/ContextMenus/QtContextMenu.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp | 14 | ||||
-rw-r--r-- | Swift/QtUI/ContextMenus/QtRosterContextMenu.h | 5 |
3 files changed, 14 insertions, 9 deletions
diff --git a/Swift/QtUI/ContextMenus/QtContextMenu.h b/Swift/QtUI/ContextMenus/QtContextMenu.h index baa0180..9e73ef9 100644 --- a/Swift/QtUI/ContextMenus/QtContextMenu.h +++ b/Swift/QtUI/ContextMenus/QtContextMenu.h @@ -7,11 +7,11 @@ #pragma once namespace Swift { - class QtTreeWidgetItem; + class RosterItem; class QtContextMenu { public: virtual ~QtContextMenu(); - virtual void show(QtTreeWidgetItem* item) = 0; + virtual void show(RosterItem* item) = 0; }; } diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp index 10e0b56..e6b5ae5 100644 --- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp +++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp @@ -11,9 +11,10 @@ #include <boost/shared_ptr.hpp> +#include "Swiften/Roster/ContactRosterItem.h" #include "Swiften/Base/String.h" -#include "Swift/Controllers/UIEvents/RemoveItemRosterAction.h" -#include "Swift/QtUI/Roster/QtTreeWidgetItem.h" +#include "Swift/Controllers/UIEvents/UIEvent.h" +#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h" #include "Swift/QtUI/QtSwiftUtil.h" namespace Swift { @@ -22,8 +23,9 @@ QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream) { eventStream_ = eventStream; } -void QtRosterContextMenu::show(QtTreeWidgetItem* item) { - if (!item->isContact()) { +void QtRosterContextMenu::show(RosterItem* item) { + ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item); + if (!contact) { return; } item_ = item; @@ -33,7 +35,9 @@ void QtRosterContextMenu::show(QtTreeWidgetItem* item) { } void QtRosterContextMenu::handleRemove() { - item_->performUserAction(boost::shared_ptr<UserRosterAction>(new RemoveItemRosterAction())); + ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item_); + assert(contact); + eventStream_->send(boost::shared_ptr<UIEvent>(new RemoveRosterItemUIEvent(contact->getJID()))); } } diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h index ffa8ba6..51556e4 100644 --- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h +++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h @@ -12,17 +12,18 @@ #include "Swift/Controllers/UIEvents/UIEventStream.h" namespace Swift { + class RosterItem; class QtRosterContextMenu : public QObject, public QtContextMenu { Q_OBJECT public: QtRosterContextMenu(UIEventStream* eventStream); - void show(QtTreeWidgetItem* item); + void show(RosterItem* item); private slots: void handleRemove(); private: - QtTreeWidgetItem* item_; + RosterItem* item_; UIEventStream* eventStream_; }; } |