static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info) { const QString locale = languageSetting(); static const QLatin1String tag_template("template"); static const QLatin1String tag_displayName("displayname"); static const QLatin1String tag_description("description"); static const QLatin1String attribute_featuresRequired("featuresRequired"); static const QLatin1String attribute_openEditor("openeditor"); static const QLatin1String attribute_priority("priority"); static const QLatin1String attribute_viewerdir("viewerdir"); static const QLatin1String attribute_viewerclassname("viewerclassname"); static const QLatin1String attribute_qrcdeployment("qrcdeployment"); static const QLatin1String attribute_stubversionminor("stubversionminor"); while (!reader.atEnd() && !reader.hasError()) { reader.readNext(); if (reader.tokenType() != QXmlStreamReader::StartElement) continue; if (reader.name() == tag_template) { info->openFile = reader.attributes().value(attribute_openEditor).toString(); if (reader.attributes().hasAttribute(attribute_priority)) info->priority = reader.attributes().value(attribute_priority).toString(); if (reader.attributes().hasAttribute(attribute_featuresRequired)) info->featuresRequired = reader.attributes().value(attribute_featuresRequired).toString(); if (reader.attributes().hasAttribute(attribute_viewerdir)) info->viewerDir = reader.attributes().value(attribute_viewerdir).toString(); if (reader.attributes().hasAttribute(attribute_viewerclassname)) info->viewerClassName = reader.attributes().value(attribute_viewerclassname).toString(); if (reader.attributes().hasAttribute(attribute_qrcdeployment)) info->qrcDeployment = reader.attributes().value(attribute_qrcdeployment).toString(); if (reader.attributes().hasAttribute(attribute_stubversionminor)) info->stubVersionMinor = reader.attributes().value(attribute_stubversionminor).toString().toInt(); } else if (reader.name() == tag_displayName) { if (!assignLanguageElementText(reader, locale, &info->displayName)) continue; } else if (reader.name() == tag_description) { if (!assignLanguageElementText(reader, locale, &info->description)) continue; } } if (reader.hasError()) { qWarning() << reader.errorString(); return false; } return true; }
// Read level sub-elements of "wizard" static bool parseCustomProjectElement(QXmlStreamReader &reader, const QString &configFileFullPath, const QString &language, CustomWizardParameters *p, Core::BaseFileWizardParameters *bp) { const QStringRef elementName = reader.name(); if (elementName == QLatin1String(iconElementC)) { const QString path = reader.readElementText(); const QIcon icon = wizardIcon(configFileFullPath, path); if (icon.availableSizes().isEmpty()) { qWarning("Invalid icon path '%s' encountered in custom project template %s.", qPrintable(path), qPrintable(configFileFullPath)); } else { bp->setIcon(icon); } return true; } if (elementName == QLatin1String(descriptionElementC)) { assignLanguageElementText(reader, language, bp, &Core::BaseFileWizardParameters::setDescription); return true; } if (elementName == QLatin1String(displayNameElementC)) { assignLanguageElementText(reader, language, bp, &Core::BaseFileWizardParameters::setDisplayName); return true; } if (elementName == QLatin1String(displayCategoryElementC)) { assignLanguageElementText(reader, language, bp, &Core::BaseFileWizardParameters::setDisplayCategory); return true; } if (elementName == QLatin1String(fieldPageTitleElementC)) { assignLanguageElementText(reader, language, &p->fieldPageTitle); return true; } return false; }
// Read sub-elements of "fields" static bool parseFieldElement(QXmlStreamReader &reader, const QString &language, CustomWizardField *m) { const QStringRef elementName = reader.name(); if (elementName == QLatin1String(fieldDescriptionElementC)) { assignLanguageElementText(reader, language, &m->description); return true; } // Copy widget control attributes if (elementName == QLatin1String(fieldControlElementC)) { foreach(const QXmlStreamAttribute &attribute, reader.attributes()) m->controlAttributes.insert(attribute.name().toString(), attribute.value().toString()); skipOverElementText(reader); return true; }