From e6a184fe5c296a3e12591ff9cd9fa4c306c611eb Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 24 Jan 2019 16:39:52 +0100 Subject: [PATCH] ProjectExplorer: Merge Qbs* into DefaultDeployConfigurationFactory DefaultDeployConfigurationFactory used extra effort to not apply to the Qbs (Desktop) case, with QbsDeployConfigurationFactory plugging exactly that hole with essentially the same functionality, which is even the default of the base class. The only differences are the display name, which is dropped in this patch, and the different keys in the .user file, which are updated with this patch. Note that the display name "Qbs Install" for the DeployConfiguration stays with this patch whereas a freshly created one will get the default "Deploy Configuration" name. Change-Id: I255371d0a0688fbc6303083eb6aa20563e876264 Reviewed-by: Christian Kandeler --- .../projectexplorer/deployconfiguration.cpp | 6 --- .../projectexplorer/deployconfiguration.h | 3 -- src/plugins/projectexplorer/project.cpp | 5 --- src/plugins/projectexplorer/project.h | 1 - .../projectexplorer/userfileaccessor.cpp | 39 ++++++++++++++++ .../qbsdeployconfigurationfactory.cpp | 45 ------------------- .../qbsdeployconfigurationfactory.h | 40 ----------------- src/plugins/qbsprojectmanager/qbsproject.cpp | 5 --- src/plugins/qbsprojectmanager/qbsproject.h | 1 - .../qbsprojectmanager/qbsprojectmanager.pro | 2 - .../qbsprojectmanager/qbsprojectmanager.qbs | 2 - .../qbsprojectmanagerplugin.cpp | 2 - 12 files changed, 39 insertions(+), 112 deletions(-) delete mode 100644 src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp delete mode 100644 src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.h diff --git a/src/plugins/projectexplorer/deployconfiguration.cpp b/src/plugins/projectexplorer/deployconfiguration.cpp index 90f8b103d13..72220e9bd7a 100644 --- a/src/plugins/projectexplorer/deployconfiguration.cpp +++ b/src/plugins/projectexplorer/deployconfiguration.cpp @@ -272,10 +272,4 @@ DefaultDeployConfigurationFactory::DefaultDeployConfigurationFactory() setDefaultDisplayName(DeployConfiguration::tr("Deploy Configuration")); } -bool DefaultDeployConfigurationFactory::canHandle(Target *parent) const -{ - return DeployConfigurationFactory::canHandle(parent) - && !parent->project()->needsSpecialDeployment(); -} - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/deployconfiguration.h b/src/plugins/projectexplorer/deployconfiguration.h index fd60277ffee..143241a6ee8 100644 --- a/src/plugins/projectexplorer/deployconfiguration.h +++ b/src/plugins/projectexplorer/deployconfiguration.h @@ -119,9 +119,6 @@ class DefaultDeployConfigurationFactory : public DeployConfigurationFactory { public: DefaultDeployConfigurationFactory(); - -private: - bool canHandle(Target *parent) const override; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index b593be2e7e2..5432ae6b986 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -819,11 +819,6 @@ void Project::configureAsExampleProject(const QSet &platforms) Q_UNUSED(platforms); } -bool Project::needsSpecialDeployment() const -{ - return false; -} - bool Project::knowsAllBuildExecutables() const { return true; diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 73be1c2f359..3a7a0109332 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -158,7 +158,6 @@ public: Kit::Predicate requiredKitPredicate() const; Kit::Predicate preferredKitPredicate() const; - virtual bool needsSpecialDeployment() const; // The build system is able to report all executables that can be built, independent // of configuration. virtual bool knowsAllBuildExecutables() const; diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp index 6776484506a..f988159baaf 100644 --- a/src/plugins/projectexplorer/userfileaccessor.cpp +++ b/src/plugins/projectexplorer/userfileaccessor.cpp @@ -133,6 +133,18 @@ public: static QVariant process(const QVariant &entry, const QStringList &path); }; +// Version 20 renames "Qbs.Deploy" to "ProjectExplorer.DefaultDeployConfiguration" +// to account for the merging of the respective factories +// run configuration fields use the same key in the settings file. +class UserFileVersion20Upgrader : public VersionUpgrader +{ +public: + UserFileVersion20Upgrader() : VersionUpgrader(20, "4.9-pre1") { } + QVariantMap upgrade(const QVariantMap &map) final; + + static QVariant process(const QVariant &entry); +}; + } // namespace // @@ -293,6 +305,7 @@ UserFileAccessor::UserFileAccessor(Project *project) : addVersionUpgrader(std::make_unique()); addVersionUpgrader(std::make_unique()); addVersionUpgrader(std::make_unique()); + addVersionUpgrader(std::make_unique()); } Project *UserFileAccessor::project() const @@ -809,6 +822,32 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const QString } } +QVariantMap UserFileVersion20Upgrader::upgrade(const QVariantMap &map) +{ + return process(map).toMap(); +} + +QVariant UserFileVersion20Upgrader::process(const QVariant &entry) +{ + switch (entry.type()) { + case QVariant::List: + return Utils::transform(entry.toList(), &UserFileVersion20Upgrader::process); + case QVariant::Map: + return Utils::transform>( + entry.toMap().toStdMap(), [](const std::pair &item) { + auto res = qMakePair(item.first, item.second); + if (item.first == "ProjectExplorer.ProjectConfiguration.Id" + && item.second == "Qbs.Deploy") + res.second = QVariant("ProjectExplorer.DefaultDeployConfiguration"); + else + res.second = UserFileVersion20Upgrader::process(item.second); + return res; + }); + default: + return entry; + } +} + #if defined(WITH_TESTS) #include diff --git a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp deleted file mode 100644 index 5ad699b5b85..00000000000 --- a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp +++ /dev/null @@ -1,45 +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 "qbsdeployconfigurationfactory.h" - -#include "qbsprojectmanagerconstants.h" -#include "qbsinstallstep.h" - -#include - -namespace QbsProjectManager { -namespace Internal { - -QbsDeployConfigurationFactory::QbsDeployConfigurationFactory() -{ - setConfigBaseId("Qbs.Deploy"); - addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); - setSupportedProjectType(Constants::PROJECT_ID); - setDefaultDisplayName(QCoreApplication::translate("Qbs", "Qbs Install")); -} - -} // namespace Internal -} // namespace QbsProjectManager diff --git a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.h b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.h deleted file mode 100644 index 588ac719735..00000000000 --- a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.h +++ /dev/null @@ -1,40 +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 - -namespace QbsProjectManager { -namespace Internal { - -class QbsDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory -{ -public: - QbsDeployConfigurationFactory(); -}; - -} // namespace Internal -} // namespace QbsProjectManager diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index 67590599027..29e14475d89 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -432,11 +432,6 @@ qbs::ProjectData QbsProject::qbsProjectData() const return m_projectData; } -bool QbsProject::needsSpecialDeployment() const -{ - return true; -} - bool QbsProject::checkCancelStatus() { const CancelStatus cancelStatus = m_cancelStatus; diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h index 6c3080ceafc..5a2db0fa659 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.h +++ b/src/plugins/qbsprojectmanager/qbsproject.h @@ -94,7 +94,6 @@ public: qbs::Project qbsProject() const; qbs::ProjectData qbsProjectData() const; - bool needsSpecialDeployment() const override; void generateErrors(const qbs::ErrorInfo &e); static QString uniqueProductName(const qbs::ProductData &product); diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro index efd74e5db42..dcd01e32ad0 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro @@ -26,7 +26,6 @@ HEADERS = \ qbsbuildinfo.h \ qbsbuildstep.h \ qbscleanstep.h \ - qbsdeployconfigurationfactory.h \ qbskitinformation.h \ qbsinstallstep.h \ qbslogsink.h \ @@ -53,7 +52,6 @@ SOURCES = \ qbsbuildinfo.cpp \ qbsbuildstep.cpp \ qbscleanstep.cpp \ - qbsdeployconfigurationfactory.cpp \ qbsinstallstep.cpp \ qbskitinformation.cpp \ qbslogsink.cpp \ diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs index a7220820183..4182fc1252e 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs @@ -80,8 +80,6 @@ QtcPlugin { "qbscleanstep.cpp", "qbscleanstep.h", "qbscleanstepconfigwidget.ui", - "qbsdeployconfigurationfactory.cpp", - "qbsdeployconfigurationfactory.h", "qbsinstallstep.cpp", "qbsinstallstep.h", "qbsinstallstepconfigwidget.ui", diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index 4aac91bad63..3087dfc7a91 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -28,7 +28,6 @@ #include "qbsbuildconfiguration.h" #include "qbsbuildstep.h" #include "qbscleanstep.h" -#include "qbsdeployconfigurationfactory.h" #include "qbsinstallstep.h" #include "qbskitinformation.h" #include "qbsnodes.h" @@ -91,7 +90,6 @@ public: QbsBuildStepFactory buildStepFactory; QbsCleanStepFactory cleanStepFactory; QbsInstallStepFactory installStepFactory; - QbsDeployConfigurationFactory deployConfigFactory; QbsRunConfigurationFactory runConfigFactory; QbsProfilesSettingsPage profilesSetttingsPage; };