summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2009-12-10 14:20:35 (GMT)
committerck <qt-info@nokia.com>2009-12-10 14:20:35 (GMT)
commit4a982617bf6de92df118ecac024f415770a7bbb6 (patch)
treea38753c41e24cd956822439bb1bb509329a78a6f /tools/assistant
parentd7159b1aa1c24cc320a3ba013c9d0f3cf97b6684 (diff)
downloadQt-4a982617bf6de92df118ecac024f415770a7bbb6.zip
Qt-4a982617bf6de92df118ecac024f415770a7bbb6.tar.gz
Qt-4a982617bf6de92df118ecac024f415770a7bbb6.tar.bz2
Assistant: Added rebuild-search-index command line option.
Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.cpp10
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.h2
-rw-r--r--tools/assistant/tools/assistant/main.cpp31
3 files changed, 40 insertions, 3 deletions
diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp
index 733e2ff..a93d63f 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.cpp
+++ b/tools/assistant/tools/assistant/cmdlineparser.cpp
@@ -72,6 +72,7 @@ const QString CmdLineParser::m_helpMessage = QLatin1String(
" file.\n"
"-setCurrentFilter filter Set the filter as the active filter.\n"
"-remove-search-index Removes the full text search index.\n"
+ "-rebuild-search-index Re-builds the full text search index (potentially slow)\n."
"-quiet Does not display any error or\n"
" status message.\n"
"-help Displays this help.\n"
@@ -87,6 +88,7 @@ CmdLineParser::CmdLineParser(const QStringList &arguments)
m_search(Untouched),
m_register(None),
m_removeSearchIndex(false),
+ m_rebuildSearchIndex(false),
m_quiet(false)
{
TRACE_OBJ
@@ -126,6 +128,8 @@ CmdLineParser::Result CmdLineParser::parse()
handleSetCurrentFilterOption();
else if (arg == QLatin1String("-remove-search-index"))
m_removeSearchIndex = true;
+ else if (arg == QLatin1String("-rebuild-search-index"))
+ m_rebuildSearchIndex = true;
else if (arg == QLatin1String("-help"))
showHelp = true;
else
@@ -343,6 +347,12 @@ bool CmdLineParser::removeSearchIndex() const
return m_removeSearchIndex;
}
+bool CmdLineParser::rebuildSearchIndex() const
+{
+ TRACE_OBJ
+ return m_rebuildSearchIndex;
+}
+
CmdLineParser::RegisterState CmdLineParser::registerRequest() const
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/cmdlineparser.h b/tools/assistant/tools/assistant/cmdlineparser.h
index c1621d6..2bc7f2a 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.h
+++ b/tools/assistant/tools/assistant/cmdlineparser.h
@@ -70,6 +70,7 @@ public:
ShowState search() const;
QString currentFilter() const;
bool removeSearchIndex() const;
+ bool rebuildSearchIndex() const;
RegisterState registerRequest() const;
QString helpFile() const;
@@ -106,6 +107,7 @@ private:
RegisterState m_register;
QString m_currentFilter;
bool m_removeSearchIndex;
+ bool m_rebuildSearchIndex;
bool m_quiet;
QString m_error;
};
diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp
index 79ed2c8..ce85854 100644
--- a/tools/assistant/tools/assistant/main.cpp
+++ b/tools/assistant/tools/assistant/main.cpp
@@ -52,7 +52,8 @@
#include <QtGui/QApplication>
#include <QtGui/QDesktopServices>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
+#include <QtHelp/QHelpSearchEngine>
#include <QtNetwork/QLocalSocket>
@@ -205,6 +206,23 @@ bool removeSearchIndex(const QString &collectionFile)
return true;
}
+bool rebuildSearchIndex(QCoreApplication &app, const QString &collectionFile,
+ CmdLineParser &cmd)
+{
+ TRACE_OBJ
+ QHelpEngine engine(collectionFile);
+ if (!engine.setupData()) {
+ cmd.showMessage(QObject::tr("Error: %1").arg(engine.error()), true);
+ return false;
+ }
+
+ QHelpSearchEngine * const searchEngine = engine.searchEngine();
+ QObject::connect(searchEngine, SIGNAL(indexingFinished()), &app,
+ SLOT(quit()));
+ searchEngine->reindexDocumentation();
+ return app.exec() == 0;
+}
+
bool checkForSqlite(CmdLineParser &cmd)
{
TRACE_OBJ
@@ -225,7 +243,8 @@ bool useGui(int argc, char *argv[])
#ifndef Q_OS_WIN
// Look for arguments that imply command-line mode.
const char * cmdModeArgs[] = {
- "-help", "-register", "-unregister", "-remove-search-index"
+ "-help", "-register", "-unregister", "-remove-search-index",
+ "-rebuild-search-index"
};
for (int i = 1; i < argc; ++i) {
for (size_t j = 0; j < sizeof cmdModeArgs/sizeof *cmdModeArgs; ++j) {
@@ -376,7 +395,13 @@ int main(int argc, char *argv[])
}
if (cmd.removeSearchIndex()) {
- return removeSearchIndex(cachedCollectionFile) ? EXIT_SUCCESS : EXIT_FAILURE;
+ return removeSearchIndex(cachedCollectionFile)
+ ? EXIT_SUCCESS : EXIT_FAILURE;
+ }
+
+ if (cmd.rebuildSearchIndex()) {
+ return rebuildSearchIndex(a, cachedCollectionFile, cmd)
+ ? EXIT_SUCCESS : EXIT_FAILURE;
}
if (!checkForSqlite(cmd))