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/Roster
parent03a5a0a4a6c7504acead164dc8334c36da86a888 (diff)
downloadswift-f1675c651a08c294447389176262ab890cc6e7b5.zip
swift-f1675c651a08c294447389176262ab890cc6e7b5.tar.bz2
Add 'remove' context menu item for rosters (not implemented).
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp16
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.h7
2 files changed, 22 insertions, 1 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index 7caa150..be11a3e 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -4,6 +4,7 @@
#include "Swiften/Roster/OpenChatRosterAction.h"
#include <qdebug.h>
+#include <QMenu>
namespace Swift {
@@ -15,6 +16,7 @@ QtTreeWidget::QtTreeWidget(QWidget* parent) : QTreeView(parent) {
delegate_ = new RosterDelegate();
setItemDelegate(delegate_);
setHeaderHidden(true);
+ contextMenu_ = NULL;
#ifdef SWIFT_PLATFORM_MACOSX
setAlternatingRowColors(true);
#endif
@@ -33,6 +35,10 @@ QtTreeWidget::~QtTreeWidget() {
delete delegate_;
}
+void QtTreeWidget::setContextMenu(QtContextMenu* contextMenu) {
+ contextMenu_ = contextMenu;
+}
+
QtTreeWidgetItem* QtTreeWidget::getRoot() {
return treeRoot_;
}
@@ -44,6 +50,16 @@ void QtTreeWidget::handleItemActivated(const QModelIndex& index) {
}
}
+void QtTreeWidget::contextMenuEvent(QContextMenuEvent* event) {
+ if (!contextMenu_) {
+ return;
+ }
+ QtTreeWidgetItem* qtItem = static_cast<QtTreeWidgetItem*>(selectedIndexes()[0].internalPointer());
+ if (qtItem) {
+ contextMenu_->show(qtItem);
+ }
+}
+
void QtTreeWidget::handleExpanded(const QModelIndex& index) {
QtTreeWidgetItem* qtItem = static_cast<QtTreeWidgetItem*>(index.internalPointer());
if (qtItem) {
diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h
index 13b6d8e..15eb22f 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.h
+++ b/Swift/QtUI/Roster/QtTreeWidget.h
@@ -10,6 +10,7 @@
#include "Swift/QtUI/Roster/QtTreeWidget.h"
#include "Swift/QtUI/Roster/RosterModel.h"
#include "Swift/QtUI/Roster/RosterDelegate.h"
+#include "Swift/QtUI/ContextMenus/QtContextMenu.h"
namespace Swift {
@@ -20,18 +21,22 @@ class QtTreeWidget : public QTreeView, public TreeWidget {
~QtTreeWidget();
void show();
QtTreeWidgetItem* getRoot();
+ void setContextMenu(QtContextMenu* contextMenu);
private slots:
void handleItemActivated(const QModelIndex&);
void handleModelItemExpanded(const QModelIndex&, bool expanded);
void handleExpanded(const QModelIndex&);
void handleCollapsed(const QModelIndex&);
void handleDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
+ protected:
+ void contextMenuEvent(QContextMenuEvent* event);
+
private:
void drawBranches(QPainter*, const QRect&, const QModelIndex&) const;
RosterModel* model_;
RosterDelegate* delegate_;
QtTreeWidgetItem* treeRoot_;
-
+ QtContextMenu* contextMenu_;
};
}