summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-02-15 16:16:53 (GMT)
committerck <qt-info@nokia.com>2010-02-15 16:36:14 (GMT)
commite885e8123fbe0d57a0d8a4c8115ea43dde31b05d (patch)
tree806307c7087b36e1e44737c1f30bef2d73e2f6f3 /tools/assistant
parent12180c397a2007970978033928b4b5b12efad7c6 (diff)
downloadQt-e885e8123fbe0d57a0d8a4c8115ea43dde31b05d.zip
Qt-e885e8123fbe0d57a0d8a4c8115ea43dde31b05d.tar.gz
Qt-e885e8123fbe0d57a0d8a4c8115ea43dde31b05d.tar.bz2
Assistant: Rebuild search index at most once at start-up.
Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp28
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h6
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp3
3 files changed, 34 insertions, 3 deletions
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index 76211c5..a181c71 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -112,6 +112,7 @@ private:
QFileSystemWatcher * const m_qchWatcher;
typedef QPair<QDateTime, QSharedPointer<TimeoutForwarder> > RecentSignal;
QMap<QString, RecentSignal> m_recentQchUpdates;
+ bool m_initialReindexingNeeded;
};
const QString HelpEngineWrapper::TrUnfiltered = tr("Unfiltered");
@@ -141,6 +142,18 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile)
: d(new HelpEngineWrapperPrivate(collectionFile))
{
TRACE_OBJ
+
+ /*
+ * Otherwise we will waste time if several new docs are found,
+ * because we will start to index them, only to be interupted
+ * by the next request. Also, there is a nasty SQLITE bug that will
+ * cause the application to hang for minutes in that case.
+ * This call is reverted by initalDocSetupDone(), which must be
+ * called after the new docs have been installed.
+ */
+ disconnect(d->m_helpEngine, SIGNAL(setupFinished()),
+ searchEngine(), SLOT(indexDocumentation()));
+
connect(d, SIGNAL(documentationRemoved(QString)),
this, SIGNAL(documentationRemoved(QString)));
connect(d, SIGNAL(documentationUpdated(QString)),
@@ -157,6 +170,15 @@ HelpEngineWrapper::~HelpEngineWrapper()
delete d;
}
+void HelpEngineWrapper::initialDocSetupDone()
+{
+ TRACE_OBJ
+ connect(d->m_helpEngine, SIGNAL(setupFinished()),
+ searchEngine(), SLOT(indexDocumentation()));
+ if (d->m_initialReindexingNeeded)
+ setupData();
+}
+
QHelpSearchEngine *HelpEngineWrapper::searchEngine() const
{
TRACE_OBJ
@@ -207,6 +229,7 @@ bool HelpEngineWrapper::registerDocumentation(const QString &docFile)
return false;
d->m_qchWatcher->addPath(docFile);
d->checkDocFilesWatched();
+ d->m_initialReindexingNeeded = true;
return true;
}
@@ -219,6 +242,7 @@ bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName)
return false;
d->m_qchWatcher->removePath(file);
d->checkDocFilesWatched();
+ d->m_initialReindexingNeeded = true;
return true;
}
@@ -698,7 +722,8 @@ void TimeoutForwarder::forward()
HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile)
: m_helpEngine(new QHelpEngine(collectionFile, this)),
- m_qchWatcher(new QFileSystemWatcher(this))
+ m_qchWatcher(new QFileSystemWatcher(this)),
+ m_initialReindexingNeeded(false)
{
TRACE_OBJ
if (!m_helpEngine->customFilters().contains(Unfiltered))
@@ -797,6 +822,7 @@ void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName,
} else {
emit documentationUpdated(ns);
}
+ m_initialReindexingNeeded = true;
m_helpEngine->setupData();
}
m_recentQchUpdates.erase(it);
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
index a30fab8..8d95273 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.h
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -101,6 +101,12 @@ public:
const QStringList filterAttributes(const QString &filterName) const;
QString error() const;
+ /*
+ * To be called after assistant has finished looking for new documentation.
+ * This will mainly cause the search index to be updated, if necessary.
+ */
+ void initialDocSetupDone();
+
const QStringList qtDocInfo(const QString &component) const;
void setQtDocInfo(const QString &component, const QStringList &doc);
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 4115d39..8096218 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -354,8 +354,6 @@ void MainWindow::lookForNewQtDocumentation()
void MainWindow::qtDocumentationInstalled(bool newDocsInstalled)
{
TRACE_OBJ
- if (newDocsInstalled)
- HelpEngineWrapper::instance().setupData();
statusBar()->clearMessage();
checkInitState();
}
@@ -383,6 +381,7 @@ void MainWindow::checkInitState()
}
emit initDone();
}
+ HelpEngineWrapper::instance().initialDocSetupDone();
}
void MainWindow::insertLastPages()