forked from qt-creator/qt-creator
Convert Examples model to FilePath
Change-Id: I56219d2f9516662b32d45fd9b2108a0ad34113cc
Reviewed-by: David Schulz <david.schulz@qt.io>
(cherry picked from commit 255afd45bf)
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -298,14 +298,15 @@ static bool isValidExampleOrDemo(ExampleItem *item)
|
||||
doesn't have any namespace */
|
||||
QString reason;
|
||||
bool ok = true;
|
||||
if (!item->hasSourceCode || !QFileInfo::exists(item->projectPath)) {
|
||||
if (!item->hasSourceCode || !item->projectPath.exists()) {
|
||||
ok = false;
|
||||
reason = QString::fromLatin1("projectPath \"%1\" empty or does not exist").arg(item->projectPath);
|
||||
reason = QString::fromLatin1("projectPath \"%1\" empty or does not exist")
|
||||
.arg(item->projectPath.toUserOutput());
|
||||
} else if (item->imageUrl.startsWith(invalidPrefix) || !QUrl(item->imageUrl).isValid()) {
|
||||
ok = false;
|
||||
reason = QString::fromLatin1("imageUrl \"%1\" not valid").arg(item->imageUrl);
|
||||
} else if (!item->docUrl.isEmpty()
|
||||
&& (item->docUrl.startsWith(invalidPrefix) || !QUrl(item->docUrl).isValid())) {
|
||||
&& (item->docUrl.startsWith(invalidPrefix) || !QUrl(item->docUrl).isValid())) {
|
||||
ok = false;
|
||||
reason = QString::fromLatin1("docUrl \"%1\" non-empty but not valid").arg(item->docUrl);
|
||||
}
|
||||
@@ -331,13 +332,17 @@ void ExamplesViewController::updateExamples()
|
||||
|
||||
QList<ExampleItem *> items;
|
||||
for (const QString &exampleSource : sources) {
|
||||
const auto manifest = FilePath::fromUserInput(exampleSource);
|
||||
if (debugExamples()) {
|
||||
qWarning() << QString::fromLatin1("Reading file \"%1\"...")
|
||||
.arg(QFileInfo(exampleSource).absoluteFilePath());
|
||||
.arg(manifest.absoluteFilePath().toUserOutput());
|
||||
}
|
||||
|
||||
const expected_str<QList<ExampleItem *>> result
|
||||
= parseExamples(exampleSource, examplesInstallPath, demosInstallPath, m_isExamples);
|
||||
= parseExamples(manifest,
|
||||
FilePath::fromUserInput(examplesInstallPath),
|
||||
FilePath::fromUserInput(demosInstallPath),
|
||||
m_isExamples);
|
||||
if (!result) {
|
||||
if (debugExamples()) {
|
||||
qWarning() << "ERROR: Could not read examples from" << exampleSource << ":"
|
||||
|
||||
Reference in New Issue
Block a user