diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 23 | ||||
| -rw-r--r-- | src/qml/types/qqmldelegatemodel_p_p.h | 8 | ||||
| -rw-r--r-- | src/qml/util/qqmladaptormodel.cpp | 30 | ||||
| -rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 2 |
4 files changed, 31 insertions, 32 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 15d6bed2db..68bb185eaa 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1960,6 +1960,8 @@ QQmlDelegateModelItem::QQmlDelegateModelItem( , scriptRef(0) , groups(0) , index(modelIndex) + , row(QQmlDelegateModelPrivate::get(metaType->model)->m_adaptorModel.rowAt(modelIndex)) + , column(QQmlDelegateModelPrivate::get(metaType->model)->m_adaptorModel.columnAt(modelIndex)) { metaType->addref(); } @@ -1994,6 +1996,27 @@ void QQmlDelegateModelItem::Dispose() delete this; } +void QQmlDelegateModelItem::setModelIndex(int idx) +{ + if (idx == index) + return; + + const int prevRow = row; + const int prevColumn = column; + const QQmlAdaptorModel &adaptorModel = QQmlDelegateModelPrivate::get(metaType->model)->m_adaptorModel; + + index = idx; + row = adaptorModel.rowAt(idx); + column = adaptorModel.columnAt(idx); + + Q_EMIT modelIndexChanged(); + + if (row != prevRow) + emit rowChanged(); + if (column != prevColumn) + emit columnChanged(); +} + void QQmlDelegateModelItem::destroyObject() { Q_ASSERT(object); diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 2c0383a7e2..d5f79fab62 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -95,6 +95,8 @@ class QQmlDelegateModelItem : public QObject { Q_OBJECT Q_PROPERTY(int index READ modelIndex NOTIFY modelIndexChanged) + Q_PROPERTY(int row MEMBER row NOTIFY rowChanged) + Q_PROPERTY(int column MEMBER column NOTIFY columnChanged) Q_PROPERTY(QObject *model READ modelObject CONSTANT) public: QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *metaType, int modelIndex); @@ -121,7 +123,7 @@ public: int groupIndex(Compositor::Group group); int modelIndex() const { return index; } - virtual void setModelIndex(int idx) { index = idx; Q_EMIT modelIndexChanged(); } + virtual void setModelIndex(int idx); virtual QV4::ReturnedValue get() { return QV4::QObjectWrapper::wrap(v4, this); } @@ -148,9 +150,13 @@ public: Q_SIGNALS: void modelIndexChanged(); + void rowChanged(); + void columnChanged(); protected: void objectDestroyed(QObject *); + int row; + int column; }; namespace QV4 { diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index 15844017aa..3016316e57 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -398,8 +398,6 @@ QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::FunctionObject class QQmlDMAbstractItemModelData : public QQmlDMCachedModelData { Q_OBJECT - Q_PROPERTY(int row MEMBER row NOTIFY rowChanged) - Q_PROPERTY(int column MEMBER column NOTIFY columnChanged) Q_PROPERTY(bool hasModelChildren READ hasModelChildren CONSTANT) public: @@ -408,8 +406,6 @@ public: VDMModelDelegateDataType *dataType, int index) : QQmlDMCachedModelData(metaType, dataType, index) - , row(type->model->rowAt(index)) - , column(type->model->columnAt(index)) { } @@ -447,16 +443,6 @@ public: ++scriptRef; return o.asReturnedValue(); } - - void setModelIndex(int idx) override; - -Q_SIGNALS: - void rowChanged(); - void columnChanged(); - -private: - int row; - int column; }; class VDMAbstractItemModelDataType : public VDMModelDelegateDataType @@ -577,22 +563,6 @@ public: } }; -void QQmlDMAbstractItemModelData::setModelIndex(int idx) -{ - QQmlDMCachedModelData::setModelIndex(idx); - - int prevRow = row; - int prevColumn = column; - - row = type->model->rowAt(idx); - column = type->model->columnAt(idx); - - if (row != prevRow) - emit rowChanged(); - if (column != prevColumn) - emit columnChanged(); -} - //----------------------------------------------------------------- // QQmlListAccessor //----------------------------------------------------------------- diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index a7c512f063..161fe893a2 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -58,7 +58,7 @@ static const qreal kDefaultColumnWidth = 50; class FxTableItem; -class QQuickTableViewPrivate : public QQuickFlickablePrivate +class Q_QML_AUTOTEST_EXPORT QQuickTableViewPrivate : public QQuickFlickablePrivate { Q_DECLARE_PUBLIC(QQuickTableView) |
