iOS: De-Q_OBJECT-ify and hide IosDeployStep implementation

Change-Id: I8c0589e5c5c2ac69f3c48f299a97c0dbea9b5922
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-02-20 13:21:52 +01:00
parent 1d513ecd06
commit af8120a05c
3 changed files with 76 additions and 82 deletions

View File

@@ -24,12 +24,14 @@
****************************************************************************/ ****************************************************************************/
#include "iosdeploystep.h" #include "iosdeploystep.h"
#include "iosbuildstep.h"
#include "iosconstants.h"
#include "iosrunconfiguration.h"
#include "iostoolhandler.h"
#include <coreplugin/messagemanager.h> #include "iosbuildstep.h"
#include "iosconfigurations.h"
#include "iosconstants.h"
#include "iosdevice.h"
#include "iosrunconfiguration.h"
#include "iossimulator.h"
#include "iostoolhandler.h"
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -39,22 +41,64 @@
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
#include <qtsupport/qtkitinformation.h>
#include <utils/temporaryfile.h> #include <utils/temporaryfile.h>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QSettings> #include <QSettings>
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace Ios { namespace Ios {
namespace Internal { namespace Internal {
class IosDeployStep final : public BuildStep
{
Q_DECLARE_TR_FUNCTIONS(Ios::Internal::IosDeployStep)
public:
enum TransferStatus {
NoTransfer,
TransferInProgress,
TransferOk,
TransferFailed
};
IosDeployStep(BuildStepList *bc, Core::Id id);
private:
void cleanup();
void doRun() final;
void doCancel() final;
void handleIsTransferringApp(IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, int progress, int maxProgress,
const QString &info);
void handleDidTransferApp(IosToolHandler *handler, const QString &bundlePath, const QString &deviceId,
IosToolHandler::OpStatus status);
void handleFinished(IosToolHandler *handler);
void handleErrorMsg(IosToolHandler *handler, const QString &msg);
void updateDisplayNames();
bool init() final;
BuildStepConfigWidget *createConfigWidget() final;
IDevice::ConstPtr device() const;
IosDevice::ConstPtr iosdevice() const;
IosSimulator::ConstPtr iossimulator() const;
QString deviceId() const;
void checkProvisioningProfile();
TransferStatus m_transferStatus = NoTransfer;
IosToolHandler *m_toolHandler = nullptr;
IDevice::ConstPtr m_device;
FilePath m_bundlePath;
IosDeviceType m_deviceType;
bool m_expectFail = false;
};
IosDeployStep::IosDeployStep(BuildStepList *parent, Core::Id id) IosDeployStep::IosDeployStep(BuildStepList *parent, Core::Id id)
: BuildStep(parent, id) : BuildStep(parent, id)
{ {
@@ -66,15 +110,9 @@ IosDeployStep::IosDeployStep(BuildStepList *parent, Core::Id id)
this, &IosDeployStep::updateDisplayNames); this, &IosDeployStep::updateDisplayNames);
} }
Core::Id IosDeployStep::stepId()
{
return "Qt4ProjectManager.IosDeployStep";
}
void IosDeployStep::updateDisplayNames() void IosDeployStep::updateDisplayNames()
{ {
IDevice::ConstPtr dev = IDevice::ConstPtr dev = DeviceKitAspect::device(target()->kit());
DeviceKitAspect::device(target()->kit());
const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName(); const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName();
setDefaultDisplayName(tr("Deploy to %1").arg(devName)); setDefaultDisplayName(tr("Deploy to %1").arg(devName));
setDisplayName(tr("Deploy to %1").arg(devName)); setDisplayName(tr("Deploy to %1").arg(devName));
@@ -95,7 +133,7 @@ bool IosDeployStep::init()
m_deviceType = runConfig->deviceType(); m_deviceType = runConfig->deviceType();
} else { } else {
emit addOutput(tr("Error: no device available, deploy failed."), emit addOutput(tr("Error: no device available, deploy failed."),
BuildStep::OutputFormat::ErrorMessage); OutputFormat::ErrorMessage);
return false; return false;
} }
return true; return true;
@@ -190,7 +228,7 @@ void IosDeployStep::handleErrorMsg(IosToolHandler *handler, const QString &msg)
if (msg.contains(QLatin1String("AMDeviceInstallApplication returned -402653103"))) if (msg.contains(QLatin1String("AMDeviceInstallApplication returned -402653103")))
TaskHub::addTask(DeploymentTask(Task::Warning, tr("The Info.plist might be incorrect."))); TaskHub::addTask(DeploymentTask(Task::Warning, tr("The Info.plist might be incorrect.")));
emit addOutput(msg, BuildStep::OutputFormat::ErrorMessage); emit addOutput(msg, OutputFormat::ErrorMessage);
} }
BuildStepConfigWidget *IosDeployStep::createConfigWidget() BuildStepConfigWidget *IosDeployStep::createConfigWidget()
@@ -236,7 +274,7 @@ void IosDeployStep::checkProvisioningProfile()
return; return;
end += 8; end += 8;
Utils::TemporaryFile f("iosdeploy"); TemporaryFile f("iosdeploy");
if (!f.open()) if (!f.open())
return; return;
f.write(provisionData.mid(start, end - start)); f.write(provisionData.mid(start, end - start));
@@ -278,5 +316,21 @@ IosSimulator::ConstPtr IosDeployStep::iossimulator() const
return m_device.dynamicCast<const IosSimulator>(); return m_device.dynamicCast<const IosSimulator>();
} }
// IosDeployStepFactory
IosDeployStepFactory::IosDeployStepFactory()
{
registerStep<IosDeployStep>(stepId());
setDisplayName(IosDeployStep::tr("Deploy to iOS device or emulator"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
setSupportedDeviceTypes({Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE});
setRepeatable(false);
}
Core::Id IosDeployStepFactory::stepId()
{
return "Qt4ProjectManager.IosDeployStep";
}
} // namespace Internal } // namespace Internal
} // namespace Ios } // namespace Ios

View File

@@ -25,64 +25,17 @@
#pragma once #pragma once
#include "iosconfigurations.h"
#include "iosdevice.h"
#include "iossimulator.h"
#include <projectexplorer/buildstep.h> #include <projectexplorer/buildstep.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <QProcess>
namespace Ios { namespace Ios {
class IosToolHandler;
namespace Internal { namespace Internal {
class IosDeployStep : public ProjectExplorer::BuildStep class IosDeployStepFactory final : public ProjectExplorer::BuildStepFactory
{ {
Q_OBJECT
public: public:
enum TransferStatus { IosDeployStepFactory();
NoTransfer,
TransferInProgress,
TransferOk,
TransferFailed
};
friend class IosDeployStepFactory;
IosDeployStep(ProjectExplorer::BuildStepList *bc, Core::Id id);
static Core::Id stepId(); static Core::Id stepId();
void cleanup();
private:
void doRun() override;
void doCancel() override;
void handleIsTransferringApp(Ios::IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, int progress, int maxProgress,
const QString &info);
void handleDidTransferApp(Ios::IosToolHandler *handler, const QString &bundlePath, const QString &deviceId,
Ios::IosToolHandler::OpStatus status);
void handleFinished(Ios::IosToolHandler *handler);
void handleErrorMsg(Ios::IosToolHandler *handler, const QString &msg);
void updateDisplayNames();
bool init() override;
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
ProjectExplorer::IDevice::ConstPtr device() const;
IosDevice::ConstPtr iosdevice() const;
IosSimulator::ConstPtr iossimulator() const;
QString deviceId() const;
void checkProvisioningProfile();
TransferStatus m_transferStatus = NoTransfer;
IosToolHandler *m_toolHandler = nullptr;
ProjectExplorer::IDevice::ConstPtr m_device;
Utils::FilePath m_bundlePath;
IosDeviceType m_deviceType;
static const Core::Id Id;
bool m_expectFail = false;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -53,19 +53,6 @@ namespace Internal {
Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common", QtWarningMsg) Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common", QtWarningMsg)
class IosDeployStepFactory : public BuildStepFactory
{
public:
IosDeployStepFactory()
{
registerStep<IosDeployStep>(IosDeployStep::stepId());
setDisplayName(IosDeployStep::tr("Deploy to iOS device or emulator"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
setSupportedDeviceTypes({Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE});
setRepeatable(false);
}
};
class IosDeployConfigurationFactory : public DeployConfigurationFactory class IosDeployConfigurationFactory : public DeployConfigurationFactory
{ {
public: public:
@@ -76,7 +63,7 @@ public:
addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE); addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE);
addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE); addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE);
setDefaultDisplayName(QCoreApplication::translate("Ios::Internal", "Deploy on iOS")); setDefaultDisplayName(QCoreApplication::translate("Ios::Internal", "Deploy on iOS"));
addInitialStep(IosDeployStep::stepId()); addInitialStep(IosDeployStepFactory::stepId());
} }
}; };