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.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
#include "qmlprojecttarget.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
#include "qmlproject.h"
|
2010-02-16 13:39:13 +01:00
|
|
|
#include "qmlprojectmanagerconstants.h"
|
|
|
|
|
#include "qmlprojectrunconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
#include <QtGui/QApplication>
|
|
|
|
|
#include <QtGui/QStyle>
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
namespace Internal {
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTarget::QmlProjectTarget(QmlProject *parent) :
|
|
|
|
|
ProjectExplorer::Target(parent, QLatin1String(Constants::QML_VIEWER_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
setDisplayName(QApplication::translate("QmlProjectManager::QmlTarget",
|
2010-02-16 13:39:13 +01:00
|
|
|
Constants::QML_VIEWER_TARGET_DISPLAY_NAME,
|
2010-03-18 10:50:20 +01:00
|
|
|
"QML Runtime target display name"));
|
2010-02-08 15:50:06 +01:00
|
|
|
setIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTarget::~QmlProjectTarget()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProject *QmlProjectTarget::qmlProject() const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
return static_cast<QmlProject *>(project());
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
ProjectExplorer::IBuildConfigurationFactory *QmlProjectTarget::buildConfigurationFactory(void) const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
bool QmlProjectTarget::fromMap(const QVariantMap &map)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
if (!Target::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2010-02-10 12:16:01 +01:00
|
|
|
setDisplayName(QApplication::translate("QmlProjectManager::QmlTarget",
|
2010-02-16 13:39:13 +01:00
|
|
|
Constants::QML_VIEWER_TARGET_DISPLAY_NAME,
|
2010-03-18 10:50:20 +01:00
|
|
|
"QML Runtime target display name"));
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTargetFactory::QmlProjectTargetFactory(QObject *parent) :
|
2010-02-08 15:50:06 +01:00
|
|
|
ITargetFactory(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTargetFactory::~QmlProjectTargetFactory()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QStringList QmlProjectTargetFactory::availableCreationIds(ProjectExplorer::Project *parent) const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
if (!qobject_cast<QmlProject *>(parent))
|
|
|
|
|
return QStringList();
|
2010-02-16 13:39:13 +01:00
|
|
|
return QStringList() << QLatin1String(Constants::QML_VIEWER_TARGET_ID);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QString QmlProjectTargetFactory::displayNameForId(const QString &id) const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2010-02-16 13:39:13 +01:00
|
|
|
if (id == QLatin1String(Constants::QML_VIEWER_TARGET_ID))
|
2010-02-08 15:50:06 +01:00
|
|
|
return QCoreApplication::translate("QmlProjectManager::QmlTarget",
|
2010-02-16 13:39:13 +01:00
|
|
|
Constants::QML_VIEWER_TARGET_DISPLAY_NAME,
|
2010-03-18 10:50:20 +01:00
|
|
|
"QML Runtime target display name");
|
2010-02-08 15:50:06 +01:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
bool QmlProjectTargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
if (!qobject_cast<QmlProject *>(parent))
|
|
|
|
|
return false;
|
2010-02-16 13:39:13 +01:00
|
|
|
return id == QLatin1String(Constants::QML_VIEWER_TARGET_ID);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTarget *QmlProjectTargetFactory::create(ProjectExplorer::Project *parent, const QString &id)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
|
return 0;
|
|
|
|
|
QmlProject *qmlproject(static_cast<QmlProject *>(parent));
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTarget *t(new QmlProjectTarget(qmlproject));
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-03-18 10:50:20 +01:00
|
|
|
// Add RunConfiguration (QML does not have BuildConfigurations)
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectRunConfiguration *runConf(new QmlProjectRunConfiguration(t));
|
2010-02-08 15:50:06 +01:00
|
|
|
t->addRunConfiguration(runConf);
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
bool QmlProjectTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTarget *QmlProjectTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
|
|
|
|
QmlProject *qmlproject(static_cast<QmlProject *>(parent));
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectTarget *target(new QmlProjectTarget(qmlproject));
|
2010-02-08 15:50:06 +01:00
|
|
|
if (target->fromMap(map))
|
|
|
|
|
return target;
|
|
|
|
|
delete target;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProjectManager
|