diff --git a/src/plugins/coreplugin/helpmanager.cpp b/src/plugins/coreplugin/helpmanager.cpp index 6fbb3f0ac166a7403d02dd6b8f67b255b46eb809..da2151a4d0918e6b25dedd56b678460c88e2efad 100644 --- a/src/plugins/coreplugin/helpmanager.cpp +++ b/src/plugins/coreplugin/helpmanager.cpp @@ -35,6 +35,7 @@ #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFileInfo> +#include <QtCore/QFileSystemWatcher> #include <QtCore/QStringList> #include <QtHelp/QHelpEngineCore> @@ -94,7 +95,8 @@ HelpManager* HelpManager::instance() QString HelpManager::collectionFilePath() { - return QDir::cleanPath(Core::ICore::instance()->userResourcePath() + QLatin1String("/helpcollection.qhc")); + return QDir::cleanPath(Core::ICore::instance()->userResourcePath() + + QLatin1String("/helpcollection.qhc")); } void HelpManager::registerDocumentation(const QStringList &files) @@ -392,7 +394,7 @@ void HelpManager::setupHelpManager() // this might come from the installer const QLatin1String key("AddedDocs"); - const QString &addedDocs = m_helpEngine->customValue(key).toString(); + const QString addedDocs = m_helpEngine->customValue(key).toString(); if (!addedDocs.isEmpty()) { m_helpEngine->removeCustomValue(key); m_filesToRegister += addedDocs.split(QLatin1Char(';')); @@ -407,9 +409,24 @@ void HelpManager::setupHelpManager() for (it = m_customValues.constBegin(); it != m_customValues.constEnd(); ++it) setCustomValue(it.key(), it.value()); + m_collectionWatcher = new QFileSystemWatcher(QStringList() << collectionFilePath(), + this); + connect(m_collectionWatcher, SIGNAL(fileChanged(QString)), this, + SLOT(collectionFileModified())); + emit setupFinished(); } +void HelpManager::collectionFileModified() +{ + const QLatin1String key("AddedDocs"); + const QString addedDocs = m_helpEngine->customValue(key).toString(); + if (!addedDocs.isEmpty()) { + m_helpEngine->removeCustomValue(key); + registerDocumentation(addedDocs.split(QLatin1Char(';'))); + } +} + // -- private void HelpManager::verifyDocumenation() diff --git a/src/plugins/coreplugin/helpmanager.h b/src/plugins/coreplugin/helpmanager.h index 6346f9be2e131486c8a676618c7ed0202bc1b59a..9d40102386c226d7aaae8d63ae1b3b5cd5f72bbf 100644 --- a/src/plugins/coreplugin/helpmanager.h +++ b/src/plugins/coreplugin/helpmanager.h @@ -41,6 +41,7 @@ #include <QtCore/QVariant> #include <QtCore/QByteArray> +QT_FORWARD_DECLARE_CLASS(QFileSystemWatcher) QT_FORWARD_DECLARE_CLASS(QHelpEngineCore) QT_FORWARD_DECLARE_CLASS(QSqlQuery) @@ -93,6 +94,7 @@ signals: private slots: void setupHelpManager(); + void collectionFileModified(); private: void verifyDocumenation(); @@ -100,6 +102,7 @@ private: private: bool m_needsSetup; QHelpEngineCore *m_helpEngine; + QFileSystemWatcher *m_collectionWatcher; QStringList m_filesToRegister; QStringList m_nameSpacesToUnregister;