forked from qt-creator/qt-creator
Monitor the collection file for doc updates during sdk update.
Reviewed-by: ck
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QFileSystemWatcher>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
#include <QtHelp/QHelpEngineCore>
|
#include <QtHelp/QHelpEngineCore>
|
||||||
@@ -94,7 +95,8 @@ HelpManager* HelpManager::instance()
|
|||||||
|
|
||||||
QString HelpManager::collectionFilePath()
|
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)
|
void HelpManager::registerDocumentation(const QStringList &files)
|
||||||
@@ -392,7 +394,7 @@ void HelpManager::setupHelpManager()
|
|||||||
|
|
||||||
// this might come from the installer
|
// this might come from the installer
|
||||||
const QLatin1String key("AddedDocs");
|
const QLatin1String key("AddedDocs");
|
||||||
const QString &addedDocs = m_helpEngine->customValue(key).toString();
|
const QString addedDocs = m_helpEngine->customValue(key).toString();
|
||||||
if (!addedDocs.isEmpty()) {
|
if (!addedDocs.isEmpty()) {
|
||||||
m_helpEngine->removeCustomValue(key);
|
m_helpEngine->removeCustomValue(key);
|
||||||
m_filesToRegister += addedDocs.split(QLatin1Char(';'));
|
m_filesToRegister += addedDocs.split(QLatin1Char(';'));
|
||||||
@@ -407,9 +409,24 @@ void HelpManager::setupHelpManager()
|
|||||||
for (it = m_customValues.constBegin(); it != m_customValues.constEnd(); ++it)
|
for (it = m_customValues.constBegin(); it != m_customValues.constEnd(); ++it)
|
||||||
setCustomValue(it.key(), it.value());
|
setCustomValue(it.key(), it.value());
|
||||||
|
|
||||||
|
m_collectionWatcher = new QFileSystemWatcher(QStringList() << collectionFilePath(),
|
||||||
|
this);
|
||||||
|
connect(m_collectionWatcher, SIGNAL(fileChanged(QString)), this,
|
||||||
|
SLOT(collectionFileModified()));
|
||||||
|
|
||||||
emit setupFinished();
|
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
|
// -- private
|
||||||
|
|
||||||
void HelpManager::verifyDocumenation()
|
void HelpManager::verifyDocumenation()
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtCore/QByteArray>
|
#include <QtCore/QByteArray>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QFileSystemWatcher)
|
||||||
QT_FORWARD_DECLARE_CLASS(QHelpEngineCore)
|
QT_FORWARD_DECLARE_CLASS(QHelpEngineCore)
|
||||||
QT_FORWARD_DECLARE_CLASS(QSqlQuery)
|
QT_FORWARD_DECLARE_CLASS(QSqlQuery)
|
||||||
|
|
||||||
@@ -93,6 +94,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupHelpManager();
|
void setupHelpManager();
|
||||||
|
void collectionFileModified();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void verifyDocumenation();
|
void verifyDocumenation();
|
||||||
@@ -100,6 +102,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool m_needsSetup;
|
bool m_needsSetup;
|
||||||
QHelpEngineCore *m_helpEngine;
|
QHelpEngineCore *m_helpEngine;
|
||||||
|
QFileSystemWatcher *m_collectionWatcher;
|
||||||
|
|
||||||
QStringList m_filesToRegister;
|
QStringList m_filesToRegister;
|
||||||
QStringList m_nameSpacesToUnregister;
|
QStringList m_nameSpacesToUnregister;
|
||||||
|
|||||||
Reference in New Issue
Block a user