diff options
author | Ali Kianian <ali.kianian@qt.io> | 2023-01-27 10:14:06 +0200 |
---|---|---|
committer | Ali Kianian <ali.kianian@qt.io> | 2023-03-01 16:50:04 +0000 |
commit | 003ae4db879a5643412bb7a8a539ec80f42da72b (patch) | |
tree | ea94271a327aad7aa6a6563ebaf68bd3ae6340c3 /src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h | |
parent | 6ccef0cc2966398f457942ef5d1e73536f33f19d (diff) | |
download | qt-creator-003ae4db879a5643412bb7a8a539ec80f42da72b.tar.gz |
QmlDesigner: Show the material name in the property editor
The material name for the property editor's material field
is presented in the following format:
MaterialName [MaterialId]
Task-number: QDS-8663
Change-Id: I59fdfcb52ecb2ce9a1079ae20b7e2d748bbc1d61
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h')
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h b/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h index e93c669585..54b29f1fd7 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h +++ b/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h @@ -6,12 +6,13 @@ #include <qmlitemnode.h> #include <QDir> +#include <QHash> #include <QObject> #include <QStringList> #include <QUrl> #include <QtQml> -class ItemFilterModel : public QObject +class ItemFilterModel : public QAbstractListModel { Q_OBJECT @@ -21,6 +22,13 @@ class ItemFilterModel : public QObject Q_PROPERTY(bool selectionOnly READ selectionOnly WRITE setSelectionOnly NOTIFY selectionOnlyChanged) public: + enum Roles { + IdRole = Qt::UserRole + 1, + NameRole, + IdAndNameRole + }; + Q_ENUM(Roles) + explicit ItemFilterModel(QObject *parent = nullptr); void setModelNodeBackend(const QVariant &modelNodeBackend); @@ -33,6 +41,14 @@ public: static void registerDeclarativeType(); + // Make index accessible for Qml side since it's not accessible by default in QAbstractListModel + Q_INVOKABLE QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; + Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; + Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Q_INVOKABLE virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + + virtual QHash<int,QByteArray> roleNames() const override; + signals: void modelNodeBackendChanged(); void itemModelChanged(); @@ -40,13 +56,14 @@ signals: private: QVariant modelNodeBackend() const; + QmlDesigner::ModelNode modelNodeForRow(const int &row) const; private: QString m_typeFilter; - bool m_lock; - QStringList m_model; + QList<qint32> m_modelInternalIds; QmlDesigner::ModelNode m_modelNode; bool m_selectionOnly; + static QHash<int, QByteArray> m_roles; }; QML_DECLARE_TYPE(ItemFilterModel) |