summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index 0933f3a..9dabc81 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -11,6 +11,7 @@
#include <qdebug.h>
#include <QMenu>
+#include <QContextMenuEvent>
namespace Swift {
@@ -56,11 +57,12 @@ void QtTreeWidget::handleItemActivated(const QModelIndex& index) {
}
}
-void QtTreeWidget::contextMenuEvent(QContextMenuEvent* /*event*/) {
+void QtTreeWidget::contextMenuEvent(QContextMenuEvent* event) {
if (!contextMenu_) {
return;
}
- QtTreeWidgetItem* qtItem = static_cast<QtTreeWidgetItem*>(selectedIndexes()[0].internalPointer());
+ QModelIndex index = indexAt(event->pos());
+ QtTreeWidgetItem* qtItem = index.isValid() ? static_cast<QtTreeWidgetItem*>(index.internalPointer()) : NULL;
if (qtItem) {
contextMenu_->show(qtItem);
}