Commit 8c504dc6 authored by Ulf Hermann's avatar Ulf Hermann

QmlProjectManager: Drop support for QtQuick1

Change-Id: Id60c9768d8fad03f588207af07bba676dbfc76fc
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent 0c9c747d
......@@ -47,7 +47,6 @@
#include <utils/algorithm.h>
#include <QDebug>
#include <QRegExp>
using namespace Core;
using namespace ProjectExplorer;
......@@ -55,8 +54,8 @@ using namespace ProjectExplorer;
namespace QmlProjectManager {
QmlProject::QmlProject(const Utils::FileName &fileName) :
Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName, [this]() { refreshProjectFile(); }),
m_defaultImport(UnknownImport)
Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName,
[this]() { refreshProjectFile(); })
{
setId("QmlProjectManager.QmlProject");
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
......@@ -109,19 +108,6 @@ QDir QmlProject::projectDir() const
return projectFilePath().toFileInfo().dir();
}
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;
}
void QmlProject::parseProject(RefreshOptions options)
{
if (options & Files) {
......@@ -155,8 +141,6 @@ void QmlProject::parseProject(RefreshOptions options)
MessageManager::write(tr("Warning while loading project file %1.")
.arg(projectFilePath().toUserOutput()));
MessageManager::write(errorMessage);
} else {
m_defaultImport = detectImport(QString::fromUtf8(reader.data()));
}
}
}
......@@ -227,11 +211,6 @@ void QmlProject::refreshProjectFile()
refresh(QmlProject::ProjectFile | Files);
}
QmlProject::QmlImport QmlProject::defaultImport() const
{
return m_defaultImport;
}
void QmlProject::refreshFiles(const QSet<QString> &/*added*/, const QSet<QString> &removed)
{
refresh(Files);
......@@ -257,14 +236,7 @@ bool QmlProject::supportsKit(Kit *k, QString *errorMessage) const
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 (version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)) {
if (errorMessage)
*errorMessage = tr("Qt version is too old.");
return false;
......@@ -300,25 +272,10 @@ Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *erro
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;
}));
return version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0)
&& !version->qmlsceneCommand().isEmpty();
})
);
if (!kits.isEmpty()) {
Kit *kit = 0;
......
......@@ -70,9 +70,6 @@ public:
void refreshProjectFile();
enum QmlImport { UnknownImport, QtQuick1Import, QtQuick2Import };
QmlImport defaultImport() const;
protected:
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
......@@ -87,7 +84,6 @@ private:
// plain format
void parseProject(RefreshOptions options);
QmlImport m_defaultImport;
ProjectExplorer::Target *m_activeTarget = nullptr;
QPointer<QmlProjectItem> m_projectItem;
......
......@@ -31,8 +31,6 @@ namespace QmlProjectManager {
namespace Constants {
const char QML_RC_ID[] = "QmlProjectManager.QmlRunConfiguration";
const char QML_VIEWER_RC_ID[] = "QmlProjectManager.QmlRunConfiguration";
const char QML_SCENE_RC_ID[] = "QmlProjectManager.QmlRunConfiguration.QmlScene";
const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
const char QML_VIEWER_TARGET_DISPLAY_NAME[] = "QML Viewer";
......
......@@ -68,14 +68,12 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target)
void QmlProjectRunConfiguration::initialize(Id id)
{
QTC_ASSERT(id == Constants::QML_SCENE_RC_ID, return);
RunConfiguration::initialize(id);
m_scriptFile = M_CURRENT_FILE;
if (id == Constants::QML_SCENE_RC_ID)
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
else
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
updateEnabledState();
}
......@@ -96,7 +94,7 @@ QString QmlProjectRunConfiguration::disabledReason() const
if (mainScript().isEmpty())
return tr("No script file to execute.");
if (!QFileInfo::exists(executable()))
return tr("No qmlviewer or qmlscene found.");
return tr("No qmlscene found.");
return RunConfiguration::disabledReason();
}
......@@ -106,9 +104,7 @@ QString QmlProjectRunConfiguration::executable() const
if (!version)
return QString();
if (id() == Constants::QML_SCENE_RC_ID)
return version->qmlsceneCommand();
return version->qmlviewerCommand();
return version->qmlsceneCommand();
}
QString QmlProjectRunConfiguration::commandLineArguments() const
......@@ -295,7 +291,7 @@ bool QmlProjectRunConfiguration::isValidVersion(QtSupport::BaseQtVersion *versio
{
if (version
&& version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
&& !version->qmlviewerCommand().isEmpty()) {
&& !version->qmlsceneCommand().isEmpty()) {
return true;
}
return false;
......
......@@ -36,7 +36,6 @@
namespace QmlProjectManager {
namespace Internal {
const char QML_VIEWER_SUFFIX[] = "";
const char QML_SCENE_SUFFIX[] = ".QmlScene";
QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory(QObject *parent) :
......@@ -53,47 +52,24 @@ QList<QString> QmlProjectRunConfigurationFactory::availableBuildTargets(ProjectE
QtSupport::BaseQtVersion *version
= QtSupport::QtKitInformation::qtVersion(parent->kit());
const QString viewer = QML_VIEWER_SUFFIX;
const QString scene = QML_SCENE_SUFFIX;
// First id will be the default run configuration
if (version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0)) {
QmlProject *project = static_cast<QmlProject*>(parent->project());
switch (project->defaultImport()) {
case QmlProject::QtQuick1Import:
return {viewer};
case QmlProject::QtQuick2Import:
return {scene};
case QmlProject::UnknownImport:
default:
return {scene, viewer};
}
}
return {viewer};
return (version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0))
? QList<QString>({QML_SCENE_SUFFIX}) : QList<QString>();
}
QString QmlProjectRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
{
if (buildTarget == QML_VIEWER_SUFFIX)
return tr("QML Viewer");
if (buildTarget == QML_SCENE_SUFFIX)
return tr("QML Scene");
return QString();
QTC_ASSERT(buildTarget == QML_SCENE_SUFFIX, return QString());
return tr("QML Scene");
}
bool QmlProjectRunConfigurationFactory::canCreateHelper(ProjectExplorer::Target *parent,
const QString &buildTarget) const
{
if (buildTarget == QML_VIEWER_SUFFIX)
return true;
QTC_ASSERT(buildTarget == QML_SCENE_SUFFIX, return false);
if (buildTarget == QML_SCENE_SUFFIX) {
// only support qmlscene if it's Qt5
QtSupport::BaseQtVersion *version
= QtSupport::QtKitInformation::qtVersion(parent->kit());
return version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0);
}
return false;
const QtSupport::BaseQtVersion *version
= QtSupport::QtKitInformation::qtVersion(parent->kit());
return version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0);
}
} // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment