Commit 41b57bfd authored by Kai Koehne's avatar Kai Koehne

Remove Qt 4 fallback for examples browser

Remove fallback file, and rather use the examples-manifest.xml,
demos-manifest.xml files that are part of Qt 4.8.0 or newer.

Change-Id: I6291bd01b75b891a5ddab7fb01cdfc29ed8bec34
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 0d23d2d4
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -352,12 +352,8 @@ void ExamplesListModel::updateExamples() ...@@ -352,12 +352,8 @@ void ExamplesListModel::updateExamples()
{ {
QString examplesInstallPath; QString examplesInstallPath;
QString demosInstallPath; QString demosInstallPath;
QString examplesFallback;
QString demosFallback;
QString sourceFallback;
QStringList sources = exampleSources(&examplesInstallPath, &demosInstallPath, QStringList sources = exampleSources(&examplesInstallPath, &demosInstallPath);
&examplesFallback, &demosFallback, &sourceFallback);
beginResetModel(); beginResetModel();
m_tags.clear(); m_tags.clear();
...@@ -375,18 +371,6 @@ void ExamplesListModel::updateExamples() ...@@ -375,18 +371,6 @@ void ExamplesListModel::updateExamples()
QString offsetPath = fi.path(); QString offsetPath = fi.path();
QDir examplesDir(offsetPath); QDir examplesDir(offsetPath);
QDir demosDir(offsetPath); QDir demosDir(offsetPath);
if (!examplesFallback.isEmpty()) {
// Look at Qt source directory at first,
// since examplesPath() / demosPath() points at the build directory
examplesDir = sourceFallback + QLatin1String("/examples");
demosDir = sourceFallback + QLatin1String("/demos");
// if examples or demos don't exist in source, try the directories
// that qmake -query gave (i.e. in the build directory)
if (!examplesDir.exists() || !demosDir.exists()) {
examplesDir = examplesFallback;
demosDir = demosFallback;
}
}
if (debugExamples()) if (debugExamples())
qWarning() << QString::fromLatin1("Reading file '%1'...").arg(fi.absoluteFilePath()); qWarning() << QString::fromLatin1("Reading file '%1'...").arg(fi.absoluteFilePath());
...@@ -488,13 +472,8 @@ int ExamplesListModel::findHighestQtVersion() const ...@@ -488,13 +472,8 @@ int ExamplesListModel::findHighestQtVersion() const
return newVersion->uniqueId(); return newVersion->uniqueId();
} }
QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QString *demosInstallPath, QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QString *demosInstallPath)
QString *examplesFallback, QString *demosFallback,
QString *sourceFallback)
{ {
QTC_CHECK(examplesFallback);
QTC_CHECK(demosFallback);
QTC_CHECK(sourceFallback);
QStringList sources; QStringList sources;
QString resourceDir = Core::ICore::resourcePath() + QLatin1String("/welcomescreen/"); QString resourceDir = Core::ICore::resourcePath() + QLatin1String("/welcomescreen/");
...@@ -523,12 +502,6 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr ...@@ -523,12 +502,6 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr
if (size > 0) if (size > 0)
return sources; return sources;
// try to find a suitable Qt version
// fallbacks are passed back if no example manifest is found
// and we fallback to Qt Creator's shipped manifest (e.g. only old Qt Versions found)
QString potentialExamplesFallback;
QString potentialDemosFallback;
QString potentialSourceFallback;
const QStringList pattern(QLatin1String("*.xml")); const QStringList pattern(QLatin1String("*.xml"));
foreach (BaseQtVersion *version, qtVersions()) { foreach (BaseQtVersion *version, qtVersions()) {
...@@ -536,29 +509,25 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr ...@@ -536,29 +509,25 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr
if (version->uniqueId() != m_uniqueQtId && m_uniqueQtId != noQtVersionsId) if (version->uniqueId() != m_uniqueQtId && m_uniqueQtId != noQtVersionsId)
continue; continue;
if (version->qtVersion().majorVersion == 5) { // search for examples-manifest.xml, demos-manifest.xml in doc/*/
// examples directory in Qt5 is under the qtbase submodule, QDir qt5docPath = QDir(version->documentationPath());
// search other submodule directories for further manifest files const QStringList examplesPattern(QLatin1String("examples-manifest.xml"));
QDir qt5docPath = QDir(version->documentationPath()); const QStringList demosPattern(QLatin1String("demos-manifest.xml"));
const QStringList examplesPattern(QLatin1String("examples-manifest.xml")); QFileInfoList fis;
const QStringList demosPattern(QLatin1String("demos-manifest.xml")); foreach (QFileInfo subDir, qt5docPath.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
QFileInfoList fis; fis << QDir(subDir.absoluteFilePath()).entryInfoList(examplesPattern);
foreach (QFileInfo subDir, qt5docPath.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { fis << QDir(subDir.absoluteFilePath()).entryInfoList(demosPattern);
fis << QDir(subDir.absoluteFilePath()).entryInfoList(examplesPattern); }
fis << QDir(subDir.absoluteFilePath()).entryInfoList(demosPattern); if (!fis.isEmpty()) {
} foreach (const QFileInfo &fi, fis)
if (!fis.isEmpty()) { sources.append(fi.filePath());
foreach (const QFileInfo &fi, fis) if (examplesInstallPath)
sources.append(fi.filePath()); *examplesInstallPath = version->examplesPath();
if (examplesInstallPath) if (demosInstallPath)
*examplesInstallPath = version->examplesPath(); *demosInstallPath = version->demosPath();
if (demosInstallPath) return sources;
*demosInstallPath = version->demosPath();
return sources;
}
} }
QFileInfoList fis;
fis << QDir(version->examplesPath()).entryInfoList(pattern); fis << QDir(version->examplesPath()).entryInfoList(pattern);
fis << QDir(version->demosPath()).entryInfoList(pattern); fis << QDir(version->demosPath()).entryInfoList(pattern);
if (!fis.isEmpty()) { if (!fis.isEmpty()) {
...@@ -566,27 +535,8 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr ...@@ -566,27 +535,8 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr
sources.append(fi.filePath()); sources.append(fi.filePath());
return sources; return sources;
} }
// check if this Qt version would be the preferred fallback, Qt 4 only
if (version->qtVersion().majorVersion == 4) { // cached, so no performance hit
if (potentialExamplesFallback.isEmpty()) {
potentialExamplesFallback = version->examplesPath();
potentialDemosFallback = version->demosPath();
potentialSourceFallback = version->sourcePath().toString();
}
}
} }
if (!potentialExamplesFallback.isEmpty()) {
// We didn't find a manifest, use Creator-provided XML file with fall back Qt version
// qDebug() << Q_FUNC_INFO << "falling through to Creator-provided XML file";
sources << QString(resourceDir + QLatin1String("/examples_fallback.xml"));
if (examplesFallback)
*examplesFallback = potentialExamplesFallback;
if (demosFallback)
*demosFallback = potentialDemosFallback;
if (sourceFallback)
*sourceFallback = potentialSourceFallback;
}
return sources; return sources;
} }
......
...@@ -134,9 +134,7 @@ private: ...@@ -134,9 +134,7 @@ private:
void parseDemos(QXmlStreamReader *reader, const QString &projectsOffset, void parseDemos(QXmlStreamReader *reader, const QString &projectsOffset,
const QString &demosInstallPath); const QString &demosInstallPath);
void parseTutorials(QXmlStreamReader *reader, const QString &projectsOffset); void parseTutorials(QXmlStreamReader *reader, const QString &projectsOffset);
QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath, QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath);
QString *examplesFallback, QString *demosFallback,
QString *sourceFallback);
QList<BaseQtVersion*> m_qtVersions; QList<BaseQtVersion*> m_qtVersions;
QList<ExampleItem> m_exampleItems; QList<ExampleItem> m_exampleItems;
......
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