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>
This commit is contained in:
hjk
2019-02-20 19:13:28 +01:00
parent 317ab49793
commit 9e965409d1
44 changed files with 492 additions and 910 deletions

View File

@@ -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 \

View File

@@ -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",

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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