Convert Examples model to FilePath

Change-Id: I56219d2f9516662b32d45fd9b2108a0ad34113cc
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2023-02-22 10:17:19 +01:00
parent 7e75097447
commit 255afd45bf
5 changed files with 101 additions and 107 deletions

View File

@@ -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 << ":"