2010-02-08 15:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
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
|
|
|
|
2010-03-31 10:36:01 +02:00
|
|
|
#include <QtCore/QDebug>
|
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-05-20 11:59:42 +02:00
|
|
|
"QML Viewer 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-12-06 12:45:05 +01:00
|
|
|
ProjectExplorer::BuildConfigWidget *QmlProjectTarget::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
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-03-31 10:36:01 +02:00
|
|
|
if (runConfigurations().isEmpty()) {
|
|
|
|
|
qWarning() << "Failed to restore run configuration of QML project!";
|
|
|
|
|
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-05-20 11:59:42 +02:00
|
|
|
"QML Viewer 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-12-06 12:05:11 +01:00
|
|
|
bool QmlProjectTargetFactory::supportsTargetId(const QString &id) const
|
|
|
|
|
{
|
|
|
|
|
return id == QLatin1String(Constants::QML_VIEWER_TARGET_ID);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
QStringList QmlProjectTargetFactory::supportedTargetIds(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-05-20 11:59:42 +02:00
|
|
|
"QML Viewer 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-12-06 16:15:41 +01:00
|
|
|
QmlProjectTarget *target = 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-12-06 16:15:41 +01:00
|
|
|
QmlProjectRunConfiguration *runConf = new QmlProjectRunConfiguration(target);
|
|
|
|
|
target->addRunConfiguration(runConf);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-12-06 16:15:41 +01:00
|
|
|
return target;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
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
|