diff options
author | Eike Ziller <eike.ziller@digia.com> | 2014-06-16 12:50:32 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2014-06-17 16:48:05 +0200 |
commit | 232024253ffe14b9d81561458bb1c2ec000efe9b (patch) | |
tree | 45e6de3e99ecc0ce7fd2a6b6f3219414c2e89d46 /src/plugins/qtsupport | |
parent | 2a6b41101ec6eea79005490da0256c04d9eca722 (diff) | |
download | qt-creator-232024253ffe14b9d81561458bb1c2ec000efe9b.tar.gz |
Examples: Support new mainFile attribute
Qt 5.3 adds a mainFile="yes" attribute to the fileToOpen tag for the
file that should be visible after opening the files.
Change-Id: I3ff67e514a16811cc730633e0fbcc470c4e54e5e
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/plugins/qtsupport')
-rw-r--r-- | src/plugins/qtsupport/exampleslistmodel.cpp | 13 | ||||
-rw-r--r-- | src/plugins/qtsupport/exampleslistmodel.h | 3 | ||||
-rw-r--r-- | src/plugins/qtsupport/gettingstartedwelcomepage.cpp | 14 | ||||
-rw-r--r-- | src/plugins/qtsupport/gettingstartedwelcomepage.h | 3 |
4 files changed, 27 insertions, 6 deletions
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 40a909893d..37c2840a42 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -207,6 +207,7 @@ ExamplesListModel::ExamplesListModel(QObject *parent) : roleNames[Description] = "description"; roleNames[DocUrl] = "docUrl"; roleNames[FilesToOpen] = "filesToOpen"; + roleNames[MainFile] = "mainFile"; roleNames[Tags] = "tags"; roleNames[Difficulty] = "difficulty"; roleNames[Type] = "type"; @@ -332,8 +333,14 @@ void ExamplesListModel::parseExamples(QXmlStreamReader *reader, item.isHighlighted = attributes.value(QLatin1String("isHighlighted")).toString() == QLatin1String("true"); } else if (reader->name() == QLatin1String("fileToOpen")) { - item.filesToOpen.append(relativeOrInstallPath(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement), - projectsOffset, examplesInstallPath)); + const QString mainFileAttribute = reader->attributes().value( + QLatin1String("mainFile")).toString(); + const QString filePath = relativeOrInstallPath( + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement), + projectsOffset, examplesInstallPath); + item.filesToOpen.append(filePath); + if (mainFileAttribute.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0) + item.mainFile = filePath; } else if (reader->name() == QLatin1String("description")) { item.description = fixStringForTags(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)); } else if (reader->name() == QLatin1String("dependency")) { @@ -668,6 +675,8 @@ QVariant ExamplesListModel::data(const QModelIndex &index, int role) const return item.docUrl; case FilesToOpen: return item.filesToOpen; + case MainFile: + return item.mainFile; case Tags: return item.tags; case Difficulty: diff --git a/src/plugins/qtsupport/exampleslistmodel.h b/src/plugins/qtsupport/exampleslistmodel.h index 17d8a36e14..bc322373dc 100644 --- a/src/plugins/qtsupport/exampleslistmodel.h +++ b/src/plugins/qtsupport/exampleslistmodel.h @@ -74,7 +74,7 @@ private: enum ExampleRoles { Name = Qt::UserRole, ProjectPath, Description, ImageUrl, - DocUrl, FilesToOpen, Tags, Difficulty, HasSourceCode, + DocUrl, FilesToOpen, MainFile, Tags, Difficulty, HasSourceCode, Type, Dependencies, IsVideo, VideoUrl, VideoLength, Platforms, IsHighlighted }; @@ -93,6 +93,7 @@ struct ExampleItem QString imageUrl; QString docUrl; QStringList filesToOpen; + QString mainFile; /* file to be visible after opening filesToOpen */ QStringList tags; QStringList dependencies; InstructionalType type; diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp index 38a7231836..9d38cc4317 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp @@ -380,14 +380,24 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI } -void ExamplesWelcomePage::openProject(const QString &projectFile, const QStringList &additionalFilesToOpen, - const QUrl &help, const QStringList &dependencies, const QStringList &) +void ExamplesWelcomePage::openProject(const QString &projectFile, + const QStringList &additionalFilesToOpen, + const QString &mainFile, + const QUrl &help, + const QStringList &dependencies, + const QStringList &) { QString proFile = projectFile; if (proFile.isEmpty()) return; QStringList filesToOpen = additionalFilesToOpen; + if (!mainFile.isEmpty()) { + // ensure that the main file is opened on top (i.e. opened last) + filesToOpen.removeAll(mainFile); + filesToOpen.append(mainFile); + } + QFileInfo proFileInfo(proFile); if (!proFileInfo.exists()) return; diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.h b/src/plugins/qtsupport/gettingstartedwelcomepage.h index 187a29311e..377a9d9dba 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.h +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.h @@ -64,7 +64,8 @@ public slots: void openSplitHelp(const QUrl &help); void openHelp(const QUrl &help); void openProject(const QString& projectFile, const QStringList& additionalFilesToOpen, - const QUrl& help, const QStringList &dependencies, const QStringList &platforms); + const QString &mainFile, const QUrl& help, const QStringList &dependencies, + const QStringList &platforms); private: ExamplesListModel *examplesModel() const; |