summaryrefslogtreecommitdiffstats
path: root/tools/assistant/lib/qhelpgenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/assistant/lib/qhelpgenerator.cpp')
-rw-r--r--tools/assistant/lib/qhelpgenerator.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/tools/assistant/lib/qhelpgenerator.cpp b/tools/assistant/lib/qhelpgenerator.cpp
index a193134..63164cd 100644
--- a/tools/assistant/lib/qhelpgenerator.cpp
+++ b/tools/assistant/lib/qhelpgenerator.cpp
@@ -538,7 +538,8 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa
}
int fileId = -1;
- if (!d->fileMap.contains(fileName)) {
+ QMap<QString, int>::Iterator fileMapIt = d->fileMap.find(fileName);
+ if (fileMapIt == d->fileMap.end()) {
fileDataList.append(qCompress(data));
fileNameData.name = fileName;
@@ -552,18 +553,20 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa
++tableFileId;
} else {
- fileId = d->fileMap.value(fileName);
+ fileId = fileMapIt.value();
+ QSet<int> &fileFilterSet = d->fileFilterMap[fileId];
+ QSet<int> &tmpFileFilterSet = tmpFileFilterMap[fileId];
foreach (const int &filter, filterAtts) {
- if (!d->fileFilterMap.value(fileId).contains(filter)
- && !tmpFileFilterMap.value(fileId).contains(filter)) {
- d->fileFilterMap[fileId].insert(filter);
- tmpFileFilterMap[fileId].insert(filter);
+ if (!fileFilterSet.contains(filter)
+ && !tmpFileFilterSet.contains(filter)) {
+ fileFilterSet.insert(filter);
+ tmpFileFilterSet.insert(filter);
}
}
}
}
- if (tmpFileFilterMap.count()) {
+ if (!tmpFileFilterMap.isEmpty()) {
d->query->exec(QLatin1String("BEGIN"));
QMap<int, QSet<int> >::const_iterator it = tmpFileFilterMap.constBegin();
while (it != tmpFileFilterMap.constEnd()) {
@@ -626,8 +629,7 @@ bool QHelpGenerator::registerCustomFilter(const QString &filterName,
while (d->query->next()) {
attributeMap.insert(d->query->value(1).toString(),
d->query->value(0).toInt());
- if (idsToInsert.contains(d->query->value(1).toString()))
- idsToInsert.removeAll(d->query->value(1).toString());
+ idsToInsert.removeAll(d->query->value(1).toString());
}
foreach (QString id, idsToInsert) {
@@ -675,7 +677,7 @@ bool QHelpGenerator::registerCustomFilter(const QString &filterName,
return true;
}
-bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> keywords,
+bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> &keywords,
const QStringList &filterAttributes)
{
if (!d->query)
@@ -705,7 +707,17 @@ bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> keywords,
int i = 0;
d->query->exec(QLatin1String("BEGIN"));
- foreach (QHelpDataIndexItem itm, keywords) {
+ QSet<QString> indices;
+ foreach (const QHelpDataIndexItem &itm, keywords) {
+
+ /*
+ * Identical ids make no sense and just confuse the Assistant user,
+ * so we ignore all repetitions.
+ */
+ if (indices.contains(itm.identifier))
+ continue;
+ indices.insert(itm.identifier);
+
pos = itm.reference.indexOf(QLatin1Char('#'));
fileName = itm.reference.left(pos);
if (pos > -1)
@@ -717,8 +729,9 @@ bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> keywords,
if (fName.startsWith(QLatin1String("./")))
fName = fName.mid(2);
- if (d->fileMap.contains(fName))
- fileId = d->fileMap.value(fName);
+ QMap<QString, int>::ConstIterator it = d->fileMap.find(fName);
+ if (it != d->fileMap.end())
+ fileId = it.value();
else
fileId = 1;
@@ -750,7 +763,7 @@ bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> keywords,
d->query->exec(QLatin1String("COMMIT"));
d->query->exec(QLatin1String("SELECT COUNT(Id) FROM IndexTable"));
- if (d->query->next() && d->query->value(0).toInt() >= keywords.count())
+ if (d->query->next() && d->query->value(0).toInt() >= indices.count())
return true;
return false;
}