[vlc-commits] Qt: menus: do not store QModelIndex.
Francois Cartegnie
git at videolan.org
Fri Sep 6 15:24:58 CEST 2013
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep 6 15:22:23 2013 +0200| [666851ce3af8f910daa63358797b196771f8302a] | committer: Francois Cartegnie
Qt: menus: do not store QModelIndex.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=666851ce3af8f910daa63358797b196771f8302a
---
modules/gui/qt4/util/qmenuview.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt4/util/qmenuview.cpp b/modules/gui/qt4/util/qmenuview.cpp
index 909cbb5..8f783bf 100644
--- a/modules/gui/qt4/util/qmenuview.cpp
+++ b/modules/gui/qt4/util/qmenuview.cpp
@@ -30,7 +30,6 @@
#include <QVariant>
#include <assert.h>
-
/***
* This is a simple view, like a QListView, but displayed as a QMenu
* So far, this is quite limited.
@@ -41,7 +40,7 @@
* - deal with a root item
***/
-Q_DECLARE_METATYPE(QModelIndex); // So we can store it in a QVariant
+Q_DECLARE_METATYPE(QPersistentModelIndex); // So we can store it in a QVariant
QMenuView::QMenuView( QWidget * parent, int _iMaxVisibleCount )
: QMenu( parent ), iMaxVisibleCount( _iMaxVisibleCount )
@@ -107,7 +106,7 @@ QAction* QMenuView::createActionFromIndex( QModelIndex index )
action->setEnabled( index.flags().testFlag( Qt::ItemIsEnabled ) );
/* */
- QVariant variant; variant.setValue( index );
+ QVariant variant; variant.setValue( QPersistentModelIndex( index ) );
action->setData( variant );
return action;
@@ -119,9 +118,9 @@ void QMenuView::activate( QAction* action )
assert( m_model );
QVariant variant = action->data();
- if( variant.canConvert<QModelIndex>() )
+ if( variant.canConvert<QPersistentModelIndex>() )
{
- emit activated( variant.value<QModelIndex>());
+ emit activated( variant.value<QPersistentModelIndex>());
}
}
More information about the vlc-commits
mailing list