diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-08-03 05:41:34 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-08-03 05:41:34 (GMT) |
commit | 3c0ea527433dde04ee69c94a3f95f2d2d6b6a02d (patch) | |
tree | 5622cfc3f966892d3192e7a8433f257cf977a7fd /src/declarative/fx/qfxpathview.cpp | |
parent | 651b7aa72052faa90b3a268f00f82d56460166d3 (diff) | |
download | Qt-3c0ea527433dde04ee69c94a3f95f2d2d6b6a02d.zip Qt-3c0ea527433dde04ee69c94a3f95f2d2d6b6a02d.tar.gz Qt-3c0ea527433dde04ee69c94a3f95f2d2d6b6a02d.tar.bz2 |
Rework VisualItemModel into VisualItemModel & VisualDataModel
QFXVisualModel provides a base class for visual models.
QFxVisualDataModel provides a visual model for Qt item view models.
QFxVisualItemModel provides a model of QFxItems.
Diffstat (limited to 'src/declarative/fx/qfxpathview.cpp')
-rw-r--r-- | src/declarative/fx/qfxpathview.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 17f6dd3..6dcfcd1 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -144,7 +144,7 @@ QFxPathView::~QFxPathView() \brief the model providing data for the view. The model must be either a \l QListModelInterface or - \l QFxVisualItemModel subclass. + \l QFxVisualModel subclass. */ QVariant QFxPathView::model() const { @@ -168,8 +168,8 @@ void QFxPathView::setModel(const QVariant &model) d->modelVariant = model; QObject *object = qvariant_cast<QObject*>(model); - QFxVisualItemModel *vim = 0; - if (object && (vim = qobject_cast<QFxVisualItemModel *>(object))) { + QFxVisualModel *vim = 0; + if (object && (vim = qobject_cast<QFxVisualModel *>(object))) { if (d->ownModel) { delete d->model; d->ownModel = false; @@ -177,10 +177,11 @@ void QFxPathView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setModel(model); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + dataModel->setModel(model); } if (d->model) { connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); @@ -341,18 +342,25 @@ void QFxPathView::setDragMargin(qreal dragMargin) QmlComponent *QFxPathView::delegate() const { Q_D(const QFxPathView); - return d->model ? d->model->delegate() : 0; + if (d->model) { + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + return dataModel->delegate(); + } + + return 0; } void QFxPathView::setDelegate(QmlComponent *c) { Q_D(QFxPathView); if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setDelegate(c); - d->regenerate(); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) { + dataModel->setDelegate(c); + d->regenerate(); + } } /*! |