Commit 4d5c95e1 authored by Eike Ziller's avatar Eike Ziller

More diagnostic messages when debugging examples model.

And less messages when not debugging.

Change-Id: Ib30dfe061c399aeeb3523544232b394e12ccb1b6
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 990ddf2c
......@@ -116,21 +116,37 @@ static QString relativeOrInstallPath(const QString &path, const QString &manifes
return relativeResolvedPath;
}
static bool debugExamples()
{
static bool isDebugging = !qgetenv("QTC_DEBUG_EXAMPLESMODEL").isEmpty();
return isDebugging;
}
static bool isValidExampleOrDemo(ExampleItem &item)
{
static QString invalidPrefix = QLatin1String("qthelp:////"); /* means that the qthelp url
doesn't have any namespace */
QString reason;
bool ok = true;
if (!item.hasSourceCode || !QFileInfo(item.projectPath).exists())
if (!item.hasSourceCode || !QFileInfo(item.projectPath).exists()) {
ok = false;
else if (item.imageUrl.startsWith(invalidPrefix) || !QUrl(item.imageUrl).isValid())
reason = QString::fromLatin1("projectPath '%1' empty or does not exist").arg(item.projectPath);
} else if (item.imageUrl.startsWith(invalidPrefix) || !QUrl(item.imageUrl).isValid()) {
ok = false;
else if (!item.docUrl.isEmpty()
&& (item.imageUrl.startsWith(invalidPrefix) || !QUrl(item.docUrl).isValid()))
reason = QString::fromLatin1("imageUrl '%1' not valid").arg(item.imageUrl);
} else if (!item.docUrl.isEmpty()
&& (item.docUrl.startsWith(invalidPrefix) || !QUrl(item.docUrl).isValid())) {
ok = false;
if (!ok)
reason = QString::fromLatin1("docUrl '%1' non-empty but not valid").arg(item.docUrl);
}
if (!ok) {
item.tags.append(QLatin1String("broken"));
return ok || !qgetenv("QTC_DEBUG_EXAMPLESMODEL").isEmpty();
if (debugExamples())
qWarning() << QString::fromLatin1("ERROR: Item '%1' broken: %2").arg(item.name, reason);
}
if (debugExamples() && item.description.isEmpty())
qWarning() << QString::fromLatin1("WARNING: Item '%1' has no description").arg(item.name);
return ok || debugExamples();
}
QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader *reader,
......@@ -298,7 +314,8 @@ void ExamplesListModel::updateExamples()
&examplesFallback, &demosFallback, &sourceFallback)) {
QFile exampleFile(exampleSource);
if (!exampleFile.open(QIODevice::ReadOnly)) {
qDebug() << Q_FUNC_INFO << "Could not open file" << exampleSource;
if (debugExamples())
qWarning() << "ERROR: Could not open file" << exampleSource;
continue;
}
......@@ -319,6 +336,8 @@ void ExamplesListModel::updateExamples()
}
}
if (debugExamples())
qWarning() << QString::fromLatin1("Reading file '%1'...").arg(fi.absoluteFilePath());
QXmlStreamReader reader(&exampleFile);
while (!reader.atEnd())
switch (reader.readNext()) {
......@@ -334,8 +353,8 @@ void ExamplesListModel::updateExamples()
break;
}
if (reader.hasError())
qDebug() << "error parsing file" << exampleSource << "as XML document";
if (reader.hasError() && debugExamples())
qWarning() << QString::fromLatin1("ERROR: Could not parse file as XML document ('%1')").arg(exampleSource);
}
m_tags.sort();
......
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