summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Roster/QtTreeWidget.cpp')
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp16
1 files changed, 16 insertions, 0 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) {