2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-05-04 12:19:22 +02:00
|
|
|
|
|
|
|
#include "qmlproject.h"
|
2013-07-11 17:37:02 +02:00
|
|
|
#include "fileformat/qmlprojectfileformat.h"
|
2010-02-16 13:39:13 +01:00
|
|
|
#include "fileformat/qmlprojectitem.h"
|
2010-03-08 14:36:44 +01:00
|
|
|
#include "qmlprojectrunconfiguration.h"
|
2011-04-12 12:17:19 +02:00
|
|
|
#include "qmlprojectconstants.h"
|
2017-12-08 14:50:57 +01:00
|
|
|
#include "qmlprojectmanagerconstants.h"
|
2011-08-18 16:46:26 +02:00
|
|
|
#include "qmlprojectnodes.h"
|
2010-02-17 13:37:00 +01:00
|
|
|
|
2017-02-28 16:31:07 +01:00
|
|
|
#include <coreplugin/icontext.h>
|
2010-02-17 13:37:00 +01:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
#include <coreplugin/messagemanager.h>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/documentmanager.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
|
2017-11-28 15:57:15 +01:00
|
|
|
#include <projectexplorer/deploymentdata.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
#include <projectexplorer/kitmanager.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
|
|
|
|
#include <qtsupport/baseqtversion.h>
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2013-03-07 14:02:04 +01:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2017-11-27 11:58:57 +01:00
|
|
|
#include <qtsupport/desktopqtversion.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
2011-04-15 15:55:11 +02:00
|
|
|
|
2017-03-01 14:26:46 +01:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2013-09-05 01:52:17 +02:00
|
|
|
using namespace Core;
|
2013-09-10 17:59:34 +02:00
|
|
|
using namespace ProjectExplorer;
|
2010-01-18 16:32:14 +01:00
|
|
|
|
2013-09-05 01:52:17 +02:00
|
|
|
namespace QmlProjectManager {
|
2013-03-07 14:02:04 +01:00
|
|
|
|
2017-02-28 16:31:07 +01:00
|
|
|
QmlProject::QmlProject(const Utils::FileName &fileName) :
|
2017-11-27 11:48:43 +01:00
|
|
|
Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName,
|
|
|
|
[this]() { refreshProjectFile(); })
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2017-11-28 15:57:15 +01:00
|
|
|
const QString normalized
|
|
|
|
= Utils::FileUtils::normalizePathName(fileName.toFileInfo().canonicalFilePath());
|
|
|
|
m_canonicalProjectDir = Utils::FileName::fromString(normalized).parentDir();
|
|
|
|
|
2017-12-08 14:50:57 +01:00
|
|
|
setId(QmlProjectManager::Constants::QML_PROJECT_ID);
|
2017-01-30 14:59:10 +01:00
|
|
|
setProjectLanguages(Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
|
2017-04-07 14:35:49 +02:00
|
|
|
setDisplayName(fileName.toFileInfo().completeBaseName());
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QmlProject::~QmlProject()
|
|
|
|
{
|
2010-09-24 14:29:40 +02:00
|
|
|
delete m_projectItem.data();
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
2015-02-03 23:48:57 +02:00
|
|
|
void QmlProject::addedTarget(Target *target)
|
2012-10-09 16:20:26 +02:00
|
|
|
{
|
2017-11-28 15:57:15 +01:00
|
|
|
updateDeploymentData(target);
|
2012-10-09 16:20:26 +02:00
|
|
|
}
|
|
|
|
|
2015-02-03 23:48:57 +02:00
|
|
|
void QmlProject::onActiveTargetChanged(Target *target)
|
2013-11-06 12:59:04 +01:00
|
|
|
{
|
|
|
|
if (m_activeTarget)
|
2015-02-03 23:48:57 +02:00
|
|
|
disconnect(m_activeTarget, &Target::kitChanged, this, &QmlProject::onKitChanged);
|
2013-11-06 12:59:04 +01:00
|
|
|
m_activeTarget = target;
|
|
|
|
if (m_activeTarget)
|
2016-07-01 12:19:37 +03:00
|
|
|
connect(target, &Target::kitChanged, this, &QmlProject::onKitChanged);
|
2013-11-06 12:59:04 +01:00
|
|
|
|
|
|
|
// make sure e.g. the default qml imports are adapted
|
|
|
|
refresh(Configuration);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProject::onKitChanged()
|
2013-05-02 15:29:33 +02:00
|
|
|
{
|
|
|
|
// make sure e.g. the default qml imports are adapted
|
|
|
|
refresh(Configuration);
|
|
|
|
}
|
|
|
|
|
2017-11-28 15:57:15 +01:00
|
|
|
Utils::FileName QmlProject::canonicalProjectDir() const
|
2009-05-06 16:13:44 +02:00
|
|
|
{
|
2017-11-28 15:57:15 +01:00
|
|
|
return m_canonicalProjectDir;
|
2009-05-06 16:13:44 +02:00
|
|
|
}
|
|
|
|
|
2009-05-04 12:19:22 +02:00
|
|
|
void QmlProject::parseProject(RefreshOptions options)
|
|
|
|
{
|
|
|
|
if (options & Files) {
|
2010-01-19 13:53:48 +01:00
|
|
|
if (options & ProjectFile)
|
|
|
|
delete m_projectItem.data();
|
2010-01-18 16:32:14 +01:00
|
|
|
if (!m_projectItem) {
|
2013-07-11 17:37:02 +02:00
|
|
|
QString errorMessage;
|
2016-01-08 12:12:27 +01:00
|
|
|
m_projectItem = QmlProjectFileFormat::parseProjectFile(projectFilePath(), &errorMessage);
|
2013-07-11 17:37:02 +02:00
|
|
|
if (m_projectItem) {
|
2016-07-01 12:19:37 +03:00
|
|
|
connect(m_projectItem.data(), &QmlProjectItem::qmlFilesChanged,
|
|
|
|
this, &QmlProject::refreshFiles);
|
2013-07-11 17:37:02 +02:00
|
|
|
|
|
|
|
} else {
|
2015-02-02 00:37:38 +02:00
|
|
|
MessageManager::write(tr("Error while loading project file %1.")
|
2016-01-08 12:12:27 +01:00
|
|
|
.arg(projectFilePath().toUserOutput()),
|
2015-02-02 00:37:38 +02:00
|
|
|
MessageManager::NoModeSwitch);
|
2013-09-05 01:52:17 +02:00
|
|
|
MessageManager::write(errorMessage);
|
2013-07-11 17:37:02 +02:00
|
|
|
}
|
2010-01-18 16:32:14 +01:00
|
|
|
}
|
|
|
|
if (m_projectItem) {
|
2017-11-28 15:57:15 +01:00
|
|
|
m_projectItem.data()->setSourceDirectory(canonicalProjectDir().toString());
|
|
|
|
if (m_projectItem->targetDirectory().isEmpty())
|
|
|
|
m_projectItem->setTargetDirectory(canonicalProjectDir().toString());
|
|
|
|
|
2017-03-14 11:18:09 +01:00
|
|
|
if (auto modelManager = QmlJS::ModelManagerInterface::instance())
|
|
|
|
modelManager->updateSourceFiles(m_projectItem.data()->files(), true);
|
2012-01-02 15:54:51 +01:00
|
|
|
|
|
|
|
QString mainFilePath = m_projectItem.data()->mainFile();
|
|
|
|
if (!mainFilePath.isEmpty()) {
|
2017-11-28 15:57:15 +01:00
|
|
|
mainFilePath
|
|
|
|
= QDir(canonicalProjectDir().toString()).absoluteFilePath(mainFilePath);
|
2013-01-21 13:54:20 +01:00
|
|
|
Utils::FileReader reader;
|
|
|
|
QString errorMessage;
|
|
|
|
if (!reader.fetch(mainFilePath, &errorMessage)) {
|
2015-02-02 00:37:38 +02:00
|
|
|
MessageManager::write(tr("Warning while loading project file %1.")
|
2016-01-08 12:12:27 +01:00
|
|
|
.arg(projectFilePath().toUserOutput()));
|
2013-09-05 01:52:17 +02:00
|
|
|
MessageManager::write(errorMessage);
|
2012-01-02 15:54:51 +01:00
|
|
|
}
|
|
|
|
}
|
2010-01-18 16:32:14 +01:00
|
|
|
}
|
2017-03-01 14:26:46 +01:00
|
|
|
generateProjectTree();
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (options & Configuration) {
|
|
|
|
// update configuration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProject::refresh(RefreshOptions options)
|
|
|
|
{
|
2017-07-13 10:51:15 +02:00
|
|
|
emitParsingStarted();
|
2009-05-04 12:19:22 +02:00
|
|
|
parseProject(options);
|
|
|
|
|
|
|
|
if (options & Files)
|
2017-03-01 14:26:46 +01:00
|
|
|
generateProjectTree();
|
2010-06-22 12:54:19 +02:00
|
|
|
|
2017-03-14 11:18:09 +01:00
|
|
|
auto modelManager = QmlJS::ModelManagerInterface::instance();
|
|
|
|
if (!modelManager)
|
2014-07-24 11:48:30 +02:00
|
|
|
return;
|
|
|
|
|
2012-12-06 17:20:58 +01:00
|
|
|
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
|
2017-03-14 11:18:09 +01:00
|
|
|
modelManager->defaultProjectInfoForProject(this);
|
2018-02-26 14:26:07 +01:00
|
|
|
foreach (const QString &searchPath, makeAbsolute(canonicalProjectDir(), customImportPaths()))
|
2014-07-22 19:06:44 +02:00
|
|
|
projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(searchPath),
|
|
|
|
QmlJS::Dialect::Qml);
|
2013-01-10 16:12:45 +01:00
|
|
|
|
2017-03-14 11:18:09 +01:00
|
|
|
modelManager->updateProjectInfo(projectInfo, this);
|
2016-10-20 13:18:54 +02:00
|
|
|
|
2017-07-13 10:51:15 +02:00
|
|
|
emitParsingFinished(true);
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
QString QmlProject::mainFile() const
|
|
|
|
{
|
|
|
|
if (m_projectItem)
|
|
|
|
return m_projectItem.data()->mainFile();
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2017-11-28 15:57:15 +01:00
|
|
|
Utils::FileName QmlProject::targetDirectory(const Target *target) const
|
|
|
|
{
|
|
|
|
if (DeviceTypeKitInformation::deviceTypeId(target->kit())
|
|
|
|
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
|
|
|
|
return canonicalProjectDir();
|
|
|
|
|
|
|
|
return m_projectItem ? Utils::FileName::fromString(m_projectItem->targetDirectory())
|
|
|
|
: Utils::FileName();
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils::FileName QmlProject::targetFile(const Utils::FileName &sourceFile,
|
|
|
|
const Target *target) const
|
|
|
|
{
|
|
|
|
const QDir sourceDir(m_projectItem ? m_projectItem->sourceDirectory()
|
|
|
|
: canonicalProjectDir().toString());
|
|
|
|
const QDir targetDir(targetDirectory(target).toString());
|
|
|
|
const QString relative = sourceDir.relativeFilePath(sourceFile.toString());
|
|
|
|
return Utils::FileName::fromString(QDir::cleanPath(targetDir.absoluteFilePath(relative)));
|
|
|
|
}
|
|
|
|
|
2018-01-29 13:38:41 +01:00
|
|
|
QList<Utils::EnvironmentItem> QmlProject::environment() const
|
|
|
|
{
|
|
|
|
if (m_projectItem)
|
|
|
|
return m_projectItem.data()->environment();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2010-02-17 13:37:00 +01:00
|
|
|
bool QmlProject::validProjectFile() const
|
|
|
|
{
|
|
|
|
return !m_projectItem.isNull();
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:28:34 +01:00
|
|
|
QStringList QmlProject::customImportPaths() const
|
2010-02-03 09:13:23 +01:00
|
|
|
{
|
|
|
|
if (m_projectItem)
|
2018-02-24 18:36:58 +01:00
|
|
|
return m_projectItem.data()->importPaths();
|
|
|
|
return {};
|
2010-02-03 09:13:23 +01:00
|
|
|
}
|
|
|
|
|
2010-02-17 11:20:35 +01:00
|
|
|
bool QmlProject::addFiles(const QStringList &filePaths)
|
|
|
|
{
|
|
|
|
QStringList toAdd;
|
|
|
|
foreach (const QString &filePath, filePaths) {
|
|
|
|
if (!m_projectItem.data()->matchesFile(filePath))
|
|
|
|
toAdd << filePaths;
|
|
|
|
}
|
|
|
|
return toAdd.isEmpty();
|
|
|
|
}
|
|
|
|
|
2010-01-19 13:53:48 +01:00
|
|
|
void QmlProject::refreshProjectFile()
|
|
|
|
{
|
|
|
|
refresh(QmlProject::ProjectFile | Files);
|
|
|
|
}
|
|
|
|
|
2018-04-19 13:30:15 +02:00
|
|
|
bool QmlProject::needsBuildConfigurations() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-26 14:26:07 +01:00
|
|
|
QStringList QmlProject::makeAbsolute(const Utils::FileName &path, const QStringList &relativePaths)
|
|
|
|
{
|
|
|
|
if (path.isEmpty())
|
|
|
|
return relativePaths;
|
|
|
|
|
|
|
|
const QDir baseDir(path.toString());
|
|
|
|
return Utils::transform(relativePaths, [&baseDir](const QString &path) {
|
|
|
|
return QDir::cleanPath(baseDir.absoluteFilePath(path));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-05-18 13:40:35 +02:00
|
|
|
void QmlProject::refreshFiles(const QSet<QString> &/*added*/, const QSet<QString> &removed)
|
2010-01-19 13:53:48 +01:00
|
|
|
{
|
|
|
|
refresh(Files);
|
2017-03-14 11:18:09 +01:00
|
|
|
if (!removed.isEmpty()) {
|
|
|
|
if (auto modelManager = QmlJS::ModelManagerInterface::instance())
|
|
|
|
modelManager->removeFiles(removed.toList());
|
|
|
|
}
|
2017-11-28 15:57:15 +01:00
|
|
|
refreshTargetDirectory();
|
2010-01-19 13:53:48 +01:00
|
|
|
}
|
|
|
|
|
2017-11-28 15:57:15 +01:00
|
|
|
void QmlProject::refreshTargetDirectory()
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2017-11-28 15:57:15 +01:00
|
|
|
const QList<Target *> targetList = targets();
|
|
|
|
for (Target *target : targetList)
|
|
|
|
updateDeploymentData(target);
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2018-04-18 13:39:05 +02:00
|
|
|
QList<Task> QmlProject::projectIssues(const Kit *k) const
|
2017-11-28 15:57:15 +01:00
|
|
|
{
|
2018-04-18 13:39:05 +02:00
|
|
|
QList<Task> result = Project::projectIssues(k);
|
|
|
|
|
|
|
|
const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
if (!version)
|
|
|
|
result.append(createProjectTask(Task::TaskType::Error, tr("No Qt version set in kit.")));
|
2018-03-08 17:46:20 +01:00
|
|
|
|
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
2018-04-18 13:39:05 +02:00
|
|
|
if (dev.isNull())
|
|
|
|
result.append(createProjectTask(Task::TaskType::Error, tr("Kit has no device.")));
|
2018-03-08 17:46:20 +01:00
|
|
|
|
2018-04-18 13:39:05 +02:00
|
|
|
if (version && version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0))
|
|
|
|
result.append(createProjectTask(Task::TaskType::Error, tr("Qt version is too old.")));
|
|
|
|
|
|
|
|
if (dev.isNull() || !version)
|
|
|
|
return result; // No need to check deeper than this
|
2018-03-08 17:46:20 +01:00
|
|
|
|
|
|
|
if (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
2018-03-08 17:46:51 +01:00
|
|
|
if (version->type() == QtSupport::Constants::DESKTOPQT) {
|
2018-04-18 13:39:05 +02:00
|
|
|
if (static_cast<const QtSupport::DesktopQtVersion *>(version)->qmlsceneCommand().isEmpty()) {
|
|
|
|
result.append(createProjectTask(Task::TaskType::Error,
|
|
|
|
tr("Qt version has no qmlscene command.")));
|
2018-03-08 17:46:20 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Non-desktop Qt on a desktop device? We don't support that.
|
2018-04-18 13:39:05 +02:00
|
|
|
result.append(createProjectTask(Task::TaskType::Error,
|
2018-06-08 13:53:51 +02:00
|
|
|
tr("Non-desktop Qt is used with a desktop device.")));
|
2018-03-08 17:46:20 +01:00
|
|
|
}
|
2018-04-18 13:39:05 +02:00
|
|
|
} else {
|
|
|
|
// If not a desktop device, don't check the Qt version for qmlscene.
|
|
|
|
// The device is responsible for providing it and we assume qmlscene can be found
|
|
|
|
// in $PATH if it's not explicitly given.
|
2018-03-08 17:46:20 +01:00
|
|
|
}
|
|
|
|
|
2018-04-18 13:39:05 +02:00
|
|
|
return result;
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
2015-05-18 16:57:29 +02:00
|
|
|
Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2015-05-18 16:57:29 +02:00
|
|
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
2015-09-08 17:15:17 +02:00
|
|
|
if (result != RestoreResult::Ok)
|
2015-05-18 16:57:29 +02:00
|
|
|
return result;
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2013-01-21 13:54:20 +01:00
|
|
|
// refresh first - project information is used e.g. to decide the default RC's
|
|
|
|
refresh(Everything);
|
|
|
|
|
2013-03-07 14:02:04 +01:00
|
|
|
if (!activeTarget()) {
|
|
|
|
// find a kit that matches prerequisites (prefer default one)
|
2018-04-18 13:39:05 +02:00
|
|
|
const QList<Kit*> kits = KitManager::kits([this](const Kit *k) {
|
|
|
|
return !containsType(projectIssues(k), Task::TaskType::Error);
|
|
|
|
});
|
2013-03-07 14:02:04 +01:00
|
|
|
|
|
|
|
if (!kits.isEmpty()) {
|
2018-03-08 17:46:20 +01:00
|
|
|
Kit *kit = kits.contains(KitManager::defaultKit()) ? KitManager::defaultKit() : kits.first();
|
2013-03-07 14:02:04 +01:00
|
|
|
addTarget(createTarget(kit));
|
|
|
|
}
|
|
|
|
}
|
2009-05-07 12:27:52 +02:00
|
|
|
|
2012-10-16 18:49:46 +02:00
|
|
|
// addedTarget calls updateEnabled on the runconfigurations
|
|
|
|
// which needs to happen after refresh
|
2013-09-10 17:59:34 +02:00
|
|
|
foreach (Target *t, targets())
|
2012-10-16 18:49:46 +02:00
|
|
|
addedTarget(t);
|
|
|
|
|
2015-03-31 13:04:19 +02:00
|
|
|
connect(this, &ProjectExplorer::Project::addedTarget, this, &QmlProject::addedTarget);
|
2012-10-16 18:49:46 +02:00
|
|
|
|
2015-03-31 13:04:19 +02:00
|
|
|
connect(this, &ProjectExplorer::Project::activeTargetChanged,
|
|
|
|
this, &QmlProject::onActiveTargetChanged);
|
2013-05-02 15:29:33 +02:00
|
|
|
|
2014-12-03 13:30:37 +01:00
|
|
|
onActiveTargetChanged(activeTarget());
|
2013-11-06 12:59:04 +01:00
|
|
|
|
2015-05-18 16:57:29 +02:00
|
|
|
return RestoreResult::Ok;
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
2017-03-01 14:26:46 +01:00
|
|
|
void QmlProject::generateProjectTree()
|
|
|
|
{
|
2017-03-27 12:12:38 +02:00
|
|
|
if (!m_projectItem)
|
|
|
|
return;
|
|
|
|
|
2018-04-26 14:41:46 +02:00
|
|
|
auto newRoot = std::make_unique<Internal::QmlProjectNode>(this);
|
2017-03-01 14:26:46 +01:00
|
|
|
|
2017-03-27 12:12:38 +02:00
|
|
|
for (const QString &f : m_projectItem.data()->files()) {
|
2017-11-23 11:41:35 +01:00
|
|
|
const Utils::FileName fileName = Utils::FileName::fromString(f);
|
|
|
|
const FileType fileType = (fileName == projectFilePath())
|
|
|
|
? FileType::Project : FileNode::fileTypeForFileName(fileName);
|
2018-04-26 15:07:56 +02:00
|
|
|
newRoot->addNestedNode(std::make_unique<FileNode>(fileName, fileType, false));
|
2017-03-10 17:30:40 +01:00
|
|
|
}
|
2018-04-26 15:07:56 +02:00
|
|
|
newRoot->addNestedNode(std::make_unique<FileNode>(projectFilePath(), FileType::Project, false));
|
2017-03-01 14:26:46 +01:00
|
|
|
|
2018-04-26 14:41:46 +02:00
|
|
|
setRootProjectNode(std::move(newRoot));
|
2017-11-28 15:57:15 +01:00
|
|
|
refreshTargetDirectory();
|
2017-03-01 14:26:46 +01:00
|
|
|
}
|
|
|
|
|
2017-11-28 15:57:15 +01:00
|
|
|
void QmlProject::updateDeploymentData(ProjectExplorer::Target *target)
|
|
|
|
{
|
|
|
|
if (!m_projectItem)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (DeviceTypeKitInformation::deviceTypeId(target->kit())
|
|
|
|
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::DeploymentData deploymentData;
|
|
|
|
for (const QString &file : m_projectItem->files()) {
|
|
|
|
deploymentData.addFile(
|
|
|
|
file,
|
|
|
|
targetFile(Utils::FileName::fromString(file), target).parentDir().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
target->setDeploymentData(deploymentData);
|
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
} // namespace QmlProjectManager
|
2009-12-17 09:54:16 +01:00
|
|
|
|