summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2019-09-10 16:56:58 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2019-09-30 15:21:37 +0000
commitda0601e470d6a1f6e5f81eaf8e842a6fd6f241c7 (patch)
tree92dc5e280821f10354319dbf1b9b3b8fb77bb67c /src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h
parent2509dd4c3233ebb9876d2caa4119d4f5614af61d (diff)
downloadqt-creator-da0601e470d6a1f6e5f81eaf8e842a6fd6f241c7.tar.gz
QmlDesigner: Add ItemFilterModel
This exposes a model to QML that allows to get a list of all ids of items of a specific type. This allows implementing a combobox that can e.g. set the id of any image element in the file. Change-Id: Ibc825cb5a66c951d29df12676f9433c9232fd8af Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h')
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h b/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h
new file mode 100644
index 0000000000..032bd2baff
--- /dev/null
+++ b/src/plugins/qmldesigner/components/propertyeditor/itemfiltermodel.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include <qmlitemnode.h>
+
+#include <QDir>
+#include <QObject>
+#include <QStringList>
+#include <QUrl>
+#include <QtQml>
+
+class ItemFilterModel : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString typeFilter READ typeFilter WRITE setTypeFilter)
+ Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged)
+ Q_PROPERTY(QStringList itemModel READ itemModel NOTIFY itemModelChanged)
+
+public:
+ explicit ItemFilterModel(QObject *parent = nullptr);
+
+ void setModelNodeBackend(const QVariant &modelNodeBackend);
+ void setTypeFilter(const QString &typeFilter);
+ QString typeFilter() const;
+ void setupModel();
+ QStringList itemModel() const;
+
+ static void registerDeclarativeType();
+
+signals:
+ void modelNodeBackendChanged();
+ void itemModelChanged();
+
+private:
+ QVariant modelNodeBackend() const;
+
+private:
+ QString m_typeFilter;
+ bool m_lock;
+ QStringList m_model;
+ QmlDesigner::ModelNode m_modelNode;
+};
+
+QML_DECLARE_TYPE(ItemFilterModel)