summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@theqtcompany.com>2015-08-21 15:05:43 +0200
committerTim Jenssen <tim.jenssen@theqtcompany.com>2015-08-26 12:31:51 +0000
commitced554aaabbad09d1a79691f0a34b9e6e52296a4 (patch)
treeb8ead7ac8305cfd1a0b01c54f4924c724afdacfc
parent78d304674f85be8a8575f83fddb520e3b53dce7c (diff)
downloadqt-creator-ced554aaabbad09d1a79691f0a34b9e6e52296a4.tar.gz
Qml2Puppet: Use helper functions from Qt 5.6
In Qt 5.6 we do not need to access the private API directly. QmlPrivateGate is forwarded to the helper functions in Qt. This removes direct dependencies to QML internals in qml2puppet. Change-Id: I274cb306815824c988b6d79966f007298f6d1e60 (cherry picked from commit d6d0bd60357a41cd6c83b511fd30ab12157ed95d) Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
-rw-r--r--share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri11
-rw-r--r--share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp392
2 files changed, 402 insertions, 1 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri
index 89b61e260d..357c85c920 100644
--- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri
+++ b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri
@@ -1,5 +1,14 @@
INCLUDEPATH += $$PWD/
+minQtVersion(5, 6, 0) {
+HEADERS += \
+ $$PWD/qmlprivategate.h
+
+SOURCES += \
+ $$PWD/qmlprivategate_56.cpp
+
+} else {
+
HEADERS += \
$$PWD/qmlprivategate.h \
$$PWD/metaobject.h \
@@ -9,4 +18,4 @@ SOURCES += \
$$PWD/qmlprivategate.cpp \
$$PWD/metaobject.cpp \
$$PWD/designercustomobjectdata.cpp
-
+}
diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp
new file mode 100644
index 0000000000..a44e3262bf
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp
@@ -0,0 +1,392 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "qmlprivategate.h"
+
+#include "metaobject.h"
+#include "designercustomobjectdata.h"
+
+#include <objectnodeinstance.h>
+#include <nodeinstanceserver.h>
+
+#include <QQuickItem>
+#include <QQmlComponent>
+#include <QFileInfo>
+
+#include <private/qquickdesignersupport_p.h>
+#include <private/qquickdesignersupportmetainfo_p.h>
+#include <private/qquickdesignersupportitems_p.h>
+#include <private/qquickdesignersupportproperties_p.h>
+#include <private/qquickdesignersupportpropertychanges_p.h>
+#include <private/qquickdesignersupportstates_p.h>
+
+namespace QmlDesigner {
+
+namespace Internal {
+
+namespace QmlPrivateGate {
+
+bool isPropertyBlackListed(const QmlDesigner::PropertyName &propertyName)
+{
+ return QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName);
+}
+
+PropertyNameList allPropertyNames(QObject *object,
+ const PropertyName &baseName,
+ QObjectList *inspectedObjects)
+{
+ return QQuickDesignerSupportProperties::allPropertyNames(object, baseName, inspectedObjects);
+}
+
+PropertyNameList propertyNameListForWritableProperties(QObject *object,
+ const PropertyName &baseName,
+ QObjectList *inspectedObjects)
+{
+ return QQuickDesignerSupportProperties::propertyNameListForWritableProperties(object, baseName, inspectedObjects);
+}
+
+static void fixResourcePathsForObject(QObject *object)
+{
+ if (qgetenv("QMLDESIGNER_RC_PATHS").isEmpty())
+ return;
+
+ PropertyNameList propertyNameList = propertyNameListForWritableProperties(object);
+
+ foreach (const PropertyName &propertyName, propertyNameList) {
+ QQmlProperty property(object, propertyName, QQmlEngine::contextForObject(object));
+
+ const QVariant value = property.read();
+ const QVariant fixedValue = fixResourcePaths(value);
+ if (value != fixedValue) {
+ property.write(fixedValue);
+ }
+ }
+}
+
+void tweakObjects(QObject *object)
+{
+ QQuickDesignerSupportItems::tweakObjects(object);
+}
+
+void createNewDynamicProperty(QObject *object, QQmlEngine *engine, const QString &name)
+{
+ QQuickDesignerSupportProperties::createNewDynamicProperty(object, engine, name);
+}
+
+void registerNodeInstanceMetaObject(QObject *object, QQmlEngine *engine)
+{
+ QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(object, engine);
+}
+
+QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context)
+{
+ return QQuickDesignerSupportItems::createPrimitive(typeName, majorNumber, minorNumber, context);
+}
+
+QVariant fixResourcePaths(const QVariant &value)
+{
+ if (value.type() == QVariant::Url)
+ {
+ const QUrl url = value.toUrl();
+ if (url.scheme() == QLatin1String("qrc")) {
+ const QString path = QLatin1String("qrc:") + url.path();
+ QString qrcSearchPath = qgetenv("QMLDESIGNER_RC_PATHS");
+ if (!qrcSearchPath.isEmpty()) {
+ const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
+ foreach (const QString &qrcPath, searchPaths) {
+ const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
+ if (qrcDefintion.count() == 2) {
+ QString fixedPath = path;
+ fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
+ if (QFileInfo(fixedPath).exists()) {
+ fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
+ fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
+ return QUrl(fixedPath);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (value.type() == QVariant::String) {
+ const QString str = value.toString();
+ if (str.contains(QLatin1String("qrc:"))) {
+ QString qrcSearchPath = qgetenv("QMLDESIGNER_RC_PATHS");
+ if (!qrcSearchPath.isEmpty()) {
+ const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
+ foreach (const QString &qrcPath, searchPaths) {
+ const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
+ if (qrcDefintion.count() == 2) {
+ QString fixedPath = str;
+ fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
+ if (QFileInfo(fixedPath).exists()) {
+ fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
+ fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
+ return fixedPath;
+ }
+ }
+ }
+ }
+ }
+ }
+ return value;
+}
+
+
+QObject *createComponent(const QUrl &componentUrl, QQmlContext *context)
+{
+ return QQuickDesignerSupportItems::createComponent(componentUrl, context);
+}
+
+bool hasFullImplementedListInterface(const QQmlListReference &list)
+{
+ return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
+}
+
+void registerCustomData(QObject *object)
+{
+ QQuickDesignerSupportProperties::registerCustomData(object);
+}
+
+QVariant getResetValue(QObject *object, const PropertyName &propertyName)
+{
+ return QQuickDesignerSupportProperties::getResetValue(object, propertyName);
+}
+
+void doResetProperty(QObject *object, QQmlContext *context, const PropertyName &propertyName)
+{
+ QQuickDesignerSupportProperties::doResetProperty(object, context, propertyName);
+}
+
+bool hasValidResetBinding(QObject *object, const PropertyName &propertyName)
+{
+ return QQuickDesignerSupportProperties::hasValidResetBinding(object, propertyName);
+}
+
+bool hasBindingForProperty(QObject *object, QQmlContext *context, const PropertyName &propertyName, bool *hasChanged)
+{
+ return QQuickDesignerSupportProperties::hasBindingForProperty(object, context, propertyName, hasChanged);
+}
+
+void setPropertyBinding(QObject *object, QQmlContext *context, const PropertyName &propertyName, const QString &expression)
+{
+ QQuickDesignerSupportProperties::setPropertyBinding(object, context, propertyName, expression);
+}
+
+void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer)
+{
+ if (object) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(object);
+
+ if (item && DesignerSupport::isComponentComplete(item))
+ return;
+
+ QList<QObject*> childList = object->children();
+
+ if (item) {
+ foreach (QQuickItem *childItem, item->childItems()) {
+ if (!childList.contains(childItem))
+ childList.append(childItem);
+ }
+ }
+
+ foreach (QObject *child, childList) {
+ if (!nodeInstanceServer->hasInstanceForObject(child))
+ doComponentCompleteRecursive(child, nodeInstanceServer);
+ }
+
+ if (item) {
+ static_cast<QQmlParserStatus*>(item)->componentComplete();
+ } else {
+ QQmlParserStatus *qmlParserStatus = dynamic_cast< QQmlParserStatus*>(object);
+ if (qmlParserStatus)
+ qmlParserStatus->componentComplete();
+ }
+ }
+}
+
+
+void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const PropertyName &propertyName)
+{
+ QQuickDesignerSupportProperties::keepBindingFromGettingDeleted(object, context, propertyName);
+}
+
+bool objectWasDeleted(QObject *object)
+{
+ return QQuickDesignerSupportItems::objectWasDeleted(object);
+}
+
+void disableNativeTextRendering(QQuickItem *item)
+{
+ QQuickDesignerSupportItems::disableNativeTextRendering(item);
+}
+
+void disableTextCursor(QQuickItem *item)
+{
+ QQuickDesignerSupportItems::disableTextCursor(item);
+}
+
+void disableTransition(QObject *object)
+{
+ QQuickDesignerSupportItems::disableTransition(object);
+}
+
+void disableBehaivour(QObject *object)
+{
+ QQuickDesignerSupportItems::disableBehaivour(object);
+}
+
+void stopUnifiedTimer()
+{
+ QQuickDesignerSupportItems::stopUnifiedTimer();
+}
+
+bool isPropertyQObject(const QMetaProperty &metaProperty)
+{
+ return QQuickDesignerSupportProperties::isPropertyQObject(metaProperty);
+}
+
+QObject *readQObjectProperty(const QMetaProperty &metaProperty, QObject *object)
+{
+ return QQuickDesignerSupportProperties::readQObjectProperty(metaProperty, object);
+}
+
+namespace States {
+
+bool isStateActive(QObject *object, QQmlContext *context)
+{
+
+ return QQuickDesignerSupportStates::isStateActive(object, context);
+}
+
+void activateState(QObject *object, QQmlContext *context)
+{
+ QQuickDesignerSupportStates::activateState(object, context);
+}
+
+void deactivateState(QObject *object)
+{
+ QQuickDesignerSupportStates::deactivateState(object);
+}
+
+bool changeValueInRevertList(QObject *state, QObject *target, const PropertyName &propertyName, const QVariant &value)
+{
+ return QQuickDesignerSupportStates::changeValueInRevertList(state, target, propertyName, value);
+}
+
+bool updateStateBinding(QObject *state, QObject *target, const PropertyName &propertyName, const QString &expression)
+{
+ return QQuickDesignerSupportStates::updateStateBinding(state, target, propertyName, expression);
+}
+
+bool resetStateProperty(QObject *state, QObject *target, const PropertyName &propertyName, const QVariant &value)
+{
+ return QQuickDesignerSupportStates::resetStateProperty(state, target, propertyName, value);
+}
+
+} //namespace States
+
+namespace PropertyChanges {
+
+void detachFromState(QObject *propertyChanges)
+{
+ return QQuickDesignerSupportPropertyChanges::detachFromState(propertyChanges);
+}
+
+void attachToState(QObject *propertyChanges)
+{
+ return QQuickDesignerSupportPropertyChanges::attachToState(propertyChanges);
+}
+
+QObject *targetObject(QObject *propertyChanges)
+{
+ return QQuickDesignerSupportPropertyChanges::targetObject(propertyChanges);
+}
+
+void removeProperty(QObject *propertyChanges, const PropertyName &propertyName)
+{
+ QQuickDesignerSupportPropertyChanges::removeProperty(propertyChanges, propertyName);
+}
+
+QVariant getProperty(QObject *propertyChanges, const PropertyName &propertyName)
+{
+ return QQuickDesignerSupportPropertyChanges::getProperty(propertyChanges, propertyName);
+}
+
+void changeValue(QObject *propertyChanges, const PropertyName &propertyName, const QVariant &value)
+{
+ QQuickDesignerSupportPropertyChanges::changeValue(propertyChanges, propertyName, value);
+}
+
+void changeExpression(QObject *propertyChanges, const PropertyName &propertyName, const QString &expression)
+{
+ QQuickDesignerSupportPropertyChanges::changeExpression(propertyChanges, propertyName, expression);
+}
+
+QObject *stateObject(QObject *propertyChanges)
+{
+ return QQuickDesignerSupportPropertyChanges::stateObject(propertyChanges);
+}
+
+bool isNormalProperty(const PropertyName &propertyName)
+{
+ return QQuickDesignerSupportPropertyChanges::isNormalProperty(propertyName);
+}
+
+} // namespace PropertyChanges
+
+bool isSubclassOf(QObject *object, const QByteArray &superTypeName)
+{
+ return QQuickDesignerSupportMetaInfo::isSubclassOf(object, superTypeName);
+}
+
+void getPropertyCache(QObject *object, QQmlEngine *engine)
+{
+ QQuickDesignerSupportProperties::getPropertyCache(object, engine);
+}
+
+void registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &))
+{
+ QQuickDesignerSupportMetaInfo::registerNotifyPropertyChangeCallBack(callback);
+}
+
+ComponentCompleteDisabler::ComponentCompleteDisabler()
+{
+ DesignerSupport::disableComponentComplete();
+}
+
+ComponentCompleteDisabler::~ComponentCompleteDisabler()
+{
+ DesignerSupport::enableComponentComplete();
+}
+
+} // namespace QmlPrivateGate
+} // namespace Internal
+} // namespace QmlDesigner