From bbbfdbd820e84cff8c72cedfd04ea6de0dcca68b Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Wed, 30 Oct 2013 22:11:03 +0000 Subject: [PATCH] Minor improvements --- widgets/actionitemdelegate.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/widgets/actionitemdelegate.cpp b/widgets/actionitemdelegate.cpp index 2464b93cc..2ac1506d0 100644 --- a/widgets/actionitemdelegate.cpp +++ b/widgets/actionitemdelegate.cpp @@ -190,6 +190,11 @@ bool ActionItemDelegate::helpEvent(QHelpEvent *e, QAbstractItemView *view, const QAction * ActionItemDelegate::getAction(const QModelIndex &index) const { + QList actions=index.data(ItemView::Role_Actions).value >(); + if (actions.isEmpty()) { + return 0; + } + QAbstractItemView *view=(QAbstractItemView *)parent(); bool rtl = Qt::RightToLeft==QApplication::layoutDirection(); QListView *lv=qobject_cast(view); @@ -215,11 +220,11 @@ QAction * ActionItemDelegate::getAction(const QModelIndex &index) const QRect actionRect=calcActionRect(rtl, actionPos, rect); QRect actionRect2(actionRect); ActionItemDelegate::adjustActionRect(rtl, actionPos, actionRect2, iconSize); - QList actions=index.data(ItemView::Role_Actions).value >(); + QPoint cursorPos=QCursor::pos(); foreach (const QPointer &a, actions) { actionRect=actionPos ? actionRect.adjusted(0, -2, 0, 2) : actionRect.adjusted(-2, 0, 2, 0); - if (actionRect.contains(QCursor::pos())) { + if (actionRect.contains(cursorPos)) { return a; }