diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-16 00:11:14 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-16 00:11:14 (GMT) |
commit | bac82138b76ac9f6a0603fa454f6660d139287d0 (patch) | |
tree | b6dce6f4a3e39d3e3b05ba5e616150a2adef3435 /src | |
parent | 62e52a19f1c7ac81a36f394e43f916c3c8933e8f (diff) | |
download | Qt-bac82138b76ac9f6a0603fa454f6660d139287d0.zip Qt-bac82138b76ac9f6a0603fa454f6660d139287d0.tar.gz Qt-bac82138b76ac9f6a0603fa454f6660d139287d0.tar.bz2 |
Improve warning for non-Item delegates.
Task-number: QTBUG-9682
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 4365ea3..751284d 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -353,6 +353,7 @@ public: friend class QDeclarativeVisualDataModelData; bool m_metaDataCreated; bool m_metaDataCacheable; + bool m_delegateValidated; QDeclarativeVisualDataModelData *data(QObject *item); @@ -560,7 +561,7 @@ QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeV QDeclarativeVisualDataModelPrivate::QDeclarativeVisualDataModelPrivate(QDeclarativeContext *ctxt) : m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0) , m_context(ctxt), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false) -, m_metaDataCacheable(false), m_listAccessor(0) +, m_metaDataCacheable(false), m_delegateValidated(false), m_listAccessor(0) { } @@ -768,6 +769,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate) Q_D(QDeclarativeVisualDataModel); bool wasValid = d->m_delegate != 0; d->m_delegate = delegate; + d->m_delegateValidated = false; if (!wasValid && d->modelCount() && d->m_delegate) { emit itemsInserted(0, d->modelCount()); emit countChanged(); @@ -987,6 +989,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray if (d->modelCount() <= 0 || !d->m_delegate) return 0; QObject *nobj = d->m_cache.getItem(index); + bool needComplete = false; if (!nobj) { QDeclarativeContext *ccontext = d->m_context; if (!ccontext) ccontext = qmlContext(this); @@ -997,6 +1000,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray nobj = d->m_delegate->beginCreate(ctxt); if (complete) d->m_delegate->completeCreate(); + else + needComplete = true; if (nobj) { QDeclarative_setParent_noEvent(ctxt, nobj); QDeclarative_setParent_noEvent(data, nobj); @@ -1020,8 +1025,13 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray } } if (!item) { + if (needComplete) + d->m_delegate->completeCreate(); d->m_cache.releaseItem(nobj); - qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type."); + if (!d->m_delegateValidated) { + qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type."); + d->m_delegateValidated = true; + } } return item; |