2010-02-08 15:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qt4target.h"
|
|
|
|
|
|
|
|
|
|
#include "makestep.h"
|
|
|
|
|
#include "profilereader.h"
|
|
|
|
|
#include "qmakestep.h"
|
|
|
|
|
#include "qt4project.h"
|
|
|
|
|
#include "qt4runconfiguration.h"
|
2010-02-25 16:51:27 +01:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2010-07-12 11:07:36 +02:00
|
|
|
#include "qt-maemo/maemodeploystep.h"
|
2010-04-06 16:56:47 +02:00
|
|
|
#include "qt-maemo/maemopackagecreationstep.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "qt-maemo/maemorunconfiguration.h"
|
|
|
|
|
#include "qt-s60/s60devicerunconfiguration.h"
|
|
|
|
|
#include "qt-s60/s60emulatorrunconfiguration.h"
|
2010-03-23 18:54:04 +01:00
|
|
|
#include "qt-s60/s60createpackagestep.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-03-30 18:45:04 +02:00
|
|
|
#include <projectexplorer/customexecutablerunconfiguration.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2010-02-09 19:05:15 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <symbianutils/symbiandevicemanager.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
#include <QtGui/QApplication>
|
2010-02-09 19:05:15 +01:00
|
|
|
#include <QtGui/QPixmap>
|
|
|
|
|
#include <QtGui/QPainter>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
QString displayNameForId(const QString &id) {
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::DESKTOP_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Desktop", "Qt4 Desktop target display name");
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID))
|
2010-02-10 12:16:01 +01:00
|
|
|
return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Symbian Emulator", "Qt4 Symbian Emulator target display name");
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID))
|
2010-02-10 12:16:01 +01:00
|
|
|
return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Symbian Device", "Qt4 Symbian Device target display name");
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
|
2010-02-26 11:30:11 +01:00
|
|
|
return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Maemo", "Qt4 Maemo target display name");
|
2010-02-24 14:10:36 +01:00
|
|
|
if (id == QLatin1String(Constants::QT_SIMULATOR_TARGET_ID))
|
|
|
|
|
return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Qt Simulator", "Qt4 Simulator target display name");
|
2010-02-08 15:50:06 +01:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QIcon iconForId(const QString &id) {
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::DESKTOP_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
return QIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon));
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID))
|
2010-02-19 14:32:33 +01:00
|
|
|
return QIcon(":/projectexplorer/images/SymbianEmulator.png");
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID))
|
2010-02-19 14:32:33 +01:00
|
|
|
return QIcon(":/projectexplorer/images/SymbianDevice.png");
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
|
2010-02-19 14:32:33 +01:00
|
|
|
return QIcon(":/projectexplorer/images/MaemoDevice.png");
|
2010-02-24 14:10:36 +01:00
|
|
|
if (id == QLatin1String(Constants::QT_SIMULATOR_TARGET_ID))
|
|
|
|
|
return QIcon(":/projectexplorer/images/SymbianEmulator.png");
|
2010-02-08 15:50:06 +01:00
|
|
|
return QIcon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Qt4TargetFactory
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Qt4TargetFactory::Qt4TargetFactory(QObject *parent) :
|
|
|
|
|
ITargetFactory(parent)
|
|
|
|
|
{
|
|
|
|
|
connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
|
|
|
|
|
this, SIGNAL(availableCreationIdsChanged()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4TargetFactory::~Qt4TargetFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList Qt4TargetFactory::availableCreationIds(ProjectExplorer::Project *parent) const
|
|
|
|
|
{
|
|
|
|
|
if (!qobject_cast<Qt4Project *>(parent))
|
|
|
|
|
return QStringList();
|
|
|
|
|
|
|
|
|
|
return parent->possibleTargetIds().toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4TargetFactory::displayNameForId(const QString &id) const
|
|
|
|
|
{
|
|
|
|
|
return ::displayNameForId(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Qt4TargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
|
|
|
|
|
{
|
|
|
|
|
if (!qobject_cast<Qt4Project *>(parent))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return parent->canAddTarget(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Target *Qt4TargetFactory::create(ProjectExplorer::Project *parent, const QString &id)
|
2010-02-17 16:18:21 +01:00
|
|
|
{
|
2010-03-26 10:26:28 +01:00
|
|
|
QList<QtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id);
|
|
|
|
|
if (knownVersions.count() > 1)
|
|
|
|
|
knownVersions = knownVersions.mid(0, 1);
|
|
|
|
|
return create(parent, id, knownVersions);
|
2010-02-17 16:18:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Target *Qt4TargetFactory::create(ProjectExplorer::Project *parent, const QString &id, QList<QtVersion *> versions)
|
2010-03-26 10:26:28 +01:00
|
|
|
{
|
|
|
|
|
QList<BuildConfigurationInfo> infos;
|
|
|
|
|
foreach (QtVersion *version, versions) {
|
|
|
|
|
bool buildAll = false;
|
|
|
|
|
if (version && version->isValid() && (version->defaultBuildConfig() & QtVersion::BuildAll))
|
|
|
|
|
buildAll = true;
|
|
|
|
|
|
|
|
|
|
if (buildAll) {
|
|
|
|
|
infos.append(BuildConfigurationInfo(version, QtVersion::BuildAll | QtVersion::DebugBuild));
|
|
|
|
|
infos.append(BuildConfigurationInfo(version, QtVersion::BuildAll));
|
|
|
|
|
} else {
|
|
|
|
|
infos.append(BuildConfigurationInfo(version, QtVersion::DebugBuild));
|
|
|
|
|
infos.append(BuildConfigurationInfo(version, QtVersion::QmakeBuildConfig(0)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return create(parent, id, infos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Target *Qt4TargetFactory::create(ProjectExplorer::Project *parent, const QString &id, QList<BuildConfigurationInfo> infos)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2010-03-26 10:26:28 +01:00
|
|
|
Qt4Project *qt4project = static_cast<Qt4Project *>(parent);
|
|
|
|
|
Qt4Target *t = new Qt4Target(qt4project, id);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-02-17 16:18:21 +01:00
|
|
|
QList<QtVersion *> knownVersions(QtVersionManager::instance()->versionsForTargetId(id));
|
|
|
|
|
if (knownVersions.isEmpty())
|
2010-02-08 15:50:06 +01:00
|
|
|
return t;
|
|
|
|
|
|
2010-03-26 10:26:28 +01:00
|
|
|
// count Qt versions:
|
|
|
|
|
int qtVersionCount = 0;
|
|
|
|
|
{
|
|
|
|
|
QSet<QtVersion *> differentVersions;
|
|
|
|
|
foreach (const BuildConfigurationInfo &info, infos) {
|
|
|
|
|
if (knownVersions.contains(info.version))
|
|
|
|
|
differentVersions.insert(info.version);
|
|
|
|
|
}
|
|
|
|
|
qtVersionCount = differentVersions.count();
|
|
|
|
|
}
|
2010-02-17 16:18:21 +01:00
|
|
|
|
2010-03-26 10:26:28 +01:00
|
|
|
// Create Buildconfigurations:
|
|
|
|
|
foreach (const BuildConfigurationInfo &info, infos) {
|
|
|
|
|
if (!info.version || !knownVersions.contains(info.version))
|
2010-02-17 16:18:21 +01:00
|
|
|
continue;
|
|
|
|
|
|
2010-03-26 10:26:28 +01:00
|
|
|
QString displayName;
|
2010-02-17 16:18:21 +01:00
|
|
|
|
2010-03-26 10:26:28 +01:00
|
|
|
if (qtVersionCount > 1)
|
2010-03-29 17:11:48 +02:00
|
|
|
displayName = info.version->displayName() + QChar(' ');
|
|
|
|
|
displayName.append((info.buildConfig & QtVersion::DebugBuild) ? tr("Debug") : tr("Release"));
|
2010-02-17 16:18:21 +01:00
|
|
|
|
2010-03-26 10:26:28 +01:00
|
|
|
// Skip release builds for the symbian emulator.
|
2010-04-01 11:32:53 +02:00
|
|
|
if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID) &&
|
|
|
|
|
!(info.buildConfig & QtVersion::DebugBuild))
|
2010-03-26 10:26:28 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
t->addQt4BuildConfiguration(displayName, info.version, info.buildConfig, info.additionalArguments, info.directory);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-26 10:26:28 +01:00
|
|
|
// create RunConfigurations:
|
2010-02-09 18:07:00 +01:00
|
|
|
QStringList pathes = qt4project->applicationProFilePathes();
|
|
|
|
|
foreach (const QString &path, pathes)
|
|
|
|
|
t->addRunConfigurationForPath(path);
|
|
|
|
|
|
2010-03-30 18:45:04 +02:00
|
|
|
if (t->runConfigurations().isEmpty())
|
|
|
|
|
t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Qt4TargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
|
|
|
|
|
{
|
|
|
|
|
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Target *Qt4TargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
Qt4Project * qt4project(static_cast<Qt4Project *>(parent));
|
|
|
|
|
Qt4Target *t(new Qt4Target(qt4project, QLatin1String("transient ID")));
|
|
|
|
|
if (t->fromMap(map))
|
|
|
|
|
return t;
|
|
|
|
|
delete t;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Qt4Target
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Qt4Target::Qt4Target(Qt4Project *parent, const QString &id) :
|
|
|
|
|
ProjectExplorer::Target(parent, id),
|
2010-02-19 14:32:33 +01:00
|
|
|
m_connectedPixmap(QLatin1String(":/projectexplorer/images/ConnectionOn.png")),
|
|
|
|
|
m_disconnectedPixmap(QLatin1String(":/projectexplorer/images/ConnectionOff.png")),
|
2010-02-08 15:50:06 +01:00
|
|
|
m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this))
|
|
|
|
|
{
|
|
|
|
|
connect(project(), SIGNAL(supportedTargetIdsChanged()),
|
|
|
|
|
this, SLOT(updateQtVersion()));
|
2010-03-10 16:55:37 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(this, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
2010-03-10 16:55:37 +01:00
|
|
|
this, SLOT(emitProFileEvaluateNeeded()));
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(this, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SIGNAL(environmentChanged()));
|
2010-02-09 19:05:15 +01:00
|
|
|
connect(this, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(onAddedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
2010-02-15 17:33:56 +01:00
|
|
|
connect(this, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(onAddedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
2010-02-09 19:05:15 +01:00
|
|
|
connect(this, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(updateToolTipAndIcon()));
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
setDisplayName(displayNameForId(id));
|
2010-02-23 16:52:03 +01:00
|
|
|
setIcon(iconForId(id));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Target::~Qt4Target()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4BuildConfiguration *Qt4Target::activeBuildConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<Qt4BuildConfiguration *>(Target::activeBuildConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Project *Qt4Target::qt4Project() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<Qt4Project *>(project());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4BuildConfiguration *Qt4Target::addQt4BuildConfiguration(QString displayName, QtVersion *qtversion,
|
|
|
|
|
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
|
2010-03-26 10:26:28 +01:00
|
|
|
QStringList additionalArguments,
|
|
|
|
|
QString directory)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(qtversion);
|
|
|
|
|
bool debug = qmakeBuildConfiguration & QtVersion::DebugBuild;
|
|
|
|
|
|
|
|
|
|
// Add the buildconfiguration
|
|
|
|
|
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(this);
|
|
|
|
|
bc->setDisplayName(displayName);
|
|
|
|
|
|
|
|
|
|
QMakeStep *qmakeStep = new QMakeStep(bc);
|
2010-07-06 17:49:09 +02:00
|
|
|
bc->insertStep(ProjectExplorer::BuildStep::Build, 0, qmakeStep);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
MakeStep *makeStep = new MakeStep(bc);
|
2010-07-06 17:49:09 +02:00
|
|
|
bc->insertStep(ProjectExplorer::BuildStep::Build, 1, makeStep);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-03-23 18:54:04 +01:00
|
|
|
if (id() == Constants::S60_DEVICE_TARGET_ID) {
|
|
|
|
|
S60CreatePackageStep *packageStep = new S60CreatePackageStep(bc);
|
2010-07-06 17:56:01 +02:00
|
|
|
bc->insertStep(ProjectExplorer::BuildStep::Deploy, 2, packageStep);
|
2010-04-06 16:56:47 +02:00
|
|
|
} else if (id() == Constants::MAEMO_DEVICE_TARGET_ID) {
|
2010-07-12 11:07:36 +02:00
|
|
|
bc->insertStep(ProjectExplorer::BuildStep::Deploy, 2,
|
|
|
|
|
new MaemoPackageCreationStep(bc));
|
2010-07-13 15:24:21 +02:00
|
|
|
bc->insertStep(ProjectExplorer::BuildStep::Deploy, 3,
|
|
|
|
|
new MaemoDeployStep(bc));
|
2010-03-23 18:54:04 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
MakeStep* cleanStep = new MakeStep(bc);
|
|
|
|
|
cleanStep->setClean(true);
|
|
|
|
|
cleanStep->setUserArguments(QStringList() << "clean");
|
2010-07-06 17:49:09 +02:00
|
|
|
bc->insertStep(ProjectExplorer::BuildStep::Clean, 0, cleanStep);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!additionalArguments.isEmpty())
|
|
|
|
|
qmakeStep->setUserArguments(additionalArguments);
|
|
|
|
|
|
|
|
|
|
// set some options for qmake and make
|
|
|
|
|
if (qmakeBuildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets
|
|
|
|
|
makeStep->setUserArguments(QStringList() << (debug ? "debug" : "release"));
|
|
|
|
|
|
|
|
|
|
bc->setQMakeBuildConfiguration(qmakeBuildConfiguration);
|
|
|
|
|
|
|
|
|
|
// Finally set the qt version & ToolChain
|
|
|
|
|
bc->setQtVersion(qtversion);
|
|
|
|
|
ToolChain::ToolChainType defaultTc = preferredToolChainType(filterToolChainTypes(bc->qtVersion()->possibleToolChainTypes()));
|
|
|
|
|
bc->setToolChainType(defaultTc);
|
2010-03-26 10:26:28 +01:00
|
|
|
if (!directory.isEmpty())
|
|
|
|
|
bc->setShadowBuildAndDirectory(directory != project()->projectDirectory(), directory);
|
2010-02-08 15:50:06 +01:00
|
|
|
addBuildConfiguration(bc);
|
|
|
|
|
|
|
|
|
|
return bc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4BuildConfigurationFactory *Qt4Target::buildConfigurationFactory() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildConfigurationFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Target::addRunConfigurationForPath(const QString &proFilePath)
|
|
|
|
|
{
|
2010-02-24 14:10:36 +01:00
|
|
|
if (id() == QLatin1String(Constants::DESKTOP_TARGET_ID) ||
|
|
|
|
|
id() == QLatin1String(Constants::QT_SIMULATOR_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
addRunConfiguration(new Qt4RunConfiguration(this, proFilePath));
|
2010-02-25 16:51:27 +01:00
|
|
|
else if (id() == QLatin1String(Constants::S60_EMULATOR_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
addRunConfiguration(new S60EmulatorRunConfiguration(this, proFilePath));
|
2010-02-25 16:51:27 +01:00
|
|
|
else if (id() == QLatin1String(Constants::S60_DEVICE_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
addRunConfiguration(new S60DeviceRunConfiguration(this, proFilePath));
|
2010-02-25 16:51:27 +01:00
|
|
|
else if (id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
addRunConfiguration(new MaemoRunConfiguration(this, proFilePath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ToolChain::ToolChainType> Qt4Target::filterToolChainTypes(const QList<ToolChain::ToolChainType> &candidates) const
|
|
|
|
|
{
|
|
|
|
|
QList<ToolChain::ToolChainType> tmp(candidates);
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id() == QLatin1String(Constants::S60_EMULATOR_TARGET_ID)) {
|
2010-02-08 15:50:06 +01:00
|
|
|
if (tmp.contains(ToolChain::WINSCW))
|
|
|
|
|
return QList<ToolChain::ToolChainType>() << ToolChain::WINSCW;
|
|
|
|
|
else
|
|
|
|
|
return QList<ToolChain::ToolChainType>();
|
2010-02-25 16:51:27 +01:00
|
|
|
} else if (id() == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) {
|
2010-02-08 15:50:06 +01:00
|
|
|
tmp.removeAll(ToolChain::WINSCW);
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::ToolChainType Qt4Target::preferredToolChainType(const QList<ToolChain::ToolChainType> &candidates) const
|
|
|
|
|
{
|
|
|
|
|
ToolChain::ToolChainType preferredType = ToolChain::INVALID;
|
2010-02-25 16:51:27 +01:00
|
|
|
if (id() == QLatin1String(Constants::S60_EMULATOR_TARGET_ID) &&
|
2010-02-08 15:50:06 +01:00
|
|
|
candidates.contains(ToolChain::WINSCW))
|
|
|
|
|
preferredType = ToolChain::WINSCW;
|
|
|
|
|
if (!candidates.isEmpty())
|
|
|
|
|
preferredType = candidates.at(0);
|
|
|
|
|
return preferredType;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-25 11:55:29 +01:00
|
|
|
QString Qt4Target::defaultBuildDirectory() const
|
|
|
|
|
{
|
|
|
|
|
if (id() == QLatin1String(Constants::S60_DEVICE_TARGET_ID)
|
|
|
|
|
|| id() == QLatin1String(Constants::S60_EMULATOR_TARGET_ID)
|
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
|
|| id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)
|
|
|
|
|
#endif
|
|
|
|
|
)
|
|
|
|
|
return project()->projectDirectory();
|
|
|
|
|
|
2010-06-08 14:19:05 +02:00
|
|
|
return defaultShadowBuildDirectory(qt4Project()->defaultTopLevelBuildDirectory(), id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4Target::defaultShadowBuildDirectory(const QString &projectLocation, const QString &id)
|
|
|
|
|
{
|
2010-03-25 11:55:29 +01:00
|
|
|
QString shortName = QLatin1String("unknown");
|
2010-06-08 14:19:05 +02:00
|
|
|
if (id == QLatin1String(Constants::DESKTOP_TARGET_ID))
|
2010-03-25 11:55:29 +01:00
|
|
|
shortName = QLatin1String("desktop");
|
2010-06-08 14:19:05 +02:00
|
|
|
else if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID))
|
2010-03-25 11:55:29 +01:00
|
|
|
shortName = QLatin1String("symbian_emulator");
|
2010-06-08 14:19:05 +02:00
|
|
|
else if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID))
|
2010-03-25 11:55:29 +01:00
|
|
|
shortName = QLatin1String("symbian");
|
2010-06-08 14:19:05 +02:00
|
|
|
else if (id == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
|
2010-03-25 11:55:29 +01:00
|
|
|
shortName = QLatin1String("maemo");
|
2010-06-08 14:19:05 +02:00
|
|
|
else if (id == QLatin1String(Constants::QT_SIMULATOR_TARGET_ID))
|
2010-02-24 14:10:36 +01:00
|
|
|
shortName = QLatin1String("simulator");
|
2010-03-25 11:55:29 +01:00
|
|
|
|
2010-04-13 12:27:01 +02:00
|
|
|
// currently we can't have the build directory to be deeper then the source directory
|
|
|
|
|
// since that is broken in qmake
|
|
|
|
|
// Once qmake is fixed we can change that to have a top directory and
|
|
|
|
|
// subdirectories per build. (Replacing "QChar('-')" with "QChar('/') )
|
2010-06-08 14:19:05 +02:00
|
|
|
return projectLocation + QChar('-') + shortName;
|
2010-03-25 11:55:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool Qt4Target::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!Target::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2010-02-10 12:16:01 +01:00
|
|
|
setDisplayName(displayNameForId(id()));
|
2010-02-23 16:52:03 +01:00
|
|
|
setIcon(iconForId(id()));
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Target::updateQtVersion()
|
|
|
|
|
{
|
|
|
|
|
setEnabled(project()->supportedTargetIds().contains(id()));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
void Qt4Target::onAddedRunConfiguration(ProjectExplorer::RunConfiguration *rc)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(rc);
|
|
|
|
|
S60DeviceRunConfiguration *deviceRc(qobject_cast<S60DeviceRunConfiguration *>(rc));
|
|
|
|
|
if (!deviceRc)
|
|
|
|
|
return;
|
|
|
|
|
connect(deviceRc, SIGNAL(serialPortNameChanged()),
|
|
|
|
|
this, SLOT(slotUpdateDeviceInformation()));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-15 17:33:56 +01:00
|
|
|
void Qt4Target::onAddedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(bc);
|
|
|
|
|
Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(bc);
|
|
|
|
|
Q_ASSERT(qt4bc);
|
|
|
|
|
connect(qt4bc, SIGNAL(buildDirectoryInitialized()),
|
|
|
|
|
this, SIGNAL(buildDirectoryInitialized()));
|
2010-03-10 16:55:37 +01:00
|
|
|
connect(qt4bc, SIGNAL(proFileEvaluateNeeded(Qt4ProjectManager::Internal::Qt4BuildConfiguration *)),
|
|
|
|
|
this, SLOT(onProFileEvaluateNeeded(Qt4ProjectManager::Internal::Qt4BuildConfiguration *)));
|
2010-02-15 17:33:56 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
void Qt4Target::slotUpdateDeviceInformation()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2010-02-09 19:05:15 +01:00
|
|
|
S60DeviceRunConfiguration *deviceRc(qobject_cast<S60DeviceRunConfiguration *>(sender()));
|
|
|
|
|
if (deviceRc && deviceRc == activeRunConfiguration()) {
|
|
|
|
|
updateToolTipAndIcon();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
void Qt4Target::onProFileEvaluateNeeded(Qt4ProjectManager::Internal::Qt4BuildConfiguration *bc)
|
2010-02-16 13:05:32 +01:00
|
|
|
{
|
|
|
|
|
if (bc && bc == activeBuildConfiguration())
|
2010-03-10 16:55:37 +01:00
|
|
|
emit proFileEvaluateNeeded(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4Target::emitProFileEvaluateNeeded()
|
|
|
|
|
{
|
|
|
|
|
emit proFileEvaluateNeeded(this);
|
2010-02-16 13:05:32 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
void Qt4Target::updateToolTipAndIcon()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2010-02-23 16:52:03 +01:00
|
|
|
static const int TARGET_OVERLAY_ORIGINAL_SIZE = 32;
|
2010-02-11 12:31:59 +01:00
|
|
|
if (const S60DeviceRunConfiguration *s60DeviceRc = qobject_cast<S60DeviceRunConfiguration *>(activeRunConfiguration())) {
|
|
|
|
|
const SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
|
|
|
|
|
const int deviceIndex = sdm->findByPortName(s60DeviceRc->serialPortName());
|
2010-02-23 16:52:03 +01:00
|
|
|
QPixmap overlay;
|
2010-02-11 12:31:59 +01:00
|
|
|
if (deviceIndex == -1) {
|
2010-02-09 19:05:15 +01:00
|
|
|
setToolTip(tr("<b>Device:</b> Not connected"));
|
2010-02-23 16:52:03 +01:00
|
|
|
overlay = m_disconnectedPixmap;
|
2010-02-11 12:31:59 +01:00
|
|
|
} else {
|
|
|
|
|
// device connected
|
|
|
|
|
const SymbianUtils::SymbianDevice device = sdm->devices().at(deviceIndex);
|
|
|
|
|
const QString tooltip = device.additionalInformation().isEmpty() ?
|
|
|
|
|
tr("<b>Device:</b> %1").arg(device.friendlyName()) :
|
|
|
|
|
tr("<b>Device:</b> %1, %2").arg(device.friendlyName(), device.additionalInformation());
|
|
|
|
|
setToolTip(tooltip);
|
2010-02-23 16:52:03 +01:00
|
|
|
overlay = m_connectedPixmap;
|
2010-02-09 19:05:15 +01:00
|
|
|
}
|
2010-02-23 16:52:03 +01:00
|
|
|
double factor = Core::Constants::TARGET_ICON_SIZE / (double)TARGET_OVERLAY_ORIGINAL_SIZE;
|
|
|
|
|
QSize overlaySize(overlay.size().width()*factor, overlay.size().height()*factor);
|
|
|
|
|
QPixmap pixmap(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE);
|
|
|
|
|
pixmap.fill(Qt::transparent);
|
|
|
|
|
QPainter painter(&pixmap);
|
|
|
|
|
painter.drawPixmap(Core::Constants::TARGET_ICON_SIZE - overlaySize.width(),
|
|
|
|
|
Core::Constants::TARGET_ICON_SIZE - overlaySize.height(),
|
|
|
|
|
overlay.scaled(overlaySize));
|
|
|
|
|
|
|
|
|
|
setOverlayIcon(QIcon(pixmap));
|
|
|
|
|
} else {
|
|
|
|
|
setToolTip(QString());
|
|
|
|
|
setOverlayIcon(QIcon());
|
2010-02-09 19:05:15 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|