aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/labsmodels
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/labsmodels')
-rw-r--r--src/imports/labsmodels/CMakeLists.txt4
-rw-r--r--src/imports/labsmodels/labsmodels.pro2
-rw-r--r--src/imports/labsmodels/plugin.cpp8
-rw-r--r--src/imports/labsmodels/qqmldelegatecomponent.cpp24
-rw-r--r--src/imports/labsmodels/qqmldelegatecomponent_p.h5
-rw-r--r--src/imports/labsmodels/qqmltablemodel.cpp17
-rw-r--r--src/imports/labsmodels/qqmltablemodel_p.h3
-rw-r--r--src/imports/labsmodels/qqmltablemodelcolumn_p.h1
8 files changed, 58 insertions, 6 deletions
diff --git a/src/imports/labsmodels/CMakeLists.txt b/src/imports/labsmodels/CMakeLists.txt
index 358bd5df18..efd3339e2f 100644
--- a/src/imports/labsmodels/CMakeLists.txt
+++ b/src/imports/labsmodels/CMakeLists.txt
@@ -6,7 +6,7 @@
qt_add_qml_module(labsmodelsplugin
URI "Qt.labs.qmlmodels"
- VERSION "1.0"
+ VERSION "${CMAKE_PROJECT_VERSION}"
CLASSNAME QtQmlLabsModelsPlugin
SKIP_TYPE_REGISTRATION
GENERATE_QMLTYPES
@@ -19,7 +19,7 @@ qt_add_qml_module(labsmodelsplugin
#### Keys ignored in scope 1:.:.:labsmodels.pro:<TRUE>:
# CXX_MODULE = "qml"
-# IMPORT_VERSION = "1.0"
+# QML_IMPORT_VERSION = "$$QT_VERSION"
# TARGETPATH = "Qt/labs/qmlmodels"
## Scopes:
diff --git a/src/imports/labsmodels/labsmodels.pro b/src/imports/labsmodels/labsmodels.pro
index 13468348cb..9fc52ce9cc 100644
--- a/src/imports/labsmodels/labsmodels.pro
+++ b/src/imports/labsmodels/labsmodels.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = labsmodelsplugin
TARGETPATH = Qt/labs/qmlmodels
-IMPORT_VERSION = 1.0
+QML_IMPORT_VERSION = $$QT_VERSION
QT = qml-private qmlmodels-private
diff --git a/src/imports/labsmodels/plugin.cpp b/src/imports/labsmodels/plugin.cpp
index feb4f3ba0a..ab5e0023a6 100644
--- a/src/imports/labsmodels/plugin.cpp
+++ b/src/imports/labsmodels/plugin.cpp
@@ -50,6 +50,8 @@
#include "qqmldelegatecomponent_p.h"
#endif
+extern void qml_register_types_Qt_labs_qmlmodels();
+
QT_BEGIN_NAMESPACE
/*!
@@ -74,7 +76,11 @@ class QtQmlLabsModelsPlugin : public QQmlEngineExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtQmlLabsModelsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) { }
+ QtQmlLabsModelsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_Qt_labs_qmlmodels;
+ Q_UNUSED(registration);
+ }
};
//![class decl]
diff --git a/src/imports/labsmodels/qqmldelegatecomponent.cpp b/src/imports/labsmodels/qqmldelegatecomponent.cpp
index aaf3fea5da..b8eb8049b3 100644
--- a/src/imports/labsmodels/qqmldelegatecomponent.cpp
+++ b/src/imports/labsmodels/qqmldelegatecomponent.cpp
@@ -250,7 +250,9 @@ QQmlListProperty<QQmlDelegateChoice> QQmlDelegateChooser::choices()
QQmlDelegateChooser::choices_append,
QQmlDelegateChooser::choices_count,
QQmlDelegateChooser::choices_at,
- QQmlDelegateChooser::choices_clear);
+ QQmlDelegateChooser::choices_clear,
+ QQmlDelegateChooser::choices_replace,
+ QQmlDelegateChooser::choices_removeLast);
}
void QQmlDelegateChooser::choices_append(QQmlListProperty<QQmlDelegateChoice> *prop, QQmlDelegateChoice *choice)
@@ -282,6 +284,26 @@ void QQmlDelegateChooser::choices_clear(QQmlListProperty<QQmlDelegateChoice> *pr
q->delegateChanged();
}
+void QQmlDelegateChooser::choices_replace(QQmlListProperty<QQmlDelegateChoice> *prop, int index,
+ QQmlDelegateChoice *choice)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser *>(prop->object);
+ disconnect(q->m_choices[index], &QQmlDelegateChoice::changed,
+ q, &QQmlAbstractDelegateComponent::delegateChanged);
+ q->m_choices[index] = choice;
+ connect(choice, &QQmlDelegateChoice::changed, q,
+ &QQmlAbstractDelegateComponent::delegateChanged);
+ q->delegateChanged();
+}
+
+void QQmlDelegateChooser::choices_removeLast(QQmlListProperty<QQmlDelegateChoice> *prop)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser *>(prop->object);
+ disconnect(q->m_choices.takeLast(), &QQmlDelegateChoice::changed,
+ q, &QQmlAbstractDelegateComponent::delegateChanged);
+ q->delegateChanged();
+}
+
QQmlComponent *QQmlDelegateChooser::delegate(QQmlAdaptorModel *adaptorModel, int row, int column) const
{
QVariant v;
diff --git a/src/imports/labsmodels/qqmldelegatecomponent_p.h b/src/imports/labsmodels/qqmldelegatecomponent_p.h
index 4c39dc0d0a..9655d1baf9 100644
--- a/src/imports/labsmodels/qqmldelegatecomponent_p.h
+++ b/src/imports/labsmodels/qqmldelegatecomponent_p.h
@@ -69,6 +69,8 @@ class QQmlDelegateChoice : public QObject
Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
QML_NAMED_ELEMENT(DelegateChoice)
+ QML_ADDED_IN_VERSION(1, 0)
+
public:
QVariant roleValue() const;
void setRoleValue(const QVariant &roleValue);
@@ -106,6 +108,7 @@ class QQmlDelegateChooser : public QQmlAbstractDelegateComponent
Q_PROPERTY(QQmlListProperty<QQmlDelegateChoice> choices READ choices CONSTANT)
Q_CLASSINFO("DefaultProperty", "choices")
QML_NAMED_ELEMENT(DelegateChooser)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QString role() const { return m_role; }
@@ -116,6 +119,8 @@ public:
static int choices_count(QQmlListProperty<QQmlDelegateChoice> *);
static QQmlDelegateChoice *choices_at(QQmlListProperty<QQmlDelegateChoice> *, int);
static void choices_clear(QQmlListProperty<QQmlDelegateChoice> *);
+ static void choices_replace(QQmlListProperty<QQmlDelegateChoice> *, int, QQmlDelegateChoice *);
+ static void choices_removeLast(QQmlListProperty<QQmlDelegateChoice> *);
QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = -1) const override;
diff --git a/src/imports/labsmodels/qqmltablemodel.cpp b/src/imports/labsmodels/qqmltablemodel.cpp
index b6468d760f..6ba2cecf19 100644
--- a/src/imports/labsmodels/qqmltablemodel.cpp
+++ b/src/imports/labsmodels/qqmltablemodel.cpp
@@ -644,7 +644,9 @@ QQmlListProperty<QQmlTableModelColumn> QQmlTableModel::columns()
&QQmlTableModel::columns_append,
&QQmlTableModel::columns_count,
&QQmlTableModel::columns_at,
- &QQmlTableModel::columns_clear);
+ &QQmlTableModel::columns_clear,
+ &QQmlTableModel::columns_replace,
+ &QQmlTableModel::columns_removeLast);
}
void QQmlTableModel::columns_append(QQmlListProperty<QQmlTableModelColumn> *property,
@@ -674,6 +676,19 @@ void QQmlTableModel::columns_clear(QQmlListProperty<QQmlTableModelColumn> *prope
return model->mColumns.clear();
}
+void QQmlTableModel::columns_replace(QQmlListProperty<QQmlTableModelColumn> *property, int index, QQmlTableModelColumn *value)
+{
+ QQmlTableModel *model = static_cast<QQmlTableModel*>(property->object);
+ if (QQmlTableModelColumn *column = qobject_cast<QQmlTableModelColumn*>(value))
+ return model->mColumns.replace(index, column);
+}
+
+void QQmlTableModel::columns_removeLast(QQmlListProperty<QQmlTableModelColumn> *property)
+{
+ QQmlTableModel *model = static_cast<QQmlTableModel*>(property->object);
+ model->mColumns.removeLast();
+}
+
/*!
\qmlmethod QModelIndex TableModel::index(int row, int column)
diff --git a/src/imports/labsmodels/qqmltablemodel_p.h b/src/imports/labsmodels/qqmltablemodel_p.h
index d6e982d19a..ae46cbe35c 100644
--- a/src/imports/labsmodels/qqmltablemodel_p.h
+++ b/src/imports/labsmodels/qqmltablemodel_p.h
@@ -74,6 +74,7 @@ class QQmlTableModel : public QAbstractTableModel, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_CLASSINFO("DefaultProperty", "columns")
QML_NAMED_ELEMENT(TableModel)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QQmlTableModel(QObject *parent = nullptr);
@@ -96,6 +97,8 @@ public:
static int columns_count(QQmlListProperty<QQmlTableModelColumn> *property);
static QQmlTableModelColumn *columns_at(QQmlListProperty<QQmlTableModelColumn> *property, int index);
static void columns_clear(QQmlListProperty<QQmlTableModelColumn> *property);
+ static void columns_replace(QQmlListProperty<QQmlTableModelColumn> *property, int index, QQmlTableModelColumn *value);
+ static void columns_removeLast(QQmlListProperty<QQmlTableModelColumn> *property);
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
diff --git a/src/imports/labsmodels/qqmltablemodelcolumn_p.h b/src/imports/labsmodels/qqmltablemodelcolumn_p.h
index a18f21ab4f..2860a915cc 100644
--- a/src/imports/labsmodels/qqmltablemodelcolumn_p.h
+++ b/src/imports/labsmodels/qqmltablemodelcolumn_p.h
@@ -97,6 +97,7 @@ class QQmlTableModelColumn : public QObject
Q_PROPERTY(QJSValue sizeHint READ sizeHint WRITE setSizeHint NOTIFY sizeHintChanged FINAL)
Q_PROPERTY(QJSValue setSizeHint READ getSetSizeHint WRITE setSetSizeHint NOTIFY setSizeHintChanged FINAL)
QML_NAMED_ELEMENT(TableModelColumn)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QQmlTableModelColumn(QObject *parent = nullptr);