diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-05-02 14:42:48 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-05-02 14:42:48 (GMT) |
commit | cc721d1878fda8b4ba294fb4272e2e6a324c9976 (patch) | |
tree | acdddb5e4a51c6d2bb54b0db50a146407f18e0df | |
parent | 53c24201ab19c660c31a104c848b8ca94187b7c4 (diff) | |
download | swift-contrib-cc721d1878fda8b4ba294fb4272e2e6a324c9976.zip swift-contrib-cc721d1878fda8b4ba294fb4272e2e6a324c9976.tar.bz2 |
Use cursor position to determine roster item for context menu.
Resolves: #333
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 6 |
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); } |