qdoc: Switched to QList from QMap for subprojects list

QMap sorts the subproject entries by default, which doesn't seem
logical for the qch use case. The subprojects should be listed in the
order they are defined in the qdocconf. Moreover, the no. of
subproject entries in the map is often less than 4, at least for qt.
So there is no performance gain in using QMap for this scenario.

QList just serves the purpose of storing the subprojects in a list
before they are written to the qhp file.

Change-Id: I841934289e09e8e232859353a3dfa15c491dba2e
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
This commit is contained in:
Venugopal Shivashankar 2015-02-05 18:17:09 +01:00
parent d4789294a4
commit aabbb87f4a
2 changed files with 16 additions and 18 deletions

View File

@ -107,13 +107,13 @@ void HelpProjectWriter::reset(const Config &config,
subproject.sortPages = config.getBool(subprefix + "sortPages"); subproject.sortPages = config.getBool(subprefix + "sortPages");
subproject.type = config.getString(subprefix + "type"); subproject.type = config.getString(subprefix + "type");
readSelectors(subproject, config.getStringList(subprefix + "selectors")); readSelectors(subproject, config.getStringList(subprefix + "selectors"));
project.subprojects[name] = subproject; project.subprojects.append(subproject);
} }
if (project.subprojects.isEmpty()) { if (project.subprojects.isEmpty()) {
SubProject subproject; SubProject subproject;
readSelectors(subproject, config.getStringList(prefix + "selectors")); readSelectors(subproject, config.getStringList(prefix + "selectors"));
project.subprojects.insert(QString(), subproject); project.subprojects.insert(0, subproject);
} }
projects.append(project); projects.append(project);
@ -260,16 +260,16 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
// Only add nodes to the set for each subproject if they match a selector. // Only add nodes to the set for each subproject if they match a selector.
// Those that match will be listed in the table of contents. // Those that match will be listed in the table of contents.
foreach (const QString &name, project.subprojects.keys()) { for (int i = 0; i < project.subprojects.length(); i++) {
SubProject subproject = project.subprojects[name]; SubProject subproject = project.subprojects[i];
// No selectors: accept all nodes. // No selectors: accept all nodes.
if (subproject.selectors.isEmpty()) { if (subproject.selectors.isEmpty()) {
project.subprojects[name].nodes[objName] = node; project.subprojects[i].nodes[objName] = node;
} }
else if (subproject.selectors.contains(node->type())) { else if (subproject.selectors.contains(node->type())) {
// Accept only the node types in the selectors hash. // Accept only the node types in the selectors hash.
if (node->type() != Node::Document) if (node->type() != Node::Document)
project.subprojects[name].nodes[objName] = node; project.subprojects[i].nodes[objName] = node;
else { else {
// Accept only fake nodes with subtypes contained in the selector's // Accept only fake nodes with subtypes contained in the selector's
// mask. // mask.
@ -278,7 +278,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
docNode->subType() != Node::ExternalPage && docNode->subType() != Node::ExternalPage &&
!docNode->fullTitle().isEmpty()) { !docNode->fullTitle().isEmpty()) {
project.subprojects[name].nodes[objName] = node; project.subprojects[i].nodes[objName] = node;
} }
} }
} }
@ -713,8 +713,8 @@ void HelpProjectWriter::generateProject(HelpProject &project)
generateSections(project, writer, rootNode); generateSections(project, writer, rootNode);
foreach (const QString &name, project.subprojects.keys()) { for (int i = 0; i < project.subprojects.length(); i++) {
SubProject subproject = project.subprojects[name]; SubProject subproject = project.subprojects[i];
if (subproject.type == QLatin1String("manual")) { if (subproject.type == QLatin1String("manual")) {
@ -769,13 +769,12 @@ void HelpProjectWriter::generateProject(HelpProject &project)
} else { } else {
if (!name.isEmpty()) { writer.writeStartElement("section");
writer.writeStartElement("section"); QString indexPath = gen_->fullDocumentLocation(qdb_->findNodeForTarget(subproject.indexTitle, 0),
QString indexPath = gen_->fullDocumentLocation(qdb_->findNodeForTarget(subproject.indexTitle, 0),
false); false);
writer.writeAttribute("ref", indexPath); writer.writeAttribute("ref", indexPath);
writer.writeAttribute("title", subproject.title); writer.writeAttribute("title", subproject.title);
}
if (subproject.sortPages) { if (subproject.sortPages) {
QStringList titles = subproject.nodes.keys(); QStringList titles = subproject.nodes.keys();
titles.sort(); titles.sort();
@ -815,8 +814,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
} }
} }
if (!name.isEmpty()) writer.writeEndElement(); // section
writer.writeEndElement(); // section
} }
} }

View File

@ -70,7 +70,7 @@ struct HelpProject
QSet<QString> filterAttributes; QSet<QString> filterAttributes;
QHash<QString, QSet<QString> > customFilters; QHash<QString, QSet<QString> > customFilters;
QSet<QString> excluded; QSet<QString> excluded;
QMap<QString, SubProject> subprojects; QList<SubProject> subprojects;
QHash<const Node *, QSet<Node::Status> > memberStatus; QHash<const Node *, QSet<Node::Status> > memberStatus;
bool includeIndexNodes; bool includeIndexNodes;
}; };