diff options
author | hjk <hjk@qt.io> | 2019-02-20 19:13:28 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-02-21 13:20:16 +0000 |
commit | 9e965409d1cbe6270c6a994bfe41d61a154d1d77 (patch) | |
tree | c7099baa704c1d3b0ddf01250e6757b132394ebf /src/plugins/ios | |
parent | 317ab497936cc6c32da80bd0d3de58975bb308f1 (diff) |
Move IDeviceFactory closer to IDevice implementation
Except for the DesktopDevice, which is kind of special. Also try
a bit to make (and partially fail at doing so) naming and code
structure (#include, use of namespaces) more similar to each other.
Change-Id: I9fe266e706b72c14f59ff03ca1ae02dba3adcc71
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/ios')
-rw-r--r-- | src/plugins/ios/ios.pro | 4 | ||||
-rw-r--r-- | src/plugins/ios/ios.qbs | 4 | ||||
-rw-r--r-- | src/plugins/ios/iosdevice.cpp | 22 | ||||
-rw-r--r-- | src/plugins/ios/iosdevice.h | 11 | ||||
-rw-r--r-- | src/plugins/ios/iosdevicefactory.cpp | 54 | ||||
-rw-r--r-- | src/plugins/ios/iosdevicefactory.h | 43 | ||||
-rw-r--r-- | src/plugins/ios/iosplugin.cpp | 3 | ||||
-rw-r--r-- | src/plugins/ios/iossimulator.cpp | 12 | ||||
-rw-r--r-- | src/plugins/ios/iossimulator.h | 11 | ||||
-rw-r--r-- | src/plugins/ios/iossimulatorfactory.cpp | 47 | ||||
-rw-r--r-- | src/plugins/ios/iossimulatorfactory.h | 41 |
11 files changed, 54 insertions, 198 deletions
diff --git a/src/plugins/ios/ios.pro b/src/plugins/ios/ios.pro index a6bf22abf80..6ded641b9c3 100644 --- a/src/plugins/ios/ios.pro +++ b/src/plugins/ios/ios.pro @@ -17,10 +17,8 @@ HEADERS += \ iosdsymbuildstep.h \ iosqtversion.h \ iosplugin.h \ - iosdevicefactory.h \ iosdevice.h \ iossimulator.h \ - iossimulatorfactory.h \ iosprobe.h \ iosbuildstep.h \ iostoolhandler.h \ @@ -43,10 +41,8 @@ SOURCES += \ iosdsymbuildstep.cpp \ iosqtversion.cpp \ iosplugin.cpp \ - iosdevicefactory.cpp \ iosdevice.cpp \ iossimulator.cpp \ - iossimulatorfactory.cpp \ iosprobe.cpp \ iosbuildstep.cpp \ iostoolhandler.cpp \ diff --git a/src/plugins/ios/ios.qbs b/src/plugins/ios/ios.qbs index 223b7705add..e1dca5ff545 100644 --- a/src/plugins/ios/ios.qbs +++ b/src/plugins/ios/ios.qbs @@ -36,8 +36,6 @@ QtcPlugin { "iosdeploystepwidget.ui", "iosdevice.cpp", "iosdevice.h", - "iosdevicefactory.cpp", - "iosdevicefactory.h", "iosdsymbuildstep.cpp", "iosdsymbuildstep.h", "iosplugin.cpp", @@ -58,8 +56,6 @@ QtcPlugin { "iossettingswidget.ui", "iossimulator.cpp", "iossimulator.h", - "iossimulatorfactory.cpp", - "iossimulatorfactory.h", "iostoolhandler.cpp", "iostoolhandler.h", "simulatorcontrol.cpp", diff --git a/src/plugins/ios/iosdevice.cpp b/src/plugins/ios/iosdevice.cpp index abb94ffe24e..53d956fa76a 100644 --- a/src/plugins/ios/iosdevice.cpp +++ b/src/plugins/ios/iosdevice.cpp @@ -547,5 +547,27 @@ IosDevice::ConstPtr IosKitAspect::device(Kit *kit) return res; } + +// Factory + +IosDeviceFactory::IosDeviceFactory() + : IDeviceFactory(Constants::IOS_DEVICE_ID) +{ + setObjectName(QLatin1String("IosDeviceFactory")); + setDisplayName(IosDevice::name()); + setCombinedIcon(":/ios/images/iosdevicesmall.png", + ":/ios/images/iosdevice.png"); + setConstructionFunction([] { return IDevice::Ptr(new IosDevice); }); +} + +bool IosDeviceFactory::canRestore(const QVariantMap &map) const +{ + QVariantMap vMap = map.value(QLatin1String(Constants::EXTRA_INFO_KEY)).toMap(); + if (vMap.isEmpty() + || vMap.value(QLatin1String("deviceName")).toString() == QLatin1String("*unknown*")) + return false; // transient device (probably generated during an activation) + return true; +} + } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosdevice.h b/src/plugins/ios/iosdevice.h index 990227827ff..afd2cbecfce 100644 --- a/src/plugins/ios/iosdevice.h +++ b/src/plugins/ios/iosdevice.h @@ -28,11 +28,11 @@ #include "iostoolhandler.h" #include <projectexplorer/devicesupport/idevice.h> +#include <projectexplorer/devicesupport/idevicefactory.h> #include <QVariantMap> #include <QMap> #include <QString> -#include <QSharedPointer> #include <QStringList> #include <QTimer> @@ -79,6 +79,15 @@ protected: mutable quint16 m_lastPort; }; +class IosDeviceFactory : public ProjectExplorer::IDeviceFactory +{ + Q_OBJECT +public: + IosDeviceFactory(); + + bool canRestore(const QVariantMap &map) const override; +}; + class IosDeviceManager : public QObject { Q_OBJECT public: diff --git a/src/plugins/ios/iosdevicefactory.cpp b/src/plugins/ios/iosdevicefactory.cpp deleted file mode 100644 index 6370cbce409..00000000000 --- a/src/plugins/ios/iosdevicefactory.cpp +++ /dev/null @@ -1,54 +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 "iosdevicefactory.h" -#include "iosdevice.h" - -#include "iosconstants.h" - -namespace Ios { -namespace Internal { - -IosDeviceFactory::IosDeviceFactory() - : ProjectExplorer::IDeviceFactory(Constants::IOS_DEVICE_ID) -{ - setObjectName(QLatin1String("IosDeviceFactory")); - setDisplayName(IosDevice::name()); - setCombinedIcon(":/ios/images/iosdevicesmall.png", - ":/ios/images/iosdevice.png"); - setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosDevice); }); -} - -bool IosDeviceFactory::canRestore(const QVariantMap &map) const -{ - QVariantMap vMap = map.value(QLatin1String(Constants::EXTRA_INFO_KEY)).toMap(); - if (vMap.isEmpty() - || vMap.value(QLatin1String("deviceName")).toString() == QLatin1String("*unknown*")) - return false; // transient device (probably generated during an activation) - return true; -} - -} // namespace Internal -} // namespace Ios diff --git a/src/plugins/ios/iosdevicefactory.h b/src/plugins/ios/iosdevicefactory.h deleted file mode 100644 index cdf3d61ffd5..00000000000 --- a/src/plugins/ios/iosdevicefactory.h +++ /dev/null @@ -1,43 +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 <projectexplorer/devicesupport/idevicefactory.h> - -namespace Ios { -namespace Internal { - -class IosDeviceFactory : public ProjectExplorer::IDeviceFactory -{ - Q_OBJECT -public: - IosDeviceFactory(); - - bool canRestore(const QVariantMap &map) const override; -}; - -} // namespace Internal -} // namespace Ios diff --git a/src/plugins/ios/iosplugin.cpp b/src/plugins/ios/iosplugin.cpp index b7c7172eae7..b2f3e482acf 100644 --- a/src/plugins/ios/iosplugin.cpp +++ b/src/plugins/ios/iosplugin.cpp @@ -30,13 +30,12 @@ #include "iosconfigurations.h" #include "iosconstants.h" #include "iosdeploystep.h" -#include "iosdevicefactory.h" +#include "iosdevice.h" #include "iosdsymbuildstep.h" #include "iosqtversion.h" #include "iosrunner.h" #include "iossettingspage.h" #include "iossimulator.h" -#include "iossimulatorfactory.h" #include "iostoolhandler.h" #include "iosrunconfiguration.h" diff --git a/src/plugins/ios/iossimulator.cpp b/src/plugins/ios/iossimulator.cpp index 259c5334f2c..7033d59f785 100644 --- a/src/plugins/ios/iossimulator.cpp +++ b/src/plugins/ios/iossimulator.cpp @@ -281,5 +281,17 @@ QDebug operator <<(QDebug debug, const IosDeviceType &deviceType) return debug; } +// Factory + +IosSimulatorFactory::IosSimulatorFactory() + : ProjectExplorer::IDeviceFactory(Constants::IOS_SIMULATOR_TYPE) +{ + setObjectName(QLatin1String("IosSimulatorFactory")); + setDisplayName(tr("iOS Simulator")); + setCombinedIcon(":/ios/images/iosdevicesmall.png", + ":/ios/images/iosdevice.png"); + setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosSimulator()); }); +} + } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iossimulator.h b/src/plugins/ios/iossimulator.h index d4652dfe4ba..b7bea6d6294 100644 --- a/src/plugins/ios/iossimulator.h +++ b/src/plugins/ios/iossimulator.h @@ -26,11 +26,11 @@ #pragma once #include <projectexplorer/devicesupport/idevice.h> +#include <projectexplorer/devicesupport/idevicefactory.h> + #include <utils/fileutils.h> -#include <QMutex> #include <QDebug> -#include <QSharedPointer> namespace ProjectExplorer { class Kit; } namespace Ios { @@ -87,6 +87,13 @@ private: mutable quint16 m_lastPort; }; +class IosSimulatorFactory : public ProjectExplorer::IDeviceFactory +{ + Q_OBJECT +public: + IosSimulatorFactory(); +}; + namespace IosKitInformation { IosSimulator::ConstPtr simulator(ProjectExplorer::Kit *kit); } // namespace IosKitInformation diff --git a/src/plugins/ios/iossimulatorfactory.cpp b/src/plugins/ios/iossimulatorfactory.cpp deleted file mode 100644 index 163bfac1b44..00000000000 --- a/src/plugins/ios/iossimulatorfactory.cpp +++ /dev/null @@ -1,47 +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 "iossimulatorfactory.h" - -#include "iosconstants.h" -#include "iossimulator.h" - -#include <utils/qtcassert.h> - -namespace Ios { -namespace Internal { - -IosSimulatorFactory::IosSimulatorFactory() - : ProjectExplorer::IDeviceFactory(Constants::IOS_SIMULATOR_TYPE) -{ - setObjectName(QLatin1String("IosSimulatorFactory")); - setDisplayName(tr("iOS Simulator")); - setCombinedIcon(":/ios/images/iosdevicesmall.png", - ":/ios/images/iosdevice.png"); - setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosSimulator()); }); -} - -} // namespace Internal -} // namespace Ios diff --git a/src/plugins/ios/iossimulatorfactory.h b/src/plugins/ios/iossimulatorfactory.h deleted file mode 100644 index 5d05c7b370f..00000000000 --- a/src/plugins/ios/iossimulatorfactory.h +++ /dev/null @@ -1,41 +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 <projectexplorer/devicesupport/idevicefactory.h> - -namespace Ios { -namespace Internal { - -class IosSimulatorFactory : public ProjectExplorer::IDeviceFactory -{ - Q_OBJECT -public: - IosSimulatorFactory(); -}; - -} // namespace Internal -} // namespace Ios |