Commit d106b085 authored by hjk's avatar hjk

Qnx: Use new Core::Id interfaces

Less conversions, shorter code.

Change-Id: I7c7aba1e7ee3096ea436250520e626259f519a38
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 2d7e49c7
......@@ -41,15 +41,9 @@
using namespace Qnx;
using namespace Qnx::Internal;
namespace {
QString pathFromId(const Core::Id id)
static QString pathFromId(const Core::Id id)
{
QString idStr = id.toString();
if (idStr.startsWith(QLatin1String(Constants::QNX_BB_RUNCONFIGURATION_PREFIX)))
return idStr.mid(QString::fromLatin1(Constants::QNX_BB_RUNCONFIGURATION_PREFIX).size());
return QString();
}
return id.suffixAfter(Constants::QNX_BB_RUNCONFIGURATION_PREFIX);
}
BlackBerryRunConfigurationFactory::BlackBerryRunConfigurationFactory(QObject *parent) :
......@@ -80,7 +74,7 @@ QString BlackBerryRunConfigurationFactory::displayNameForId(const Core::Id id) c
if (path.isEmpty())
return QString();
if (id.toString().startsWith(QLatin1String(Constants::QNX_BB_RUNCONFIGURATION_PREFIX)))
if (id.name().startsWith(Constants::QNX_BB_RUNCONFIGURATION_PREFIX))
return tr("%1 on BlackBerry Device").arg(QFileInfo(path).completeBaseName());
return QString();
......@@ -95,7 +89,7 @@ bool BlackBerryRunConfigurationFactory::canCreate(ProjectExplorer::Target *paren
if (!qt4Project)
return false;
if (!id.toString().startsWith(QLatin1String(Constants::QNX_BB_RUNCONFIGURATION_PREFIX)))
if (!id.name().startsWith(Constants::QNX_BB_RUNCONFIGURATION_PREFIX))
return false;
return qt4Project->hasApplicationProFile(pathFromId(id));
......@@ -116,7 +110,7 @@ bool BlackBerryRunConfigurationFactory::canRestore(ProjectExplorer::Target *pare
if (!canHandle(parent))
return false;
return ProjectExplorer::idFromMap(map).toString().startsWith(QLatin1String(Constants::QNX_BB_RUNCONFIGURATION_PREFIX));
return ProjectExplorer::idFromMap(map).name().startsWith(Constants::QNX_BB_RUNCONFIGURATION_PREFIX);
}
ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::restore(
......
......@@ -59,7 +59,7 @@ QList<Core::Id> QnxDeployConfigurationFactory::availableCreationIds(ProjectExplo
QString QnxDeployConfigurationFactory::displayNameForId(const Core::Id id) const
{
if (id.toString().startsWith(QLatin1String(Constants::QNX_QNX_DEPLOYCONFIGURATION_ID)))
if (id.name().startsWith(Constants::QNX_QNX_DEPLOYCONFIGURATION_ID))
return tr("Deploy to QNX Device");
return QString();
......@@ -67,11 +67,7 @@ QString QnxDeployConfigurationFactory::displayNameForId(const Core::Id id) const
bool QnxDeployConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const
{
if (!canHandle(parent)
|| !id.toString().startsWith(QLatin1String(Constants::QNX_QNX_DEPLOYCONFIGURATION_ID)))
return false;
return true;
return canHandle(parent) && id.name().startsWith(Constants::QNX_QNX_DEPLOYCONFIGURATION_ID);
}
ProjectExplorer::DeployConfiguration *QnxDeployConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
......
......@@ -42,15 +42,9 @@
using namespace Qnx;
using namespace Qnx::Internal;
namespace {
QString pathFromId(const Core::Id id)
static QString pathFromId(const Core::Id id)
{
const QString idStr = id.toString();
if (idStr.startsWith(QLatin1String(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)))
return idStr.mid(QString::fromLatin1(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX).size());
return QString();
}
return id.suffixAfter(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX);
}
QnxRunConfigurationFactory::QnxRunConfigurationFactory(QObject *parent) :
......@@ -80,7 +74,7 @@ QString QnxRunConfigurationFactory::displayNameForId(const Core::Id id) const
if (path.isEmpty())
return QString();
if (id.toString().startsWith(QLatin1String(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)))
if (id.name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX))
return tr("%1 on QNX Device").arg(QFileInfo(path).completeBaseName());
return QString();
......@@ -103,7 +97,7 @@ ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::create(ProjectExp
if (!canCreate(parent, id))
return 0;
if (id.toString().startsWith(QLatin1String(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)))
if (id.name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX))
return new QnxRunConfiguration(parent, id, pathFromId(id));
return 0;
......@@ -111,10 +105,8 @@ ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::create(ProjectExp
bool QnxRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
{
if (!canHandle(parent))
return false;
return ProjectExplorer::idFromMap(map).toString().startsWith(QLatin1String(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX));
return canHandle(parent)
&& ProjectExplorer::idFromMap(map).name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX);
}
ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
......
......@@ -97,7 +97,7 @@ bool QnxRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mo
return false;
if (!runConfiguration->isEnabled()
|| !runConfiguration->id().toString().startsWith(QLatin1String(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX))) {
|| !runConfiguration->id().name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)) {
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment