6#include <QtGui/QGuiApplication>
9 Q_DECLARE_TR_FUNCTIONS(QCollectionGenerator)
12void CollectionConfigReader::raiseErrorWithLine()
14 raiseError(QCG::tr(
"Unknown token at line %1.").arg(lineNumber()));
17void CollectionConfigReader::readData(
const QByteArray &contents)
19 m_enableFilterFunctionality =
true;
20 m_hideFilterFunctionality =
true;
21 m_enableAddressBar =
true;
22 m_hideAddressBar =
true;
23 m_enableDocumentationManager =
true;
24 m_enableFullTextSearchFallback =
false;
29 if (isStartElement()) {
30 if (name() == QLatin1String(
"QHelpCollectionProject")
31 && attributes().value(QLatin1String(
"version")) == QLatin1String(
"1.0"))
34 raiseError(QCG::tr(
"Unknown token at line %1. "
35 "Expected \"QtHelpCollectionProject\".")
41void CollectionConfigReader::readConfig()
46 if (isStartElement()) {
47 if (name() == QLatin1String(
"assistant"))
48 readAssistantSettings();
49 else if (name() == QLatin1String(
"docFiles"))
53 }
else if (isEndElement() && name() == QLatin1String(
"QHelpCollectionProject")) {
57 if (!ok && !hasError())
58 raiseError(QCG::tr(
"Missing end tags."));
61void CollectionConfigReader::readAssistantSettings()
65 if (isStartElement()) {
66 if (name() == QLatin1String(
"title")) {
67 m_title = readElementText();
68 }
else if (name() == QLatin1String(
"homePage")) {
69 m_homePage = readElementText();
70 }
else if (name() == QLatin1String(
"startPage")) {
71 m_startPage = readElementText();
72 }
else if (name() == QLatin1String(
"currentFilter")) {
73 m_currentFilter = readElementText();
74 }
else if (name() == QLatin1String(
"applicationIcon")) {
75 m_applicationIcon = readElementText();
76 }
else if (name() == QLatin1String(
"enableFilterFunctionality")) {
77 if (attributes().value(QLatin1String(
"visible")) == QLatin1String(
"true"))
78 m_hideFilterFunctionality =
false;
79 if (readElementText() == QLatin1String(
"false"))
80 m_enableFilterFunctionality =
false;
81 }
else if (name() == QLatin1String(
"enableDocumentationManager")) {
82 if (readElementText() == QLatin1String(
"false"))
83 m_enableDocumentationManager =
false;
84 }
else if (name() == QLatin1String(
"enableAddressBar")) {
85 if (attributes().value(QLatin1String(
"visible")) == QLatin1String(
"true"))
86 m_hideAddressBar =
false;
87 if (readElementText() == QLatin1String(
"false"))
88 m_enableAddressBar =
false;
89 }
else if (name() == QLatin1String(
"aboutMenuText")) {
91 }
else if (name() == QLatin1String(
"aboutDialog")) {
93 }
else if (name() == u"cacheDirectory") {
94 m_cacheDirRelativeToCollection =
95 attributes().value(QLatin1String(
"base"))
96 == QLatin1String(
"collection");
97 m_cacheDirectory = readElementText();
98 }
else if (name() == QLatin1String(
"enableFullTextSearchFallback")) {
99 if (readElementText() == QLatin1String(
"true"))
100 m_enableFullTextSearchFallback =
true;
102 raiseErrorWithLine();
104 }
else if (isEndElement() && name() == QLatin1String(
"assistant")) {
110void CollectionConfigReader::readMenuTexts()
114 if (isStartElement()) {
115 if (name() == QLatin1String(
"text")) {
116 QString lang = attributes().value(QLatin1String(
"language")).toString();
118 lang = QLatin1String(
"default");
119 m_aboutMenuTexts.insert(lang, readElementText());
121 raiseErrorWithLine();
123 }
else if (isEndElement() && name() == QLatin1String(
"aboutMenuText")) {
129void CollectionConfigReader::readAboutDialog()
133 if (isStartElement()) {
134 if (name() == QLatin1String(
"file")) {
135 QString lang = attributes().value(QLatin1String(
"language")).toString();
137 lang = QLatin1String(
"default");
138 m_aboutTextFiles.insert(lang, readElementText());
139 }
else if (name() == QLatin1String(
"icon")) {
140 m_aboutIcon = readElementText();
142 raiseErrorWithLine();
144 }
else if (isEndElement() && name() == QLatin1String(
"aboutDialog")) {
150void CollectionConfigReader::readDocFiles()
154 if (isStartElement()) {
155 if (name() == QLatin1String(
"generate")) {
157 }
else if (name() == QLatin1String(
"register")) {
160 raiseErrorWithLine();
162 }
else if (isEndElement() && name() == QLatin1String(
"docFiles")) {
168void CollectionConfigReader::readGenerate()
172 if (isStartElement()) {
173 if (name() == QLatin1String(
"file"))
176 raiseErrorWithLine();
177 }
else if (isEndElement() && name() == QLatin1String(
"generate")) {
183void CollectionConfigReader::readFiles()
189 if (isStartElement()) {
190 if (name() == QLatin1String(
"input"))
191 input = readElementText();
192 else if (name() == QLatin1String(
"output"))
193 output = readElementText();
195 raiseErrorWithLine();
196 }
else if (isEndElement() && name() == QLatin1String(
"file")) {
200 if (input.isEmpty() || output.isEmpty()) {
201 raiseError(QCG::tr(
"Missing input or output file for help file generation."));
204 m_filesToGenerate.insert(input, output);
207void CollectionConfigReader::readRegister()
211 if (isStartElement()) {
212 if (name() == QLatin1String(
"file"))
213 m_filesToRegister.append(readElementText());
215 raiseErrorWithLine();
216 }
else if (isEndElement() && name() == QLatin1String(
"register")) {