summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-04 11:55:11 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-04 11:55:11 (GMT)
commitf1675c651a08c294447389176262ab890cc6e7b5 (patch)
tree5371b7db58ac31b22b747822b224db3565442084 /Swift/QtUI/ContextMenus
parent03a5a0a4a6c7504acead164dc8334c36da86a888 (diff)
downloadswift-f1675c651a08c294447389176262ab890cc6e7b5.zip
swift-f1675c651a08c294447389176262ab890cc6e7b5.tar.bz2
Add 'remove' context menu item for rosters (not implemented).
Diffstat (limited to 'Swift/QtUI/ContextMenus')
-rw-r--r--Swift/QtUI/ContextMenus/QtContextmenu.h9
-rw-r--r--Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp33
-rw-r--r--Swift/QtUI/ContextMenus/QtRosterContextMenu.h22
3 files changed, 64 insertions, 0 deletions
diff --git a/Swift/QtUI/ContextMenus/QtContextmenu.h b/Swift/QtUI/ContextMenus/QtContextmenu.h
new file mode 100644
index 0000000..cc0227d
--- /dev/null
+++ b/Swift/QtUI/ContextMenus/QtContextmenu.h
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace Swift {
+ class QtTreeWidgetItem;
+ class QtContextMenu {
+ public:
+ virtual void show(QtTreeWidgetItem* item) = 0;
+ };
+}
diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
new file mode 100644
index 0000000..feb1226
--- /dev/null
+++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
@@ -0,0 +1,33 @@
+#include "Swift/QtUI/ContextMenus/QtRosterContextMenu.h"
+
+#include <QMenu>
+#include <QDebug>
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Base/String.h"
+#include "Swift/Controllers/UIEvents/RemoveItemRosterAction.h"
+#include "Swift/QtUI/Roster/QtTreeWidgetItem.h"
+#include "Swift/QtUI/QtSwiftUtil.h"
+
+namespace Swift {
+
+QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream) {
+ eventStream_ = eventStream;
+}
+
+void QtRosterContextMenu::show(QtTreeWidgetItem* item) {
+ if (!item->isContact()) {
+ return;
+ }
+ item_ = item;
+ QMenu* contextMenu = new QMenu();
+ contextMenu->addAction("Remove", this, SLOT(handleRemove()));
+ contextMenu->exec(QCursor::pos());
+}
+
+void QtRosterContextMenu::handleRemove() {
+ item_->performUserAction(boost::shared_ptr<UserRosterAction>(new RemoveItemRosterAction()));
+}
+
+}
diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
new file mode 100644
index 0000000..74dcb98
--- /dev/null
+++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <QObject>
+
+#include "Swift/QtUI/ContextMenus/QtContextMenu.h"
+#include "Swift/Controllers/UIEvents/UIEventStream.h"
+
+namespace Swift {
+ class QtRosterContextMenu : public QObject, public QtContextMenu {
+ Q_OBJECT
+ public:
+ QtRosterContextMenu(UIEventStream* eventStream);
+ void show(QtTreeWidgetItem* item);
+
+ private slots:
+ void handleRemove();
+
+ private:
+ QtTreeWidgetItem* item_;
+ UIEventStream* eventStream_;
+ };
+}