From 810ba37075e10372e150395b501cf1966134c5cb Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 25 Sep 2017 11:03:01 +0200 Subject: [PATCH 01/11] Clang: Fix build with older clang Change-Id: Iafe2f706f90ecce236bc2b3b602b55491df19f94 Reviewed-by: Christian Stenger --- .../ipcsource/clangcreateinitialdocumentpreamblejob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clangbackend/ipcsource/clangcreateinitialdocumentpreamblejob.cpp b/src/tools/clangbackend/ipcsource/clangcreateinitialdocumentpreamblejob.cpp index b60a5ca613f..aab58b0edb7 100644 --- a/src/tools/clangbackend/ipcsource/clangcreateinitialdocumentpreamblejob.cpp +++ b/src/tools/clangbackend/ipcsource/clangcreateinitialdocumentpreamblejob.cpp @@ -41,7 +41,7 @@ IAsyncJob::AsyncPrepareResult CreateInitialDocumentPreambleJob::prepareAsyncRun( const TranslationUnitUpdateInput updateInput = m_pinnedDocument.createUpdateInput(); setRunner([translationUnit, updateInput]() { TIME_SCOPE_DURATION("CreateInitialDocumentPreambleJobRunner"); - return translationUnit.reparse(updateInput); + translationUnit.reparse(updateInput); }); return AsyncPrepareResult{translationUnit.id()}; From 5b94c3730b7332d31170e1cd6a9e068410ae1e04 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 15 Sep 2017 16:29:26 +0200 Subject: [PATCH 02/11] Squish: Update tst_SCOM02 ...for changed QML file in project template. Change-Id: I3a0999650bffc35bc09d0f8ae92a33b80ac90474 Reviewed-by: Christian Stenger --- tests/system/suite_SCOM/tst_SCOM02/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/suite_SCOM/tst_SCOM02/test.py b/tests/system/suite_SCOM/tst_SCOM02/test.py index 7c9dd60cea7..64fbf7d65c1 100644 --- a/tests/system/suite_SCOM/tst_SCOM02/test.py +++ b/tests/system/suite_SCOM/tst_SCOM02/test.py @@ -35,7 +35,7 @@ def main(): createNewQtQuickApplication(tempDir(), "SampleApp") # create syntax error in qml file openDocument("SampleApp.Resources.qml\.qrc./.main\\.qml") - if not appendToLine(waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget"), "TextEdit {", "SyntaxError"): + if not appendToLine(waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget"), "Window {", "SyntaxError"): invokeMenuItem("File", "Exit") return # save all to invoke qml parsing From 92693b9ac9893593e07e913b9a7ad56665ab321d Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 22 Sep 2017 16:49:44 +0200 Subject: [PATCH 03/11] Clang: Remove unused messages Change-Id: Ibe2678de726a867308fac16c6a14b0eff10cbacb Reviewed-by: Tim Jenssen --- .../clangcodemodelclientinterface.cpp | 6 -- .../clangcodemodelclientinterface.h | 4 - .../clangcodemodelclientmessages.h | 2 - .../clangcodemodelclientproxy.cpp | 10 --- .../clangsupport/clangcodemodelclientproxy.h | 2 - src/libs/clangsupport/clangsupport-lib.pri | 4 - src/libs/clangsupport/clangsupport_global.h | 3 - src/libs/clangsupport/messageenvelop.cpp | 6 -- .../projectpartsdonotexistmessage.cpp | 55 ------------ .../projectpartsdonotexistmessage.h | 77 ---------------- .../translationunitdoesnotexistmessage.cpp | 55 ------------ .../translationunitdoesnotexistmessage.h | 88 ------------------- .../clangbackendipcintegration.h | 3 - .../unittest/clientserverinprocess-test.cpp | 24 ----- tests/unit/unittest/dummyclangipcclient.h | 2 - .../unit/unittest/mockclangcodemodelclient.h | 4 - 16 files changed, 345 deletions(-) delete mode 100644 src/libs/clangsupport/projectpartsdonotexistmessage.cpp delete mode 100644 src/libs/clangsupport/projectpartsdonotexistmessage.h delete mode 100644 src/libs/clangsupport/translationunitdoesnotexistmessage.cpp delete mode 100644 src/libs/clangsupport/translationunitdoesnotexistmessage.h diff --git a/src/libs/clangsupport/clangcodemodelclientinterface.cpp b/src/libs/clangsupport/clangcodemodelclientinterface.cpp index 77bd1a589ea..0de9f39044a 100644 --- a/src/libs/clangsupport/clangcodemodelclientinterface.cpp +++ b/src/libs/clangsupport/clangcodemodelclientinterface.cpp @@ -44,12 +44,6 @@ void ClangCodeModelClientInterface::dispatch(const MessageEnvelop &messageEnvelo case MessageType::CodeCompletedMessage: codeCompleted(messageEnvelop.message()); break; - case MessageType::TranslationUnitDoesNotExistMessage: - translationUnitDoesNotExist(messageEnvelop.message()); - break; - case MessageType::ProjectPartsDoNotExistMessage: - projectPartsDoNotExist(messageEnvelop.message()); - break; case MessageType::DocumentAnnotationsChangedMessage: documentAnnotationsChanged(messageEnvelop.message()); break; diff --git a/src/libs/clangsupport/clangcodemodelclientinterface.h b/src/libs/clangsupport/clangcodemodelclientinterface.h index 04682ff4830..3577abb1543 100644 --- a/src/libs/clangsupport/clangcodemodelclientinterface.h +++ b/src/libs/clangsupport/clangcodemodelclientinterface.h @@ -35,7 +35,6 @@ class CodeCompletedMessage; class CompleteCodeMessage; class DocumentAnnotationsChangedMessage; class EchoMessage; -class ProjectPartsDoNotExistMessage; class ReferencesMessage; class FollowSymbolMessage; class RegisterProjectPartsForEditorMessage; @@ -44,7 +43,6 @@ class RegisterUnsavedFilesForEditorMessage; class RequestDocumentAnnotationsMessage; class RequestReferencesMessage; class RequestFollowSymbolMessage; -class TranslationUnitDoesNotExistMessage; class UnregisterProjectPartsForEditorMessage; class UnregisterTranslationUnitsForEditorMessage; class UnregisterUnsavedFilesForEditorMessage; @@ -59,8 +57,6 @@ public: virtual void alive() = 0; virtual void echo(const EchoMessage &message) = 0; virtual void codeCompleted(const CodeCompletedMessage &message) = 0; - virtual void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) = 0; - virtual void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) = 0; virtual void documentAnnotationsChanged(const DocumentAnnotationsChangedMessage &message) = 0; virtual void references(const ReferencesMessage &message) = 0; virtual void followSymbol(const FollowSymbolMessage &message) = 0; diff --git a/src/libs/clangsupport/clangcodemodelclientmessages.h b/src/libs/clangsupport/clangcodemodelclientmessages.h index 99f9a41c054..5b5c9b42edb 100644 --- a/src/libs/clangsupport/clangcodemodelclientmessages.h +++ b/src/libs/clangsupport/clangcodemodelclientmessages.h @@ -29,7 +29,5 @@ #include "cmbcodecompletedmessage.h" #include "cmbechomessage.h" #include "documentannotationschangedmessage.h" -#include "projectpartsdonotexistmessage.h" #include "referencesmessage.h" #include "followsymbolmessage.h" -#include "translationunitdoesnotexistmessage.h" diff --git a/src/libs/clangsupport/clangcodemodelclientproxy.cpp b/src/libs/clangsupport/clangcodemodelclientproxy.cpp index b9ec51cac96..6a285c23668 100644 --- a/src/libs/clangsupport/clangcodemodelclientproxy.cpp +++ b/src/libs/clangsupport/clangcodemodelclientproxy.cpp @@ -80,16 +80,6 @@ void ClangCodeModelClientProxy::codeCompleted(const CodeCompletedMessage &messag m_writeMessageBlock.write(message); } -void ClangCodeModelClientProxy::translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) -{ - m_writeMessageBlock.write(message); -} - -void ClangCodeModelClientProxy::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) -{ - m_writeMessageBlock.write(message); -} - void ClangCodeModelClientProxy::documentAnnotationsChanged(const DocumentAnnotationsChangedMessage &message) { m_writeMessageBlock.write(message); diff --git a/src/libs/clangsupport/clangcodemodelclientproxy.h b/src/libs/clangsupport/clangcodemodelclientproxy.h index a86321888de..91cf900eb46 100644 --- a/src/libs/clangsupport/clangcodemodelclientproxy.h +++ b/src/libs/clangsupport/clangcodemodelclientproxy.h @@ -54,8 +54,6 @@ public: void alive() override; void echo(const EchoMessage &message) override; void codeCompleted(const CodeCompletedMessage &message) override; - void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) override; - void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) override; void documentAnnotationsChanged(const DocumentAnnotationsChangedMessage &message) override; void references(const ReferencesMessage &message) override; void followSymbol(const FollowSymbolMessage &message) override; diff --git a/src/libs/clangsupport/clangsupport-lib.pri b/src/libs/clangsupport/clangsupport-lib.pri index 6c7d00b7d87..25b48dfc075 100644 --- a/src/libs/clangsupport/clangsupport-lib.pri +++ b/src/libs/clangsupport/clangsupport-lib.pri @@ -53,7 +53,6 @@ SOURCES += \ $$PWD/projectpartcontainer.cpp \ $$PWD/projectpartcontainerv2.cpp \ $$PWD/projectpartpch.cpp \ - $$PWD/projectpartsdonotexistmessage.cpp \ $$PWD/readmessageblock.cpp \ $$PWD/refactoringclientinterface.cpp \ $$PWD/refactoringclientproxy.cpp \ @@ -79,7 +78,6 @@ SOURCES += \ $$PWD/sourcerangescontainer.cpp \ $$PWD/sourcerangesforquerymessage.cpp \ $$PWD/sourcerangewithtextcontainer.cpp \ - $$PWD/translationunitdoesnotexistmessage.cpp \ $$PWD/unregisterunsavedfilesforeditormessage.cpp \ $$PWD/updatepchprojectpartsmessage.cpp \ $$PWD/updatetranslationunitsforeditormessage.cpp \ @@ -138,7 +136,6 @@ HEADERS += \ $$PWD/projectpartcontainer.h \ $$PWD/projectpartcontainerv2.h \ $$PWD/projectpartpch.h \ - $$PWD/projectpartsdonotexistmessage.h \ $$PWD/readmessageblock.h \ $$PWD/refactoringclientinterface.h \ $$PWD/refactoringclientproxy.h \ @@ -165,7 +162,6 @@ HEADERS += \ $$PWD/sourcerangesforquerymessage.h \ $$PWD/sourcerangewithtextcontainer.h \ $$PWD/stringcache.h \ - $$PWD/translationunitdoesnotexistmessage.h \ $$PWD/unregisterunsavedfilesforeditormessage.h \ $$PWD/updatepchprojectpartsmessage.h \ $$PWD/updatetranslationunitsforeditormessage.h \ diff --git a/src/libs/clangsupport/clangsupport_global.h b/src/libs/clangsupport/clangsupport_global.h index 18e15f52ea6..b2fc639291a 100644 --- a/src/libs/clangsupport/clangsupport_global.h +++ b/src/libs/clangsupport/clangsupport_global.h @@ -124,9 +124,6 @@ enum class MessageType : quint8 { CompleteCodeMessage, CodeCompletedMessage, - TranslationUnitDoesNotExistMessage, - ProjectPartsDoNotExistMessage, - SourceLocationsForRenamingMessage, RequestSourceLocationsForRenamingMessage, diff --git a/src/libs/clangsupport/messageenvelop.cpp b/src/libs/clangsupport/messageenvelop.cpp index 489806a986b..58139c4c8fd 100644 --- a/src/libs/clangsupport/messageenvelop.cpp +++ b/src/libs/clangsupport/messageenvelop.cpp @@ -83,12 +83,6 @@ QDebug operator<<(QDebug debug, const MessageEnvelop &messageEnvelop) case MessageType::ReferencesMessage: qDebug() << messageEnvelop.message(); break; - case MessageType::TranslationUnitDoesNotExistMessage: - qDebug() << messageEnvelop.message(); - break; - case MessageType::ProjectPartsDoNotExistMessage: - qDebug() << messageEnvelop.message(); - break; case MessageType::DocumentAnnotationsChangedMessage: qDebug() << messageEnvelop.message(); break; diff --git a/src/libs/clangsupport/projectpartsdonotexistmessage.cpp b/src/libs/clangsupport/projectpartsdonotexistmessage.cpp deleted file mode 100644 index 18fc44e0ab7..00000000000 --- a/src/libs/clangsupport/projectpartsdonotexistmessage.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "projectpartsdonotexistmessage.h" - -#include - -#include - -namespace ClangBackEnd { - -QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message) -{ - debug.nospace() << "ProjectPartDoesNotExistMessage("; - - debug.nospace() << message.projectPartIds(); - - debug.nospace() << ")"; - - return debug; -} - -std::ostream &operator<<(std::ostream &os, const ProjectPartsDoNotExistMessage &message) -{ - os << "(" - << message.projectPartIds() - << ")"; - - return os; -} - -} // namespace ClangBackEnd - diff --git a/src/libs/clangsupport/projectpartsdonotexistmessage.h b/src/libs/clangsupport/projectpartsdonotexistmessage.h deleted file mode 100644 index 1c579929062..00000000000 --- a/src/libs/clangsupport/projectpartsdonotexistmessage.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "clangsupport_global.h" - -#include - -#include - -namespace ClangBackEnd { - -class ProjectPartsDoNotExistMessage -{ -public: - ProjectPartsDoNotExistMessage() = default; - ProjectPartsDoNotExistMessage(const Utf8StringVector &projectPartIds) - : m_projectPartIds(projectPartIds) - { - } - - const Utf8StringVector &projectPartIds() const - { - return m_projectPartIds; - } - - friend QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistMessage &message) - { - out << message.m_projectPartIds; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistMessage &message) - { - in >> message.m_projectPartIds; - - return in; - } - - friend bool operator==(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second) - { - return first.m_projectPartIds == second.m_projectPartIds; - } - -private: - Utf8StringVector m_projectPartIds; -}; - -CMBIPC_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message); -std::ostream &operator<<(std::ostream &os, const ProjectPartsDoNotExistMessage &message); - -DECLARE_MESSAGE(ProjectPartsDoNotExistMessage) -} // namespace ClangBackEnd diff --git a/src/libs/clangsupport/translationunitdoesnotexistmessage.cpp b/src/libs/clangsupport/translationunitdoesnotexistmessage.cpp deleted file mode 100644 index 28f54325bb3..00000000000 --- a/src/libs/clangsupport/translationunitdoesnotexistmessage.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "translationunitdoesnotexistmessage.h" - -#include - -#include - -namespace ClangBackEnd { - -QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message) -{ - debug.nospace() << "TranslationUnitDoesNotExistMessage("; - - debug.nospace() << message.fileContainer(); - - debug.nospace() << ")"; - - return debug; -} - -std::ostream &operator<<(std::ostream &os, const TranslationUnitDoesNotExistMessage &message) -{ - os << "(" - << message.fileContainer() - << ")"; - - return os; -} - -} // namespace ClangBackEnd - diff --git a/src/libs/clangsupport/translationunitdoesnotexistmessage.h b/src/libs/clangsupport/translationunitdoesnotexistmessage.h deleted file mode 100644 index 67c6601fae9..00000000000 --- a/src/libs/clangsupport/translationunitdoesnotexistmessage.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "filecontainer.h" - -namespace ClangBackEnd { - -class TranslationUnitDoesNotExistMessage -{ -public: - TranslationUnitDoesNotExistMessage() = default; - TranslationUnitDoesNotExistMessage(const FileContainer &fileContainer) - : m_fileContainer(fileContainer) - { - } - - TranslationUnitDoesNotExistMessage(const Utf8String &filePath, const Utf8String &projectPartId) - : m_fileContainer(filePath, projectPartId) - { - } - - const FileContainer &fileContainer() const - { - return m_fileContainer; - } - - const Utf8String &filePath() const - { - return m_fileContainer.filePath(); - } - - const Utf8String &projectPartId() const - { - return m_fileContainer.projectPartId(); - } - - friend QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistMessage &message) - { - out << message.m_fileContainer; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistMessage &message) - { - in >> message.m_fileContainer; - - return in; - } - - friend bool operator==(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second) - { - return first.m_fileContainer == second.m_fileContainer; - } - -private: - FileContainer m_fileContainer; -}; - -CMBIPC_EXPORT QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message); -std::ostream &operator<<(std::ostream &os, const TranslationUnitDoesNotExistMessage &message); - -DECLARE_MESSAGE(TranslationUnitDoesNotExistMessage) -} // namespace ClangBackEnd diff --git a/src/plugins/clangcodemodel/clangbackendipcintegration.h b/src/plugins/clangcodemodel/clangbackendipcintegration.h index 63c9d768017..589c0357818 100644 --- a/src/plugins/clangcodemodel/clangbackendipcintegration.h +++ b/src/plugins/clangcodemodel/clangbackendipcintegration.h @@ -94,9 +94,6 @@ private: void references(const ClangBackEnd::ReferencesMessage &message) override; void followSymbol(const ClangBackEnd::FollowSymbolMessage &message) override; - void translationUnitDoesNotExist(const ClangBackEnd::TranslationUnitDoesNotExistMessage &) override {} - void projectPartsDoNotExist(const ClangBackEnd::ProjectPartsDoNotExistMessage &) override {} - private: AliveHandler m_aliveHandler; QHash m_assistProcessorsTable; diff --git a/tests/unit/unittest/clientserverinprocess-test.cpp b/tests/unit/unittest/clientserverinprocess-test.cpp index d085a3f779c..f45677e4476 100644 --- a/tests/unit/unittest/clientserverinprocess-test.cpp +++ b/tests/unit/unittest/clientserverinprocess-test.cpp @@ -30,7 +30,6 @@ #include #include -#include #include @@ -226,29 +225,6 @@ TEST_F(ClientServerInProcess, UpdateVisibleTranslationUnitsMessage) scheduleServerMessages(); } -TEST_F(ClientServerInProcess, SendTranslationUnitDoesNotExistMessage) -{ - ClangBackEnd::TranslationUnitDoesNotExistMessage message(fileContainer); - - EXPECT_CALL(mockClangCodeModelClient, translationUnitDoesNotExist(message)) - .Times(1); - - clientProxy.translationUnitDoesNotExist(message); - scheduleClientMessages(); -} - - -TEST_F(ClientServerInProcess, SendProjectPartDoesNotExistMessage) -{ - ClangBackEnd::ProjectPartsDoNotExistMessage message({Utf8StringLiteral("projectId")}); - - EXPECT_CALL(mockClangCodeModelClient, projectPartsDoNotExist(message)) - .Times(1); - - clientProxy.projectPartsDoNotExist(message); - scheduleClientMessages(); -} - TEST_F(ClientServerInProcess, SendDocumentAnnotationsChangedMessage) { ClangBackEnd::HighlightingMarkContainer highlightingMark(1, 1, 1, ClangBackEnd::HighlightingType::Keyword); diff --git a/tests/unit/unittest/dummyclangipcclient.h b/tests/unit/unittest/dummyclangipcclient.h index 027182bfdb7..3908f9e89f2 100644 --- a/tests/unit/unittest/dummyclangipcclient.h +++ b/tests/unit/unittest/dummyclangipcclient.h @@ -35,8 +35,6 @@ public: void alive() override {} void echo(const ClangBackEnd::EchoMessage &) override {} void codeCompleted(const ClangBackEnd::CodeCompletedMessage &) override {} - void translationUnitDoesNotExist(const ClangBackEnd::TranslationUnitDoesNotExistMessage &) override {} - void projectPartsDoNotExist(const ClangBackEnd::ProjectPartsDoNotExistMessage &) override {} void documentAnnotationsChanged(const ClangBackEnd::DocumentAnnotationsChangedMessage &) override {} void references(const ClangBackEnd::ReferencesMessage &) override {} void followSymbol(const ClangBackEnd::FollowSymbolMessage &) override {} diff --git a/tests/unit/unittest/mockclangcodemodelclient.h b/tests/unit/unittest/mockclangcodemodelclient.h index 47da03e33d1..2e287909ddf 100644 --- a/tests/unit/unittest/mockclangcodemodelclient.h +++ b/tests/unit/unittest/mockclangcodemodelclient.h @@ -39,10 +39,6 @@ public: void(const ClangBackEnd::EchoMessage &message)); MOCK_METHOD1(codeCompleted, void(const ClangBackEnd::CodeCompletedMessage &message)); - MOCK_METHOD1(translationUnitDoesNotExist, - void(const ClangBackEnd::TranslationUnitDoesNotExistMessage &message)); - MOCK_METHOD1(projectPartsDoNotExist, - void(const ClangBackEnd::ProjectPartsDoNotExistMessage &message)); MOCK_METHOD1(documentAnnotationsChanged, void(const ClangBackEnd::DocumentAnnotationsChangedMessage &message)); MOCK_METHOD1(references, From 3c219903de60ea43a055be1678830cd228456fb6 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 25 Sep 2017 11:51:51 +0200 Subject: [PATCH 04/11] Clang: Fix clang version extracting also for git \w did not match the '-' in "5.0.1git-81029f14223". Change-Id: I5f8d8110b93ac3efed2ec903504f86833cc32aa7 Reviewed-by: Ivan Donchevskii Reviewed-by: Marco Bubke --- src/shared/clang/clang_installation.pri | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/shared/clang/clang_installation.pri b/src/shared/clang/clang_installation.pri index f7428c0be3c..45fb643b5c2 100644 --- a/src/shared/clang/clang_installation.pri +++ b/src/shared/clang/clang_installation.pri @@ -3,10 +3,11 @@ LLVM_INSTALL_DIR = $$clean_path($$LLVM_INSTALL_DIR) isEmpty(LLVM_INSTALL_DIR): error("No LLVM_INSTALL_DIR provided") !exists($$LLVM_INSTALL_DIR): error("LLVM_INSTALL_DIR does not exist: $$LLVM_INSTALL_DIR") -defineReplace(extractVersion) { return($$replace(1, ^(\\d+\\.\\d+\\.\\d+)\\w*$, \\1)) } -defineReplace(extractMajorVersion) { return($$replace(1, ^(\\d+)\\.\\d+\\.\\d+\\w*$, \\1)) } -defineReplace(extractMinorVersion) { return($$replace(1, ^\\d+\\.(\\d+)\\.\\d+\\w*$, \\1)) } -defineReplace(extractPatchVersion) { return($$replace(1, ^\\d+\\.\\d+\\.(\\d+)\\w*$, \\1)) } +# Expected input: "3.9.1", "5.0.0svn", "5.0.1git-81029f14223" +defineReplace(extractVersion) { return($$replace(1, ^(\\d+\\.\\d+\\.\\d+).*$, \\1)) } +defineReplace(extractMajorVersion) { return($$replace(1, ^(\\d+)\\.\\d+\\.\\d+.*$, \\1)) } +defineReplace(extractMinorVersion) { return($$replace(1, ^\\d+\\.(\\d+)\\.\\d+.*$, \\1)) } +defineReplace(extractPatchVersion) { return($$replace(1, ^\\d+\\.\\d+\\.(\\d+).*$, \\1)) } defineTest(versionIsAtLeast) { actual_major_version = $$extractMajorVersion($$1) From 3924d3deac33827f924f9d51e17f09d3e1ece76f Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 24 Sep 2017 22:16:47 +0300 Subject: [PATCH 05/11] UnitTest: Fix build with clang 3.9.1 llvm-config-3.9 --cxxflags has -g1 which is substituted by 1. Change-Id: I626f3f15c659f7de030c08883b5b739b1d636ada Reviewed-by: Marco Bubke --- tests/unit/unittest/clang_dependency.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/unittest/clang_dependency.pri b/tests/unit/unittest/clang_dependency.pri index 354ebd0c905..bbce04a527a 100644 --- a/tests/unit/unittest/clang_dependency.pri +++ b/tests/unit/unittest/clang_dependency.pri @@ -20,7 +20,7 @@ win32 { LIBS += $$LIBTOOLING_LIBS $$LIBCLANG_LIBS QMAKE_RPATHDIR += $$LLVM_LIBDIR -LLVM_CXXFLAGS ~= s,-g, +LLVM_CXXFLAGS ~= s,-g\d?, QMAKE_CXXFLAGS += $$LLVM_CXXFLAGS } From 83210400b1967496977122fb89e8b744f4745732 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 6 Sep 2017 16:18:29 +0200 Subject: [PATCH 06/11] Benchmarks: Provide infrastructure for benchmarks ... and use it for the profiling report. Instantiate a Utils::Benchmarker(...) to report a data point (which will be created at destruction time, reporting the live-time of the object). Alternatively you can use Utils::Benchmarker::report(...) to record your data point. Independent of how you create a datapoint, it will be reported through the qtc.benchmark logging category and can get pushed to a database from a script parsing creator's output. Note: The plugin-loading uses the existing -profiling infrastructure, so you need to start Creator with -profile to see data points. Change-Id: I18e6b84137d0f49ee5e12e7c3d75323005ce5a29 Reviewed-by: Christian Stenger --- src/libs/extensionsystem/pluginmanager.cpp | 9 +++ src/libs/utils/benchmarker.cpp | 67 ++++++++++++++++++++++ src/libs/utils/benchmarker.h | 53 +++++++++++++++++ src/libs/utils/utils-lib.pri | 5 +- src/libs/utils/utils.qbs | 2 + 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/libs/utils/benchmarker.cpp create mode 100644 src/libs/utils/benchmarker.h diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index 1266e944334..fd554be5857 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -1559,6 +1560,13 @@ void PluginManagerPrivate::profilingReport(const char *what, const PluginSpec *s qDebug("%-22s %-22s %8dms (%8dms)", what, qPrintable(spec->name()), absoluteElapsedMS, elapsedMS); else qDebug("%-45s %8dms (%8dms)", what, absoluteElapsedMS, elapsedMS); + if (what && *what == '<') { + QString tc; + if (spec) + tc = spec->name() + '_'; + tc += QString::fromUtf8(QByteArray(what + 1)); + Utils::Benchmarker::report("loadPlugins", tc, elapsedMS); + } } } @@ -1579,6 +1587,7 @@ void PluginManagerPrivate::profilingSummary() const qDebug("%-22s %8dms ( %5.2f%% )", qPrintable(it.value()->name()), it.key(), 100.0 * it.key() / total); qDebug("Total: %8dms", total); + Utils::Benchmarker::report("loadPlugins", "Total", total); } } diff --git a/src/libs/utils/benchmarker.cpp b/src/libs/utils/benchmarker.cpp new file mode 100644 index 00000000000..61f4f37d190 --- /dev/null +++ b/src/libs/utils/benchmarker.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "benchmarker.h" + +#include + +static Q_LOGGING_CATEGORY(benchmarksLog, "qtc.benchmark"); + +namespace Utils { + +Benchmarker::Benchmarker(const QString &testsuite, const QString &testcase, + const QString &tagData) : + m_tagData(tagData), + m_testsuite(testsuite), + m_testcase(testcase) +{ + m_timer.start(); +} + +Benchmarker::~Benchmarker() +{ + if (m_timer.isValid()) + report(m_timer.elapsed()); +} + +void Benchmarker::report(qint64 ms) +{ + m_timer.invalidate(); + report(m_testsuite, m_testcase, ms, m_tagData); +} + +void Benchmarker::report(const QString &testsuite, const QString &testcase, qint64 ms, + const QString &tags) +{ + QString t = "unit=ms"; + if (!tags.isEmpty()) + t += "," + tags; + + qCDebug(benchmarksLog, "%s::%s: %lld { %s }", + testsuite.toUtf8().data(), testcase.toUtf8().data(), ms, t.toUtf8().data()); +} + + +} // namespace Utils diff --git a/src/libs/utils/benchmarker.h b/src/libs/utils/benchmarker.h new file mode 100644 index 00000000000..bcff6d341c7 --- /dev/null +++ b/src/libs/utils/benchmarker.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "utils_global.h" + +#include +#include + +namespace Utils { + +class QTCREATOR_UTILS_EXPORT Benchmarker +{ +public: + Benchmarker(const QString &testsuite, const QString &testcase, + const QString &tags = QString()); + ~Benchmarker(); + + void report(qint64 ms); + static void report(const QString &testsuite, const QString &testcase, qint64 ms, + const QString &tags = QString()); + +private: + QElapsedTimer m_timer; + QString m_tagData; + QString m_testsuite; + QString m_testcase; +}; + +} // namespace Utils diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index c181a8e25ae..822d247e903 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -21,7 +21,9 @@ win32: LIBS += -luser32 -lshell32 # PortsGatherer win32: LIBS += -liphlpapi -lws2_32 -SOURCES += $$PWD/environment.cpp \ +SOURCES += \ + $$PWD/benchmarker.cpp \ + $$PWD/environment.cpp \ $$PWD/environmentmodel.cpp \ $$PWD/environmentdialog.cpp \ $$PWD/qtcprocess.cpp \ @@ -122,6 +124,7 @@ win32:SOURCES += $$PWD/consoleprocess_win.cpp else:SOURCES += $$PWD/consoleprocess_unix.cpp HEADERS += \ + $$PWD/benchmarker.h \ $$PWD/environment.h \ $$PWD/environmentmodel.h \ $$PWD/environmentdialog.h \ diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 56b1b31e608..d761c668900 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -48,6 +48,8 @@ Project { "appmainwindow.h", "basetreeview.cpp", "basetreeview.h", + "benchmarker.cpp", + "benchmarker.h", "bracematcher.cpp", "bracematcher.h", "buildablehelperlibrary.cpp", From 64a14019195773a3218c9b317bebc6a7d3be7098 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 22 Sep 2017 17:11:54 +0200 Subject: [PATCH 07/11] QmlDesigner: Fix notifications In case we did a mapping to PropertyChanges we notified the change on the ProperyChange instead of the target item. Change-Id: I876a998589cddd16e4968fd1dd0eebaab42863dc Reviewed-by: Tim Jenssen --- .../qmldesigner/designercore/instances/nodeinstanceview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index b7acd55c458..caad75eaea1 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -651,13 +651,13 @@ void NodeInstanceView::updateChildren(const NodeAbstractProperty &newPropertyPar void setXValue(NodeInstance &instance, const VariantProperty &variantProperty, QMultiHash &informationChangeHash) { instance.setX(variantProperty.value().toDouble()); - informationChangeHash.insert(variantProperty.parentModelNode(), Transform); + informationChangeHash.insert(instance.modelNode(), Transform); } void setYValue(NodeInstance &instance, const VariantProperty &variantProperty, QMultiHash &informationChangeHash) { instance.setY(variantProperty.value().toDouble()); - informationChangeHash.insert(variantProperty.parentModelNode(), Transform); + informationChangeHash.insert(instance.modelNode(), Transform); } From 34a4c60da37766806e004458c6d3f9c0e2cec917 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 22 Sep 2017 17:36:04 +0200 Subject: [PATCH 08/11] QmlDesigner: Ignore property without node location This means that the node was created during this transaction and the correct value will be set when creating the node. Change-Id: Ie70df3c9156f8958c099bd49551f3dc42d815e25 Reviewed-by: Tim Jenssen --- src/plugins/qmldesigner/designercore/model/rewriteaction.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp b/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp index 6779b5cc3de..154a80f760b 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriteaction.cpp @@ -181,6 +181,8 @@ bool ChangePropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNode { if (m_sheduledInHierarchy) { const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode()); + if (nodeLocation < 0) + return true; bool result = false; if (m_property.isDefaultProperty()) { From ad62b1e02251a3303430fbe8f697106430acbdef Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Fri, 22 Sep 2017 16:36:26 +0200 Subject: [PATCH 09/11] EditorManager: move all openEditor functions to one place Remove code duplication for openEditor function that gets search result as a parameter. Change-Id: I3eb1c41b8a0fda3b2e8a4929cef1d5924295f1f5 Reviewed-by: Eike Ziller --- .../clangrefactoring/qtcreatorsearch.cpp | 11 +++------- .../clangrefactoring/qtcreatorsearch.h | 5 +---- .../editormanager/editormanager.cpp | 12 +++++++++++ .../coreplugin/editormanager/editormanager.h | 2 ++ src/plugins/cpptools/cppfindreferences.cpp | 20 ++++++------------- src/plugins/cpptools/cppfindreferences.h | 1 - .../qmljseditor/qmljsfindreferences.cpp | 15 +++----------- src/plugins/qmljseditor/qmljsfindreferences.h | 1 - src/plugins/texteditor/basefilefind.cpp | 12 ++--------- 9 files changed, 29 insertions(+), 50 deletions(-) diff --git a/src/plugins/clangrefactoring/qtcreatorsearch.cpp b/src/plugins/clangrefactoring/qtcreatorsearch.cpp index 61f317c22a3..d5802c9c971 100644 --- a/src/plugins/clangrefactoring/qtcreatorsearch.cpp +++ b/src/plugins/clangrefactoring/qtcreatorsearch.cpp @@ -50,7 +50,9 @@ std::unique_ptr QtCreatorSearch::startNewSearch(const QString &sea QObject::connect(searchResult, &Core::SearchResult::activated, - &QtCreatorSearch::openEditor); + [](const Core::SearchResultItem& item) { + Core::EditorManager::openEditorAtSearchResult(item); + }); auto searchHandle = std::unique_ptr(new QtCreatorSearchHandle(searchResult)); @@ -61,11 +63,4 @@ std::unique_ptr QtCreatorSearch::startNewSearch(const QString &sea return searchHandle; } -void QtCreatorSearch::openEditor(const Core::SearchResultItem &item) -{ - Core::EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()), - item.mainRange.begin.line, - item.mainRange.begin.column); -} - } // namespace ClangRefactoring diff --git a/src/plugins/clangrefactoring/qtcreatorsearch.h b/src/plugins/clangrefactoring/qtcreatorsearch.h index 68d884a1804..ebef545d90d 100644 --- a/src/plugins/clangrefactoring/qtcreatorsearch.h +++ b/src/plugins/clangrefactoring/qtcreatorsearch.h @@ -41,10 +41,7 @@ public: QtCreatorSearch(Core::SearchResultWindow &searchResultWindow); std::unique_ptr startNewSearch(const QString &searchLabel, - const QString &searchTerm); - -private: - static void openEditor(const Core::SearchResultItem &item); + const QString &searchTerm); private: Core::SearchResultWindow &searchResultWindow; diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index e6a56ab9b6e..261e3560d69 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -2646,6 +2647,17 @@ IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int colu fileName, line, column, editorId, flags, newEditor); } +void EditorManager::openEditorAtSearchResult(const SearchResultItem &item, OpenEditorFlags flags) +{ + if (item.path.empty()) { + openEditor(QDir::fromNativeSeparators(item.text), Id(), flags); + return; + } + + openEditorAt(QDir::fromNativeSeparators(item.path.first()), item.mainRange.begin.line, + item.mainRange.begin.column, Id(), flags); +} + EditorManager::FilePathInfo EditorManager::splitLineAndColumnNumber(const QString &fullFilePath) { // :10:2 GCC/Clang-style diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 5c8c37113d8..7c28c27eb70 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -50,6 +50,7 @@ class IMode; class IVersionControl; class EditorToolBar; +class SearchResultItem; enum MakeWritableResult { OpenedWithVersionControl, @@ -114,6 +115,7 @@ public: static IEditor *openEditorAt(const QString &fileName, int line, int column = 0, Id editorId = Id(), OpenEditorFlags flags = NoFlags, bool *newEditor = 0); + static void openEditorAtSearchResult(const SearchResultItem &item, OpenEditorFlags flags = NoFlags); static IEditor *openEditorWithContents(Id editorId, QString *titlePattern = 0, const QByteArray &contents = QByteArray(), const QString &uniqueId = QString(), diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 9e521ac46ff..fa3f48a04aa 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -370,7 +370,9 @@ void CppFindReferences::findAll_helper(SearchResult *search, Symbol *symbol, return; } connect(search, &SearchResult::activated, - this, &CppFindReferences::openEditor); + [](const SearchResultItem& item) { + Core::EditorManager::openEditorAtSearchResult(item); + }); SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus); const WorkingCopy workingCopy = m_modelManager->workingCopy(); @@ -589,18 +591,6 @@ static void searchFinished(SearchResult *search, QFutureWatcher *watcher) watcher->deleteLater(); } -void CppFindReferences::openEditor(const SearchResultItem &item) -{ - if (item.path.size() > 0) { - EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()), - item.mainRange.begin.line, - item.mainRange.begin.column); - } else { - EditorManager::openEditor(QDir::fromNativeSeparators(item.text)); - } -} - - namespace { class FindMacroUsesInFile: public std::unary_function > @@ -728,7 +718,9 @@ void CppFindReferences::findMacroUses(const CPlusPlus::Macro ¯o, const QStri SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus); connect(search, &SearchResult::activated, - this, &CppFindReferences::openEditor); + [](const Core::SearchResultItem& item) { + Core::EditorManager::openEditorAtSearchResult(item); + }); const Snapshot snapshot = m_modelManager->snapshot(); const WorkingCopy workingCopy = m_modelManager->workingCopy(); diff --git a/src/plugins/cpptools/cppfindreferences.h b/src/plugins/cpptools/cppfindreferences.h index 422eedb0c9e..2dece068830 100644 --- a/src/plugins/cpptools/cppfindreferences.h +++ b/src/plugins/cpptools/cppfindreferences.h @@ -77,7 +77,6 @@ public: void renameMacroUses(const CPlusPlus::Macro ¯o, const QString &replacement = QString()); private: - void openEditor(const Core::SearchResultItem &item); void onReplaceButtonClicked(const QString &text, const QList &items, bool preserveCase); void searchAgain(); diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index 2e8bb9e407c..7806d9c385e 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -959,7 +959,9 @@ void FindReferences::displayResults(int first, int last) this, &FindReferences::onReplaceButtonClicked); } connect(m_currentSearch.data(), &SearchResult::activated, - this, &FindReferences::openEditor); + [](const Core::SearchResultItem& item) { + Core::EditorManager::openEditorAtSearchResult(item); + }); connect(m_currentSearch.data(), &SearchResult::cancelled, this, &FindReferences::cancel); connect(m_currentSearch.data(), &SearchResult::paused, this, &FindReferences::setPaused); SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch | IOutputPane::WithFocus)); @@ -1005,17 +1007,6 @@ void FindReferences::setPaused(bool paused) m_watcher.setPaused(paused); } -void FindReferences::openEditor(const SearchResultItem &item) -{ - if (item.path.size() > 0) { - EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()), - item.mainRange.begin.line, - item.mainRange.begin.column); - } else { - EditorManager::openEditor(QDir::fromNativeSeparators(item.text)); - } -} - void FindReferences::onReplaceButtonClicked(const QString &text, const QList &items, bool preserveCase) { const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase); diff --git a/src/plugins/qmljseditor/qmljsfindreferences.h b/src/plugins/qmljseditor/qmljsfindreferences.h index e7075b47993..0de23bd7223 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.h +++ b/src/plugins/qmljseditor/qmljsfindreferences.h @@ -82,7 +82,6 @@ private: void searchFinished(); void cancel(); void setPaused(bool paused); - void openEditor(const Core::SearchResultItem &item); void onReplaceButtonClicked(const QString &text, const QList &items, bool preserveCase); QPointer m_currentSearch; diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index 7486cfd0d42..dcb33b50ae3 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -448,16 +448,8 @@ void BaseFileFind::openEditor(const SearchResultItem &item) FileFindParameters parameters = result->userData().value(); IEditor *openedEditor = d->m_searchEngines[parameters.searchEngineIndex]->openEditor(item, parameters); - if (!openedEditor) { - if (item.path.size() > 0) { - openedEditor = EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()), - item.mainRange.begin.line, - item.mainRange.begin.column, Id(), - EditorManager::DoNotSwitchToDesignMode); - } else { - openedEditor = EditorManager::openEditor(QDir::fromNativeSeparators(item.text)); - } - } + if (!openedEditor) + EditorManager::openEditorAtSearchResult(item, EditorManager::DoNotSwitchToDesignMode); if (d->m_currentFindSupport) d->m_currentFindSupport->clearHighlights(); d->m_currentFindSupport = 0; From 0521b7e1effdad551f5c1d31495d44b4c13cff92 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 19 Sep 2017 14:10:43 +0200 Subject: [PATCH 10/11] QmlDesigner: Implement model support for timeline This patch implements the basic support for the timelien in the model. The type names will most likely change. Change-Id: Ib3161d480468cf88e9f155130f7cba70451a8c7e Reviewed-by: Tim Jenssen --- .../designercore/designercore-lib.pri | 8 +- .../designercore/include/abstractview.h | 7 + .../designercore/include/qmlobjectnode.h | 3 + .../designercore/include/qmlstate.h | 1 - .../include/qmltimelinekeyframes.h | 65 +++++++ .../designercore/include/qmltimelinemutator.h | 62 +++++++ .../instances/nodeinstanceview.cpp | 17 ++ .../designercore/model/abstractview.cpp | 31 ++++ .../qmldesigner/designercore/model/model.cpp | 33 ++++ .../qmldesigner/designercore/model/model_p.h | 3 + .../designercore/model/qmlobjectnode.cpp | 45 +++++ .../model/qmltimelinekeyframes.cpp | 147 +++++++++++++++ .../designercore/model/qmltimelinemutator.cpp | 167 ++++++++++++++++++ src/plugins/qmldesigner/qmldesignerplugin.qbs | 4 + 14 files changed, 590 insertions(+), 3 deletions(-) create mode 100644 src/plugins/qmldesigner/designercore/include/qmltimelinekeyframes.h create mode 100644 src/plugins/qmldesigner/designercore/include/qmltimelinemutator.h create mode 100644 src/plugins/qmldesigner/designercore/model/qmltimelinekeyframes.cpp create mode 100644 src/plugins/qmldesigner/designercore/model/qmltimelinemutator.cpp diff --git a/src/plugins/qmldesigner/designercore/designercore-lib.pri b/src/plugins/qmldesigner/designercore/designercore-lib.pri index 2acf4922057..b7f36ac47c9 100644 --- a/src/plugins/qmldesigner/designercore/designercore-lib.pri +++ b/src/plugins/qmldesigner/designercore/designercore-lib.pri @@ -78,7 +78,9 @@ SOURCES += $$PWD/model/abstractview.cpp \ $$PWD/model/signalhandlerproperty.cpp \ $$PWD/model/internalsignalhandlerproperty.cpp \ $$PWD/model/anchorline.cpp \ - $$PWD/instances/puppetdialog.cpp + $$PWD/instances/puppetdialog.cpp \ + $$PWD/model/qmltimelinemutator.cpp \ + $$PWD/model/qmltimelinekeyframes.cpp HEADERS += $$PWD/include/qmldesignercorelib_global.h \ $$PWD/include/abstractview.h \ @@ -152,7 +154,9 @@ HEADERS += $$PWD/include/qmldesignercorelib_global.h \ $$PWD/include/signalhandlerproperty.h \ $$PWD/model/internalsignalhandlerproperty.h \ $$PWD/include/anchorline.h \ - $$PWD/instances/puppetdialog.h + $$PWD/instances/puppetdialog.h \ + $$PWD/include/qmltimelinemutator.h \ + $$PWD/include/qmltimelinekeyframes.h \ FORMS += \ $$PWD/instances/puppetdialog.ui diff --git a/src/plugins/qmldesigner/designercore/include/abstractview.h b/src/plugins/qmldesigner/designercore/include/abstractview.h index 6987d747df4..8b085f91371 100644 --- a/src/plugins/qmldesigner/designercore/include/abstractview.h +++ b/src/plugins/qmldesigner/designercore/include/abstractview.h @@ -55,6 +55,7 @@ namespace QmlDesigner { class NodeInstanceView; class RewriterView; class QmlModelState; +class QmlTimelineMutator; enum DesignerWidgetFlags { DisableOnError, @@ -232,6 +233,8 @@ public: virtual void documentMessagesChanged(const QList &errors, const QList &warnings); + virtual void currentTimelineChanged(const ModelNode &node); + void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion); NodeInstanceView *nodeInstanceView() const; @@ -240,6 +243,7 @@ public: void setCurrentStateNode(const ModelNode &node); ModelNode currentStateNode() const; QmlModelState currentState() const; + QmlTimelineMutator currentTimeline() const; int majorQtQuickVersion() const; int minorQtQuickVersion() const; @@ -253,6 +257,9 @@ public: virtual QString contextHelpId() const; + void activateTimelineRecording(const ModelNode &mutator); + void deactivateTimelineRecording(); + protected: void setModel(Model * model); void removeModel(); diff --git a/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h b/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h index 3e9d5ff7e4e..e5d58910767 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h +++ b/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h @@ -28,6 +28,7 @@ #include #include "qmlmodelnodefacade.h" #include "qmlstate.h" +#include "qmltimelinemutator.h" #include "qmlchangeset.h" #include @@ -63,6 +64,7 @@ public: QString validId(); QmlModelState currentState() const; + QmlTimelineMutator currentTimeline() const; void setVariantProperty(const PropertyName &name, const QVariant &value); void setBindingProperty(const PropertyName &name, const QString &expression); NodeAbstractProperty nodeAbstractProperty(const PropertyName &name) const; @@ -83,6 +85,7 @@ public: QString stripedTranslatableText(const PropertyName &name) const; QString expression(const PropertyName &name) const; bool isInBaseState() const; + bool timelineIsActive() const; QmlPropertyChanges propertyChangeForCurrentState() const; virtual bool instanceCanReparent() const; diff --git a/src/plugins/qmldesigner/designercore/include/qmlstate.h b/src/plugins/qmldesigner/designercore/include/qmlstate.h index 4ee216f84f2..ac6dd39b577 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlstate.h +++ b/src/plugins/qmldesigner/designercore/include/qmlstate.h @@ -72,7 +72,6 @@ public: protected: void addChangeSetIfNotExists(const ModelNode &node); static QmlModelState createBaseState(const AbstractView *view); - }; } //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/include/qmltimelinekeyframes.h b/src/plugins/qmldesigner/designercore/include/qmltimelinekeyframes.h new file mode 100644 index 00000000000..2969d4dd9a9 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/include/qmltimelinekeyframes.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include "qmlmodelnodefacade.h" +#include "qmlchangeset.h" + +namespace QmlDesigner { + +class AbstractViewAbstractVieweGroup; +class QmlObjectNode; + +class QMLDESIGNERCORE_EXPORT QmlTimelineFrames : public QmlModelNodeFacade +{ + +public: + QmlTimelineFrames(); + QmlTimelineFrames(const ModelNode &modelNode); + + bool isValid() const; + static bool isValidQmlTimelineFrames(const ModelNode &modelNode); + void destroy(); + + ModelNode target() const; + void setTarget(const ModelNode &target); + + PropertyName propertyName() const; + void setPropertyName(const PropertyName &propertyName); + + void setValue(const QVariant &value, qreal frame); + QVariant value(qreal frame) const; + + qreal currentFrame() const; + + bool hasKeyframe(qreal frame); + + static bool isValidKeyframe(const ModelNode &node); + static QmlTimelineFrames keyframesForKeyframe(const ModelNode &node); +}; + +} //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/include/qmltimelinemutator.h b/src/plugins/qmldesigner/designercore/include/qmltimelinemutator.h new file mode 100644 index 00000000000..44327fcb25c --- /dev/null +++ b/src/plugins/qmldesigner/designercore/include/qmltimelinemutator.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include "qmlmodelnodefacade.h" + +namespace QmlDesigner { + +class AbstractViewAbstractVieweGroup; +class QmlObjectNode; +class QmlModelStateGroup; +class QmlTimelineFrames; + +class QMLDESIGNERCORE_EXPORT QmlTimelineMutator : public QmlModelNodeFacade +{ + +public: + QmlTimelineMutator(); + QmlTimelineMutator(const ModelNode &modelNode); + + bool isValid() const; + static bool isValidQmlTimelineMutator(const ModelNode &modelNode); + void destroy(); + + QmlTimelineFrames timelineFrames(const ModelNode &modelNode, const PropertyName &propertyName); + bool hasTimeline(const ModelNode &modelNode, const PropertyName &propertyName); + + qreal startFrame() const; + qreal endFrame() const; + qreal currentFrame() const; + +private: + void addFramesIfNotExists(const ModelNode &node, const PropertyName &propertyName); + bool hasFrames(const ModelNode &node, const PropertyName &propertyName) const; + QList frames() const; +}; + +} //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index caad75eaea1..bbb34e906a6 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -43,6 +43,8 @@ #include "nodelistproperty.h" #include "nodeproperty.h" #include "qmlchangeset.h" +#include "qmltimelinemutator.h" +#include "qmltimelinekeyframes.h" #include "createscenecommand.h" #include "createinstancescommand.h" @@ -690,6 +692,21 @@ void NodeInstanceView::updatePosition(const QList &propertyList NodeInstance instance = instanceForModelNode(modelNode); setYValue(instance, variantProperty, informationChangeHash); } + } else if (currentTimeline().isValid() + && variantProperty.name() == "value" + && QmlTimelineFrames::isValidKeyframe(variantProperty.parentModelNode())) { + + QmlTimelineFrames frames = QmlTimelineFrames::keyframesForKeyframe(variantProperty.parentModelNode()); + + if (frames.isValid() && frames.propertyName() == "x" && frames.target().isValid()) { + + NodeInstance instance = instanceForModelNode(frames.target()); + setXValue(instance, variantProperty, informationChangeHash); + } else if (frames.isValid() && frames.propertyName() == "y" && frames.target().isValid()) { + NodeInstance instance = instanceForModelNode(frames.target()); + setYValue(instance, variantProperty, informationChangeHash); + } + } } diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp index f8092b9c7fa..57ce5f8ddce 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp @@ -30,6 +30,7 @@ #include "internalnode_p.h" #include "nodeinstanceview.h" #include +#include #ifndef QMLDESIGNER_TEST #include @@ -359,6 +360,11 @@ void AbstractView::documentMessagesChanged(const QList &/*error { } +void AbstractView::currentTimelineChanged(const ModelNode & /*node*/) +{ + +} + QList AbstractView::toModelNodeList(const QList &nodeList) const { return QmlDesigner::toModelNodeList(nodeList, const_cast(this)); @@ -565,6 +571,21 @@ QString AbstractView::contextHelpId() const return helpId; } +void AbstractView::activateTimelineRecording(const ModelNode &mutator) +{ + Internal::WriteLocker locker(m_model.data()); + if (model()) + model()->d->notifyCurrentTimelineChanged(mutator); + +} + +void AbstractView::deactivateTimelineRecording() +{ + Internal::WriteLocker locker(m_model.data()); + if (model()) + model()->d->notifyCurrentTimelineChanged(ModelNode()); +} + QList AbstractView::allModelNodes() const { return toModelNodeList(model()->d->allNodes()); @@ -688,6 +709,16 @@ QmlModelState AbstractView::currentState() const return QmlModelState(currentStateNode()); } +QmlTimelineMutator AbstractView::currentTimeline() const +{ + if (model()) + return QmlTimelineMutator(ModelNode(m_model.data()->d->currentTimelineNode(), + m_model.data(), + const_cast(this))); + + return QmlTimelineMutator(); +} + static int getMinorVersionFromImport(const Model *model) { foreach (const Import &import, model->imports()) { diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index 011a5271d3d..561910006ca 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -85,6 +85,7 @@ ModelPrivate::ModelPrivate(Model *model) : { m_rootInternalNode = createNode("QtQuick.Item", 1, 0, PropertyListType(), PropertyListType(), QString(), ModelNode::NodeWithoutSource,true); m_currentStateNode = m_rootInternalNode; + m_currentTimelineMutatorNode = m_rootInternalNode; } ModelPrivate::~ModelPrivate() @@ -641,6 +642,33 @@ void ModelPrivate::notifyCurrentStateChanged(const ModelNode &node) resetModelByRewriter(description); } +void ModelPrivate::notifyCurrentTimelineChanged(const ModelNode &node) +{ + bool resetModel = false; + QString description; + + m_currentTimelineMutatorNode = node.internalNode(); + + try { + if (rewriterView()) + rewriterView()->currentTimelineChanged(ModelNode(node.internalNode(), model(), rewriterView())); + } catch (const RewritingException &e) { + description = e.description(); + resetModel = true; + } + + for (const QPointer &view : m_viewList) { + Q_ASSERT(view != 0); + view->currentTimelineChanged(ModelNode(node.internalNode(), model(), view.data())); + } + + if (nodeInstanceView()) + nodeInstanceView()->currentTimelineChanged(ModelNode(node.internalNode(), model(), nodeInstanceView())); + + if (resetModel) + resetModelByRewriter(description); +} + void ModelPrivate::notifyRewriterBeginTransaction() { bool resetModel = false; @@ -1707,6 +1735,11 @@ NodeInstanceView *ModelPrivate::nodeInstanceView() const return m_nodeInstanceView.data(); } +InternalNodePointer ModelPrivate::currentTimelineNode() const +{ + return m_currentTimelineMutatorNode; +} + InternalNodePointer ModelPrivate::nodeForId(const QString &id) const { return m_idNodeHash.value(id); diff --git a/src/plugins/qmldesigner/designercore/model/model_p.h b/src/plugins/qmldesigner/designercore/model/model_p.h index 882ea0599d9..f67e59aed1b 100644 --- a/src/plugins/qmldesigner/designercore/model/model_p.h +++ b/src/plugins/qmldesigner/designercore/model/model_p.h @@ -157,6 +157,7 @@ public: void notifyInstanceToken(const QString &token, int number, const QVector &nodeVector); void notifyCurrentStateChanged(const ModelNode &node); + void notifyCurrentTimelineChanged(const ModelNode &node); void setDocumentMessages(const QList &errors, const QList &warnings); @@ -226,6 +227,7 @@ public: NodeInstanceView *nodeInstanceView() const; InternalNodePointer currentStateNode() const; + InternalNodePointer currentTimelineNode() const; private: //functions void removePropertyWithoutNotification(const InternalPropertyPointer &property); @@ -249,6 +251,7 @@ private: QSet m_nodeSet; InternalNodePointer m_currentStateNode; InternalNodePointer m_rootInternalNode; + InternalNodePointer m_currentTimelineMutatorNode; QUrl m_fileUrl; QPointer m_rewriterView; QPointer m_nodeInstanceView; diff --git a/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp index 4c58c15dc1f..218601d4099 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp @@ -26,6 +26,7 @@ #include "qmlobjectnode.h" #include "qmlitemnode.h" #include "qmlstate.h" +#include "qmltimelinekeyframes.h" #include "variantproperty.h" #include "nodeproperty.h" #include @@ -48,6 +49,19 @@ void QmlObjectNode::setVariantProperty(const PropertyName &name, const QVariant if (!isValid()) throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); + if (timelineIsActive()) { + modelNode().validId(); + + QmlTimelineFrames timelineFrames(currentTimeline().timelineFrames(modelNode(), name)); + + Q_ASSERT(timelineFrames.isValid()); + + qreal frame = currentTimeline().modelNode().auxiliaryData("currentFrame@NodeInstance").toReal(); + timelineFrames.setValue(value, frame); + + return; + } + if (isInBaseState()) { modelNode().variantProperty(name).setValue(value); //basestate } else { @@ -83,6 +97,14 @@ QmlModelState QmlObjectNode::currentState() const return QmlModelState(); } +QmlTimelineMutator QmlObjectNode::currentTimeline() const +{ + if (isValid()) + return view()->currentTimeline(); + else + return QmlTimelineMutator(); +} + bool QmlObjectNode::isRootModelNode() const { return modelNode().isRootNode(); @@ -161,6 +183,9 @@ bool QmlObjectNode::propertyAffectedByCurrentState(const PropertyName &name) con if (currentState().isBaseState()) return modelNode().hasProperty(name); + if (timelineIsActive() && currentTimeline().hasTimeline(modelNode(), name)) + return true; + if (!currentState().hasPropertyChanges(modelNode())) return false; @@ -172,6 +197,21 @@ QVariant QmlObjectNode::modelValue(const PropertyName &name) const if (!isValid()) throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); + if (timelineIsActive() && currentTimeline().hasTimeline(modelNode(), name)) { + QmlTimelineFrames timelineFrames(currentTimeline().timelineFrames(modelNode(), name)); + + Q_ASSERT(timelineFrames.isValid()); + + qreal frame = currentTimeline().modelNode().auxiliaryData("currentFrame@NodeInstance").toReal(); + + QVariant value = timelineFrames.value(frame); + + if (!value.isValid()) //interpolation is not done in the model + value = instanceValue(name); + + return value; + } + if (currentState().isBaseState()) return modelNode().variantProperty(name).value(); @@ -239,6 +279,11 @@ bool QmlObjectNode::isInBaseState() const return currentState().isBaseState(); } +bool QmlObjectNode::timelineIsActive() const +{ + return currentTimeline().isValid(); +} + bool QmlObjectNode::instanceCanReparent() const { return isInBaseState(); diff --git a/src/plugins/qmldesigner/designercore/model/qmltimelinekeyframes.cpp b/src/plugins/qmldesigner/designercore/model/qmltimelinekeyframes.cpp new file mode 100644 index 00000000000..959f2ea3f66 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/model/qmltimelinekeyframes.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "qmltimelinekeyframes.h" +#include "abstractview.h" +#include +#include +#include +#include +#include "bindingproperty.h" +#include "qmlitemnode.h" + +#include + +namespace QmlDesigner { + +QmlTimelineFrames::QmlTimelineFrames() +{ + +} + +QmlTimelineFrames::QmlTimelineFrames(const ModelNode &modelNode) : QmlModelNodeFacade(modelNode) +{ + +} + +bool QmlTimelineFrames::isValid() const +{ + return isValidQmlTimelineFrames(modelNode()); +} + +bool QmlTimelineFrames::isValidQmlTimelineFrames(const ModelNode &modelNode) +{ + return isValidQmlModelNodeFacade(modelNode) + && modelNode.metaInfo().isValid() + && modelNode.metaInfo().isSubclassOf("QtQuick.Timeline.Keyframes"); +} + +void QmlTimelineFrames::destroy() +{ + Q_ASSERT(isValid()); + modelNode().destroy(); +} + +ModelNode QmlTimelineFrames::target() const +{ + if (modelNode().property("target").isBindingProperty()) + return modelNode().bindingProperty("target").resolveToModelNode(); + else + return ModelNode(); //exception? +} + +void QmlTimelineFrames::setTarget(const ModelNode &target) +{ + modelNode().bindingProperty("target").setExpression(target.id()); +} + + +PropertyName QmlTimelineFrames::propertyName() const +{ + return modelNode().variantProperty("property").value().toString().toUtf8(); +} + +void QmlTimelineFrames::setPropertyName(const PropertyName &propertyName) +{ + modelNode().variantProperty("property").setValue(QString::fromUtf8(propertyName)); +} + +void QmlTimelineFrames::setValue(const QVariant &value, qreal currentFrame) +{ + + for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) { + if (qFuzzyCompare(childNode.variantProperty("frame").value().toReal(), currentFrame)) { + childNode.variantProperty("value").setValue(value); + return; + } + } + + const QList > propertyPairList{{PropertyName("frame"), QVariant(currentFrame)}, + {PropertyName("value"), value}}; + + ModelNode frame = modelNode().view()->createModelNode("QtQuick.Timeline.Keyframe", 1, 0, propertyPairList); + modelNode().defaultNodeListProperty().reparentHere(frame); +} + +QVariant QmlTimelineFrames::value(qreal frame) const +{ + for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) { + if (qFuzzyCompare(childNode.variantProperty("frame").value().toReal(), frame)) { + return childNode.variantProperty("value").value(); + } + } + + return QVariant(); +} + +bool QmlTimelineFrames::hasKeyframe(qreal frame) +{ + for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) { + if (qFuzzyCompare(childNode.variantProperty("frame").value().toReal(), frame)) + return true; + } + + return false; +} + +bool QmlTimelineFrames::isValidKeyframe(const ModelNode &node) +{ + return isValidQmlModelNodeFacade(node) + && node.metaInfo().isValid() + && node.metaInfo().isSubclassOf("QtQuick.Timeline.Keyframe"); +} + +QmlTimelineFrames QmlTimelineFrames::keyframesForKeyframe(const ModelNode &node) +{ + if (isValidKeyframe(node) && node.hasParentProperty()) { + const QmlTimelineFrames timeline(node.parentProperty().parentModelNode()); + if (timeline.isValid()) + return timeline; + } + + return QmlTimelineFrames(); +} + +} // QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/qmltimelinemutator.cpp b/src/plugins/qmldesigner/designercore/model/qmltimelinemutator.cpp new file mode 100644 index 00000000000..7e22a615650 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/model/qmltimelinemutator.cpp @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "qmltimelinemutator.h" +#include "qmltimelinekeyframes.h" +#include "abstractview.h" +#include +#include +#include +#include +#include +#include "bindingproperty.h" +#include "qmlitemnode.h" + +#include + +namespace QmlDesigner { + +QmlTimelineMutator::QmlTimelineMutator() +{ + +} + +QmlTimelineMutator::QmlTimelineMutator(const ModelNode &modelNode) : QmlModelNodeFacade(modelNode) +{ + +} + +bool QmlTimelineMutator::isValid() const +{ + return isValidQmlTimelineMutator(modelNode()); +} + +bool QmlTimelineMutator::isValidQmlTimelineMutator(const ModelNode &modelNode) +{ + return isValidQmlModelNodeFacade(modelNode) + && modelNode.metaInfo().isValid() + && modelNode.metaInfo().isSubclassOf("QtQuick.Timeline.KeyframeMutator"); +} + +void QmlTimelineMutator::destroy() +{ + Q_ASSERT(isValid()); + modelNode().destroy(); +} + +QmlTimelineFrames QmlTimelineMutator::timelineFrames(const ModelNode &node, const PropertyName &propertyName) +{ + if (isValid()) { + addFramesIfNotExists(node, propertyName); + for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) { + if (QmlTimelineFrames::isValidQmlTimelineFrames(childNode)) { + const QmlTimelineFrames frames(childNode); + + if (frames.target().isValid() + && frames.target() == node + && frames.propertyName() == propertyName) + return frames; + } + } + } + + return QmlTimelineFrames(); //not found +} + +bool QmlTimelineMutator::hasTimeline(const ModelNode &node, const PropertyName &propertyName) +{ + if (isValid()) { + for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) { + if (QmlTimelineFrames::isValidQmlTimelineFrames(childNode)) { + const QmlTimelineFrames frames(childNode); + + if (frames.target().isValid() + && frames.target() == node + && frames.propertyName() == propertyName) + return true; + } + } + } + return false; +} + +qreal QmlTimelineMutator::startFrame() const +{ + if (isValid()) + return QmlObjectNode(modelNode()).instanceValue("startFrame").toReal(); + return 0; +} + +qreal QmlTimelineMutator::endFrame() const +{ + if (isValid()) + return QmlObjectNode(modelNode()).instanceValue("endFrame").toReal(); + return 0; +} + +qreal QmlTimelineMutator::currentFrame() const +{ + if (isValid()) + return QmlObjectNode(modelNode()).instanceValue("currentFrame").toReal(); + return 0; +} + +void QmlTimelineMutator::addFramesIfNotExists(const ModelNode &node, const PropertyName &propertyName) +{ + if (!isValid()) + throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); + + if (!hasFrames(node, propertyName)) { + ModelNode frames = modelNode().view()->createModelNode("QtQuick.Timeline.Keyframes", 1, 0); + modelNode().defaultNodeListProperty().reparentHere(frames); + + QmlTimelineFrames(frames).setTarget(node); + QmlTimelineFrames(frames).setPropertyName(propertyName); + + Q_ASSERT(QmlTimelineFrames::isValidQmlTimelineFrames(frames)); + } +} + + +bool QmlTimelineMutator::hasFrames(const ModelNode &node, const PropertyName &propertyName) const +{ + for (const QmlTimelineFrames &frames : frames()) { + if (frames.target().isValid() + && frames.target() == node + && frames.propertyName() == propertyName) + return true; + } + + return false; +} + +QList QmlTimelineMutator::frames() const +{ + QList returnList; + + for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) { + if (QmlTimelineFrames::isValidQmlTimelineFrames(childNode)) + returnList.append(QmlTimelineFrames(childNode)); + } + + return returnList; +} + +} // QmlDesigner diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 6e88e6f101e..50ad382b1ab 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -280,6 +280,8 @@ Project { "include/subcomponentmanager.h", "include/textmodifier.h", "include/variantproperty.h", + "include/qmltimelinekeyframes.h", + "include/qmltimelinemutator.h", "instances/nodeinstance.cpp", "instances/nodeinstanceserverproxy.cpp", "instances/nodeinstanceserverproxy.h", @@ -357,6 +359,8 @@ Project { "model/texttomodelmerger.h", "model/variantproperty.cpp", "model/viewmanager.cpp", + "model/qmltimelinekeyframes.cpp", + "model/qmltimelinemutator.cpp", "pluginmanager/widgetpluginmanager.cpp", "pluginmanager/widgetpluginmanager.h", "pluginmanager/widgetpluginpath.cpp", From 5e95553c5c4e90d2432ae265375a984fec727acf Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 22 Sep 2017 17:10:55 +0200 Subject: [PATCH 11/11] QmlDesigner: Check if we are actually in a state Mapping the QmlPropertyChanges back to the item makes only sense if we are in a state. Change-Id: I47d7a8810b3f920b53bc73eb21980c8abd04c572 Reviewed-by: Thomas Hartmann --- .../qmldesigner/designercore/instances/nodeinstanceview.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index bbb34e906a6..1f972b68a70 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -43,6 +43,7 @@ #include "nodelistproperty.h" #include "nodeproperty.h" #include "qmlchangeset.h" +#include "qmlstate.h" #include "qmltimelinemutator.h" #include "qmltimelinekeyframes.h" @@ -670,7 +671,7 @@ void NodeInstanceView::updatePosition(const QList &propertyList foreach (const VariantProperty &variantProperty, propertyList) { if (variantProperty.name() == "x") { const ModelNode modelNode = variantProperty.parentModelNode(); - if (QmlPropertyChanges::isValidQmlPropertyChanges(modelNode)) { + if (!currentState().isBaseState() && QmlPropertyChanges::isValidQmlPropertyChanges(modelNode)) { ModelNode targetModelNode = QmlPropertyChanges(modelNode).target(); if (targetModelNode.isValid()) { NodeInstance instance = instanceForModelNode(targetModelNode); @@ -682,7 +683,7 @@ void NodeInstanceView::updatePosition(const QList &propertyList } } else if (variantProperty.name() == "y") { const ModelNode modelNode = variantProperty.parentModelNode(); - if (QmlPropertyChanges::isValidQmlPropertyChanges(modelNode)) { + if (!currentState().isBaseState() && QmlPropertyChanges::isValidQmlPropertyChanges(modelNode)) { ModelNode targetModelNode = QmlPropertyChanges(modelNode).target(); if (targetModelNode.isValid()) { NodeInstance instance = instanceForModelNode(targetModelNode);