2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-05-04 12:19:22 +02:00
|
|
|
|
|
|
|
#include "qmlproject.h"
|
2010-02-16 13:39:13 +01:00
|
|
|
#include "qmlprojectfile.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"
|
2011-08-18 16:46:26 +02:00
|
|
|
#include "qmlprojectnodes.h"
|
|
|
|
#include "qmlprojectmanager.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>
|
2011-05-20 21:40:53 +02:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2014-07-24 11:48:30 +02:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.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>
|
2013-03-07 14:02:04 +01:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2011-04-15 15:55:11 +02:00
|
|
|
|
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
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName)
|
2009-05-04 12:19:22 +02:00
|
|
|
: m_manager(manager),
|
2009-09-04 17:54:38 +02:00
|
|
|
m_fileName(fileName),
|
2013-01-21 13:54:20 +01:00
|
|
|
m_defaultImport(UnknownImport),
|
2013-11-06 12:59:04 +01:00
|
|
|
m_activeTarget(0)
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2013-09-27 16:30:20 +02:00
|
|
|
setId("QmlProjectManager.QmlProject");
|
2013-09-05 01:52:17 +02:00
|
|
|
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
|
|
|
|
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_QMLJS));
|
2011-04-12 12:17:19 +02:00
|
|
|
|
2009-05-04 12:19:22 +02:00
|
|
|
QFileInfo fileInfo(m_fileName);
|
2009-05-06 15:56:54 +02:00
|
|
|
m_projectName = fileInfo.completeBaseName();
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
m_file = new Internal::QmlProjectFile(this, fileName);
|
|
|
|
m_rootNode = new Internal::QmlProjectNode(this, m_file);
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2013-09-05 01:52:17 +02:00
|
|
|
DocumentManager::addDocument(m_file, true);
|
2010-01-19 13:53:48 +01:00
|
|
|
|
2009-05-04 12:19:22 +02:00
|
|
|
m_manager->registerProject(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
QmlProject::~QmlProject()
|
|
|
|
{
|
|
|
|
m_manager->unregisterProject(this);
|
|
|
|
|
2013-09-05 01:52:17 +02:00
|
|
|
DocumentManager::removeDocument(m_file);
|
2011-09-15 13:05:36 +02:00
|
|
|
|
2010-09-24 14:29:40 +02:00
|
|
|
delete m_projectItem.data();
|
2009-05-04 12:19:22 +02:00
|
|
|
delete m_rootNode;
|
|
|
|
}
|
|
|
|
|
2012-10-09 16:20:26 +02:00
|
|
|
void QmlProject::addedTarget(ProjectExplorer::Target *target)
|
|
|
|
{
|
|
|
|
connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
|
|
|
foreach (ProjectExplorer::RunConfiguration *rc, target->runConfigurations())
|
|
|
|
addedRunConfiguration(rc);
|
|
|
|
}
|
|
|
|
|
2013-11-06 12:59:04 +01:00
|
|
|
void QmlProject::onActiveTargetChanged(ProjectExplorer::Target *target)
|
|
|
|
{
|
|
|
|
if (m_activeTarget)
|
2015-01-30 11:02:24 +01:00
|
|
|
disconnect(m_activeTarget, &ProjectExplorer::Target::kitChanged, this, &QmlProject::onKitChanged);
|
2013-11-06 12:59:04 +01:00
|
|
|
m_activeTarget = target;
|
|
|
|
if (m_activeTarget)
|
|
|
|
connect(target, SIGNAL(kitChanged()), this, SLOT(onKitChanged()));
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2012-10-09 16:20:26 +02:00
|
|
|
void QmlProject::addedRunConfiguration(ProjectExplorer::RunConfiguration *rc)
|
|
|
|
{
|
|
|
|
// The enabled state of qml runconfigurations can only be decided after
|
|
|
|
// they have been added to a project
|
|
|
|
QmlProjectRunConfiguration *qmlrc = qobject_cast<QmlProjectRunConfiguration *>(rc);
|
|
|
|
if (qmlrc)
|
|
|
|
qmlrc->updateEnabled();
|
|
|
|
}
|
|
|
|
|
2009-05-06 16:13:44 +02:00
|
|
|
QDir QmlProject::projectDir() const
|
|
|
|
{
|
2014-05-02 12:22:58 +02:00
|
|
|
return projectFilePath().toFileInfo().dir();
|
2009-05-06 16:13:44 +02:00
|
|
|
}
|
|
|
|
|
2009-05-04 12:19:22 +02:00
|
|
|
QString QmlProject::filesFileName() const
|
2009-05-06 15:56:54 +02:00
|
|
|
{ return m_fileName; }
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2013-01-21 13:54:20 +01:00
|
|
|
static QmlProject::QmlImport detectImport(const QString &qml) {
|
|
|
|
static QRegExp qtQuick1RegExp(QLatin1String("import\\s+QtQuick\\s+1"));
|
|
|
|
static QRegExp qtQuick2RegExp(QLatin1String("import\\s+QtQuick\\s+2"));
|
|
|
|
|
|
|
|
if (qml.contains(qtQuick1RegExp))
|
|
|
|
return QmlProject::QtQuick1Import;
|
|
|
|
else if (qml.contains(qtQuick2RegExp))
|
|
|
|
return QmlProject::QtQuick2Import;
|
|
|
|
else
|
|
|
|
return QmlProject::UnknownImport;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
m_projectItem = QmlProjectFileFormat::parseProjectFile(m_fileName, &errorMessage);
|
|
|
|
if (m_projectItem) {
|
|
|
|
connect(m_projectItem.data(), SIGNAL(qmlFilesChanged(QSet<QString>,QSet<QString>)),
|
|
|
|
this, SLOT(refreshFiles(QSet<QString>,QSet<QString>)));
|
|
|
|
|
|
|
|
} else {
|
2013-09-05 01:52:17 +02:00
|
|
|
MessageManager::write(tr("Error while loading project file %1.").arg(m_fileName), MessageManager::NoModeSwitch);
|
|
|
|
MessageManager::write(errorMessage);
|
2013-07-11 17:37:02 +02:00
|
|
|
}
|
2010-01-18 16:32:14 +01:00
|
|
|
}
|
|
|
|
if (m_projectItem) {
|
|
|
|
m_projectItem.data()->setSourceDirectory(projectDir().path());
|
2014-07-24 11:48:30 +02:00
|
|
|
if (modelManager())
|
|
|
|
modelManager()->updateSourceFiles(m_projectItem.data()->files(), true);
|
2012-01-02 15:54:51 +01:00
|
|
|
|
|
|
|
QString mainFilePath = m_projectItem.data()->mainFile();
|
|
|
|
if (!mainFilePath.isEmpty()) {
|
|
|
|
mainFilePath = projectDir().absoluteFilePath(mainFilePath);
|
2013-01-21 13:54:20 +01:00
|
|
|
Utils::FileReader reader;
|
|
|
|
QString errorMessage;
|
|
|
|
if (!reader.fetch(mainFilePath, &errorMessage)) {
|
2013-09-05 01:52:17 +02:00
|
|
|
MessageManager::write(tr("Warning while loading project file %1.").arg(m_fileName));
|
|
|
|
MessageManager::write(errorMessage);
|
2013-01-21 13:54:20 +01:00
|
|
|
} else {
|
|
|
|
m_defaultImport = detectImport(QString::fromUtf8(reader.data()));
|
2012-01-02 15:54:51 +01:00
|
|
|
}
|
|
|
|
}
|
2010-01-18 16:32:14 +01:00
|
|
|
}
|
|
|
|
m_rootNode->refresh();
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (options & Configuration) {
|
|
|
|
// update configuration
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options & Files)
|
|
|
|
emit fileListChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmlProject::refresh(RefreshOptions options)
|
|
|
|
{
|
|
|
|
parseProject(options);
|
|
|
|
|
|
|
|
if (options & Files)
|
|
|
|
m_rootNode->refresh();
|
2010-06-22 12:54:19 +02:00
|
|
|
|
2014-07-24 11:48:30 +02:00
|
|
|
if (!modelManager())
|
|
|
|
return;
|
|
|
|
|
2012-12-06 17:20:58 +01:00
|
|
|
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
|
2014-07-24 11:48:30 +02:00
|
|
|
modelManager()->defaultProjectInfoForProject(this);
|
2014-07-22 19:06:44 +02:00
|
|
|
foreach (const QString &searchPath, customImportPaths())
|
|
|
|
projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(searchPath),
|
|
|
|
QmlJS::Dialect::Qml);
|
2013-01-10 16:12:45 +01:00
|
|
|
|
2014-07-24 11:48:30 +02:00
|
|
|
modelManager()->updateProjectInfo(projectInfo, this);
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList QmlProject::convertToAbsoluteFiles(const QStringList &paths) const
|
|
|
|
{
|
|
|
|
const QDir projectDir(QFileInfo(m_fileName).dir());
|
|
|
|
QStringList absolutePaths;
|
|
|
|
foreach (const QString &file, paths) {
|
|
|
|
QFileInfo fileInfo(projectDir, file);
|
|
|
|
absolutePaths.append(fileInfo.absoluteFilePath());
|
|
|
|
}
|
|
|
|
absolutePaths.removeDuplicates();
|
|
|
|
return absolutePaths;
|
|
|
|
}
|
|
|
|
|
2014-07-24 11:48:30 +02:00
|
|
|
QmlJS::ModelManagerInterface *QmlProject::modelManager() const
|
|
|
|
{
|
|
|
|
return QmlJS::ModelManagerInterface::instance();
|
|
|
|
}
|
|
|
|
|
2009-05-04 12:19:22 +02:00
|
|
|
QStringList QmlProject::files() const
|
2010-01-18 16:32:14 +01:00
|
|
|
{
|
|
|
|
QStringList files;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_projectItem)
|
2010-01-28 17:12:07 +01:00
|
|
|
files = m_projectItem.data()->files();
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2010-01-18 16:32:14 +01:00
|
|
|
files = m_files;
|
|
|
|
return files;
|
|
|
|
}
|
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();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-03-21 09:36:54 +01:00
|
|
|
QStringList importPaths;
|
2010-02-03 09:13:23 +01:00
|
|
|
if (m_projectItem)
|
2010-03-21 09:36:54 +01:00
|
|
|
importPaths = m_projectItem.data()->importPaths();
|
2010-10-13 13:03:32 +02:00
|
|
|
|
2010-03-21 09:36:54 +01:00
|
|
|
return importPaths;
|
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);
|
|
|
|
}
|
|
|
|
|
2013-01-21 13:54:20 +01:00
|
|
|
QmlProject::QmlImport QmlProject::defaultImport() const
|
|
|
|
{
|
|
|
|
return m_defaultImport;
|
|
|
|
}
|
|
|
|
|
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);
|
2014-07-24 11:48:30 +02:00
|
|
|
if (!removed.isEmpty() && modelManager())
|
|
|
|
modelManager()->removeFiles(removed.toList());
|
2010-01-19 13:53:48 +01:00
|
|
|
}
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString QmlProject::displayName() const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
|
|
|
return m_projectName;
|
|
|
|
}
|
|
|
|
|
2013-09-05 01:52:17 +02:00
|
|
|
IDocument *QmlProject::document() const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
|
|
|
return m_file;
|
|
|
|
}
|
|
|
|
|
2011-08-18 16:46:26 +02:00
|
|
|
ProjectExplorer::IProjectManager *QmlProject::projectManager() const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
|
|
|
return m_manager;
|
|
|
|
}
|
|
|
|
|
2012-09-20 11:16:47 +02:00
|
|
|
bool QmlProject::supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2013-09-05 01:52:17 +02:00
|
|
|
Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k);
|
2012-09-20 11:16:47 +02:00
|
|
|
if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
|
|
|
if (errorMessage)
|
|
|
|
*errorMessage = tr("Device type is not desktop.");
|
2012-04-24 15:49:09 +02:00
|
|
|
return false;
|
2012-09-20 11:16:47 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
2013-01-21 13:54:20 +01:00
|
|
|
if (!version) {
|
|
|
|
if (errorMessage)
|
|
|
|
*errorMessage = tr("No Qt version set in kit.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (version->qtVersion() < QtSupport::QtVersionNumber(4, 7, 0)) {
|
|
|
|
if (errorMessage)
|
|
|
|
*errorMessage = tr("Qt version is too old.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)
|
|
|
|
&& defaultImport() == QtQuick2Import) {
|
|
|
|
if (errorMessage)
|
|
|
|
*errorMessage = tr("Qt version is too old.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
2011-08-18 16:46:26 +02:00
|
|
|
ProjectExplorer::ProjectNode *QmlProject::rootProjectNode() const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
|
|
|
return m_rootNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList QmlProject::files(FilesMode) const
|
|
|
|
{
|
2010-01-18 16:32:14 +01:00
|
|
|
return files();
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
bool QmlProject::fromMap(const QVariantMap &map)
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2010-02-04 11:51:35 +01:00
|
|
|
if (!Project::fromMap(map))
|
|
|
|
return false;
|
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)
|
2014-07-23 09:09:20 +02:00
|
|
|
QList<Kit*> kits = KitManager::matchingKits(
|
|
|
|
std::function<bool(const Kit *)>([this](const Kit *k) -> bool {
|
|
|
|
if (!k->isValid())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
|
|
|
if (dev.isNull() || dev->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
|
|
|
|
return false;
|
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
if (!version || version->type() != QLatin1String(QtSupport::Constants::DESKTOPQT))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool hasViewer = false; // Initialization needed for dumb compilers.
|
|
|
|
QtSupport::QtVersionNumber minVersion;
|
|
|
|
switch (m_defaultImport) {
|
|
|
|
case QmlProject::UnknownImport:
|
|
|
|
minVersion = QtSupport::QtVersionNumber(4, 7, 0);
|
|
|
|
hasViewer = !version->qmlviewerCommand().isEmpty() || !version->qmlsceneCommand().isEmpty();
|
|
|
|
break;
|
|
|
|
case QmlProject::QtQuick1Import:
|
|
|
|
minVersion = QtSupport::QtVersionNumber(4, 7, 1);
|
|
|
|
hasViewer = !version->qmlviewerCommand().isEmpty();
|
|
|
|
break;
|
|
|
|
case QmlProject::QtQuick2Import:
|
|
|
|
minVersion = QtSupport::QtVersionNumber(5, 0, 0);
|
|
|
|
hasViewer = !version->qmlsceneCommand().isEmpty();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return version->qtVersion() >= minVersion && hasViewer;
|
|
|
|
}));
|
2013-03-07 14:02:04 +01:00
|
|
|
|
|
|
|
if (!kits.isEmpty()) {
|
2013-09-10 17:59:34 +02:00
|
|
|
Kit *kit = 0;
|
2013-11-11 22:20:47 +02:00
|
|
|
if (kits.contains(KitManager::defaultKit()))
|
2013-09-10 17:59:34 +02:00
|
|
|
kit = KitManager::defaultKit();
|
2013-11-11 22:20:47 +02:00
|
|
|
else
|
2013-03-07 14:02:04 +01:00
|
|
|
kit = kits.first();
|
|
|
|
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-01-30 11:02:24 +01:00
|
|
|
connect(this, &QmlProject::addedTarget, this, &QmlProject::addedTarget);
|
2012-10-16 18:49:46 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(this, &QmlProject::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
|
|
|
|
2009-07-03 16:46:01 +02:00
|
|
|
return true;
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
} // namespace QmlProjectManager
|
2009-12-17 09:54:16 +01:00
|
|
|
|