summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2009-12-03 17:23:08 (GMT)
committerck <qt-info@nokia.com>2009-12-03 17:23:08 (GMT)
commit7e80ffdf19946280fede44e39a9a740202d4e8e6 (patch)
tree4f99d6a077cfebe4de4c10e5d1f4fd6ce53d2041 /tools/assistant
parentb15b08e1f09320299a13bd4344663d6efb44d53f (diff)
downloadQt-7e80ffdf19946280fede44e39a9a740202d4e8e6.zip
Qt-7e80ffdf19946280fede44e39a9a740202d4e8e6.tar.gz
Qt-7e80ffdf19946280fede44e39a9a740202d4e8e6.tar.bz2
Assistant: Another small refactoring.
Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/main.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp
index a80b4cc..d009210 100644
--- a/tools/assistant/tools/assistant/main.cpp
+++ b/tools/assistant/tools/assistant/main.cpp
@@ -150,6 +150,38 @@ QString cachedCollectionFile(const QHelpEngineCore &collection)
return dir + QDir::separator() + fileName;
}
+bool synchronizeDocs(const QHelpEngineCore &collection,
+ QHelpEngineCore &cachedCollection)
+{
+ const QStringList &docs = collection.registeredDocumentations();
+ const QStringList &cachedDocs = cachedCollection.registeredDocumentations();
+
+ /*
+ * Step 1: Ensure that the cached collection contains all docs that
+ * the collection contains.
+ */
+ foreach (const QString &doc, docs) {
+ if (!cachedDocs.contains(doc)) {
+ if (!cachedCollection.registerDocumentation(
+ collection.documentationFileName(doc)))
+ return false;
+ }
+ }
+
+ /*
+ * Step 2: Ensure that the cached collection contains no docs that
+ * the collection doesn't contain.
+ */
+ QLatin1String intern("com.trolltech.com.assistantinternal-");
+ foreach (const QString &doc, cachedDocs) {
+ if (!collection.contains(doc) && !doc.startsWith(intern)
+ && !cachedCollection.unregisterDocumentation(doc))
+ return false;
+ }
+
+ return true;
+}
+
} // Anonymous namespace.
int main(int argc, char *argv[])
@@ -278,20 +310,7 @@ int main(int argc, char *argv[])
docUpdate = true;
if (docUpdate) {
- QStringList callerDocs = caller.registeredDocumentations();
- foreach (const QString &doc, callerDocs) {
- if (!userDocs.contains(doc)) {
- user.registerDocumentation(
- caller.documentationFileName(doc));
- }
- }
-
- QLatin1String intern("com.trolltech.com.assistantinternal-");
- foreach (const QString &doc, userDocs) {
- if (!callerDocs.contains(doc) && !doc.startsWith(intern))
- user.unregisterDocumentation(doc);
- }
-
+ synchronizeDocs(caller, user);
CollectionConfiguration::setDocUpdatePending(caller, false);
}
}