Profile introduction

Introduce Profiles to store sets of values that describe a system/device.

These profiles are held by a target, getting rid of much of the information
stored in the Build-/Run-/DeployConfigurations, greatly simplifying those.

This is a squash of the wip/profile branch which has been on gerrit for a
while, rebased to current master.

Change-Id: I25956c8dd4d1962b2134bfaa8a8076ae3909460f
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Tobias Hunger
2012-04-24 15:49:09 +02:00
parent 8c77b8c9d7
commit 2431456216
379 changed files with 12690 additions and 14437 deletions

View File

@@ -36,13 +36,17 @@
#include "androiddebugsupport.h"
#include "androidrunconfiguration.h"
#include "androidruncontrol.h"
#include "androidtarget.h"
#include "androidmanager.h"
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <debugger/debuggerconstants.h>
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4nodes.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qtsupport/customexecutablerunconfiguration.h>
#include <qtsupport/qtprofileinformation.h>
#include <qtsupport/qtsupportconstants.h>
namespace Android {
@@ -55,7 +59,7 @@ namespace {
QString pathFromId(const Core::Id id)
{
QString pathStr = QString::fromUtf8(id.name());
QString pathStr = id.toString();
const QString prefix = QLatin1String(ANDROID_RC_ID_PREFIX);
if (!pathStr.startsWith(prefix))
return QString();
@@ -65,34 +69,25 @@ QString pathFromId(const Core::Id id)
} // namespace
AndroidRunConfigurationFactory::AndroidRunConfigurationFactory(QObject *parent)
: IRunConfigurationFactory(parent)
{
}
: QmakeRunConfigurationFactory(parent)
{ setObjectName(QLatin1String("AndroidRunConfigurationFactory")); }
AndroidRunConfigurationFactory::~AndroidRunConfigurationFactory()
{ }
bool AndroidRunConfigurationFactory::canCreate(Target *parent, const Core::Id id) const
{
if (!canHandle(parent))
return false;
return availableCreationIds(parent).contains(id);
}
bool AndroidRunConfigurationFactory::canCreate(Target *parent,
const Core::Id/*id*/) const
bool AndroidRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
{
AndroidTarget *target = qobject_cast<AndroidTarget *>(parent);
if (!target
|| target->id() != Core::Id(Qt4ProjectManager::Constants::ANDROID_DEVICE_TARGET_ID)) {
if (!canHandle(parent))
return false;
}
return true;
}
bool AndroidRunConfigurationFactory::canRestore(Target *parent,
const QVariantMap &map) const
{
Q_UNUSED(parent)
Q_UNUSED(map)
if (!qobject_cast<AndroidTarget *>(parent))
return false;
QString id = QString::fromUtf8(ProjectExplorer::idFromMap(map).name());
return id.startsWith(QLatin1String(ANDROID_RC_ID));
QString id = ProjectExplorer::idFromMap(map).toString();
return id.startsWith(QLatin1String(ANDROID_RC_ID_PREFIX));
}
bool AndroidRunConfigurationFactory::canClone(Target *parent,
@@ -104,14 +99,12 @@ bool AndroidRunConfigurationFactory::canClone(Target *parent,
QList<Core::Id> AndroidRunConfigurationFactory::availableCreationIds(Target *parent) const
{
QList<Core::Id> ids;
if (AndroidTarget *t = qobject_cast<AndroidTarget *>(parent)) {
if (t->id() == Core::Id(Qt4ProjectManager::Constants::ANDROID_DEVICE_TARGET_ID)) {
QList<Qt4ProFileNode *> nodes = t->qt4Project()->allProFiles();
foreach (Qt4ProFileNode *node, nodes)
if (node->projectType() == ApplicationTemplate || node->projectType() == LibraryTemplate)
ids << Core::Id(node->targetInformation().target);
}
}
if (!AndroidManager::supportsAndroid(parent))
return ids;
QList<Qt4ProFileNode *> nodes = static_cast<Qt4Project *>(parent->project())->allProFiles();
foreach (Qt4ProFileNode *node, nodes)
if (node->projectType() == ApplicationTemplate || node->projectType() == LibraryTemplate)
ids << Core::Id(node->targetInformation().target);
return ids;
}
@@ -120,14 +113,11 @@ QString AndroidRunConfigurationFactory::displayNameForId(const Core::Id id) cons
return QFileInfo(pathFromId(id)).completeBaseName();
}
RunConfiguration *AndroidRunConfigurationFactory::create(Target *parent,
const Core::Id id)
RunConfiguration *AndroidRunConfigurationFactory::create(Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
AndroidTarget *pqt4parent = static_cast<AndroidTarget *>(parent);
return new AndroidRunConfiguration(pqt4parent, pathFromId(id));
return new AndroidRunConfiguration(parent, id, pathFromId(id));
}
RunConfiguration *AndroidRunConfigurationFactory::restore(Target *parent,
@@ -135,8 +125,8 @@ RunConfiguration *AndroidRunConfigurationFactory::restore(Target *parent,
{
if (!canRestore(parent, map))
return 0;
AndroidTarget *target = static_cast<AndroidTarget *>(parent);
AndroidRunConfiguration *rc = new AndroidRunConfiguration(target, QString());
Core::Id id = ProjectExplorer::idFromMap(map);
AndroidRunConfiguration *rc = new AndroidRunConfiguration(parent, id, pathFromId(id));
if (rc->fromMap(map))
return rc;
@@ -144,14 +134,30 @@ RunConfiguration *AndroidRunConfigurationFactory::restore(Target *parent,
return 0;
}
RunConfiguration *AndroidRunConfigurationFactory::clone(Target *parent,
RunConfiguration *source)
RunConfiguration *AndroidRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
{
if (!canClone(parent, source))
return 0;
AndroidRunConfiguration *old = static_cast<AndroidRunConfiguration *>(source);
return new AndroidRunConfiguration(static_cast<AndroidTarget *>(parent), old);
return new AndroidRunConfiguration(parent, old);
}
bool AndroidRunConfigurationFactory::canHandle(Target *t) const
{
if (!t->project()->supportsProfile(t->profile()))
return false;
return AndroidManager::supportsAndroid(t);
}
QList<RunConfiguration *> AndroidRunConfigurationFactory::runConfigurationsForNode(Target *t, ProjectExplorer::Node *n)
{
QList<ProjectExplorer::RunConfiguration *> result;
foreach (ProjectExplorer::RunConfiguration *rc, t->runConfigurations())
if (AndroidRunConfiguration *qt4c = qobject_cast<AndroidRunConfiguration *>(rc))
if (qt4c->proFilePath() == n->path())
result << rc;
return result;
}
// #pragma mark -- AndroidRunControlFactory