diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-01-27 03:33:13 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-30 16:25:09 +0100 |
commit | d9468a975210ecb58ff199e931f47df5b99b267f (patch) | |
tree | cdcf71215bca02739c80f550e9ddbed635ad38ab /src/widgets/itemviews/qitemeditorfactory.cpp | |
parent | be1867b6c4743da937d269f04c2e108a18d3f400 (diff) |
Change the type key for delegate editors to int.
Previous type of QVariant::Type does not allow for custom types.
While technically source incompatible I found no re-implementation
of this class in qttools or qt-creator (most likely to use it for
property editors). The virtual methods are not needed because
registerEditor is all the API that is really needed.
Task-number: QTBUG-1065
Change-Id: I2a9c578c444a80359416f2224a0ee03903bfe779
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets/itemviews/qitemeditorfactory.cpp')
-rw-r--r-- | src/widgets/itemviews/qitemeditorfactory.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 326207afe8..468929a554 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -126,30 +126,30 @@ public: */ /*! - Creates an editor widget with the given \a parent for the specified \a type of data, + Creates an editor widget with the given \a parent for the specified \a userType of data, and returns it as a QWidget. \sa registerEditor() */ -QWidget *QItemEditorFactory::createEditor(QVariant::Type type, QWidget *parent) const +QWidget *QItemEditorFactory::createEditor(int userType, QWidget *parent) const { - QItemEditorCreatorBase *creator = creatorMap.value(type, 0); + QItemEditorCreatorBase *creator = creatorMap.value(userType, 0); if (!creator) { const QItemEditorFactory *dfactory = defaultFactory(); - return dfactory == this ? 0 : dfactory->createEditor(type, parent); + return dfactory == this ? 0 : dfactory->createEditor(userType, parent); } return creator->createWidget(parent); } /*! - Returns the property name used to access data for the given \a type of data. + Returns the property name used to access data for the given \a userType of data. */ -QByteArray QItemEditorFactory::valuePropertyName(QVariant::Type type) const +QByteArray QItemEditorFactory::valuePropertyName(int userType) const { - QItemEditorCreatorBase *creator = creatorMap.value(type, 0); + QItemEditorCreatorBase *creator = creatorMap.value(userType, 0); if (!creator) { const QItemEditorFactory *dfactory = defaultFactory(); - return dfactory == this ? QByteArray() : dfactory->valuePropertyName(type); + return dfactory == this ? QByteArray() : dfactory->valuePropertyName(userType); } return creator->valuePropertyName(); } @@ -166,16 +166,16 @@ QItemEditorFactory::~QItemEditorFactory() } /*! - Registers an item editor creator specified by \a creator for the given \a type of data. + Registers an item editor creator specified by \a creator for the given \a userType of data. \bold{Note:} The factory takes ownership of the item editor creator and will destroy it if a new creator for the same type is registered later. \sa createEditor() */ -void QItemEditorFactory::registerEditor(QVariant::Type type, QItemEditorCreatorBase *creator) +void QItemEditorFactory::registerEditor(int userType, QItemEditorCreatorBase *creator) { - QHash<QVariant::Type, QItemEditorCreatorBase *>::iterator it = creatorMap.find(type); + QHash<int, QItemEditorCreatorBase *>::iterator it = creatorMap.find(userType); if (it != creatorMap.end()) { QItemEditorCreatorBase *oldCreator = it.value(); Q_ASSERT(oldCreator); @@ -184,20 +184,20 @@ void QItemEditorFactory::registerEditor(QVariant::Type type, QItemEditorCreatorB delete oldCreator; // if it is no more in use we can delete it } - creatorMap[type] = creator; + creatorMap[userType] = creator; } class QDefaultItemEditorFactory : public QItemEditorFactory { public: inline QDefaultItemEditorFactory() {} - QWidget *createEditor(QVariant::Type type, QWidget *parent) const; - QByteArray valuePropertyName(QVariant::Type) const; + QWidget *createEditor(int userType, QWidget *parent) const; + QByteArray valuePropertyName(int) const; }; -QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *parent) const +QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) const { - switch (type) { + switch (userType) { #ifndef QT_NO_COMBOBOX case QVariant::Bool: { QBooleanComboBox *cb = new QBooleanComboBox(parent); @@ -258,9 +258,9 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p return 0; } -QByteArray QDefaultItemEditorFactory::valuePropertyName(QVariant::Type type) const +QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const { - switch (type) { + switch (userType) { #ifndef QT_NO_COMBOBOX case QVariant::Bool: return "currentIndex"; |