summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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_;
+ };
+}