From f86eb9b78c4234e61c2f3a3492f066256b696565 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 19 May 2015 17:03:45 +0200 Subject: [PATCH] QmlPuppet: Move functions from QuickItemNodeInstance to QmlPrivateGate No need to use private API in QuickItemNodeInstance. Change-Id: I5450ea41571c2787081cc88f59494a28eea5546c Reviewed-by: Tim Jenssen --- .../instances/quickitemnodeinstance.cpp | 40 ++----------------- .../qmlprivategate/qmlprivategate.cpp | 34 +++++++++++++++- .../qmlpuppet/qmlprivategate/qmlprivategate.h | 3 ++ 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index 06b66c06752..81b98910bff 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -29,18 +29,15 @@ ****************************************************************************/ #include "quickitemnodeinstance.h" - #include "qt5nodeinstanceserver.h" +#include + #include #include #include #include -#include -#include -#include - #include #include @@ -193,35 +190,6 @@ bool QuickItemNodeInstance::hasContent() const return childItemsHaveContent(quickItem()); } -static void disableNativeTextRendering(QQuickItem *item) -{ - QQuickText *text = qobject_cast(item); - if (text) - text->setRenderType(QQuickText::QtRendering); - - QQuickTextInput *textInput = qobject_cast(item); - if (textInput) - textInput->setRenderType(QQuickTextInput::QtRendering); - - QQuickTextEdit *textEdit = qobject_cast(item); - if (textEdit) - textEdit->setRenderType(QQuickTextEdit::QtRendering); -} - -static void disableTextCursor(QQuickItem *item) -{ - foreach (QQuickItem *childItem, item->childItems()) - disableTextCursor(childItem); - - QQuickTextInput *textInput = qobject_cast(item); - if (textInput) - textInput->setCursorVisible(false); - - QQuickTextEdit *textEdit = qobject_cast(item); - if (textEdit) - textEdit->setCursorVisible(false); -} - void QuickItemNodeInstance::doComponentComplete() { ObjectNodeInstance::doComponentComplete(); @@ -230,7 +198,7 @@ void QuickItemNodeInstance::doComponentComplete() if (contentItemProperty.isValid()) m_contentItem = contentItemProperty.read().value(); - disableTextCursor(quickItem()); + QmlPrivateGate::disableTextCursor(quickItem()); DesignerSupport::emitComponentCompleteSignalForAttachedProperty(quickItem()); @@ -481,7 +449,7 @@ void QuickItemNodeInstance::updateDirtyNodesRecursive(QQuickItem *parentItem) co updateDirtyNodesRecursive(childItem); } - disableNativeTextRendering(parentItem); + QmlPrivateGate::disableNativeTextRendering(parentItem); DesignerSupport::updateDirtyNode(parentItem); } diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp index 2784c41a4c3..4b72bac0965 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp +++ b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp @@ -41,9 +41,12 @@ #include #include +#include #include #include -#include +#include +#include +#include #include @@ -512,6 +515,7 @@ void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInsta } } + void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const PropertyName &propertyName) { DesignerCustomObjectData::keepBindingFromGettingDeleted(object, context, propertyName); @@ -522,6 +526,34 @@ bool objectWasDeleted(QObject *object) return QObjectPrivate::get(object)->wasDeleted; } +void disableNativeTextRendering(QQuickItem *item) +{ + QQuickText *text = qobject_cast(item); + if (text) + text->setRenderType(QQuickText::QtRendering); + + QQuickTextInput *textInput = qobject_cast(item); + if (textInput) + textInput->setRenderType(QQuickTextInput::QtRendering); + + QQuickTextEdit *textEdit = qobject_cast(item); + if (textEdit) + textEdit->setRenderType(QQuickTextEdit::QtRendering); +} + +void disableTextCursor(QQuickItem *item) +{ + foreach (QQuickItem *childItem, item->childItems()) + disableTextCursor(childItem); + + QQuickTextInput *textInput = qobject_cast(item); + if (textInput) + textInput->setCursorVisible(false); + + QQuickTextEdit *textEdit = qobject_cast(item); + if (textEdit) + textEdit->setCursorVisible(false); +} ComponentCompleteDisabler::ComponentCompleteDisabler() { diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.h b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.h index 6347152cb66..eb60ad7d73d 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.h +++ b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.h @@ -38,6 +38,7 @@ #include #include #include +#include namespace QmlDesigner { @@ -93,6 +94,8 @@ public: void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer); bool objectWasDeleted(QObject *object); + void disableNativeTextRendering(QQuickItem *item); + void disableTextCursor(QQuickItem *item); } // namespace QmlPrivateGate } // namespace Internal