From 63088a000da149665e4b7bc74a7e300e8832eb0a Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 18 Apr 2013 15:58:00 +0200 Subject: [PATCH 01/15] QmlDesigner.Controls: Adding missing items to library Change-Id: I96b7916b4ce64c404c175e72edc2b0a3ef015155 Reviewed-by: Marco Bubke --- .../componentsplugin/components.metainfo | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/plugins/qmldesigner/componentsplugin/components.metainfo b/src/plugins/qmldesigner/componentsplugin/components.metainfo index 206d719a246..6337597aa70 100644 --- a/src/plugins/qmldesigner/componentsplugin/components.metainfo +++ b/src/plugins/qmldesigner/componentsplugin/components.metainfo @@ -235,6 +235,23 @@ MetaInfo { } } + Type { + name: "QtQuick.Controls.ToolButton" + icon: ":/desktopplugin/images/button16.png" + + ItemLibraryEntry { + name: "Tool Button" + category: "Qt Quick - Controls" + libraryIcon: ":/desktopplugin/images/button.png" + version: "1.0" + requiredImport: "QtQuick.Controls" + + Property { name: "width"; type: "int"; value: 360; } + Property { name: "height"; type: "int"; value: 50; } + } + } + + Type { name: "QtQuick.Controls.ToolBar" icon: ":/desktopplugin/images/toolbar16.png" @@ -251,6 +268,22 @@ MetaInfo { } } + Type { + name: "QtQuick.Controls.StatusBar" + icon: ":/desktopplugin/images/toolbar16.png" + + ItemLibraryEntry { + name: "Status Bar" + category: "Qt Quick - Controls" + libraryIcon: ":/desktopplugin/images/toolbar.png" + version: "1.0" + requiredImport: "QtQuick.Controls" + + Property { name: "width"; type: "int"; value: 360; } + Property { name: "height"; type: "int"; value: 50; } + } + } + Type { name: "QtQuick.Controls.Dial" //icon: ":/desktopplugin/images/progressbar16.png" @@ -267,4 +300,52 @@ MetaInfo { } } + Type { + name: "QtQuick.Layouts.RowLayout" + icon: ":/qtquickplugin/images/item-icon16.png" + + ItemLibraryEntry { + name: "Row Layout" + category: "Qt Quick - Layouts" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "1.0" + requiredImport: "QtQuick.Layouts" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + } + } + + Type { + name: "QtQuick.Layouts.ColumnLayout" + icon: ":/qtquickplugin/images/item-icon16.png" + + ItemLibraryEntry { + name: "Column Layout" + category: "Qt Quick - Layouts" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "1.0" + requiredImport: "QtQuick.Layouts" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + } + } + + Type { + name: "QtQuick.Layouts.GridLayout" + icon: ":/qtquickplugin/images/item-icon16.png" + + ItemLibraryEntry { + name: "Grid Layout" + category: "Qt Quick - Layouts" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "1.0" + requiredImport: "QtQuick.Layouts" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + } + } + } From 37cd957a94a8e181c609492cf0dd76e21ba78926 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 19 Apr 2013 12:47:13 +0200 Subject: [PATCH 02/15] Now really fix the treeviewfind test for 2.7 Change-Id: Ia3d1fa31bb8045ecb7638c5dfe800bb57f449cfa Reviewed-by: Christian Stenger --- tests/auto/treeviewfind/treeviewfind.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/treeviewfind/treeviewfind.pro b/tests/auto/treeviewfind/treeviewfind.pro index 00aa98ae5d2..c7a3bda77c0 100644 --- a/tests/auto/treeviewfind/treeviewfind.pro +++ b/tests/auto/treeviewfind/treeviewfind.pro @@ -2,7 +2,7 @@ include(../qttest.pri) include($$IDE_SOURCE_TREE/src/plugins/find/find.pri) -LIBS *= -L$$IDE_LIBRARY_PATH/QtProject +LIBS *= -L$$IDE_PLUGIN_PATH/QtProject SOURCES += \ tst_treeviewfind.cpp From d340d26eb35ef28e94b45cc1d07dd761665d6cd7 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Wed, 17 Apr 2013 11:52:16 +0200 Subject: [PATCH 03/15] Android: ant auto detection Change-Id: I3afaab99c8e71a6dabe6d61ed55247a1cecc2d45 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Eike Ziller --- src/plugins/android/androidconfigurations.cpp | 10 ++++++++++ src/plugins/android/androidsettingswidget.cpp | 20 +++++++++++++++++++ src/plugins/android/androidsettingswidget.h | 1 + 3 files changed, 31 insertions(+) diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 9d17c5b7f61..f2e923697e9 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -733,6 +734,15 @@ void AndroidConfigurations::load() QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(SettingsGroup); m_config = AndroidConfig(*settings); + + if (m_config.antLocation.isEmpty()) { + Utils::Environment env = Utils::Environment::systemEnvironment(); + QString location = env.searchInPath(QLatin1String("ant")); + QFileInfo fi(location); + if (fi.exists() && fi.isExecutable() && !fi.isDir()) + m_config.antLocation = Utils::FileName::fromString(location); + } + settings->endGroup(); } diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 8a0163df7d8..2cbbbdc6fa1 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -278,6 +278,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished() return; } m_androidConfig.sdkLocation = location; + searchForAnt(location.toString()); saveSettings(true); m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices()); m_ui->AVDManagerFrame->setEnabled(true); @@ -289,9 +290,28 @@ void AndroidSettingsWidget::ndkLocationEditingFinished() m_androidConfig.toolchainHost.clear(); // force toolchain host detection if (!checkNDK(location)) return; + searchForAnt(location.toString()); saveSettings(true); } +void AndroidSettingsWidget::searchForAnt(const QString &location) +{ + if (!m_androidConfig.antLocation.isEmpty()) + return; + if (location.isEmpty()) + return; + QDir parentFolder = QFileInfo(location).absoluteDir(); + foreach (const QString &file, parentFolder.entryList()) { + if (file.startsWith(QLatin1String("apache-ant"))) { + QString ant = parentFolder.absolutePath() + QLatin1Char('/') + file + QLatin1String("/bin/ant.bat"); + if (QFileInfo(ant).exists()) { + m_androidConfig.antLocation = Utils::FileName::fromString(ant); + m_ui->AntLocationLineEdit->setText(ant); + } + } + } +} + void AndroidSettingsWidget::antLocationEditingFinished() { Utils::FileName location = Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text()); diff --git a/src/plugins/android/androidsettingswidget.h b/src/plugins/android/androidsettingswidget.h index 957d234173f..74e7fe6d433 100644 --- a/src/plugins/android/androidsettingswidget.h +++ b/src/plugins/android/androidsettingswidget.h @@ -75,6 +75,7 @@ public: private slots: void sdkLocationEditingFinished(); void ndkLocationEditingFinished(); + void searchForAnt(const QString &location); void antLocationEditingFinished(); void openJDKLocationEditingFinished(); void browseSDKLocation(); From cf2b3f2e612201dd1cf05d459feac4f18969f2cd Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Fri, 19 Apr 2013 15:36:38 +0200 Subject: [PATCH 04/15] Doc: pointers to configuration options Add short descriptions of configuration options that we get a lot of questions about, to make it easier for users to find the information in the Manual. Change-Id: I9e5dca80dc99fbf9d241aba9d392ac11d784c5a7 Reviewed-by: Tobias Hunger Reviewed-by: Sze Howe Koh --- doc/src/howto/creator-ui.qdoc | 2 +- doc/src/overview/creator-configuring.qdoc | 161 ++++++++++++++++++ .../creator-projects-build-run-tutorial.qdoc | 2 +- doc/src/qtcreator.qdoc | 2 + 4 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 doc/src/overview/creator-configuring.qdoc diff --git a/doc/src/howto/creator-ui.qdoc b/doc/src/howto/creator-ui.qdoc index 220244da404..f08c18542ab 100644 --- a/doc/src/howto/creator-ui.qdoc +++ b/doc/src/howto/creator-ui.qdoc @@ -26,7 +26,7 @@ \contentspage index.html \previouspage creator-overview.html \page creator-quick-tour.html - \nextpage creator-build-example-application.html + \nextpage creator-configuring.html \title User Interface diff --git a/doc/src/overview/creator-configuring.qdoc b/doc/src/overview/creator-configuring.qdoc new file mode 100644 index 00000000000..4dad8b6666e --- /dev/null +++ b/doc/src/overview/creator-configuring.qdoc @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator +** +** +** GNU Free Documentation License +** +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** +****************************************************************************/ + +// ********************************************************************** +// NOTE: the sections are not ordered by their logical order to avoid +// reshuffling the file each time the index order changes (i.e., often). +// Run the fixnavi.pl script to adjust the links to the index order. +// ********************************************************************** + +/*! + \contentspage index.html + \previouspage creator-quick-tour.html + \page creator-configuring.html + \nextpage creator-build-example-application.html + + \title Configuring Qt Creator + + If you install \QC as part of a Qt installation, you should be able to use + it out-of-the-box, with the default settings and configuration options. + + However, if you install the stand-alone \QC package, build \QC from sources, + or install several Qt versions, you may need to tell \QC where to find the + Qt versions and compilers by adding the paths to them and by creating + \l{glossary-buildandrun-kit}{kits} that use them. + + To make \QC behave more like your favorite code editor or IDE, you can + change the settings for keyboard shortcuts, color schemes, generic + highlighting, code snippets, and version control systems. In addition, you + can enable experimental plugins and disable plugins that you do not need. + + The following sections summarize the options that you have and point you to + detailed information to help you specify any required settings and to make + using \QC a better experience for you. + + \section1 Checking Build and Run Settings + + \QC is an integrated development environment (IDE) that you can use to + develop Qt applications. While Qt installers typically install \QC, + stand-alone \QC installers never install Qt or any Qt tools, such as qmake. + To use \QC for Qt development, you also need to have a Qt version and a + compiler installed. + + Qt installers, such as SDKs, often attempt to auto-detect the installed + compilers and Qt versions. If they succeed, the relevant kits will + automatically become available in \QC. If they do not, you must add the kits + yourself to tell \QC where everything is. + + To add kits, select \gui Tools > \gui Options > \gui {Build & Run} > + \gui Kits > \gui Add. + + For more information, see \l{Adding Kits}. + + Each kit consists of a set of values that define one environment, such as a + device, compiler, and Qt version. If you know you have installed a Qt + version, but it is not listed in \gui Tools > \gui Options > + \gui {Build & Run} > \gui {Qt Versions}, you must add it. + + For more information, see \l{Adding Qt Versions}. + + Also check that your compiler is listed in \gui Tools > \gui Options > + \gui {Build & Run} > \gui {Compilers}. + + For more information, see \l{Adding Compilers}. + + You can connect mobile devices to the development PC to run, debug, + and analyze applications on them from \QC. You can connect the device to the + development PC via USB. Additionally, you can connect Linux-based devices + over a WLAN. You must also configure a connection between \QC and the + development PC and specify the device in a kit. + + To add devices, select \gui Tools > \gui Options > \gui Devices > \gui Add. + + For more information, see \l{Connecting Mobile Devices}. + + \section1 Changing Keyboard Shortcuts + + You can use \QC with your favorite keyboard shortcuts. + + To view and edit all keyboard shortcuts defined in \QC, select + \gui Tools > \gui Options > \gui Environment > \gui Keyboard. + + For more information, see \l{Keyboard Shortcuts}. + + \section1 Changing Color Schemes + + You can use \QC with your favorite color scheme that defines how code + elements are highlighted and which background color is used. You can select + one of the predefined color schemes or create custom ones. + The color schemes apply to highlighting C++ files, QML files, and generic + files. + + To change the color scheme, select \gui Tools > \gui Options > + \gui {Text Editor} > \gui {Fonts & Color}. + + For more information, see \l{Defining Color Schemes}. + + Generic highlighting is based on highlight definition files that are + provided by the + \l{http://kate-editor.org/2005/03/24/writing-a-syntax-highlighting-file/} + {Kate Editor}. You can download highlight definition files for use with \QC. + + To download and use highlight definition files, select \gui Tools > + \gui Options > \gui {Text Editor} > \gui {Generic Highlighter}. + + For more information, see \l{Generic Highlighting}. + + \section1 Adding Your Own Code Snippets + + As you write code, \QC suggests properties, IDs, and code snippets to + complete the code. It provides a list of context-sensitive suggestions to + the statement currently under your cursor. You can add, modify, + and remove snippets in the snippet editor. + + To open the snippet editor, select \gui Tools > \gui Options > + \gui {Text Editor} > \gui Snippets. + + For more information, see \l{Editing Code Snippets}. + + \section1 Configuring Version Control Systems + + \QC supports several version control systems. In most cases, you do not need + to configure the version control in any special way to make it work with + \QC. Once it is set up correctly on the development PC, it should just work. + + However, some configuration options are available and you can set them in + \gui Tools > \gui Options > \gui{Version Control} > \gui Common. + + For more information about the supported functions, see + \l{Using Version Control Systems}. + + \section1 Enabling and Disabling Plugins + + New \QC plugins are often introduced as \e {experimental plugins} to let + you try them out before they are fully supported. Experimental plugins + are disabled by default and you must enable them for them to become visible + after you restart \QC. + + You can also disable plugins that you do not use, to streamline \QC. + However, this might cause problems when using another plugin later if the + dependencies between plugins are changed between \QC versions. Once you + manually disable a plugin, it stays disabled even when you upgrade to a + new \QC version, and you must manually enable it to be able to use it. + + To enable and disable plugins, select \gui Help > \gui {About Plugins}. + +*/ diff --git a/doc/src/projects/creator-projects-build-run-tutorial.qdoc b/doc/src/projects/creator-projects-build-run-tutorial.qdoc index dc32f2cd0f1..a01ef7335ae 100644 --- a/doc/src/projects/creator-projects-build-run-tutorial.qdoc +++ b/doc/src/projects/creator-projects-build-run-tutorial.qdoc @@ -24,7 +24,7 @@ /*! \contentspage index.html - \previouspage creator-quick-tour.html + \previouspage creator-configuring.html \page creator-build-example-application.html \nextpage creator-tutorials.html diff --git a/doc/src/qtcreator.qdoc b/doc/src/qtcreator.qdoc index dae5b27b97d..5ab92d38e99 100644 --- a/doc/src/qtcreator.qdoc +++ b/doc/src/qtcreator.qdoc @@ -46,6 +46,7 @@ \list \li \l{IDE Overview} \li \l{User Interface} + \li \l{Configuring Qt Creator} \li \l{Building and Running an Example} \li \l{Tutorials} \endlist @@ -147,6 +148,7 @@ \list \li \l{IDE Overview} \li \l{User Interface} + \li \l{Configuring Qt Creator} \li \l{Building and Running an Example} \li \l{Tutorials} \list From 79428126e42c9c7ce972ae04942584ba80861f6f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 19 Apr 2013 16:05:50 +0200 Subject: [PATCH 05/15] Set NoRole menu role on toggle fullscreen action Again, since the default menu role is TextHeuristicRole, and when we enter fullscreen the text is set to "Exit Full Screen", the Mac QPA menu item syncing will assign this to be the quit menu item. This would cause two problems. First, pressing Cmd-Q in fullscreen would leave fullscreen mode instead of quitting the app. Second, that would make the quit menu item to be hidden when leaving fullscreen, since the toggle fullscreen action text would change back to "Enter Full Screen", and the make a round trip to the menu item heuristic logic. Task-number: QTBUG-30654 Change-Id: I7524c54c3bd77cce891c57292825f02e163fd7fa Reviewed-by: Eike Ziller --- src/plugins/coreplugin/mainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 911975ca457..ffcc62edd48 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -753,6 +753,7 @@ void MainWindow::registerDefaultActions() if (supportsFullScreen) { // Full Screen Action m_toggleFullScreenAction = new QAction(fullScreenActionText, this); + m_toggleFullScreenAction->setMenuRole(QAction::NoRole); m_toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost()); cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); From aefb9671090fbcc86cd53a4d6bea7b4461083fce Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 18 Apr 2013 15:36:48 +0200 Subject: [PATCH 06/15] Update qbs submodule. Contains a fix for in-source builds. Change-Id: Ie33bf2fa8c615498c42ec17c66c0860320dd9bf9 Reviewed-by: Joerg Bornemann --- src/shared/qbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/qbs b/src/shared/qbs index 091dc267d35..29bb66d2fdc 160000 --- a/src/shared/qbs +++ b/src/shared/qbs @@ -1 +1 @@ -Subproject commit 091dc267d3526e7b3d8e05b32a2506aea114f778 +Subproject commit 29bb66d2fdc863fd5e9b0896fbd862c5b999d541 From 06cfc22fe2ea08dfe4f24aac5b538231f7777cab Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 18 Apr 2013 13:10:16 +0200 Subject: [PATCH 07/15] QmlDesigner: Remove old function Change-Id: I065a6febd74e13740117e0a5223fa71648a7c430 Reviewed-by: Tobias Hunger --- .../qml2puppet/instances/qt5previewnodeinstanceserver.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp index 63451eb01bc..1a14ee56bf1 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp @@ -96,14 +96,6 @@ void Qt5PreviewNodeInstanceServer::changeState(const ChangeStateCommand &/*comma } -static void updateDirtyNodeRecursive(QQuickItem *parentItem) -{ - foreach (QQuickItem *childItem, parentItem->childItems()) - updateDirtyNodeRecursive(childItem); - - DesignerSupport::updateDirtyNode(parentItem); -} - QImage Qt5PreviewNodeInstanceServer::renderPreviewImage() { rootNodeInstance().updateDirtyNodeRecursive(); From 7076272bf5f0555a4badd8a7bcbb048c07ae6b34 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 19 Apr 2013 19:42:25 +0200 Subject: [PATCH 08/15] QmlDesigner.Instances: fix delemiting of type names Import are delemited with a "." and there is a "/" between import and type. e.g.: QtQuick.Layout/QQuickLayout Change-Id: I7750b333296cceef99992610cca126530f777777 Reviewed-by: Marco Bubke --- .../qml/qmlpuppet/container/instancecontainer.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp index efb173e817a..359529fa4c2 100644 --- a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp @@ -33,16 +33,25 @@ namespace QmlDesigner { +static TypeName properDelemitingOfType(const TypeName &typeName) +{ + TypeName convertedTypeName = typeName; + int lastIndex = typeName.lastIndexOf('.'); + if (lastIndex > 0) + convertedTypeName[lastIndex] = '/'; + + return convertedTypeName; +} + InstanceContainer::InstanceContainer() : m_instanceId(-1), m_majorNumber(-1), m_minorNumber(-1) { } InstanceContainer::InstanceContainer(qint32 instanceId, const TypeName &type, int majorNumber, int minorNumber, const QString &componentPath, const QString &nodeSource, NodeSourceType nodeSourceType, NodeMetaType metaType) - : m_instanceId(instanceId), m_type(type), m_majorNumber(majorNumber), m_minorNumber(minorNumber), m_componentPath(componentPath), + : m_instanceId(instanceId), m_type(properDelemitingOfType(type)), m_majorNumber(majorNumber), m_minorNumber(minorNumber), m_componentPath(componentPath), m_nodeSource(nodeSource), m_nodeSourceType(nodeSourceType), m_metaType(metaType) { - m_type.replace('.', '/'); } qint32 InstanceContainer::instanceId() const From a50f4073c85ed15fafaf44b1d22cebb6ccbdef2e Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 19 Apr 2013 13:52:38 +0200 Subject: [PATCH 09/15] Squish: Improved QmlProfiler test Change-Id: I2ad50fac22a02de79643eb4d8a06c8736bb8539c Reviewed-by: Robert Loehning --- tests/system/suite_debugger/tst_simple_analyze/test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/system/suite_debugger/tst_simple_analyze/test.py b/tests/system/suite_debugger/tst_simple_analyze/test.py index 293fe1b05b3..56ad572dd7d 100644 --- a/tests/system/suite_debugger/tst_simple_analyze/test.py +++ b/tests/system/suite_debugger/tst_simple_analyze/test.py @@ -40,6 +40,12 @@ def main(): allowAppThroughWinFW(workingDir, projectName, False) switchViewTo(ViewConstants.ANALYZE) selectFromCombo(":Analyzer Toolbar.AnalyzerManagerToolBox_QComboBox", "QML Profiler") + recordButton = waitForObject("{container=':Qt Creator.Analyzer Toolbar_QDockWidget' " + "type='QToolButton' unnamed='1' visible='1' " + "toolTip?='*able profiling'}") + if not test.verify(recordButton.checked, "Verifying recording is enabled."): + test.log("Enabling recording for the test run") + clickButton(recordButton) clickButton(waitForObject(":Analyzer Toolbar.Start_QToolButton")) stopButton = waitForObject(":Qt Creator.Stop_QToolButton") elapsedLabel = waitForObject(":Analyzer Toolbar.Elapsed:_QLabel", 3000) From 40b62e1cfaf629366789268319ccc17d2ee0c0bb Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 18 Apr 2013 18:22:15 +0200 Subject: [PATCH 10/15] QmlDesigner: Add GraphicalNodeInstance as abstraction for item and window Change-Id: Icaba711464f672a3bfbb9d83a449d47e72ba11ff Reviewed-by: Thomas Hartmann --- .../instances/graphicalnodeinstance.cpp | 558 ++++++++++++++++++ .../instances/graphicalnodeinstance.h | 95 +++ .../qml2puppet/instances/instances.pri | 2 + .../instances/objectnodeinstance.cpp | 10 + .../qml2puppet/instances/objectnodeinstance.h | 4 +- .../qt5previewnodeinstanceserver.cpp | 2 +- .../instances/quickitemnodeinstance.cpp | 515 +--------------- .../instances/quickitemnodeinstance.h | 76 +-- .../instances/quickwindownodeinstance.cpp | 482 +-------------- .../instances/quickwindownodeinstance.h | 69 +-- .../instances/servernodeinstance.cpp | 4 +- .../qml2puppet/instances/servernodeinstance.h | 2 +- 12 files changed, 690 insertions(+), 1129 deletions(-) create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp new file mode 100644 index 00000000000..96912164590 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp @@ -0,0 +1,558 @@ +#include "graphicalnodeinstance.h" + +#include "qt5nodeinstanceserver.h" + +#include + +#include + +#include + +#include +#include +#include + +namespace QmlDesigner { +namespace Internal { + +bool GraphicalNodeInstance::s_createEffectItem = false; + +GraphicalNodeInstance::GraphicalNodeInstance(QObject *object) + : ObjectNodeInstance(object), + m_hasHeight(false), + m_hasWidth(false), + m_hasContent(true), + m_x(0.0), + m_y(0.0), + m_width(0.0), + m_height(0.0) +{ +} + +void GraphicalNodeInstance::setHasContent(bool hasContent) +{ + m_hasContent = hasContent; +} + +DesignerSupport *GraphicalNodeInstance::designerSupport() const +{ + return qt5NodeInstanceServer()->designerSupport(); +} + +Qt5NodeInstanceServer *GraphicalNodeInstance::qt5NodeInstanceServer() const +{ + return qobject_cast(nodeInstanceServer()); +} + + +bool GraphicalNodeInstance::isGraphical() const +{ + return true; +} + +bool GraphicalNodeInstance::anyItemHasContent(QQuickItem *quickItem) +{ + if (quickItem->flags().testFlag(QQuickItem::ItemHasContents)) + return true; + + foreach (QQuickItem *childItem, quickItem->childItems()) { + if (anyItemHasContent(childItem)) + return true; + } + + return false; +} + +double GraphicalNodeInstance::x() const +{ + return m_x; +} + +double GraphicalNodeInstance::y() const +{ + return m_y; +} + +QQuickItem *GraphicalNodeInstance::quickItem() const +{ + return 0; +} + +bool GraphicalNodeInstance::childItemsHaveContent(QQuickItem *quickItem) +{ + foreach (QQuickItem *childItem, quickItem->childItems()) { + if (anyItemHasContent(childItem)) + return true; + } + + return false; +} + +bool GraphicalNodeInstance::hasContent() const +{ + if (m_hasContent) + return true; + + return childItemsHaveContent(quickItem()); +} + +void GraphicalNodeInstance::createEffectItem(bool createEffectItem) +{ + s_createEffectItem = createEffectItem; +} + +void GraphicalNodeInstance::updateDirtyNodeRecursive() +{ + foreach (QQuickItem *childItem, quickItem()->childItems()) + updateDirtyNodeRecursive(childItem); + + DesignerSupport::updateDirtyNode(quickItem()); +} + +GraphicalNodeInstance::~GraphicalNodeInstance() +{ + if (quickItem()) + designerSupport()->derefFromEffectItem(quickItem()); +} + +void GraphicalNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const +{ + foreach (QQuickItem *childItem, parentItem->childItems()) { + if (!nodeInstanceServer()->hasInstanceForObject(childItem)) + updateDirtyNodeRecursive(childItem); + } + + DesignerSupport::updateDirtyNode(parentItem); +} + +void GraphicalNodeInstance::updateAllDirtyNodeRecursive(QQuickItem *parentItem) const +{ + foreach (QQuickItem *childItem, parentItem->childItems()) + updateDirtyNodeRecursive(childItem); + + DesignerSupport::updateDirtyNode(parentItem); +} + +QImage GraphicalNodeInstance::renderImage() const +{ + updateDirtyNodeRecursive(quickItem()); + + QRectF boundingRect = boundingRectWithStepChilds(quickItem()); + + QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize()); + + renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); + + return renderImage; +} + +QImage GraphicalNodeInstance::renderPreviewImage(const QSize &previewImageSize) const +{ + QRectF previewItemBoundingRect = boundingRect(); + + if (previewItemBoundingRect.isValid() && quickItem()) + return designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, previewImageSize); + + return QImage(); +} + +void GraphicalNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) +{ + if (instanceId() == 0) { + DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem()); + } else { + quickItem()->setParentItem(qobject_cast(nodeInstanceServer()->quickView()->rootObject())); + } + + if (s_createEffectItem || instanceId() == 0) + designerSupport()->refFromEffectItem(quickItem()); + + ObjectNodeInstance::initialize(objectNodeInstance); + quickItem()->update(); +} + +QPointF GraphicalNodeInstance::position() const +{ + return quickItem()->position(); +} + +QTransform GraphicalNodeInstance::customTransform() const +{ + return QTransform(); +} + +QTransform GraphicalNodeInstance::sceneTransform() const +{ + return DesignerSupport::windowTransform(quickItem()); +} + +double GraphicalNodeInstance::rotation() const +{ + return quickItem()->rotation(); +} + +double GraphicalNodeInstance::scale() const +{ + return quickItem()->scale(); +} + +QPointF GraphicalNodeInstance::transformOriginPoint() const +{ + return quickItem()->transformOriginPoint(); +} + +double GraphicalNodeInstance::zValue() const +{ + return quickItem()->z(); +} + +double GraphicalNodeInstance::opacity() const +{ + return quickItem()->opacity(); +} + +QSizeF GraphicalNodeInstance::size() const +{ + double width; + + if (DesignerSupport::isValidWidth(quickItem())) { + width = quickItem()->width(); + } else { + width = quickItem()->implicitWidth(); + } + + double height; + + if (DesignerSupport::isValidHeight(quickItem())) { + height = quickItem()->height(); + } else { + height = quickItem()->implicitHeight(); + } + + + return QSizeF(width, height); +} + +static inline bool isRectangleSane(const QRectF &rect) +{ + return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); +} + +QRectF GraphicalNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const +{ + QRectF boundingRect = parentItem->boundingRect(); + + foreach (QQuickItem *childItem, parentItem->childItems()) { + if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { + QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); + if (isRectangleSane(transformedRect)) + boundingRect = boundingRect.united(transformedRect); + } + } + + return boundingRect; +} + +void GraphicalNodeInstance::resetHorizontal() + { + setPropertyVariant("x", m_x); + if (m_width > 0.0) { + setPropertyVariant("width", m_width); + } else { + setPropertyVariant("width", quickItem()->implicitWidth()); + } +} + +void GraphicalNodeInstance::resetVertical() + { + setPropertyVariant("y", m_y); + if (m_height > 0.0) { + setPropertyVariant("height", m_height); + } else { + setPropertyVariant("height", quickItem()->implicitWidth()); + } +} + +int GraphicalNodeInstance::penWidth() const +{ + return DesignerSupport::borderWidth(quickItem()); +} + + +QList GraphicalNodeInstance::childItemsForChild(QQuickItem *childItem) const +{ + QList instanceList; + + if (childItem) { + foreach (QQuickItem *childItem, childItem->childItems()) + { + if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { + instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); + } else { + instanceList.append(childItemsForChild(childItem)); + } + } + } + return instanceList; +} + +QList GraphicalNodeInstance::childItems() const +{ + QList instanceList; + + foreach (QQuickItem *childItem, quickItem()->childItems()) + { + if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { + instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); + } else { //there might be an item in between the parent instance + //and the child instance. + //Popular example is flickable which has a viewport item between + //the flickable item and the flickable children + instanceList.append(childItemsForChild(childItem)); //In such a case we go deeper inside the item and + //search for child items with instances. + } + } + + return instanceList; +} + + +void GraphicalNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) +{ + if (name == "state") + return; // states are only set by us + + if (name == "height") { + m_height = value.toDouble(); + if (value.isValid()) + m_hasHeight = true; + else + m_hasHeight = false; + } + + if (name == "width") { + m_width = value.toDouble(); + if (value.isValid()) + m_hasWidth = true; + else + m_hasWidth = false; + } + + if (name == "x") + m_x = value.toDouble(); + + if (name == "y") + m_y = value.toDouble(); + + ObjectNodeInstance::setPropertyVariant(name, value); + + quickItem()->update(); + + refresh(); + + if (isInPositioner()) + parentInstance()->refreshPositioner(); +} + +void GraphicalNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) +{ + if (name == "state") + return; // states are only set by us + + ObjectNodeInstance::setPropertyBinding(name, expression); + + quickItem()->update(); + + refresh(); + + if (isInPositioner()) + parentInstance()->refreshPositioner(); +} + +QVariant GraphicalNodeInstance::property(const PropertyName &name) const +{ + if (name == "visible") + return quickItem()->isVisible(); + + return ObjectNodeInstance::property(name); +} + +void GraphicalNodeInstance::resetProperty(const PropertyName &name) +{ + if (name == "height") { + m_hasHeight = false; + m_height = 0.0; + } + + if (name == "width") { + m_hasWidth = false; + m_width = 0.0; + } + + if (name == "x") + m_x = 0.0; + + if (name == "y") + m_y = 0.0; + + DesignerSupport::resetAnchor(quickItem(), name); + + if (name == "anchors.fill") { + resetHorizontal(); + resetVertical(); + } else if (name == "anchors.centerIn") { + resetHorizontal(); + resetVertical(); + } else if (name == "anchors.top") { + resetVertical(); + } else if (name == "anchors.left") { + resetHorizontal(); + } else if (name == "anchors.right") { + resetHorizontal(); + } else if (name == "anchors.bottom") { + resetVertical(); + } else if (name == "anchors.horizontalCenter") { + resetHorizontal(); + } else if (name == "anchors.verticalCenter") { + resetVertical(); + } else if (name == "anchors.baseline") { + resetVertical(); + } + + ObjectNodeInstance::resetProperty(name); + + quickItem()->update(); + + if (isInPositioner()) + parentInstance()->refreshPositioner(); +} + + +static bool isValidAnchorName(const PropertyName &name) +{ + static PropertyNameList anchorNameList(PropertyNameList() << "anchors.top" + << "anchors.left" + << "anchors.right" + << "anchors.bottom" + << "anchors.verticalCenter" + << "anchors.horizontalCenter" + << "anchors.fill" + << "anchors.centerIn" + << "anchors.baseline"); + + return anchorNameList.contains(name); +} + +bool GraphicalNodeInstance::hasAnchor(const PropertyName &name) const +{ + return DesignerSupport::hasAnchor(quickItem(), name); +} + +QPair GraphicalNodeInstance::anchor(const PropertyName &name) const +{ + if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name)) + return ObjectNodeInstance::anchor(name); + + QPair nameObjectPair = DesignerSupport::anchorLineTarget(quickItem(), name, context()); + + QObject *targetObject = nameObjectPair.second; + PropertyName targetName = nameObjectPair.first.toUtf8(); + + if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) { + return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject)); + } else { + return ObjectNodeInstance::anchor(name); + } +} + +static void doComponentCompleteRecursive(QQuickItem *item) +{ + if (item) { + if (DesignerSupport::isComponentComplete(item)) + return; + + foreach (QQuickItem *childItem, item->childItems()) + doComponentCompleteRecursive(childItem); + + static_cast(item)->componentComplete(); + } +} + + +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 GraphicalNodeInstance::doComponentComplete() +{ + doComponentCompleteRecursive(quickItem()); + + disableTextCursor(quickItem()); + + quickItem()->update(); +} + +bool GraphicalNodeInstance::isAnchoredByChildren() const +{ + if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item + return true; + + return false; +} + +QRectF GraphicalNodeInstance::boundingRect() const +{ + if (quickItem()) { + if (quickItem()->clip()) { + return quickItem()->boundingRect(); + } else { + return boundingRectWithStepChilds(quickItem()); + } + } + + return QRectF(); +} + +static void repositioning(QQuickItem *item) +{ + if (!item) + return; + +// QQmlBasePositioner *positioner = qobject_cast(item); +// if (positioner) +// positioner->rePositioning(); + + if (item->parentItem()) + repositioning(item->parentItem()); +} + +void GraphicalNodeInstance::refresh() +{ + repositioning(quickItem()); +} + +QList GraphicalNodeInstance::stateInstances() const +{ + QList instanceList; + QList stateList = DesignerSupport::statesForItem(quickItem()); + foreach (QObject *state, stateList) + { + if (state && nodeInstanceServer()->hasInstanceForObject(state)) + instanceList.append(nodeInstanceServer()->instanceForObject(state)); + } + + return instanceList; +} + +} +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h new file mode 100644 index 00000000000..28867a60cc0 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h @@ -0,0 +1,95 @@ +#ifndef QMLDESIGNER_GRAPHICALNODEINSTANCE_H +#define QMLDESIGNER_GRAPHICALNODEINSTANCE_H + +#include "objectnodeinstance.h" + +#include + +namespace QmlDesigner { +namespace Internal { + +class GraphicalNodeInstance : public ObjectNodeInstance +{ +public: + typedef QSharedPointer Pointer; + typedef QWeakPointer WeakPointer; + + ~GraphicalNodeInstance(); + + void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance); + + bool isGraphical() const; + bool hasContent() const; + + QRectF boundingRect() const; + QTransform customTransform() const; + QTransform sceneTransform() const; + double opacity() const; + double rotation() const; + double scale() const; + QPointF transformOriginPoint() const; + double zValue() const; + QPointF position() const; + QSizeF size() const; + + QImage renderImage() const; + QImage renderPreviewImage(const QSize &previewImageSize) const; + + QList childItems() const; + + void updateDirtyNodeRecursive(); + static void createEffectItem(bool createEffectItem); + + int penWidth() const; + + void setPropertyVariant(const PropertyName &name, const QVariant &value); + void setPropertyBinding(const PropertyName &name, const QString &expression); + + QVariant property(const PropertyName &name) const; + void resetProperty(const PropertyName &name) ; + + QList stateInstances() const; + + bool isAnchoredByChildren() const; + bool hasAnchor(const PropertyName &name) const; + QPair anchor(const PropertyName &name) const; + + void doComponentComplete(); + +protected: + explicit GraphicalNodeInstance(QObject *object); + void setHasContent(bool hasContent); + DesignerSupport *designerSupport() const; + Qt5NodeInstanceServer *qt5NodeInstanceServer() const; + void updateDirtyNodeRecursive(QQuickItem *parentItem) const; + void updateAllDirtyNodeRecursive(QQuickItem *parentItem) const; + QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; + void resetHorizontal(); + void resetVertical(); + QList childItemsForChild(QQuickItem *childItem) const; + void refresh(); + static bool anyItemHasContent(QQuickItem *quickItem); + static bool childItemsHaveContent(QQuickItem *quickItem); + + double x() const; + double y() const; + + virtual QQuickItem *quickItem() const; + +private: // functions + +private: // variables + bool m_hasHeight; + bool m_hasWidth; + bool m_hasContent; + double m_x; + double m_y; + double m_width; + double m_height; + static bool s_createEffectItem; +}; + +} // namespace Internal +} // namespace QmlDesigner + +#endif // QMLDESIGNER_GRAPHICALNODEINSTANCE_H diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index 3da4843c07e..60db67d7fdd 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -1,6 +1,7 @@ INCLUDEPATH += $$PWD/ HEADERS += $$PWD/qt5nodeinstanceserver.h +HEADERS += $$PWD//graphicalnodeinstance.h HEADERS += $$PWD/qt5informationnodeinstanceserver.h HEADERS += $$PWD/qt5rendernodeinstanceserver.h HEADERS += $$PWD/qt5previewnodeinstanceserver.h @@ -24,6 +25,7 @@ HEADERS += $$PWD/positionernodeinstance.h HEADERS += $$PWD/quickwindownodeinstance.h SOURCES += $$PWD/qt5nodeinstanceserver.cpp +SOURCES += $$PWD/graphicalnodeinstance.cpp SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp SOURCES += $$PWD/qt5rendernodeinstanceserver.cpp SOURCES += $$PWD/qt5previewnodeinstanceserver.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index 71b8544e938..f8553925dc9 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -194,6 +194,16 @@ bool ObjectNodeInstance::isQuickItem() const return false; } +bool ObjectNodeInstance::isQuickWindow() const +{ + return false; +} + +bool ObjectNodeInstance::isGraphical() const +{ + return false; +} + bool ObjectNodeInstance::equalGraphicsItem(QGraphicsItem * /*item*/) const { return false; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h index 192350763de..0f8e3822eb6 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h @@ -64,7 +64,6 @@ class ObjectNodeInstance public: typedef QSharedPointer Pointer; typedef QWeakPointer WeakPointer; - explicit ObjectNodeInstance(QObject *object); virtual ~ObjectNodeInstance(); void destroy(); @@ -98,6 +97,8 @@ public: virtual bool isTransition() const; virtual bool isPositioner() const; virtual bool isQuickItem() const; + virtual bool isQuickWindow() const; + virtual bool isGraphical() const; virtual bool equalGraphicsItem(QGraphicsItem *item) const; @@ -182,6 +183,7 @@ public: virtual void updateDirtyNodeRecursive(); protected: + explicit ObjectNodeInstance(QObject *object); void doResetProperty(const PropertyName &propertyName); void removeFromOldProperty(QObject *object, QObject *oldParent, const PropertyName &oldParentProperty); void addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp index 1a14ee56bf1..df8770c68f1 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp @@ -65,7 +65,7 @@ void Qt5PreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands() { static bool inFunction = false; - if (!rootNodeInstance().holdsQuickItem()) + if (!rootNodeInstance().holdsGraphical()) return; if (!inFunction && nodeInstanceClient()->bytesToWrite() < 10000) { diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index 39281d1ac26..57baa419945 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -45,105 +45,15 @@ namespace QmlDesigner { namespace Internal { -bool QuickItemNodeInstance::s_createEffectItem = false; - QuickItemNodeInstance::QuickItemNodeInstance(QQuickItem *item) - : ObjectNodeInstance(item), - m_hasHeight(false), - m_hasWidth(false), + : GraphicalNodeInstance(item), m_isResizable(true), - m_hasContent(true), - m_isMovable(true), - m_x(0.0), - m_y(0.0), - m_width(0.0), - m_height(0.0) + m_isMovable(true) { } QuickItemNodeInstance::~QuickItemNodeInstance() { - if (quickItem()) - designerSupport()->derefFromEffectItem(quickItem()); -} - -bool QuickItemNodeInstance::hasContent() const -{ - if (m_hasContent) - return true; - - return childItemsHaveContent(quickItem()); -} - -QList QuickItemNodeInstance::childItems() const -{ - QList instanceList; - - foreach (QQuickItem *childItem, quickItem()->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { //there might be an item in between the parent instance - //and the child instance. - //Popular example is flickable which has a viewport item between - //the flickable item and the flickable children - instanceList.append(childItemsForChild(childItem)); //In such a case we go deeper inside the item and - //search for child items with instances. - } - } - - return instanceList; -} - -QList QuickItemNodeInstance::childItemsForChild(QQuickItem *childItem) const -{ - QList instanceList; - - if (childItem) { - foreach (QQuickItem *childItem, childItem->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { - instanceList.append(childItemsForChild(childItem)); - } - } - } - return instanceList; -} - -void QuickItemNodeInstance::setHasContent(bool hasContent) -{ - m_hasContent = hasContent; -} - - -bool QuickItemNodeInstance::anyItemHasContent(QQuickItem *quickItem) -{ - if (quickItem->flags().testFlag(QQuickItem::ItemHasContents)) - return true; - - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -bool QuickItemNodeInstance::childItemsHaveContent(QQuickItem *quickItem) -{ - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -QPointF QuickItemNodeInstance::position() const -{ - return quickItem()->position(); } static QTransform transformForItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer) @@ -160,40 +70,6 @@ QTransform QuickItemNodeInstance::transform() const return transformForItem(quickItem(), nodeInstanceServer()); } -QTransform QuickItemNodeInstance::customTransform() const -{ - return QTransform(); -} - -QTransform QuickItemNodeInstance::sceneTransform() const -{ - return DesignerSupport::windowTransform(quickItem()); -} - -double QuickItemNodeInstance::rotation() const -{ - return quickItem()->rotation(); -} - -double QuickItemNodeInstance::scale() const -{ - return quickItem()->scale(); -} - -QPointF QuickItemNodeInstance::transformOriginPoint() const -{ - return quickItem()->transformOriginPoint(); -} - -double QuickItemNodeInstance::zValue() const -{ - return quickItem()->z(); -} - -double QuickItemNodeInstance::opacity() const -{ - return quickItem()->opacity(); -} QObject *QuickItemNodeInstance::parent() const { @@ -202,53 +78,6 @@ QObject *QuickItemNodeInstance::parent() const return quickItem()->parentItem(); } - -bool QuickItemNodeInstance::equalQuickItem(QQuickItem *item) const -{ - return item == quickItem(); -} - -void QuickItemNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const -{ - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) - updateDirtyNodeRecursive(childItem); - } - - DesignerSupport::updateDirtyNode(parentItem); -} - -void QuickItemNodeInstance::updateAllDirtyNodeRecursive(QQuickItem *parentItem) const -{ - foreach (QQuickItem *childItem, parentItem->childItems()) - updateDirtyNodeRecursive(childItem); - - DesignerSupport::updateDirtyNode(parentItem); -} - -QImage QuickItemNodeInstance::renderImage() const -{ - updateDirtyNodeRecursive(quickItem()); - - QRectF boundingRect = boundingRectWithStepChilds(quickItem()); - - QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize()); - - renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); - - return renderImage; -} - -QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize) const -{ - QRectF previewItemBoundingRect = boundingRect(); - - if (previewItemBoundingRect.isValid() && quickItem()) - return designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, previewImageSize); - - return QImage(); -} - bool QuickItemNodeInstance::isMovable() const { if (isRootNodeInstance()) @@ -280,212 +109,12 @@ QuickItemNodeInstance::Pointer QuickItemNodeInstance::create(QObject *object) return instance; } -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::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) -{ - if (instanceId() == 0) { - DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem()); - } else { - quickItem()->setParentItem(qobject_cast(nodeInstanceServer()->quickView()->rootObject())); - } - - if (s_createEffectItem || instanceId() == 0) - designerSupport()->refFromEffectItem(quickItem()); - - ObjectNodeInstance::initialize(objectNodeInstance); - quickItem()->update(); -} bool QuickItemNodeInstance::isQuickItem() const { return true; } -QSizeF QuickItemNodeInstance::size() const -{ - double width; - - if (DesignerSupport::isValidWidth(quickItem())) { - width = quickItem()->width(); - } else { - width = quickItem()->implicitWidth(); - } - - double height; - - if (DesignerSupport::isValidHeight(quickItem())) { - height = quickItem()->height(); - } else { - height = quickItem()->implicitHeight(); - } - - - return QSizeF(width, height); -} - -static inline bool isRectangleSane(const QRectF &rect) -{ - return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); -} - -QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const -{ - QRectF boundingRect = parentItem->boundingRect(); - - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { - QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); - if (isRectangleSane(transformedRect)) - boundingRect = boundingRect.united(transformedRect); - } - } - - return boundingRect; -} - -QRectF QuickItemNodeInstance::boundingRect() const -{ - if (quickItem()) { - if (quickItem()->clip()) { - return quickItem()->boundingRect(); - } else { - return boundingRectWithStepChilds(quickItem()); - } - } - - return QRectF(); -} - -void QuickItemNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (name == "state") - return; // states are only set by us - - if (name == "height") { - m_height = value.toDouble(); - if (value.isValid()) - m_hasHeight = true; - else - m_hasHeight = false; - } - - if (name == "width") { - m_width = value.toDouble(); - if (value.isValid()) - m_hasWidth = true; - else - m_hasWidth = false; - } - - if (name == "x") - m_x = value.toDouble(); - - if (name == "y") - m_y = value.toDouble(); - - ObjectNodeInstance::setPropertyVariant(name, value); - - quickItem()->update(); - - refresh(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); -} - -void QuickItemNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - if (name == "state") - return; // states are only set by us - - ObjectNodeInstance::setPropertyBinding(name, expression); - - quickItem()->update(); - - refresh(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); -} - -QVariant QuickItemNodeInstance::property(const PropertyName &name) const -{ - return ObjectNodeInstance::property(name); -} - -void QuickItemNodeInstance::resetHorizontal() - { - setPropertyVariant("x", m_x); - if (m_width > 0.0) { - setPropertyVariant("width", m_width); - } else { - setPropertyVariant("width", quickItem()->implicitWidth()); - } -} - -void QuickItemNodeInstance::resetVertical() - { - setPropertyVariant("y", m_y); - if (m_height > 0.0) { - setPropertyVariant("height", m_height); - } else { - setPropertyVariant("height", quickItem()->implicitWidth()); - } -} - -static void repositioning(QQuickItem *item) -{ - if (!item) - return; - -// QQmlBasePositioner *positioner = qobject_cast(item); -// if (positioner) -// positioner->rePositioning(); - - if (item->parentItem()) - repositioning(item->parentItem()); -} - -void QuickItemNodeInstance::refresh() -{ - repositioning(quickItem()); -} - -static void doComponentCompleteRecursive(QQuickItem *item) -{ - if (item) { - if (DesignerSupport::isComponentComplete(item)) - return; - - foreach (QQuickItem *childItem, item->childItems()) - doComponentCompleteRecursive(childItem); - - static_cast(item)->componentComplete(); - } -} - -void QuickItemNodeInstance::doComponentComplete() -{ - doComponentCompleteRecursive(quickItem()); - - disableTextCursor(quickItem()); - - quickItem()->update(); -} - bool QuickItemNodeInstance::isResizable() const { if (isRootNodeInstance()) @@ -494,64 +123,9 @@ bool QuickItemNodeInstance::isResizable() const return m_isResizable && quickItem() && quickItem()->parentItem(); } -void QuickItemNodeInstance::setResizable(bool resizeable) +void QuickItemNodeInstance::setResizable(bool resizable) { - m_isResizable = resizeable; -} - -int QuickItemNodeInstance::penWidth() const -{ - return DesignerSupport::borderWidth(quickItem()); -} - -void QuickItemNodeInstance::resetProperty(const PropertyName &name) -{ - if (name == "height") { - m_hasHeight = false; - m_height = 0.0; - } - - if (name == "width") { - m_hasWidth = false; - m_width = 0.0; - } - - if (name == "x") - m_x = 0.0; - - if (name == "y") - m_y = 0.0; - - DesignerSupport::resetAnchor(quickItem(), name); - - if (name == "anchors.fill") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.centerIn") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.top") { - resetVertical(); - } else if (name == "anchors.left") { - resetHorizontal(); - } else if (name == "anchors.right") { - resetHorizontal(); - } else if (name == "anchors.bottom") { - resetVertical(); - } else if (name == "anchors.horizontalCenter") { - resetHorizontal(); - } else if (name == "anchors.verticalCenter") { - resetVertical(); - } else if (name == "anchors.baseline") { - resetVertical(); - } - - ObjectNodeInstance::resetProperty(name); - - quickItem()->update(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); + m_isResizable = resizable; } void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) @@ -570,10 +144,10 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen if (oldParentInstance && oldParentInstance->isPositioner() && !(newParentInstance && newParentInstance->isPositioner())) { if (!hasBindingForProperty("x")) - setPropertyVariant("x", m_x); + setPropertyVariant("x", x()); if (!hasBindingForProperty("y")) - setPropertyVariant("y", m_y); + setPropertyVariant("y", y()); } refresh(); @@ -583,56 +157,6 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen parentInstance()->refreshPositioner(); } -static bool isValidAnchorName(const PropertyName &name) -{ - static PropertyNameList anchorNameList(PropertyNameList() << "anchors.top" - << "anchors.left" - << "anchors.right" - << "anchors.bottom" - << "anchors.verticalCenter" - << "anchors.horizontalCenter" - << "anchors.fill" - << "anchors.centerIn" - << "anchors.baseline"); - - return anchorNameList.contains(name); -} - -bool QuickItemNodeInstance::hasAnchor(const PropertyName &name) const -{ - return DesignerSupport::hasAnchor(quickItem(), name); -} - -QPair QuickItemNodeInstance::anchor(const PropertyName &name) const -{ - if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name)) - return ObjectNodeInstance::anchor(name); - - QPair nameObjectPair = DesignerSupport::anchorLineTarget(quickItem(), name, context()); - - QObject *targetObject = nameObjectPair.second; - PropertyName targetName = nameObjectPair.first.toUtf8(); - - if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) { - return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject)); - } else { - return ObjectNodeInstance::anchor(name); - } -} - -QList QuickItemNodeInstance::stateInstances() const -{ - QList instanceList; - QList stateList = DesignerSupport::statesForItem(quickItem()); - foreach (QObject *state, stateList) - { - if (state && nodeInstanceServer()->hasInstanceForObject(state)) - instanceList.append(nodeInstanceServer()->instanceForObject(state)); - } - - return instanceList; -} - bool QuickItemNodeInstance::isAnchoredBySibling() const { if (quickItem()->parentItem()) { @@ -647,43 +171,16 @@ bool QuickItemNodeInstance::isAnchoredBySibling() const return false; } -bool QuickItemNodeInstance::isAnchoredByChildren() const -{ - if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item - return true; - return false; -} QQuickItem *QuickItemNodeInstance::quickItem() const { if (object() == 0) return 0; - Q_ASSERT(qobject_cast(object())); return static_cast(object()); } -DesignerSupport *QuickItemNodeInstance::designerSupport() const -{ - return qt5NodeInstanceServer()->designerSupport(); -} - -Qt5NodeInstanceServer *QuickItemNodeInstance::qt5NodeInstanceServer() const -{ - return qobject_cast(nodeInstanceServer()); -} - -void QuickItemNodeInstance::createEffectItem(bool createEffectItem) -{ - s_createEffectItem = createEffectItem; -} - -void QuickItemNodeInstance::updateDirtyNodeRecursive() -{ - updateAllDirtyNodeRecursive(quickItem()); -} - } // namespace Internal } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h index 4015308f8f6..f978e769a24 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h @@ -32,7 +32,7 @@ #include -#include "objectnodeinstance.h" +#include "graphicalnodeinstance.h" #include #include @@ -40,7 +40,7 @@ namespace QmlDesigner { namespace Internal { -class QuickItemNodeInstance : public ObjectNodeInstance +class QuickItemNodeInstance : public GraphicalNodeInstance { public: typedef QSharedPointer Pointer; @@ -49,91 +49,27 @@ public: ~QuickItemNodeInstance(); static Pointer create(QObject *objectToBeWrapped); - void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) Q_DECL_OVERRIDE; - bool isQuickItem() const Q_DECL_OVERRIDE; - - QRectF boundingRect() const Q_DECL_OVERRIDE; - QPointF position() const Q_DECL_OVERRIDE; - QSizeF size() const Q_DECL_OVERRIDE; QTransform transform() const Q_DECL_OVERRIDE; - QTransform customTransform() const Q_DECL_OVERRIDE; - QTransform sceneTransform() const Q_DECL_OVERRIDE; - double opacity() const Q_DECL_OVERRIDE; QObject *parent() const Q_DECL_OVERRIDE; - double rotation() const Q_DECL_OVERRIDE; - double scale() const Q_DECL_OVERRIDE; - QPointF transformOriginPoint() const Q_DECL_OVERRIDE; - double zValue() const Q_DECL_OVERRIDE; - - bool equalQuickItem(QQuickItem *item) const; - - bool hasContent() const Q_DECL_OVERRIDE; - - QList childItems() const Q_DECL_OVERRIDE; - QList childItemsForChild(QQuickItem *childItem) const; - - bool isMovable() const Q_DECL_OVERRIDE; - void setMovable(bool movable); - - void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; - void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; - - QVariant property(const PropertyName &name) const Q_DECL_OVERRIDE; - void resetProperty(const PropertyName &name) Q_DECL_OVERRIDE; - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) Q_DECL_OVERRIDE; - int penWidth() const Q_DECL_OVERRIDE; - - bool hasAnchor(const PropertyName &name) const Q_DECL_OVERRIDE; - QPair anchor(const PropertyName &name) const Q_DECL_OVERRIDE; bool isAnchoredBySibling() const Q_DECL_OVERRIDE; - bool isAnchoredByChildren() const Q_DECL_OVERRIDE; - void doComponentComplete() Q_DECL_OVERRIDE; - bool isResizable() const Q_DECL_OVERRIDE; - void setResizable(bool resizeable); - - void setHasContent(bool hasContent); - - QList stateInstances() const Q_DECL_OVERRIDE; - - QImage renderImage() const Q_DECL_OVERRIDE; - QImage renderPreviewImage(const QSize &previewImageSize) const Q_DECL_OVERRIDE; - - DesignerSupport *designerSupport() const; - Qt5NodeInstanceServer *qt5NodeInstanceServer() const; - - static void createEffectItem(bool createEffectItem); - - void updateDirtyNodeRecursive() Q_DECL_OVERRIDE; + bool isMovable() const Q_DECL_OVERRIDE; + bool isQuickItem() const Q_DECL_OVERRIDE; protected: QuickItemNodeInstance(QQuickItem*); QQuickItem *quickItem() const; - void resetHorizontal(); - void resetVertical(); - void refresh(); - QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; - void updateDirtyNodeRecursive(QQuickItem *parentItem) const; - void updateAllDirtyNodeRecursive(QQuickItem *parentItem) const; - static bool anyItemHasContent(QQuickItem *graphicsItem); - static bool childItemsHaveContent(QQuickItem *graphicsItem); + void setMovable(bool movable); + void setResizable(bool resizable); private: //variables - bool m_hasHeight; - bool m_hasWidth; bool m_isResizable; - bool m_hasContent; bool m_isMovable; - double m_x; - double m_y; - double m_width; - double m_height; - static bool s_createEffectItem; }; } // namespace Internal diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp index f4f86e0b5b6..d5a87c7c486 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp @@ -29,160 +29,22 @@ #include "quickwindownodeinstance.h" -#include "qt5nodeinstanceserver.h" -#include -#include #include #include -#include - -#include - -#include - namespace QmlDesigner { namespace Internal { -bool QuickWindowNodeInstance::s_createEffectItem = false; - QuickWindowNodeInstance::QuickWindowNodeInstance(QQuickWindow *item) - : ObjectNodeInstance(item), - m_hasHeight(false), - m_hasWidth(false), - m_hasContent(true), - m_x(0.0), - m_y(0.0), - m_width(0.0), - m_height(0.0) + : GraphicalNodeInstance(item) { } QuickWindowNodeInstance::~QuickWindowNodeInstance() { - if (quickItem()) - designerSupport()->derefFromEffectItem(quickItem()); -} -bool QuickWindowNodeInstance::hasContent() const -{ - if (m_hasContent) - return true; - - return childItemsHaveContent(quickItem()); -} - -QList QuickWindowNodeInstance::childItems() const -{ - QList instanceList; - - foreach (QQuickItem *childItem, quickItem()->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { //there might be an item in between the parent instance - //and the child instance. - //Popular example is flickable which has a viewport item between - //the flickable item and the flickable children - instanceList.append(childItemsForChild(childItem)); //In such a case we go deeper inside the item and - //search for child items with instances. - } - } - - return instanceList; -} - -QList QuickWindowNodeInstance::childItemsForChild(QQuickItem *childItem) const -{ - QList instanceList; - - if (childItem) { - foreach (QQuickItem *childItem, childItem->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { - instanceList.append(childItemsForChild(childItem)); - } - } - } - return instanceList; -} - -void QuickWindowNodeInstance::setHasContent(bool hasContent) -{ - m_hasContent = hasContent; -} - - -bool QuickWindowNodeInstance::anyItemHasContent(QQuickItem *quickItem) -{ - if (quickItem->flags().testFlag(QQuickItem::ItemHasContents)) - return true; - - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -bool QuickWindowNodeInstance::childItemsHaveContent(QQuickItem *quickItem) -{ - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -QPointF QuickWindowNodeInstance::position() const -{ - return quickItem()->position(); -} - -QTransform QuickWindowNodeInstance::transform() const -{ - return DesignerSupport::parentTransform(quickItem()); -} - -QTransform QuickWindowNodeInstance::customTransform() const -{ - return QTransform(); -} - -QTransform QuickWindowNodeInstance::sceneTransform() const -{ - return DesignerSupport::windowTransform(quickItem()); -} - -double QuickWindowNodeInstance::rotation() const -{ - return quickItem()->rotation(); -} - -double QuickWindowNodeInstance::scale() const -{ - return quickItem()->scale(); -} - -QPointF QuickWindowNodeInstance::transformOriginPoint() const -{ - return quickItem()->transformOriginPoint(); -} - -double QuickWindowNodeInstance::zValue() const -{ - return quickItem()->z(); -} - -double QuickWindowNodeInstance::opacity() const -{ - return quickItem()->opacity(); } QObject *QuickWindowNodeInstance::parent() const @@ -190,49 +52,6 @@ QObject *QuickWindowNodeInstance::parent() const return 0; } -bool QuickWindowNodeInstance::equalQuickItem(QQuickItem *item) const -{ - return item == quickItem(); -} - -void QuickWindowNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const -{ - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) - updateDirtyNodeRecursive(childItem); - } - - DesignerSupport::updateDirtyNode(parentItem); -} - -QImage QuickWindowNodeInstance::renderImage() const -{ - updateDirtyNodeRecursive(quickItem()); - - QRectF boundingRect = boundingRectWithStepChilds(quickItem()); - - QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize()); - - renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); - - return renderImage; -} - -QImage QuickWindowNodeInstance::renderPreviewImage(const QSize &previewImageSize) const -{ - QRectF previewItemBoundingRect = boundingRect(); - - if (previewItemBoundingRect.isValid() && quickItem()) - return designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, previewImageSize); - - return QImage(); -} - -bool QuickWindowNodeInstance::isMovable() const -{ - return false; -} - QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object) { QQuickWindow *quickWindow = qobject_cast(object); @@ -261,229 +80,13 @@ QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object return instance; } -void QuickWindowNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) -{ - if (instanceId() == 0) { - DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem()); - } else { - quickItem()->setParentItem(qobject_cast(nodeInstanceServer()->quickView()->rootObject())); - } - if (s_createEffectItem || instanceId() == 0) - designerSupport()->refFromEffectItem(quickItem()); - ObjectNodeInstance::initialize(objectNodeInstance); - quickItem()->update(); -} - -bool QuickWindowNodeInstance::isQuickItem() const +bool QuickWindowNodeInstance::isQuickWindow() const { return true; } -QSizeF QuickWindowNodeInstance::size() const -{ - double width; - - if (DesignerSupport::isValidWidth(quickItem())) { - width = quickItem()->width(); - } else { - width = quickItem()->implicitWidth(); - } - - double height; - - if (DesignerSupport::isValidHeight(quickItem())) { - height = quickItem()->height(); - } else { - height = quickItem()->implicitHeight(); - } - - - return QSizeF(width, height); -} - -static inline bool isRectangleSane(const QRectF &rect) -{ - return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); -} - -QRectF QuickWindowNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const -{ - QRectF boundingRect = parentItem->boundingRect(); - - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { - QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); - if (isRectangleSane(transformedRect)) - boundingRect = boundingRect.united(transformedRect); - } - } - - return boundingRect; -} - -QRectF QuickWindowNodeInstance::boundingRect() const -{ - if (quickItem()) { - if (quickItem()->clip()) { - return quickItem()->boundingRect(); - } else { - return boundingRectWithStepChilds(quickItem()); - } - } - - return QRectF(); -} - -void QuickWindowNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (name == "state") - return; // states are only set by us - - if (name == "height") { - m_height = value.toDouble(); - if (value.isValid()) - m_hasHeight = true; - else - m_hasHeight = false; - } - - if (name == "width") { - m_width = value.toDouble(); - if (value.isValid()) - m_hasWidth = true; - else - m_hasWidth = false; - } - - if (name == "x") - m_x = value.toDouble(); - - if (name == "y") - m_y = value.toDouble(); - - ObjectNodeInstance::setPropertyVariant(name, value); - - quickItem()->update(); -} - -void QuickWindowNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - if (name == "state") - return; // states are only set by us - - ObjectNodeInstance::setPropertyBinding(name, expression); - - quickItem()->update(); -} - -QVariant QuickWindowNodeInstance::property(const PropertyName &name) const -{ - if (name == "visible") - return quickItem()->isVisible(); - return ObjectNodeInstance::property(name); -} - -void QuickWindowNodeInstance::resetHorizontal() - { - setPropertyVariant("x", m_x); - if (m_width > 0.0) { - setPropertyVariant("width", m_width); - } else { - setPropertyVariant("width", quickItem()->implicitWidth()); - } -} - -void QuickWindowNodeInstance::resetVertical() - { - setPropertyVariant("y", m_y); - if (m_height > 0.0) { - setPropertyVariant("height", m_height); - } else { - setPropertyVariant("height", quickItem()->implicitWidth()); - } -} - -static void doComponentCompleteRecursive(QQuickItem *item) -{ - if (item) { - if (DesignerSupport::isComponentComplete(item)) - return; - - foreach (QQuickItem *childItem, item->childItems()) - doComponentCompleteRecursive(childItem); - - static_cast(item)->componentComplete(); - } -} - -void QuickWindowNodeInstance::doComponentComplete() -{ - doComponentCompleteRecursive(quickItem()); - - quickItem()->update(); -} - -bool QuickWindowNodeInstance::isResizable() const -{ - return false; -} - -int QuickWindowNodeInstance::penWidth() const -{ - return DesignerSupport::borderWidth(quickItem()); -} - -void QuickWindowNodeInstance::resetProperty(const PropertyName &name) -{ - if (name == "height") { - m_hasHeight = false; - m_height = 0.0; - } - - if (name == "width") { - m_hasWidth = false; - m_width = 0.0; - } - - if (name == "x") - m_x = 0.0; - - if (name == "y") - m_y = 0.0; - - DesignerSupport::resetAnchor(quickItem(), name); - - if (name == "anchors.fill") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.centerIn") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.top") { - resetVertical(); - } else if (name == "anchors.left") { - resetHorizontal(); - } else if (name == "anchors.right") { - resetHorizontal(); - } else if (name == "anchors.bottom") { - resetVertical(); - } else if (name == "anchors.horizontalCenter") { - resetHorizontal(); - } else if (name == "anchors.verticalCenter") { - resetVertical(); - } else if (name == "anchors.baseline") { - resetVertical(); - } - - ObjectNodeInstance::resetProperty(name); - - quickItem()->update(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); -} void QuickWindowNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) { @@ -492,101 +95,20 @@ void QuickWindowNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldPar DesignerSupport::updateDirtyNode(quickItem()); } -static bool isValidAnchorName(const PropertyName &name) -{ - static PropertyNameList anchorNameList(PropertyNameList() << "anchors.top" - << "anchors.left" - << "anchors.right" - << "anchors.bottom" - << "anchors.verticalCenter" - << "anchors.horizontalCenter" - << "anchors.fill" - << "anchors.centerIn" - << "anchors.baseline"); - - return anchorNameList.contains(name); -} - -bool QuickWindowNodeInstance::hasAnchor(const PropertyName &name) const -{ - return DesignerSupport::hasAnchor(quickItem(), name); -} - -QPair QuickWindowNodeInstance::anchor(const PropertyName &name) const -{ - if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name)) - return ObjectNodeInstance::anchor(name); - - QPair nameObjectPair = DesignerSupport::anchorLineTarget(quickItem(), name, context()); - - QObject *targetObject = nameObjectPair.second; - PropertyName targetName = nameObjectPair.first.toUtf8(); - - if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) { - return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject)); - } else { - return ObjectNodeInstance::anchor(name); - } -} - -QList QuickWindowNodeInstance::stateInstances() const -{ - QList instanceList; - QList stateList = DesignerSupport::statesForItem(quickItem()); - foreach (QObject *state, stateList) - { - if (state && nodeInstanceServer()->hasInstanceForObject(state)) - instanceList.append(nodeInstanceServer()->instanceForObject(state)); - } - - return instanceList; -} - bool QuickWindowNodeInstance::isAnchoredBySibling() const { return false; } -bool QuickWindowNodeInstance::isAnchoredByChildren() const -{ - if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item - return true; - - return false; -} QQuickItem *QuickWindowNodeInstance::quickItem() const { if (object() == 0) return 0; - Q_ASSERT(qobject_cast(object())); return static_cast(object())->contentItem(); } -DesignerSupport *QuickWindowNodeInstance::designerSupport() const -{ - return qt5NodeInstanceServer()->designerSupport(); -} - -Qt5NodeInstanceServer *QuickWindowNodeInstance::qt5NodeInstanceServer() const -{ - return qobject_cast(nodeInstanceServer()); -} - -void QuickWindowNodeInstance::createEffectItem(bool createEffectItem) -{ - s_createEffectItem = createEffectItem; -} - -void QuickWindowNodeInstance::updateDirtyNodeRecursive() -{ - foreach (QQuickItem *childItem, quickItem()->childItems()) - updateDirtyNodeRecursive(childItem); - - DesignerSupport::updateDirtyNode(quickItem()); -} - } // namespace Internal } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h index 90f5405b97c..e9651f9e68f 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h @@ -32,7 +32,7 @@ #include -#include "objectnodeinstance.h" +#include "graphicalnodeinstance.h" #include #include @@ -40,7 +40,7 @@ namespace QmlDesigner { namespace Internal { -class QuickWindowNodeInstance : public ObjectNodeInstance +class QuickWindowNodeInstance : public GraphicalNodeInstance { public: typedef QSharedPointer Pointer; @@ -49,88 +49,27 @@ public: ~QuickWindowNodeInstance(); static Pointer create(QObject *objectToBeWrapped); - void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance); - bool isQuickItem() const Q_DECL_OVERRIDE; - - QRectF boundingRect() const Q_DECL_OVERRIDE; - QPointF position() const Q_DECL_OVERRIDE; - QSizeF size() const Q_DECL_OVERRIDE; - QTransform transform() const Q_DECL_OVERRIDE; - QTransform customTransform() const Q_DECL_OVERRIDE; - QTransform sceneTransform() const Q_DECL_OVERRIDE; - double opacity() const Q_DECL_OVERRIDE; + bool isQuickWindow() const Q_DECL_OVERRIDE; QObject *parent() const Q_DECL_OVERRIDE; - double rotation() const Q_DECL_OVERRIDE; - double scale() const Q_DECL_OVERRIDE; - QPointF transformOriginPoint() const Q_DECL_OVERRIDE; - double zValue() const Q_DECL_OVERRIDE; - - bool equalQuickItem(QQuickItem *item) const; - - bool hasContent() const Q_DECL_OVERRIDE; - - QList childItems() const Q_DECL_OVERRIDE; - QList childItemsForChild(QQuickItem *childItem) const; - - bool isMovable() const Q_DECL_OVERRIDE; - - void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; - void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; - - QVariant property(const PropertyName &name) const Q_DECL_OVERRIDE; - void resetProperty(const PropertyName &name) Q_DECL_OVERRIDE; - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, - const PropertyName &newParentProperty) Q_DECL_OVERRIDE; + const PropertyName &newParentProperty); - int penWidth() const Q_DECL_OVERRIDE; - bool hasAnchor(const PropertyName &name) const Q_DECL_OVERRIDE; - QPair anchor(const PropertyName &name) const Q_DECL_OVERRIDE; bool isAnchoredBySibling() const Q_DECL_OVERRIDE; - bool isAnchoredByChildren() const Q_DECL_OVERRIDE; - void doComponentComplete() Q_DECL_OVERRIDE; - bool isResizable() const Q_DECL_OVERRIDE; - void setHasContent(bool hasContent); - - QList stateInstances() const Q_DECL_OVERRIDE; - - QImage renderImage() const Q_DECL_OVERRIDE; - QImage renderPreviewImage(const QSize &previewImageSize) const Q_DECL_OVERRIDE; - - DesignerSupport *designerSupport() const; - Qt5NodeInstanceServer *qt5NodeInstanceServer() const; - - static void createEffectItem(bool createEffectItem); - - void updateDirtyNodeRecursive() Q_DECL_OVERRIDE; protected: QuickWindowNodeInstance(QQuickWindow*); QQuickItem *quickItem() const; void resetHorizontal(); void resetVertical(); - QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; - void updateDirtyNodeRecursive(QQuickItem *parentItem) const; - static bool anyItemHasContent(QQuickItem *graphicsItem); - static bool childItemsHaveContent(QQuickItem *graphicsItem); -private: //variables - bool m_hasHeight; - bool m_hasWidth; - bool m_hasContent; - double m_x; - double m_y; - double m_width; - double m_height; - static bool s_createEffectItem; }; } // namespace Internal diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index 4bddcf1a8cb..6a7adb05db1 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -150,9 +150,9 @@ void ServerNodeInstance::setNodeSource(const QString &source) m_nodeInstance->setNodeSource(source); } -bool ServerNodeInstance::holdsQuickItem() const +bool ServerNodeInstance::holdsGraphical() const { - return m_nodeInstance->isQuickItem(); + return m_nodeInstance->isGraphical(); } void ServerNodeInstance::updateDirtyNodeRecursive() diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h index a7cdff1c368..1fcc49bc70d 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h @@ -196,7 +196,7 @@ private: // functions void setNodeSource(const QString &source); - bool holdsQuickItem() const; + bool holdsGraphical() const; void updateDirtyNodeRecursive(); From ff4457bb4613b2598aa0e274588d459e132a586c Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 18 Apr 2013 18:42:58 +0200 Subject: [PATCH 11/15] QmlDesigner: Prepare for other layout items Change-Id: I831e68877eb3d785b4bbb99db002ab8e42158d75 Reviewed-by: Thomas Hartmann --- .../container/informationcontainer.cpp | 4 ++-- .../qml/qmlpuppet/interfaces/commondefines.h | 2 +- .../instances/graphicalnodeinstance.cpp | 12 ++++++------ .../instances/nodeinstanceserver.cpp | 2 +- .../instances/objectnodeinstance.cpp | 17 +++++++++++------ .../qml2puppet/instances/objectnodeinstance.h | 9 +++++---- .../instances/positionernodeinstance.cpp | 7 ++++++- .../instances/positionernodeinstance.h | 3 ++- .../instances/quickitemnodeinstance.cpp | 8 ++++---- .../instances/servernodeinstance.cpp | 4 ++-- .../qml2puppet/instances/servernodeinstance.h | 2 +- .../qmlpuppet/instances/nodeinstanceserver.cpp | 2 +- .../qmlpuppet/instances/servernodeinstance.cpp | 2 +- .../qmlpuppet/instances/servernodeinstance.h | 2 +- .../modelnodecontextmenu_helper.cpp | 2 +- .../formeditor/abstractformeditortool.cpp | 4 ++-- .../components/formeditor/formeditorview.cpp | 2 +- .../components/formeditor/movetool.cpp | 2 +- .../components/formeditor/resizeindicator.cpp | 2 +- .../rubberbandselectionmanipulator.cpp | 4 ++-- .../components/formeditor/selectiontool.cpp | 2 +- .../designercore/include/nodeinstance.h | 4 ++-- .../designercore/include/qmlitemnode.h | 2 +- .../designercore/instances/nodeinstance.cpp | 18 +++++++++--------- .../designercore/model/qmlitemnode.cpp | 4 ++-- 25 files changed, 67 insertions(+), 55 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp index 8ed1f0ca708..d4d54b8a63e 100644 --- a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp @@ -81,8 +81,8 @@ QString InformationContainer::nameAsString() const return QLatin1String("PenWidth"); case Position: return QLatin1String("Position"); - case IsInPositioner: - return QLatin1String("IsInPositioner"); + case IsInLayoutable: + return QLatin1String("IsInLayoutable"); case SceneTransform: return QLatin1String("SceneTransform"); case IsResizable: diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h index bf0e36025ef..4d39c6abdfb 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h @@ -47,7 +47,7 @@ enum InformationName InstanceTypeForProperty, PenWidth, Position, - IsInPositioner, + IsInLayoutable, SceneTransform, IsResizable, IsMovable, diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp index 96912164590..7f5dc9301d8 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp @@ -350,8 +350,8 @@ void GraphicalNodeInstance::setPropertyVariant(const PropertyName &name, const Q refresh(); - if (isInPositioner()) - parentInstance()->refreshPositioner(); + if (isInLayoutable()) + parentInstance()->refreshLayoutable(); } void GraphicalNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) @@ -365,8 +365,8 @@ void GraphicalNodeInstance::setPropertyBinding(const PropertyName &name, const Q refresh(); - if (isInPositioner()) - parentInstance()->refreshPositioner(); + if (isInLayoutable()) + parentInstance()->refreshLayoutable(); } QVariant GraphicalNodeInstance::property(const PropertyName &name) const @@ -423,8 +423,8 @@ void GraphicalNodeInstance::resetProperty(const PropertyName &name) quickItem()->update(); - if (isInPositioner()) - parentInstance()->refreshPositioner(); + if (isInLayoutable()) + parentInstance()->refreshLayoutable(); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp index fe4ba684879..8ed4a77c53e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp @@ -892,7 +892,7 @@ static QVector createInformationVector(const QList m_object; NodeInstanceMetaObject *m_metaObject; NodeInstanceSignalSpy m_signalSpy; - bool m_isInPositioner; + bool m_isInLayoutable; }; } // namespace Internal diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp index 83f20fb7e42..6bb6ad2ad3a 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp @@ -42,6 +42,11 @@ bool PositionerNodeInstance::isPositioner() const return true; } +bool PositionerNodeInstance::isLayoutable() const +{ + return true; +} + bool PositionerNodeInstance::isResizable() const { return true; @@ -87,7 +92,7 @@ QQuickBasePositioner *PositionerNodeInstance::positioner() const return static_cast(object()); } -void PositionerNodeInstance::refreshPositioner() +void PositionerNodeInstance::refreshLayoutable() { bool success = QMetaObject::invokeMethod(positioner(), "prePositioning"); Q_ASSERT(success); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h index f81e22e717f..8ab8333f1f8 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h @@ -51,10 +51,11 @@ public: void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; bool isPositioner() const Q_DECL_OVERRIDE; + bool isLayoutable() const Q_DECL_OVERRIDE; bool isResizable() const Q_DECL_OVERRIDE; - void refreshPositioner() Q_DECL_OVERRIDE; + void refreshLayoutable() Q_DECL_OVERRIDE; protected: PositionerNodeInstance(QQuickBasePositioner *item); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index 57baa419945..12d6f39b86d 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -131,14 +131,14 @@ void QuickItemNodeInstance::setResizable(bool resizable) void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) { if (oldParentInstance && oldParentInstance->isPositioner()) { - setInPositioner(false); + setInLayoutable(false); setMovable(true); } ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty); if (newParentInstance && newParentInstance->isPositioner()) { - setInPositioner(true); + setInLayoutable(true); setMovable(false); } @@ -153,8 +153,8 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen refresh(); DesignerSupport::updateDirtyNode(quickItem()); - if (parentInstance() && isInPositioner()) - parentInstance()->refreshPositioner(); + if (parentInstance() && isInLayoutable()) + parentInstance()->refreshLayoutable(); } bool QuickItemNodeInstance::isAnchoredBySibling() const diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index 6a7adb05db1..7a8e0e65013 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -408,9 +408,9 @@ bool ServerNodeInstance::isMovable() const return m_nodeInstance->isMovable(); } -bool ServerNodeInstance::isInPositioner() const +bool ServerNodeInstance::isInLayoutable() const { - return m_nodeInstance->isInPositioner(); + return m_nodeInstance->isInLayoutable(); } bool ServerNodeInstance::hasAnchor(const PropertyName &name) const diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h index 1fcc49bc70d..85b27d902ed 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h @@ -130,7 +130,7 @@ public: bool hasContent() const; bool isResizable() const; bool isMovable() const; - bool isInPositioner() const; + bool isInLayoutable() const; bool isSubclassOf(const QString &superTypeName) const; bool isRootNodeInstance() const; diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp index 2f74cef3895..e9e6d08e2b1 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp @@ -886,7 +886,7 @@ static QVector createInformationVector(const QListisMovable(); } -bool ServerNodeInstance::isInPositioner() const +bool ServerNodeInstance::isInLayoutable() const { return m_nodeInstance->isInPositioner(); } diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h index 9f49fd76acc..8e2cd67dff8 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h @@ -127,7 +127,7 @@ public: bool hasContent() const; bool isResizable() const; bool isMovable() const; - bool isInPositioner() const; + bool isInLayoutable() const; bool isSubclassOf(const QString &superTypeName) const; bool isRootNodeInstance() const; diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp index 675f8b8b134..6a4e1748b89 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp @@ -144,7 +144,7 @@ static inline bool itemsHaveSameParent(const QList &siblingList) QmlItemNode currentParent = currentItem.instanceParent().toQmlItemNode(); if (!currentParent.isValid()) return false; - if (currentItem.instanceIsInPositioner()) + if (currentItem.instanceIsInLayoutable()) return false; if (currentParent != parent) return false; diff --git a/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp b/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp index 5480f18b76e..ca6618f81fc 100644 --- a/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp @@ -103,7 +103,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QListqmlItemNode()) && formEditorItem->qmlItemNode().instanceIsMovable() - && !formEditorItem->qmlItemNode().instanceIsInPositioner() + && !formEditorItem->qmlItemNode().instanceIsInLayoutable() && (formEditorItem->qmlItemNode().hasShowContent())) return true; } @@ -113,7 +113,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QListqmlItemNode().isValid() && formEditorItem->qmlItemNode().instanceIsMovable() - && !formEditorItem->qmlItemNode().instanceIsInPositioner() + && !formEditorItem->qmlItemNode().instanceIsInLayoutable() && selectedNodes.contains(formEditorItem->qmlItemNode())) return true; } diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index a3e3f2ba648..4fdb92baa13 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -634,7 +634,7 @@ bool FormEditorView::isMoveToolAvailable() const { if (selectedQmlItemNodes().count() == 1) return selectedQmlItemNodes().first().instanceIsMovable() && - !selectedQmlItemNodes().first().instanceIsInPositioner(); + !selectedQmlItemNodes().first().instanceIsInLayoutable(); return true; } diff --git a/src/plugins/qmldesigner/components/formeditor/movetool.cpp b/src/plugins/qmldesigner/components/formeditor/movetool.cpp index 59fb681dc40..e284da2eaa1 100644 --- a/src/plugins/qmldesigner/components/formeditor/movetool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/movetool.cpp @@ -367,7 +367,7 @@ QList movalbeItems(const QList &itemList) QMutableListIterator listIterator(filteredItemList); while (listIterator.hasNext()) { FormEditorItem *item = listIterator.next(); - if (!item->qmlItemNode().isValid() || !item->qmlItemNode().instanceIsMovable() || item->qmlItemNode().instanceIsInPositioner()) + if (!item->qmlItemNode().isValid() || !item->qmlItemNode().instanceIsMovable() || item->qmlItemNode().instanceIsInLayoutable()) listIterator.remove(); } diff --git a/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp b/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp index 13a35d7cc2b..f21ce88bbb3 100644 --- a/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp @@ -75,7 +75,7 @@ void ResizeIndicator::setItems(const QList &itemList) && item->qmlItemNode().isValid() && item->qmlItemNode().instanceIsResizable() && !item->qmlItemNode().instanceHasRotationTransform() - && !item->qmlItemNode().instanceIsInPositioner()) { + && !item->qmlItemNode().instanceIsInLayoutable()) { ResizeController controller(m_layerItem, item); m_itemControllerHash.insert(item, controller); } diff --git a/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp index 58d50126540..8d3565acdfd 100644 --- a/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp @@ -104,7 +104,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType) && formEditorItem->qmlItemNode().isValid() && m_beginFormEditorItem->childItems().contains(formEditorItem) && formEditorItem->qmlItemNode().instanceIsMovable() - && !formEditorItem->qmlItemNode().instanceIsInPositioner()) + && !formEditorItem->qmlItemNode().instanceIsInLayoutable()) { newNodeList.append(formEditorItem->qmlItemNode()); } @@ -113,7 +113,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType) if (newNodeList.isEmpty() && m_beginFormEditorItem->qmlItemNode().isValid() && m_beginFormEditorItem->qmlItemNode().instanceIsMovable() - && !m_beginFormEditorItem->qmlItemNode().instanceIsInPositioner()) + && !m_beginFormEditorItem->qmlItemNode().instanceIsInLayoutable()) newNodeList.append(m_beginFormEditorItem->qmlItemNode()); QList nodeList; diff --git a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp index e7d88725bd2..e1673e9ecd9 100644 --- a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp @@ -152,7 +152,7 @@ void SelectionTool::hoverMoveEvent(const QList &itemList, if (formEditorItem && formEditorItem->qmlItemNode().isValid() - && !formEditorItem->qmlItemNode().instanceIsInPositioner() + && !formEditorItem->qmlItemNode().instanceIsInLayoutable() && formEditorItem->qmlItemNode().instanceIsMovable() && (formEditorItem->qmlItemNode().hasShowContent() || !m_selectOnlyContentItems)) { diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstance.h b/src/plugins/qmldesigner/designercore/include/nodeinstance.h index 5c5eafd9d5b..cb3242afadf 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstance.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstance.h @@ -66,7 +66,7 @@ public: bool isResizable() const; QTransform transform() const; QTransform sceneTransform() const; - bool isInPositioner() const; + bool isInLayoutable() const; QPointF position() const; QSizeF size() const; int penWidth() const; @@ -95,7 +95,7 @@ protected: InformationName setInformationTransform(const QTransform &transform); InformationName setInformationPenWith(int penWidth); InformationName setInformationPosition(const QPointF &position); - InformationName setInformationIsInPositioner(bool isInPositioner); + InformationName setInformationIsInLayoutable(bool isInLayoutable); InformationName setInformationSceneTransform(const QTransform &sceneTransform); InformationName setInformationIsResizable(bool isResizable); InformationName setInformationIsMovable(bool isMovable); diff --git a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h index f9c7e547665..1d37ad4416e 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h +++ b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h @@ -70,7 +70,7 @@ public: bool instanceIsAnchoredByChildren() const; bool instanceIsMovable() const; bool instanceIsResizable() const; - bool instanceIsInPositioner() const; + bool instanceIsInLayoutable() const; bool instanceHasRotationTransform() const; QRectF instanceBoundingRect() const; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp index 2216b1f6fa2..1a67bcfac5d 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp @@ -48,7 +48,7 @@ public: hasContent(false), isMovable(false), isResizable(false), - isInPositioner(false) + isInLayoutable(false) {} qint32 parentInstanceId; @@ -64,7 +64,7 @@ public: bool hasContent; bool isMovable; bool isResizable; - bool isInPositioner; + bool isInLayoutable; QHash propertyValues; @@ -198,10 +198,10 @@ QTransform NodeInstance::sceneTransform() const else return QTransform(); } -bool NodeInstance::isInPositioner() const +bool NodeInstance::isInLayoutable() const { if (isValid()) - return d->isInPositioner; + return d->isInLayoutable; else return false; } @@ -355,11 +355,11 @@ InformationName NodeInstance::setInformationPosition(const QPointF &position) return NoInformationChange; } -InformationName NodeInstance::setInformationIsInPositioner(bool isInPositioner) +InformationName NodeInstance::setInformationIsInLayoutable(bool isInLayoutable) { - if (d->isInPositioner != isInPositioner) { - d->isInPositioner = isInPositioner; - return IsInPositioner; + if (d->isInLayoutable != isInLayoutable) { + d->isInLayoutable = isInLayoutable; + return IsInLayoutable; } return NoInformationChange; @@ -474,7 +474,7 @@ InformationName NodeInstance::setInformation(InformationName name, const QVarian case Transform: return setInformationTransform(information.value()); break; case PenWidth: return setInformationPenWith(information.toInt()); break; case Position: return setInformationPosition(information.toPointF()); break; - case IsInPositioner: return setInformationIsInPositioner(information.toBool()); break; + case IsInLayoutable: return setInformationIsInLayoutable(information.toBool()); break; case SceneTransform: return setInformationSceneTransform(information.value()); break; case IsResizable: return setInformationIsResizable(information.toBool()); break; case IsMovable: return setInformationIsMovable(information.toBool()); break; diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index 697ee77ac85..24e7653370c 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -224,9 +224,9 @@ bool QmlItemNode::instanceIsResizable() const return nodeInstance().isResizable(); } -bool QmlItemNode::instanceIsInPositioner() const +bool QmlItemNode::instanceIsInLayoutable() const { - return nodeInstance().isInPositioner(); + return nodeInstance().isInLayoutable(); } bool QmlItemNode::instanceHasRotationTransform() const From 457566974d419a57dc679d5a43c631d8cd5c92e4 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Mon, 22 Apr 2013 17:25:46 +0200 Subject: [PATCH 12/15] QmlDesigner.Instances: adding LayoutNodeInstance This class wraps a QQuickLayout. Change-Id: Ib661ccb5bb5deb1acb87b9a4bef8da95cb4e40eb Reviewed-by: Thomas Hartmann --- .../instances/graphicalnodeinstance.h | 4 +- .../qml2puppet/instances/instances.pri | 2 + .../instances/layoutnodeinstance.cpp | 94 +++++++++++++++++++ .../qml2puppet/instances/layoutnodeinstance.h | 63 +++++++++++++ .../instances/servernodeinstance.cpp | 3 + 5 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h index 28867a60cc0..4aaa414d8f2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h @@ -11,8 +11,8 @@ namespace Internal { class GraphicalNodeInstance : public ObjectNodeInstance { public: - typedef QSharedPointer Pointer; - typedef QWeakPointer WeakPointer; + typedef QSharedPointer Pointer; + typedef QWeakPointer WeakPointer; ~GraphicalNodeInstance(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index 60db67d7fdd..2bb894ef1bc 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -23,6 +23,7 @@ HEADERS += $$PWD/servernodeinstance.h HEADERS += $$PWD/anchorchangesnodeinstance.h HEADERS += $$PWD/positionernodeinstance.h HEADERS += $$PWD/quickwindownodeinstance.h +HEADERS += $$PWD/layoutnodeinstance.h SOURCES += $$PWD/qt5nodeinstanceserver.cpp SOURCES += $$PWD/graphicalnodeinstance.cpp @@ -47,3 +48,4 @@ SOURCES += $$PWD/servernodeinstance.cpp SOURCES += $$PWD/anchorchangesnodeinstance.cpp SOURCES += $$PWD/positionernodeinstance.cpp SOURCES += $$PWD/quickwindownodeinstance.cpp +SOURCES += $$PWD/layoutnodeinstance.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp new file mode 100644 index 00000000000..ca7071f6925 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 "layoutnodeinstance.h" + +namespace QmlDesigner { +namespace Internal { + +LayoutNodeInstance::LayoutNodeInstance(QQuickItem *item) + : QuickItemNodeInstance(item) +{ +} + +bool LayoutNodeInstance::isLayoutable() const +{ + return true; +} + +bool LayoutNodeInstance::isResizable() const +{ + return true; +} + +void LayoutNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) +{ + if (name == "move" || name == "add" || name == "populate") + return; + + QuickItemNodeInstance::setPropertyVariant(name, value); +} + +void LayoutNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) +{ + if (name == "move" || name == "add" || name == "populate") + return; + + QuickItemNodeInstance::setPropertyBinding(name, expression); +} + +LayoutNodeInstance::Pointer LayoutNodeInstance::create(QObject *object) +{ + qDebug() << "layout" << object; + QQuickItem *item = qobject_cast(object); + + Q_ASSERT(item); + + Pointer instance(new LayoutNodeInstance(item)); + + instance->setHasContent(anyItemHasContent(item)); + item->setFlag(QQuickItem::ItemHasContents, true); + + static_cast(item)->classBegin(); + + instance->populateResetHashes(); + + return instance; +} + +void LayoutNodeInstance::refreshLayoutable() +{ + qDebug() << "before"; + if (quickItem()->parent()) + QCoreApplication::postEvent(quickItem(), new QEvent(QEvent::LayoutRequest)); + qDebug() << "refresh"; + +} + +} +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h new file mode 100644 index 00000000000..7a92f83b044 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 LAYOUTNODEINSTANCE_H +#define LAYOUTNODEINSTANCE_H + +#include "quickitemnodeinstance.h" + +namespace QmlDesigner { +namespace Internal { + +class LayoutNodeInstance : public QuickItemNodeInstance +{ + +public: + typedef QSharedPointer Pointer; + typedef QWeakPointer WeakPointer; + + static Pointer create(QObject *objectToBeWrapped); + + void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; + void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; + + bool isLayoutable() const Q_DECL_OVERRIDE; + + bool isResizable() const Q_DECL_OVERRIDE; + + void refreshLayoutable() Q_DECL_OVERRIDE; + +protected: + LayoutNodeInstance(QQuickItem *item); +}; + +} // namespace Internal +} // namespace QmlDesigner + +#endif // LAYOUTNODEINSTANCE_H diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index 7a8e0e65013..fd9a16b6d20 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -37,6 +37,7 @@ #include "qmlstatenodeinstance.h" #include "anchorchangesnodeinstance.h" #include "positionernodeinstance.h" +#include "layoutnodeinstance.h" #include "debugoutputcommand.h" #include "quickitemnodeinstance.h" @@ -181,6 +182,8 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject instance = Internal::DummyNodeInstance::create(); else if (isSubclassOf(objectToBeWrapped, "QQuickBasePositioner")) instance = Internal::PositionerNodeInstance::create(objectToBeWrapped); + else if (isSubclassOf(objectToBeWrapped, "QQuickLayout")) + instance = Internal::LayoutNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QQuickItem")) instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QQmlComponent")) From fd9d39c12ac030791be16d9de854806e26e04991 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 22 Apr 2013 17:52:57 +0200 Subject: [PATCH 13/15] QmlDesigner.Instances: properly disable component complete for 5.1 This is only available in Qt 5.1 Change-Id: I76b7916b4ce64c440c175e77edc2b0a3ef015166 Reviewed-by: Marco Bubke --- .../instances/objectnodeinstance.cpp | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index 2f715eec9a9..ececc9b722a 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -53,6 +53,32 @@ #include #include #include +#include + + +namespace { +class ComponentCompleteDisabler +{ +public: +#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) + ComponentCompleteDisabler() + { + DesignerSupport::disableComponentComplete(); + } + + ~ComponentCompleteDisabler() + { + DesignerSupport::enableComponentComplete(); + } +#else + ComponentCompleteDisabler() + { + //nothing not available yet + } +#endif +}; + +} //namespace static bool isPropertyBlackListed(const QmlDesigner::PropertyName &propertyName) { @@ -894,6 +920,10 @@ void tweakObjects(QObject *object) QObject *ObjectNodeInstance::createComponentWrap(const QString &nodeSource, const QStringList &imports, QQmlContext *context) { + ComponentCompleteDisabler disableComponentComplete; + + Q_UNUSED(disableComponentComplete) + QQmlComponent *component = new QQmlComponent(context->engine()); QByteArray importArray; @@ -949,6 +979,10 @@ static inline QString fixComponentPathForIncompatibleQt(const QString &component QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlContext *context) { + ComponentCompleteDisabler disableComponentComplete; + + Q_UNUSED(disableComponentComplete) + QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath)); QObject *object = component.beginCreate(context); @@ -968,6 +1002,10 @@ QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlC QObject *ObjectNodeInstance::createCustomParserObject(const QString &nodeSource, const QStringList &imports, QQmlContext *context) { + ComponentCompleteDisabler disableComponentComplete; + + Q_UNUSED(disableComponentComplete) + QQmlComponent component(context->engine()); QByteArray importArray; From 53fb29bddab0e57f933a5438dddacbf740e4e636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20N=C3=A4tterlund?= Date: Fri, 19 Apr 2013 13:50:17 +0200 Subject: [PATCH 14/15] QtQuick2ApplicationViewer: properly resolve install paths This is a port of commit 2982545d to also apply it to the qtquick2applicationviewer.cpp template. Change-Id: Ia9d964d9fc98ea957c52aea783c6148449552755 Reviewed-by: Christian Kandeler Reviewed-by: Eike Ziller --- .../qtquick2applicationviewer.cpp | 8 ++++++-- src/plugins/qt4projectmanager/wizards/qtquickapp.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp index 3b19047fb2a..6d7232e2609 100644 --- a/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp +++ b/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp @@ -29,11 +29,15 @@ QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) #elif defined(Q_OS_QNX) if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("app/native/%1").arg(path); -#elif defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) - const QString pathInInstallDir = +#elif !defined(Q_OS_ANDROID) + QString pathInInstallDir = QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; #endif return path; } diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp index ec50c9fbaff..7ebf816afba 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp @@ -227,7 +227,7 @@ QByteArray QtQuickApp::generateFileExtended(int fileType, int QtQuickApp::stubVersionMinor() const { - return m_componentSet == QtQuick20Components ? 3 : 23; + return m_componentSet == QtQuick20Components ? 4 : 23; } QList QtQuickApp::updateableFiles(const QString &mainProFile) const From c4be740bd6200582fe2a761533ffcf9ecbe37cd1 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 18 Apr 2013 11:19:54 +0200 Subject: [PATCH 15/15] README: Update section about private headers It's not only QmlDesigner that nowadays uses private API. Change-Id: I87ea88e780b3a8d7169d4c75e84dc4e78dd7cab7 Reviewed-by: Leena Miettinen Reviewed-by: Thomas Hartmann --- README | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/README b/README index e932975046a..75c2a09b5ef 100644 --- a/README +++ b/README @@ -37,27 +37,28 @@ Installation ("make install") is not needed. It is however possible, using make install INSTALL_ROOT=$INSTALL_DIRECTORY -Compiling Qt Quick Designer +Private Header Dependencies --------------------------- -Qt Quick Designer (QmlDesigner plugin) depends on "private" headers from Qt -4.8.0, specifically from the QtDeclarative module. These private headers always -end with an "_p.h". Digia does not promise to keep these files or APIs binary -or source compatible between releases. This means that when compiled, the -plugin has a dependency to the exact Qt version it was compiled with. Running -Qt Creator with the plugin against updated Qt libraries (also for patch -releases) might lead to link time failures, or even crashes. +The Qt Quick Designer and the QNX plugin, and on Windows the Utils library,use +private headers of Qt. These private headers always end with an "_p.h". Digia +and the Qt Project do not promise to keep these files or APIs binary or source +compatible between releases. This means that when compiled, Qt Creator has a +dependency to the exact Qt version it was compiled with. Running Qt Creator +against updated Qt libraries (also for patch releases) might lead to link time +failures, or even crashes. -If you want to disable the plugin, you can pass "QT_PRIVATE_HEADERS=" to qmake: +If you want to disable the plugins on Linux and Mac OS X, you can pass +"QT_PRIVATE_HEADERS=" to qmake: qmake "QT_PRIVATE_HEADERS=" $SOURCE_DIRECTORY/qtcreator.pro -The plugin is not compiled if the private header files are not found. This -might be the case when you use a Qt version from your distribution, or -installed a self-compiled Qt to a separate directory via 'make install'. You -can fix this by either re-building your Qt with the "-developer-build" -configure option, or by passing the include directory in the source directory -to qmake. For example: +The plugins are also automatically omitted if the private header files are +not found. This might be the case when you use a Qt version from your +distribution, or installed a self-compiled Qt to a separate directory via +'make install'. You can fix this by either re-building your Qt with the +"-developer-build" configure option, or by passing the include directory in +the source directory to qmake. For example: qmake "QT_PRIVATE_HEADERS=$$QT_BUILD_TREE/include" $SOURCE_DIRECTORY/qtcreator.pro