From 33574581017c0c310f4ad010a6e7adea825993b9 Mon Sep 17 00:00:00 2001 From: kh1 <qt-info@nokia.com> Date: Tue, 16 Mar 2010 15:48:09 +0100 Subject: [PATCH] Some more refactoring, reuse existing code. Reuse the core help engine in the settings pages. Do not setup the gui help engine at all since any getter will do so. Split update documentation into smaller pieces for better performance. Reviewed-by: ck --- src/plugins/help/docsettingspage.cpp | 108 +++++++++++-------- src/plugins/help/docsettingspage.h | 24 ++--- src/plugins/help/filtersettingspage.cpp | 130 +++++++++++----------- src/plugins/help/filtersettingspage.h | 21 ++-- src/plugins/help/helpplugin.cpp | 137 ++++++++++++------------ src/plugins/help/helpplugin.h | 6 +- 6 files changed, 219 insertions(+), 207 deletions(-) diff --git a/src/plugins/help/docsettingspage.cpp b/src/plugins/help/docsettingspage.cpp index 22714a21267..0a5a603c039 100644 --- a/src/plugins/help/docsettingspage.cpp +++ b/src/plugins/help/docsettingspage.cpp @@ -29,6 +29,7 @@ #include "docsettingspage.h" #include "helpconstants.h" +#include "helpmanager.h" #include <QtCore/QCoreApplication> @@ -36,13 +37,11 @@ #include <QtGui/QKeyEvent> #include <QtGui/QMessageBox> -#include <QtHelp/QHelpEngine> +#include <QtHelp/QHelpEngineCore> using namespace Help::Internal; -DocSettingsPage::DocSettingsPage(QHelpEngine *helpEngine) - : m_helpEngine(helpEngine), - m_registeredDocs(false) +DocSettingsPage::DocSettingsPage() { } @@ -68,46 +67,55 @@ QString DocSettingsPage::displayCategory() const QWidget *DocSettingsPage::createPage(QWidget *parent) { - QWidget *w = new QWidget(parent); - m_ui.setupUi(w); + QWidget *widget = new QWidget(parent); + m_ui.setupUi(widget); - connect(m_ui.addButton, SIGNAL(clicked()), - this, SLOT(addDocumentation())); - connect(m_ui.removeButton, SIGNAL(clicked()), - this, SLOT(removeDocumentation())); + connect(m_ui.addButton, SIGNAL(clicked()), this, SLOT(addDocumentation())); + connect(m_ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDocumentation())); m_ui.docsListWidget->installEventFilter(this); - m_ui.docsListWidget->addItems(m_helpEngine->registeredDocumentations()); - m_registeredDocs = false; - m_removeDocs.clear(); + + QHelpEngineCore *engine = &HelpManager::helpEngineCore(); + const QStringList &nameSpaces = engine->registeredDocumentations(); + foreach (const QString &nameSpace, nameSpaces) + addItem(nameSpace, engine->documentationFileName(nameSpace)); + + m_filesToRegister.clear(); + m_filesToUnregister.clear(); + if (m_searchKeywords.isEmpty()) m_searchKeywords = m_ui.groupBox->title(); - return w; + return widget; } void DocSettingsPage::addDocumentation() { - QStringList files = QFileDialog::getOpenFileNames(m_ui.addButton->parentWidget(), - tr("Add Documentation"), - QString(), tr("Qt Help Files (*.qch)")); + const QStringList &files = + QFileDialog::getOpenFileNames(m_ui.addButton->parentWidget(), + tr("Add Documentation"), m_recentDialogPath, tr("Qt Help Files (*.qch)")); if (files.isEmpty()) return; + m_recentDialogPath = QFileInfo(files.first()).canonicalPath(); + + const QHelpEngineCore &engine = HelpManager::helpEngineCore(); + const QStringList &nameSpaces = engine.registeredDocumentations(); foreach (const QString &file, files) { - QString nsName = QHelpEngineCore::namespaceName(file); - if (nsName.isEmpty()) { - QMessageBox::warning(m_ui.addButton->parentWidget(), - tr("Add Documentation"), - tr("The file %1 is not a valid Qt Help file!") - .arg(file)); + const QString &nameSpace = engine.namespaceName(file); + if (nameSpace.isEmpty()) continue; + + if (m_filesToUnregister.value(nameSpace) != QDir::cleanPath(file)) { + if (!m_filesToRegister.contains(nameSpace) && !nameSpaces.contains(nameSpace)) { + addItem(nameSpace, file); + m_filesToRegister.insert(nameSpace, QDir::cleanPath(file)); + } + } else { + addItem(nameSpace, file); + m_filesToUnregister.remove(nameSpace); } - m_helpEngine->registerDocumentation(file); - m_ui.docsListWidget->addItem(nsName); } - m_registeredDocs = true; - emit documentationAdded(); } void DocSettingsPage::removeDocumentation() @@ -118,6 +126,10 @@ void DocSettingsPage::removeDocumentation() void DocSettingsPage::apply() { emit dialogAccepted(); + emit documentationChanged(); + + m_filesToRegister.clear(); + m_filesToUnregister.clear(); } bool DocSettingsPage::matches(const QString &s) const @@ -125,25 +137,14 @@ bool DocSettingsPage::matches(const QString &s) const return m_searchKeywords.contains(s, Qt::CaseInsensitive); } -bool DocSettingsPage::applyChanges() +QStringList DocSettingsPage::docsToRegister() const { - QStringList::const_iterator it = m_removeDocs.constBegin(); - while (it != m_removeDocs.constEnd()) { - if (!m_helpEngine->unregisterDocumentation((*it))) { - QMessageBox::warning(m_ui.addButton->parentWidget(), - tr("Documentation"), - tr("Cannot unregister documentation file %1!") - .arg((*it))); - } - ++it; - } - - bool success = m_registeredDocs || m_removeDocs.count(); - - m_removeDocs.clear(); - m_registeredDocs = false; + return m_filesToRegister.values(); +} - return success; +QStringList DocSettingsPage::docsToUnregister() const +{ + return m_filesToUnregister.keys(); } bool DocSettingsPage::eventFilter(QObject *object, QEvent *event) @@ -170,8 +171,18 @@ void DocSettingsPage::removeDocumentation(const QList<QListWidgetItem*> items) return; int row = 0; + QHelpEngineCore *engine = &HelpManager::helpEngineCore(); foreach (QListWidgetItem* item, items) { - m_removeDocs.append(item->text()); + const QString &nameSpace = item->text(); + const QString &docPath = engine->documentationFileName(nameSpace); + + if (m_filesToRegister.value(nameSpace) != docPath) { + if (!m_filesToUnregister.contains(nameSpace)) + m_filesToUnregister.insert(nameSpace, docPath); + } else { + m_filesToRegister.remove(nameSpace); + } + row = m_ui.docsListWidget->row(item); delete m_ui.docsListWidget->takeItem(row); } @@ -179,3 +190,10 @@ void DocSettingsPage::removeDocumentation(const QList<QListWidgetItem*> items) m_ui.docsListWidget->setCurrentRow(qMax(row - 1, 0), QItemSelectionModel::ClearAndSelect); } + +void DocSettingsPage::addItem(const QString &nameSpace, const QString &fileName) +{ + QListWidgetItem* item = new QListWidgetItem(nameSpace); + item->setToolTip(fileName); + m_ui.docsListWidget->addItem(item); +} diff --git a/src/plugins/help/docsettingspage.h b/src/plugins/help/docsettingspage.h index 50b0aa5b57c..c8ec79f9c73 100644 --- a/src/plugins/help/docsettingspage.h +++ b/src/plugins/help/docsettingspage.h @@ -31,22 +31,18 @@ #define DOCSETTINGSPAGE_H #include "ui_docsettingspage.h" - #include <coreplugin/dialogs/ioptionspage.h> -#include <QtGui/QWidget> - -QT_FORWARD_DECLARE_CLASS(QHelpEngine) - namespace Help { namespace Internal { class DocSettingsPage : public Core::IOptionsPage { Q_OBJECT + typedef QHash<QString, QString> FilesToNameSpaceHash; public: - DocSettingsPage(QHelpEngine *helpEngine); + DocSettingsPage(); QString id() const; QString displayName() const; @@ -55,14 +51,15 @@ public: QWidget *createPage(QWidget *parent); void apply(); - void finish() { } + void finish() {} virtual bool matches(const QString &s) const; - bool applyChanges(); + QStringList docsToRegister() const; + QStringList docsToUnregister() const; signals: - void documentationAdded(); void dialogAccepted(); + void documentationChanged(); private slots: void addDocumentation(); @@ -71,13 +68,16 @@ private slots: private: bool eventFilter(QObject *object, QEvent *event); void removeDocumentation(const QList<QListWidgetItem*> items); + void addItem(const QString &nameSpace, const QString &fileName); private: - QHelpEngine *m_helpEngine; - bool m_registeredDocs; - QStringList m_removeDocs; Ui::DocSettingsPage m_ui; + QString m_searchKeywords; + QString m_recentDialogPath; + + FilesToNameSpaceHash m_filesToRegister; + FilesToNameSpaceHash m_filesToUnregister; }; } // namespace Help diff --git a/src/plugins/help/filtersettingspage.cpp b/src/plugins/help/filtersettingspage.cpp index 16d36dbf4ca..9fdf9746404 100644 --- a/src/plugins/help/filtersettingspage.cpp +++ b/src/plugins/help/filtersettingspage.cpp @@ -28,19 +28,21 @@ **************************************************************************/ #include "filtersettingspage.h" -#include "helpconstants.h" + #include "filternamedialog.h" +#include "helpconstants.h" +#include "helpmanager.h" + +#include <QtCore/QCoreApplication> #include <QtGui/QFileDialog> #include <QtGui/QMessageBox> -#include <QtCore/QCoreApplication> -#include <QtHelp/QHelpEngine> +#include <QtHelp/QHelpEngineCore> using namespace Help::Internal; -FilterSettingsPage::FilterSettingsPage(QHelpEngine *helpEngine) : - m_helpEngine(helpEngine) +FilterSettingsPage::FilterSettingsPage() { } @@ -66,11 +68,14 @@ QString FilterSettingsPage::displayCategory() const QWidget *FilterSettingsPage::createPage(QWidget *parent) { - m_currentPage = new QWidget(parent); - m_ui.setupUi(m_currentPage); + QWidget *widget = new QWidget(parent); + m_ui.setupUi(widget); + m_ui.attributeWidget->header()->hide(); m_ui.attributeWidget->setRootIsDecorated(false); + updateFilterPage(); // does call setupData on the engine + connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(updateFilterMap())); connect(m_ui.filterWidget, @@ -79,37 +84,33 @@ QWidget *FilterSettingsPage::createPage(QWidget *parent) connect(m_ui.filterAddButton, SIGNAL(clicked()), this, SLOT(addFilter())); connect(m_ui.filterRemoveButton, SIGNAL(clicked()), this, SLOT(removeFilter())); - updateFilterPage(); - if (m_searchKeywords.isEmpty()) - m_searchKeywords = m_ui.filterGroupBox->title() + QLatin1Char(' ') + m_ui.attributesGroupBox->title(); - - return m_currentPage; + if (m_searchKeywords.isEmpty()) { + m_searchKeywords = m_ui.filterGroupBox->title() + QLatin1Char(' ') + + m_ui.attributesGroupBox->title(); + } + return widget; } void FilterSettingsPage::updateFilterPage() { - if (!m_helpEngine) - return; - m_ui.filterWidget->clear(); m_ui.attributeWidget->clear(); - QHelpEngineCore help(m_helpEngine->collectionFile(), 0); - help.setupData(); m_filterMapBackup.clear(); - const QStringList filters = help.customFilters(); + const QHelpEngineCore &engine = HelpManager::helpEngineCore(); + const QStringList &filters = engine.customFilters(); foreach (const QString &filter, filters) { - const QStringList atts = help.filterAttributes(filter); - m_filterMapBackup.insert(filter, atts); + const QStringList &attributes = engine.filterAttributes(filter); + m_filterMapBackup.insert(filter, attributes); if (!m_filterMap.contains(filter)) - m_filterMap.insert(filter, atts); + m_filterMap.insert(filter, attributes); } - m_ui.filterWidget->addItems(m_filterMap.keys()); - foreach (const QString &a, help.filterAttributes()) - new QTreeWidgetItem(m_ui.attributeWidget, QStringList(a)); + const QStringList &attributes = engine.filterAttributes(); + foreach (const QString &attribute, attributes) + new QTreeWidgetItem(m_ui.attributeWidget, QStringList(attribute)); if (m_filterMap.keys().count()) m_ui.filterWidget->setCurrentRow(0); @@ -120,9 +121,9 @@ void FilterSettingsPage::updateAttributes(QListWidgetItem *item) QStringList checkedList; if (item) checkedList = m_filterMap.value(item->text()); - QTreeWidgetItem *itm; - for (int i=0; i<m_ui.attributeWidget->topLevelItemCount(); ++i) { - itm = m_ui.attributeWidget->topLevelItem(i); + + for (int i = 0; i < m_ui.attributeWidget->topLevelItemCount(); ++i) { + QTreeWidgetItem *itm = m_ui.attributeWidget->topLevelItem(i); if (checkedList.contains(itm->text(0))) itm->setCheckState(0, Qt::Checked); else @@ -134,14 +135,14 @@ void FilterSettingsPage::updateFilterMap() { if (!m_ui.filterWidget->currentItem()) return; - QString filter = m_ui.filterWidget->currentItem()->text(); + + const QString &filter = m_ui.filterWidget->currentItem()->text(); if (!m_filterMap.contains(filter)) return; QStringList newAtts; - QTreeWidgetItem *itm = 0; - for (int i=0; i<m_ui.attributeWidget->topLevelItemCount(); ++i) { - itm = m_ui.attributeWidget->topLevelItem(i); + for (int i = 0; i < m_ui.attributeWidget->topLevelItemCount(); ++i) { + QTreeWidgetItem *itm = m_ui.attributeWidget->topLevelItem(i); if (itm->checkState(0) == Qt::Checked) newAtts.append(itm->text(0)); } @@ -150,25 +151,25 @@ void FilterSettingsPage::updateFilterMap() void FilterSettingsPage::addFilter() { - FilterNameDialog dia(m_currentPage); + FilterNameDialog dia(m_ui.filterWidget); if (dia.exec() == QDialog::Rejected) return; - QString filterName = dia.filterName(); + const QString &filterName = dia.filterName(); if (!m_filterMap.contains(filterName)) { m_filterMap.insert(filterName, QStringList()); m_ui.filterWidget->addItem(filterName); } - QList<QListWidgetItem*> lst = m_ui.filterWidget - ->findItems(filterName, Qt::MatchCaseSensitive); + const QList<QListWidgetItem*> &lst = m_ui.filterWidget->findItems(filterName, + Qt::MatchCaseSensitive); m_ui.filterWidget->setCurrentItem(lst.first()); } void FilterSettingsPage::removeFilter() { - QListWidgetItem *item = m_ui.filterWidget - ->takeItem(m_ui.filterWidget->currentRow()); + QListWidgetItem *item = + m_ui.filterWidget->takeItem(m_ui.filterWidget->currentRow()); if (!item) return; @@ -187,43 +188,40 @@ void FilterSettingsPage::apply() bool FilterSettingsPage::applyChanges() { - bool changed = false; - if (m_filterMap.count() != m_filterMapBackup.count()) { - changed = true; - } else { - QMapIterator<QString, QStringList> it(m_filterMapBackup); - while (it.hasNext() && !changed) { - it.next(); - if (!m_filterMap.contains(it.key())) { - changed = true; - } else { - QStringList a = it.value(); - QStringList b = m_filterMap.value(it.key()); - if (a.count() != b.count()) { - changed = true; - } else { - QStringList::const_iterator i(a.constBegin()); - while (i != a.constEnd()) { - if (!b.contains(*i)) { - changed = true; - break; - } - ++i; + bool changed = m_filterMap.count() != m_filterMapBackup.count(); + if (!changed) { + FilterMap::const_iterator it = m_filterMapBackup.constBegin(); + for (; it != m_filterMapBackup.constEnd() && !changed; ++it) { + if (m_filterMap.contains(it.key())) { + const QStringList &a = it.value(); + const QStringList &b = m_filterMap.value(it.key()); + if (a.count() == b.count()) { + QStringList::const_iterator i = a.constBegin(); + for (; i != a.constEnd() && !changed; ++i) { + if (b.contains(*i)) + continue; + changed = true; } + } else { + changed = true; } + } else { + changed = true; } } } + if (changed) { + QHelpEngineCore *engine = &HelpManager::helpEngineCore(); foreach (const QString &filter, m_removedFilters) - m_helpEngine->removeCustomFilter(filter); - QMapIterator<QString, QStringList> it(m_filterMap); - while (it.hasNext()) { - it.next(); - m_helpEngine->addCustomFilter(it.key(), it.value()); - } + engine->removeCustomFilter(filter); + + FilterMap::const_iterator it; + for (it = m_filterMap.constBegin(); it != m_filterMap.constEnd(); ++it) + engine->addCustomFilter(it.key(), it.value()); return true; } + return false; } @@ -231,5 +229,3 @@ bool FilterSettingsPage::matches(const QString &s) const { return m_searchKeywords.contains(s, Qt::CaseInsensitive); } - - diff --git a/src/plugins/help/filtersettingspage.h b/src/plugins/help/filtersettingspage.h index eda27c08e01..e834b2f7493 100644 --- a/src/plugins/help/filtersettingspage.h +++ b/src/plugins/help/filtersettingspage.h @@ -30,12 +30,8 @@ #ifndef FILTERSETTINGSPAGE_H #define FILTERSETTINGSPAGE_H -#include <QtGui/QWidget> -#include <coreplugin/dialogs/ioptionspage.h> - #include "ui_filtersettingspage.h" - -QT_FORWARD_DECLARE_CLASS(QHelpEngine) +#include <coreplugin/dialogs/ioptionspage.h> namespace Help { namespace Internal { @@ -43,9 +39,10 @@ namespace Internal { class FilterSettingsPage : public Core::IOptionsPage { Q_OBJECT + typedef QMap<QString, QStringList> FilterMap; public: - FilterSettingsPage(QHelpEngine *helpEngine); + FilterSettingsPage(); QString id() const; QString displayName() const; @@ -54,7 +51,7 @@ public: QWidget *createPage(QWidget *parent); void apply(); - void finish() { } + void finish() {} virtual bool matches(const QString &s) const; bool applyChanges(); @@ -67,13 +64,13 @@ private slots: void removeFilter(); private: - QHelpEngine *m_helpEngine; Ui::FilterSettingsPage m_ui; - QMap<QString, QStringList> m_filterMapBackup; - QMap<QString, QStringList> m_filterMap; - QStringList m_removedFilters; - QWidget *m_currentPage; + + FilterMap m_filterMap; + FilterMap m_filterMapBackup; + QString m_searchKeywords; + QStringList m_removedFilters; }; } // namespace Help diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 6a26dd7990a..992a801d1c4 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -146,28 +146,20 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) //webSettings->setFontSize(QWebSettings::DefaultFontSize, applicationFont.pointSize()); #endif - // FIXME shouldn't the help engine create the directory if it doesn't exist? - const QFileInfo &fi(m_core->settings()->fileName()); - const QDir directory(fi.absolutePath() + QLatin1String("/qtcreator")); - if (!directory.exists()) - directory.mkpath(directory.absolutePath()); - m_helpEngine = new QHelpEngine(directory.absolutePath() + - QLatin1String("/helpcollection.qhc"), this); - m_helpEngine->setAutoSaveFilter(false); - - helpManager = new HelpManager(this); - addAutoReleasedObject(helpManager); - - m_filterSettingsPage = new FilterSettingsPage(m_helpEngine); - addAutoReleasedObject(m_filterSettingsPage); + addAutoReleasedObject(helpManager = new HelpManager(this)); + addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage()); + addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage()); - m_docSettingsPage = new DocSettingsPage(m_helpEngine); - addAutoReleasedObject(m_docSettingsPage); - - connect(m_docSettingsPage, SIGNAL(documentationAdded()), + connect(m_docSettingsPage, SIGNAL(documentationChanged()), m_filterSettingsPage, SLOT(updateFilterPage())); connect(m_docSettingsPage, SIGNAL(dialogAccepted()), this, SLOT(checkForHelpChanges())); + connect(helpManager, SIGNAL(registerDocumentation()), this, + SLOT(slotRegisterDocumentation())); + + // force a block here to avoid the expensive indexing restart signal, etc... + m_helpEngine = new QHelpEngine("", this); + m_helpEngine->blockSignals(true); m_contentWidget = new ContentWindow(m_helpEngine); m_contentWidget->setWindowTitle(tr("Contents")); @@ -414,10 +406,12 @@ void HelpPlugin::setFilesToRegister(const QStringList &files) filesToRegister += files; } -void HelpPlugin::pluginUpdateDocumentation() +void HelpPlugin::slotRegisterDocumentation() { - if (isInitialised) - updateDocumentation(); + if (isInitialised) { + if (registerDocumentation()) + m_helpEngine->setupData(); + } } void HelpPlugin::resetFilter() @@ -441,24 +435,24 @@ void HelpPlugin::resetFilter() m_helpEngine->setCurrentFilter(filterName); } -bool HelpPlugin::updateDocumentation() +bool HelpPlugin::verifiyDocumentation() { - bool needsSetup = false; + QStringList nameSpacesToUnregister; const QStringList ®isteredDocs = m_helpEngine->registeredDocumentations(); foreach (const QString &nameSpace, registeredDocs) { const QString &file = m_helpEngine->documentationFileName(nameSpace); - if (QFileInfo(file).exists()) - continue; - - if (!m_helpEngine->unregisterDocumentation(nameSpace)) { - qWarning() << "Error unregistering namespace '" - << nameSpace << "' from file '" << file << "': " - << m_helpEngine->error(); - } else { - needsSetup = true; - } + if (!QFileInfo(file).exists()) + nameSpacesToUnregister.append(nameSpace); } + if (!nameSpacesToUnregister.isEmpty()) + return unregisterDocumentation(nameSpacesToUnregister); + return false; +} + +bool HelpPlugin::registerDocumentation() +{ + bool needsSetup = false; foreach (const QString &file, filesToRegister) { const QString &nameSpace = m_helpEngine->namespaceName(file); if (nameSpace.isEmpty()) @@ -467,14 +461,27 @@ bool HelpPlugin::updateDocumentation() if (m_helpEngine->registerDocumentation(file)) { needsSetup = true; } else { - qWarning() << "error registering" << file << m_helpEngine->error(); + qWarning() << "Error registering namespace '" << nameSpace + << "' from file '" << file << "':" << m_helpEngine->error(); } } } filesToRegister.clear(); + return needsSetup; +} - if (needsSetup) - m_helpEngine->setupData(); +bool HelpPlugin::unregisterDocumentation(const QStringList &nameSpaces) +{ + bool needsSetup = false; + foreach (const QString &nameSpace, nameSpaces) { + const QString &file = m_helpEngine->documentationFileName(nameSpace); + if (m_helpEngine->unregisterDocumentation(nameSpace)) { + needsSetup = true; + } else { + qWarning() << "Error unregistering namespace '" << nameSpace + << "' from file '" << file << "': " << m_helpEngine->error(); + } + } return needsSetup; } @@ -607,13 +614,8 @@ void HelpPlugin::extensionsInitialized() { m_sideBar->readSettings(m_core->settings(), QLatin1String("HelpSideBar")); - // force a block here to avoid the expensive indexing restart signal, etc... - bool blocked = m_helpEngine->blockSignals(true); - if (!m_helpEngine->setupData()) { - m_helpEngine->blockSignals(blocked); - qWarning() << "Could not initialize help engine: " << m_helpEngine->error(); - return; - } + m_helpEngine->setCollectionFile(HelpManager::collectionFilePath()); + m_helpEngine->setAutoSaveFilter(false); const QString &docInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3") .arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE); @@ -638,21 +640,6 @@ void HelpPlugin::extensionsInitialized() m_helpEngine->removeCustomFilter(filter); } - - m_helpEngine->blockSignals(blocked); - - connect(m_helpEngine, SIGNAL(setupFinished()), this, - SLOT(updateFilterComboBox())); - - // explicit disconnect the full text search indexer, we connect and start - // it later once we really need it, e.g. the full text search is opened... - disconnect(m_helpEngine, SIGNAL(setupFinished()), m_helpEngine->searchEngine(), - SLOT(indexDocumentation())); - connect(m_helpEngine->searchEngine(), SIGNAL(indexingStarted()), this, - SLOT(indexingStarted())); - connect(m_helpEngine->searchEngine(), SIGNAL(indexingFinished()), this, - SLOT(indexingFinished())); - // Explicitly register qml.qch if located in creator directory. This is only // needed for the creator-qml package, were we want to ship the documentation // without a qt development version. @@ -674,11 +661,9 @@ void HelpPlugin::extensionsInitialized() filesToRegister += addedDocs.split(QLatin1Char(';')); } - if (!updateDocumentation()) { - // if no documentation has been added, we need to force a setup data, - // otherwise it has already been run in updateDocumentation - m_helpEngine->setupData(); - } + verifiyDocumentation(); + registerDocumentation(); + m_bookmarkManager->setupBookmarkModels(); #if !defined(QT_NO_WEBKIT) QWebSettings* webSettings = QWebSettings::globalSettings(); @@ -704,10 +689,20 @@ void HelpPlugin::extensionsInitialized() connect(m_centralWidget, SIGNAL(viewerAboutToBeRemoved(int)), this, SLOT(removeViewerFromComboBox(int))); - connect(helpManager, SIGNAL(registerDocumentation()), this, - SLOT(pluginUpdateDocumentation())); + // explicit disconnect the full text search indexer, we connect and start + // it later once we really need it, e.g. the full text search is opened... + disconnect(m_helpEngine, SIGNAL(setupFinished()), m_helpEngine->searchEngine(), + SLOT(indexDocumentation())); + + connect(m_helpEngine, SIGNAL(setupFinished()), this, + SLOT(updateFilterComboBox())); + connect(m_helpEngine->searchEngine(), SIGNAL(indexingStarted()), this, + SLOT(indexingStarted())); + connect(m_helpEngine->searchEngine(), SIGNAL(indexingFinished()), this, + SLOT(indexingFinished())); - isInitialised = true; + isInitialised = true; // helper for slotRegisterDocumentation() + m_helpEngine->blockSignals(false); // blocked in initialize() } void HelpPlugin::shutdown() @@ -736,10 +731,13 @@ void HelpPlugin::modeChanged(Core::IMode *mode) qApp->setOverrideCursor(Qt::WaitCursor); resetFilter(); - m_centralWidget->setLastShownPages(); + m_helpEngine->setupData(); connect(m_helpEngine, SIGNAL(setupFinished()), m_helpEngine->searchEngine(), SLOT(indexDocumentation())); QMetaObject::invokeMethod(m_helpEngine, "setupFinished", Qt::QueuedConnection); + + m_centralWidget->setLastShownPages(); + qApp->restoreOverrideCursor(); } } @@ -979,8 +977,9 @@ void HelpPlugin::updateFilterComboBox() void HelpPlugin::checkForHelpChanges() { - bool changed = m_docSettingsPage->applyChanges(); - changed |= m_filterSettingsPage->applyChanges(); + bool changed = unregisterDocumentation(m_docSettingsPage->docsToUnregister()); + filesToRegister += m_docSettingsPage->docsToRegister(); + changed |= registerDocumentation(); if (changed) m_helpEngine->setupData(); } diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index de006ea2e71..0a6a6e32c82 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -96,7 +96,7 @@ public: void setFilesToRegister(const QStringList &files); public slots: - void pluginUpdateDocumentation(); + void slotRegisterDocumentation(); void handleHelpRequest(const QString &url); private slots: @@ -134,7 +134,9 @@ private slots: private: void resetFilter(); - bool updateDocumentation(); + bool verifiyDocumentation(); + bool registerDocumentation(); + bool unregisterDocumentation(const QStringList &nameSpaces); private: QToolBar *createToolBar(); -- GitLab