forked from qt-creator/qt-creator
QtSupport: Simplify example reading code
The default empty QVariant converts well enough to empty strings etc to not have to check for its presence explicitly. Change-Id: I8d3b20b3e463d8b504e27e86dc44c1b5de6de63a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -302,8 +302,6 @@ void ExamplesListModel::parseExamples(QXmlStreamReader *reader,
|
||||
item.projectPath = relativeOrInstallPath(item.projectPath, projectsOffset, examplesInstallPath);
|
||||
item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString();
|
||||
item.docUrl = attributes.value(QLatin1String("docUrl")).toString();
|
||||
|
||||
if (attributes.hasAttribute(QLatin1String("isHighlighted")))
|
||||
item.isHighlighted = attributes.value(QLatin1String("isHighlighted")).toString() == QLatin1String("true");
|
||||
|
||||
} else if (reader->name() == QLatin1String("fileToOpen")) {
|
||||
@@ -357,10 +355,7 @@ void ExamplesListModel::parseDemos(QXmlStreamReader *reader,
|
||||
item.projectPath = relativeOrInstallPath(item.projectPath, projectsOffset, demosInstallPath);
|
||||
item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString();
|
||||
item.docUrl = attributes.value(QLatin1String("docUrl")).toString();
|
||||
|
||||
if (attributes.hasAttribute(QLatin1String("isHighlighted")))
|
||||
item.isHighlighted = attributes.value(QLatin1String("isHighlighted")).toString() == QLatin1String("true");
|
||||
|
||||
} else if (reader->name() == QLatin1String("fileToOpen")) {
|
||||
item.filesToOpen.append(relativeOrInstallPath(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement),
|
||||
projectsOffset, demosInstallPath));
|
||||
@@ -402,15 +397,10 @@ void ExamplesListModel::parseTutorials(QXmlStreamReader *reader, const QString &
|
||||
item.hasSourceCode = !item.projectPath.isEmpty();
|
||||
item.projectPath.prepend(slash);
|
||||
item.projectPath.prepend(projectsOffset);
|
||||
if (attributes.hasAttribute(QLatin1String("imageUrl")))
|
||||
item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString();
|
||||
if (attributes.hasAttribute(QLatin1String("docUrl")))
|
||||
item.docUrl = attributes.value(QLatin1String("docUrl")).toString();
|
||||
if (attributes.hasAttribute(QLatin1String("isVideo")))
|
||||
item.isVideo = attributes.value(QLatin1String("isVideo")).toString() == QLatin1String("true");
|
||||
if (attributes.hasAttribute(QLatin1String("videoUrl")))
|
||||
item.videoUrl = attributes.value(QLatin1String("videoUrl")).toString();
|
||||
if (attributes.hasAttribute(QLatin1String("videoLength")))
|
||||
item.videoLength = attributes.value(QLatin1String("videoLength")).toString();
|
||||
} else if (reader->name() == QLatin1String("fileToOpen")) {
|
||||
item.filesToOpen.append(projectsOffset + slash + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement));
|
||||
|
Reference in New Issue
Block a user