forked from qt-creator/qt-creator
Creator Examples: search for manifest files in qt5 submodules
Change-Id: Ifd7b838f1471ea08f942d350ed649b0b174e96c5 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -342,10 +342,33 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString
|
|||||||
QString potentialExamplesFallback;
|
QString potentialExamplesFallback;
|
||||||
QString potentialDemosFallback;
|
QString potentialDemosFallback;
|
||||||
QString potentialSourceFallback;
|
QString potentialSourceFallback;
|
||||||
bool potentialFallbackHasDeclarative = false; // we prefer Qt's with declarative as fallback
|
|
||||||
const QStringList pattern(QLatin1String("*.xml"));
|
const QStringList pattern(QLatin1String("*.xml"));
|
||||||
|
|
||||||
QtVersionManager *versionManager = QtVersionManager::instance();
|
QtVersionManager *versionManager = QtVersionManager::instance();
|
||||||
|
|
||||||
|
foreach (BaseQtVersion *version, versionManager->validVersions()) {
|
||||||
|
// qt5 with examples OR demos manifest
|
||||||
|
if (version->qtVersion().majorVersion == 5 && (version->hasExamples() || version->hasDemos())) {
|
||||||
|
// examples directory in Qt5 is under the qtbase submodule,
|
||||||
|
// search other submodule directories for further manifest files
|
||||||
|
QDir qt5docPath = QDir(version->documentationPath());
|
||||||
|
const QStringList examplesPattern(QLatin1String("examples-manifest.xml"));
|
||||||
|
const QStringList demosPattern(QLatin1String("demos-manifest.xml"));
|
||||||
|
QFileInfoList fis;
|
||||||
|
foreach (QFileInfo subDir, qt5docPath.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||||
|
if (version->hasExamples())
|
||||||
|
fis << QDir(subDir.absoluteFilePath()).entryInfoList(examplesPattern);
|
||||||
|
if (version->hasDemos())
|
||||||
|
fis << QDir(subDir.absoluteFilePath()).entryInfoList(demosPattern);
|
||||||
|
}
|
||||||
|
if (!fis.isEmpty()) {
|
||||||
|
foreach (const QFileInfo &fi, fis)
|
||||||
|
sources.append(fi.filePath());
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (BaseQtVersion *version, versionManager->validVersions()) {
|
foreach (BaseQtVersion *version, versionManager->validVersions()) {
|
||||||
QFileInfoList fis;
|
QFileInfoList fis;
|
||||||
if (version->hasExamples())
|
if (version->hasExamples())
|
||||||
@@ -357,13 +380,9 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString
|
|||||||
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
|
// check if this Qt version would be the preferred fallback, Qt 4 only
|
||||||
if (version->qtVersion().majorVersion == 4 && version->hasExamples() && version->hasDemos()) { // cached, so no performance hit
|
if (version->qtVersion().majorVersion == 4 && version->hasExamples() && version->hasDemos()) { // cached, so no performance hit
|
||||||
bool hasDeclarative = QDir(version->examplesPath() + QLatin1String("/declarative")).exists();
|
if (potentialExamplesFallback.isEmpty()) {
|
||||||
if (potentialExamplesFallback.isEmpty()
|
|
||||||
|| (!potentialFallbackHasDeclarative && hasDeclarative)) {
|
|
||||||
potentialFallbackHasDeclarative = hasDeclarative;
|
|
||||||
potentialExamplesFallback = version->examplesPath();
|
potentialExamplesFallback = version->examplesPath();
|
||||||
potentialDemosFallback = version->demosPath();
|
potentialDemosFallback = version->demosPath();
|
||||||
potentialSourceFallback = version->sourcePath().toString();
|
potentialSourceFallback = version->sourcePath().toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user