forked from qt-creator/qt-creator
DeployConfigurationFactory: Properly extract the abstract class
Make DeployConfigurationFactory a true base class. Introduce the DefaultDeployConfigurationFactory as the implementation that actually creates DefaultDeployConfigurations. This mostly moves code around. The virtual canHandle method was mostly unused and was removed from most classes. Change-Id: I170d94c648e67f3fe52a76ffb5344f389ae49efc Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -135,10 +135,5 @@ QString AndroidDeployConfigurationFactory::displayNameForId(Core::Id id) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidDeployConfigurationFactory::canHandle(Target *parent) const
|
|
||||||
{
|
|
||||||
return AndroidManager::supportsAndroid(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Android
|
} // namespace Android
|
||||||
|
@@ -70,9 +70,6 @@ public:
|
|||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
|
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
|
||||||
// used to translate the ids to names to display to the user
|
// used to translate the ids to names to display to the user
|
||||||
QString displayNameForId(Core::Id id) const;
|
QString displayNameForId(Core::Id id) const;
|
||||||
|
|
||||||
private:
|
|
||||||
bool canHandle(ProjectExplorer::Target *parent) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -128,10 +128,5 @@ QString IosDeployConfigurationFactory::displayNameForId(Core::Id id) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IosDeployConfigurationFactory::canHandle(Target *parent) const
|
|
||||||
{
|
|
||||||
return IosManager::supportsIos(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Ios
|
} // namespace Ios
|
||||||
|
@@ -72,9 +72,6 @@ public:
|
|||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const Q_DECL_OVERRIDE;
|
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const Q_DECL_OVERRIDE;
|
||||||
// used to translate the ids to names to display to the user
|
// used to translate the ids to names to display to the user
|
||||||
QString displayNameForId(Core::Id id) const Q_DECL_OVERRIDE;
|
QString displayNameForId(Core::Id id) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
|
||||||
bool canHandle(ProjectExplorer::Target *parent) const Q_DECL_OVERRIDE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -182,64 +182,6 @@ DeployConfigurationFactory::DeployConfigurationFactory(QObject *parent) :
|
|||||||
DeployConfigurationFactory::~DeployConfigurationFactory()
|
DeployConfigurationFactory::~DeployConfigurationFactory()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QList<Core::Id> DeployConfigurationFactory::availableCreationIds(Target *parent) const
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
return QList<Core::Id>() << Core::Id(Constants::DEFAULT_DEPLOYCONFIGURATION_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DeployConfigurationFactory::displayNameForId(Core::Id id) const
|
|
||||||
{
|
|
||||||
if (id == Constants::DEFAULT_DEPLOYCONFIGURATION_ID)
|
|
||||||
//: Display name of the default deploy configuration
|
|
||||||
return tr("Deploy Configuration");
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DeployConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
return id == Constants::DEFAULT_DEPLOYCONFIGURATION_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeployConfiguration *DeployConfigurationFactory::create(Target *parent, Core::Id id)
|
|
||||||
{
|
|
||||||
if (!canCreate(parent, id))
|
|
||||||
return 0;
|
|
||||||
return new DefaultDeployConfiguration(parent, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, idFromMap(map));
|
|
||||||
}
|
|
||||||
|
|
||||||
DeployConfiguration *DeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
|
||||||
{
|
|
||||||
if (!canRestore(parent, map))
|
|
||||||
return 0;
|
|
||||||
DefaultDeployConfiguration *dc = new DefaultDeployConfiguration(parent, idFromMap(map));
|
|
||||||
if (!dc->fromMap(map)) {
|
|
||||||
delete dc;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return dc;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DeployConfigurationFactory::canClone(Target *parent, DeployConfiguration *product) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, product->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
DeployConfiguration *DeployConfigurationFactory::clone(Target *parent, DeployConfiguration *product)
|
|
||||||
{
|
|
||||||
if (!canClone(parent, product))
|
|
||||||
return 0;
|
|
||||||
return new DefaultDeployConfiguration(parent, product);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
||||||
{
|
{
|
||||||
return ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>(
|
return ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>(
|
||||||
@@ -264,7 +206,69 @@ DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, Dep
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeployConfigurationFactory::canHandle(Target *parent) const
|
///
|
||||||
|
// DefaultDeployConfigurationFactory
|
||||||
|
///
|
||||||
|
|
||||||
|
QList<Core::Id> DefaultDeployConfigurationFactory::availableCreationIds(Target *parent) const
|
||||||
|
{
|
||||||
|
if (!canHandle(parent))
|
||||||
|
return QList<Core::Id>();
|
||||||
|
return QList<Core::Id>() << Core::Id(Constants::DEFAULT_DEPLOYCONFIGURATION_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DefaultDeployConfigurationFactory::displayNameForId(Core::Id id) const
|
||||||
|
{
|
||||||
|
if (id == Constants::DEFAULT_DEPLOYCONFIGURATION_ID)
|
||||||
|
//: Display name of the default deploy configuration
|
||||||
|
return tr("Deploy Configuration");
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefaultDeployConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
||||||
|
{
|
||||||
|
if (!canHandle(parent))
|
||||||
|
return false;
|
||||||
|
return id == Constants::DEFAULT_DEPLOYCONFIGURATION_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeployConfiguration *DefaultDeployConfigurationFactory::create(Target *parent, Core::Id id)
|
||||||
|
{
|
||||||
|
if (!canCreate(parent, id))
|
||||||
|
return 0;
|
||||||
|
return new DefaultDeployConfiguration(parent, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefaultDeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
||||||
|
{
|
||||||
|
return canCreate(parent, idFromMap(map));
|
||||||
|
}
|
||||||
|
|
||||||
|
DeployConfiguration *DefaultDeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
||||||
|
{
|
||||||
|
if (!canRestore(parent, map))
|
||||||
|
return 0;
|
||||||
|
DefaultDeployConfiguration *dc = new DefaultDeployConfiguration(parent, idFromMap(map));
|
||||||
|
if (!dc->fromMap(map)) {
|
||||||
|
delete dc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return dc;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefaultDeployConfigurationFactory::canClone(Target *parent, DeployConfiguration *product) const
|
||||||
|
{
|
||||||
|
return canCreate(parent, product->id());
|
||||||
|
}
|
||||||
|
|
||||||
|
DeployConfiguration *DefaultDeployConfigurationFactory::clone(Target *parent, DeployConfiguration *product)
|
||||||
|
{
|
||||||
|
if (!canClone(parent, product))
|
||||||
|
return 0;
|
||||||
|
return new DefaultDeployConfiguration(parent, product);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefaultDeployConfigurationFactory::canHandle(Target *parent) const
|
||||||
{
|
{
|
||||||
if (!parent->project()->supportsKit(parent->kit()) || parent->project()->needsSpecialDeployment())
|
if (!parent->project()->supportsKit(parent->kit()) || parent->project()->needsSpecialDeployment())
|
||||||
return false;
|
return false;
|
||||||
|
@@ -84,7 +84,7 @@ private:
|
|||||||
class PROJECTEXPLORER_EXPORT DefaultDeployConfiguration : public DeployConfiguration
|
class PROJECTEXPLORER_EXPORT DefaultDeployConfiguration : public DeployConfiguration
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class DeployConfigurationFactory; // for the ctors
|
friend class DefaultDeployConfigurationFactory; // for the ctors
|
||||||
protected:
|
protected:
|
||||||
DefaultDeployConfiguration(Target *target, Core::Id id);
|
DefaultDeployConfiguration(Target *target, Core::Id id);
|
||||||
DefaultDeployConfiguration(Target *target, DeployConfiguration *source);
|
DefaultDeployConfiguration(Target *target, DeployConfiguration *source);
|
||||||
@@ -100,17 +100,17 @@ public:
|
|||||||
virtual ~DeployConfigurationFactory();
|
virtual ~DeployConfigurationFactory();
|
||||||
|
|
||||||
// used to show the list of possible additons to a target, returns a list of types
|
// used to show the list of possible additons to a target, returns a list of types
|
||||||
virtual QList<Core::Id> availableCreationIds(Target *parent) const;
|
virtual QList<Core::Id> availableCreationIds(Target *parent) const = 0;
|
||||||
// used to translate the types to names to display to the user
|
// used to translate the types to names to display to the user
|
||||||
virtual QString displayNameForId(Core::Id id) const;
|
virtual QString displayNameForId(Core::Id id) const = 0;
|
||||||
|
|
||||||
virtual bool canCreate(Target *parent, Core::Id id) const;
|
virtual bool canCreate(Target *parent, Core::Id id) const = 0;
|
||||||
virtual DeployConfiguration *create(Target *parent, Core::Id id);
|
virtual DeployConfiguration *create(Target *parent, Core::Id id) = 0;
|
||||||
// used to recreate the runConfigurations when restoring settings
|
// used to recreate the runConfigurations when restoring settings
|
||||||
virtual bool canRestore(Target *parent, const QVariantMap &map) const;
|
virtual bool canRestore(Target *parent, const QVariantMap &map) const = 0;
|
||||||
virtual DeployConfiguration *restore(Target *parent, const QVariantMap &map);
|
virtual DeployConfiguration *restore(Target *parent, const QVariantMap &map) = 0;
|
||||||
virtual bool canClone(Target *parent, DeployConfiguration *product) const;
|
virtual bool canClone(Target *parent, DeployConfiguration *product) const = 0;
|
||||||
virtual DeployConfiguration *clone(Target *parent, DeployConfiguration *product);
|
virtual DeployConfiguration *clone(Target *parent, DeployConfiguration *product) = 0;
|
||||||
|
|
||||||
static DeployConfigurationFactory *find(Target *parent, const QVariantMap &map);
|
static DeployConfigurationFactory *find(Target *parent, const QVariantMap &map);
|
||||||
static QList<DeployConfigurationFactory *> find(Target *parent);
|
static QList<DeployConfigurationFactory *> find(Target *parent);
|
||||||
@@ -118,11 +118,22 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void availableCreationIdsChanged();
|
void availableCreationIdsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
class DefaultDeployConfigurationFactory : public DeployConfigurationFactory
|
||||||
virtual bool canHandle(Target *parent) const;
|
{
|
||||||
|
public:
|
||||||
|
QList<Core::Id> availableCreationIds(Target *parent) const;
|
||||||
|
// used to translate the types to names to display to the user
|
||||||
|
QString displayNameForId(Core::Id id) const;
|
||||||
|
bool canCreate(Target *parent, Core::Id id) const;
|
||||||
|
DeployConfiguration *create(Target *parent, Core::Id id);
|
||||||
|
bool canRestore(Target *parent, const QVariantMap &map) const;
|
||||||
|
DeployConfiguration *restore(Target *parent, const QVariantMap &map);
|
||||||
|
bool canClone(Target *parent, DeployConfiguration *product) const;
|
||||||
|
DeployConfiguration *clone(Target *parent, DeployConfiguration *product);
|
||||||
private:
|
private:
|
||||||
|
bool canHandle(Target *parent) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -1008,7 +1008,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
|
|
||||||
addAutoReleasedObject(new ProjectTreeWidgetFactory);
|
addAutoReleasedObject(new ProjectTreeWidgetFactory);
|
||||||
addAutoReleasedObject(new FolderNavigationWidgetFactory);
|
addAutoReleasedObject(new FolderNavigationWidgetFactory);
|
||||||
addAutoReleasedObject(new DeployConfigurationFactory);
|
addAutoReleasedObject(new DefaultDeployConfigurationFactory);
|
||||||
|
|
||||||
QSettings *s = ICore::settings();
|
QSettings *s = ICore::settings();
|
||||||
const QStringList fileNames =
|
const QStringList fileNames =
|
||||||
|
@@ -142,6 +142,11 @@ ProjectExplorer::DeployConfiguration
|
|||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QbsDeployConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *product) const
|
||||||
|
{
|
||||||
|
return canCreate(parent, product->id());
|
||||||
|
}
|
||||||
|
|
||||||
ProjectExplorer::DeployConfiguration
|
ProjectExplorer::DeployConfiguration
|
||||||
*QbsDeployConfigurationFactory::clone(ProjectExplorer::Target *parent,
|
*QbsDeployConfigurationFactory::clone(ProjectExplorer::Target *parent,
|
||||||
ProjectExplorer::DeployConfiguration *product)
|
ProjectExplorer::DeployConfiguration *product)
|
||||||
|
@@ -69,6 +69,7 @@ public:
|
|||||||
ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, Core::Id id);
|
ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, Core::Id id);
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||||
ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
|
ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
|
||||||
|
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *product) const;
|
||||||
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
|
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
|
||||||
ProjectExplorer::DeployConfiguration *product);
|
ProjectExplorer::DeployConfiguration *product);
|
||||||
};
|
};
|
||||||
|
@@ -58,7 +58,7 @@ public:
|
|||||||
ProjectExplorer::DeployConfiguration *source) const;
|
ProjectExplorer::DeployConfiguration *source) const;
|
||||||
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
|
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
|
||||||
ProjectExplorer::DeployConfiguration *source);
|
ProjectExplorer::DeployConfiguration *source);
|
||||||
|
private:
|
||||||
bool canHandle(ProjectExplorer::Target *t) const;
|
bool canHandle(ProjectExplorer::Target *t) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -115,6 +115,11 @@ DeployConfiguration *RemoteLinuxDeployConfigurationFactory::restore(Target *pare
|
|||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RemoteLinuxDeployConfigurationFactory::canClone(Target *parent, DeployConfiguration *product) const
|
||||||
|
{
|
||||||
|
return canCreate(parent, product->id());
|
||||||
|
}
|
||||||
|
|
||||||
DeployConfiguration *RemoteLinuxDeployConfigurationFactory::clone(Target *parent,
|
DeployConfiguration *RemoteLinuxDeployConfigurationFactory::clone(Target *parent,
|
||||||
DeployConfiguration *product)
|
DeployConfiguration *product)
|
||||||
{
|
{
|
||||||
|
@@ -48,6 +48,7 @@ public:
|
|||||||
ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, Core::Id id);
|
ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, Core::Id id);
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||||
ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
|
ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
|
||||||
|
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *product) const;
|
||||||
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
|
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
|
||||||
ProjectExplorer::DeployConfiguration *product);
|
ProjectExplorer::DeployConfiguration *product);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user