diff options
| author | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2014-06-17 15:22:31 +0200 |
|---|---|---|
| committer | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2014-06-17 16:01:22 +0200 |
| commit | 9117e29ea6fcff27a7c411c73dd88760e5f65164 (patch) | |
| tree | 32d8574580f9650d2e48502690ce3e96f638acf2 /src | |
| parent | 836e17a57cab9fd94a0ee490ee33870df106e2bd (diff) | |
| download | qt-creator-9117e29ea6fcff27a7c411c73dd88760e5f65164.tar.gz | |
QmlDesigner.PropertyEditor: Adding TabViewIndexModel
Adding this to the plugin for components.
Change-Id: Ia9612dc398f54880a3abd7142ca4096fa7aa1b7c
Reviewed-by: Marco Bubke <marco.bubke@digia.com>
Diffstat (limited to 'src')
4 files changed, 169 insertions, 4 deletions
diff --git a/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp b/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp index c8d91399cd..75d3d720d0 100644 --- a/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp +++ b/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp @@ -28,6 +28,8 @@ ****************************************************************************/ #include "componentsplugin.h" + +#include "tabviewindexmodel.h" #include <QtPlugin> namespace QmlDesigner { @@ -35,7 +37,7 @@ namespace QmlDesigner { ComponentsPlugin::ComponentsPlugin() { - + TabViewIndexModel::registerDeclarativeType(); } QString ComponentsPlugin::pluginName() const diff --git a/src/plugins/qmldesigner/componentsplugin/componentsplugin.pri b/src/plugins/qmldesigner/componentsplugin/componentsplugin.pri index cefb782aea..fae09da893 100644 --- a/src/plugins/qmldesigner/componentsplugin/componentsplugin.pri +++ b/src/plugins/qmldesigner/componentsplugin/componentsplugin.pri @@ -2,13 +2,26 @@ TARGET = componentsplugin TEMPLATE = lib CONFIG += plugin +QT += qml + include (../designercore/iwidgetplugin.pri) +include (../qmldesigner_dependencies.pri) -DEFINES += COMPONENTS_LIBRARY -SOURCES += $$PWD/componentsplugin.cpp +LIBS += -L$$IDE_PLUGIN_PATH +LIBS += -l$$qtLibraryName(QmlDesigner) -HEADERS += $$PWD/componentsplugin.h $$PWD/../designercore/include/iwidgetplugin.h +DEFINES += COMPONENTS_LIBRARY RESOURCES += $$PWD/componentsplugin.qrc +HEADERS += \ + $$PWD/tabviewindexmodel.h \ + $$PWD/componentsplugin.h \ + $$PWD/../designercore/include/iwidgetplugin.h + +SOURCES += \ + $$PWD/componentsplugin.cpp \ + $$PWD/tabviewindexmodel.cpp + + OTHER_FILES += $$PWD/components.metainfo diff --git a/src/plugins/qmldesigner/componentsplugin/tabviewindexmodel.cpp b/src/plugins/qmldesigner/componentsplugin/tabviewindexmodel.cpp new file mode 100644 index 0000000000..824576fd92 --- /dev/null +++ b/src/plugins/qmldesigner/componentsplugin/tabviewindexmodel.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "tabviewindexmodel.h" + +#include <metainfo.h> +#include <variantproperty.h> +#include <nodelistproperty.h> + +TabViewIndexModel::TabViewIndexModel(QObject *parent) : + QObject(parent) +{ +} + +void TabViewIndexModel::setModelNodeBackend(const QVariant &modelNodeBackend) +{ + QObject* modelNodeBackendObject = modelNodeBackend.value<QObject*>(); + + if (modelNodeBackendObject) + m_modelNode = modelNodeBackendObject->property("modelNode").value<QmlDesigner::ModelNode>(); + + setupModel(); + emit modelNodeBackendChanged(); +} + +QStringList TabViewIndexModel::tabViewIndexModel() const +{ + return m_tabViewIndexModel; +} + +void TabViewIndexModel::setupModel() +{ + m_tabViewIndexModel.clear(); + if (m_modelNode.isValid() + && m_modelNode.metaInfo().isValid() + && m_modelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1)) { + + foreach (const QmlDesigner::ModelNode &childModelNode, m_modelNode.defaultNodeAbstractProperty().directSubNodes()) { + if (childModelNode.metaInfo().isValid() + && childModelNode.metaInfo().isSubclassOf("QtQuick.Controls.Tab", -1, -1)) { + QmlDesigner::QmlItemNode itemNode(childModelNode); + if (itemNode.isValid()) { + m_tabViewIndexModel.append(itemNode.instanceValue("title").toString()); + } + } + } + } +} + +void TabViewIndexModel::registerDeclarativeType() +{ + qmlRegisterType<TabViewIndexModel>("HelperWidgets",2,0,"TabViewIndexModel"); +} + +QVariant TabViewIndexModel::modelNodeBackend() const +{ + return QVariant::fromValue(m_modelNode); +} diff --git a/src/plugins/qmldesigner/componentsplugin/tabviewindexmodel.h b/src/plugins/qmldesigner/componentsplugin/tabviewindexmodel.h new file mode 100644 index 0000000000..fa421434d6 --- /dev/null +++ b/src/plugins/qmldesigner/componentsplugin/tabviewindexmodel.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef TABVIEWINDEXMODEL_H +#define TABVIEWINDEXMODEL_H + +#include <qmlitemnode.h> + +#include <QObject> +#include <QtQml> + +class TabViewIndexModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged) + Q_PROPERTY(QStringList tabViewIndexModel READ tabViewIndexModel NOTIFY modelNodeBackendChanged) + +public: + explicit TabViewIndexModel(QObject *parent = 0); + + void setModelNodeBackend(const QVariant &modelNodeBackend); + QStringList tabViewIndexModel() const; + void setupModel(); + + static void registerDeclarativeType(); + +signals: + void modelNodeBackendChanged(); + +private: + QVariant modelNodeBackend() const; + + QmlDesigner::ModelNode m_modelNode; + QStringList m_tabViewIndexModel; + +}; + +QML_DECLARE_TYPE(TabViewIndexModel) + +#endif // TABVIEWINDEXMODEL_H |
