Change a slot into a virtual method.
authorStephen Kelly <stephen.kelly@kdab.com>
Thu, 15 Dec 2011 16:43:48 +0000 (17:43 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Dec 2011 09:42:26 +0000 (10:42 +0100)
Implements a BiC Qt5 TODO.

Change-Id: Ie7dc32d954335019166dbd78d8b01ef79e2ad5c2
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/widgets/itemviews/qabstractitemdelegate.cpp
src/widgets/itemviews/qabstractitemdelegate.h
src/widgets/itemviews/qabstractitemview.cpp

index bdc5d69..514e98e 100644 (file)
@@ -347,7 +347,6 @@ QString QAbstractItemDelegate::elidedText(const QFontMetrics &fontMetrics, int w
 
     \sa QHelpEvent
 */
-// ### Qt 5: Make this a virtual non-slot function
 bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
                                       QAbstractItemView *view,
                                       const QStyleOptionViewItem &option,
index f494f0b..a4859f2 100644 (file)
@@ -108,11 +108,10 @@ public:
     static QString elidedText(const QFontMetrics &fontMetrics, int width,
                               Qt::TextElideMode mode, const QString &text);
 
-public Q_SLOTS:
-    bool helpEvent(QHelpEvent *event,
-                   QAbstractItemView *view,
-                   const QStyleOptionViewItem &option,
-                   const QModelIndex &index);
+    virtual bool helpEvent(QHelpEvent *event,
+                           QAbstractItemView *view,
+                           const QStyleOptionViewItem &option,
+                           const QModelIndex &index);
 
 Q_SIGNALS:
     void commitData(QWidget *editor);
index 06544e3..0776ca6 100644 (file)
@@ -1658,15 +1658,11 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
         QStyleOptionViewItemV4 option = d->viewOptionsV4();
         option.rect = visualRect(index);
         option.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
-        bool retval = false;
-        // ### Qt 5: make this a normal function call to a virtual function
-        QMetaObject::invokeMethod(d->delegateForIndex(index), "helpEvent",
-                                  Q_RETURN_ARG(bool, retval),
-                                  Q_ARG(QHelpEvent *, he),
-                                  Q_ARG(QAbstractItemView *, this),
-                                  Q_ARG(QStyleOptionViewItem, option),
-                                  Q_ARG(QModelIndex, index));
-        return retval;
+
+        QAbstractItemDelegate *delegate = d->delegateForIndex(index);
+        if (!delegate)
+            return false;
+        return delegate->helpEvent(he, this, option, index);
     }
     case QEvent::FontChange:
         d->doDelayedItemsLayout(); // the size of the items will change