diff options
author | ck <qt-info@nokia.com> | 2009-11-12 13:26:52 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2009-11-12 13:26:52 (GMT) |
commit | b60ed9f084e45314787b84b686231ae68e0d39ba (patch) | |
tree | 612f4f2f981feffc5af3598a5ef46d8b18ea4747 | |
parent | e59578eb338b7374a361e4eca55589996c74ecbb (diff) | |
download | Qt-b60ed9f084e45314787b84b686231ae68e0d39ba.zip Qt-b60ed9f084e45314787b84b686231ae68e0d39ba.tar.gz Qt-b60ed9f084e45314787b84b686231ae68e0d39ba.tar.bz2 |
Assistant: Allow (un)registering documentation files remotely.
Task-number: QT-2903
Reviewed-by: kh1
4 files changed, 34 insertions, 10 deletions
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index b708343..1c62954 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -1001,7 +1001,7 @@ void CentralWidget::updateBrowserFont() int i = searchAttached ? 1 : 0; getBrowserFontFor(tabWidget->widget(i), &font); - for (i; i < tabWidget->count(); ++i) + for (; i < tabWidget->count(); ++i) setBrowserFontFor(tabWidget->widget(i), font); } @@ -1142,6 +1142,17 @@ CentralWidget::highlightSearchTerms() #endif } + +void CentralWidget::closeTabs(const QList<int> &indices) +{ + QList<int> sortedIndices = indices; + qSort(sortedIndices); + for (int i = sortedIndices.count(); --i >= 0;) + closeTabAt(sortedIndices.at(i)); + if (availableHelpViewer() == 0) + setSource(QUrl(QLatin1String("about:blank"))); +} + void CentralWidget::closeTabAt(int index) { HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(index)); diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 8c186f0..c348abf 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -42,6 +42,7 @@ #ifndef CENTRALWIDGET_H #define CENTRALWIDGET_H +#include <QtCore/QList> #include <QtCore/QUrl> #include <QtCore/QPoint> #include <QtCore/QObject> @@ -134,6 +135,7 @@ public: int availableHelpViewer() const; bool enableTabCloseAction() const; + void closeTabs(const QList<int> &indices); void closeTabAt(int index); QMap<int, QString> currentSourceFileList() const; diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index d964015..2aa451e 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -378,12 +378,7 @@ void PreferencesDialog::applyChanges() } } - qSort(m_TabsToClose); - CentralWidget* widget = CentralWidget::instance(); - for (int i = m_TabsToClose.count(); --i >= 0;) - widget->closeTabAt(m_TabsToClose.at(i)); - if (widget->availableHelpViewer()== 0) - widget->setSource(QUrl(QLatin1String("about:blank"))); + CentralWidget::instance()->closeTabs(m_TabsToClose); if (m_unregDocs.count()) { foreach (const QString &doc, m_unregDocs) diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index ac7e16f..c1b995d 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -44,6 +44,7 @@ #include "centralwidget.h" #include <QtCore/QFile> +#include <QtCore/QFileInfo> #include <QtCore/QThread> #include <QtCore/QTextStream> #include <QtCore/QSocketNotifier> @@ -236,15 +237,30 @@ void RemoteControl::handleCommandString(const QString &cmdString) m_expandTOC = depth; else m_mainWindow->expandTOC(depth); - } else if (cmd == QLatin1String("setcurrentfilter")) { - if (!m_helpEngine->customFilters().contains(arg)) - return; + } else if (cmd == QLatin1String("setcurrentfilter") + && m_helpEngine->customFilters().contains(arg)) { if (m_caching) { clearCache(); m_currentFilter = arg; } else { m_helpEngine->setCurrentFilter(arg); } + } else if (cmd == QLatin1String("register")) { + const QString &absFileName = QFileInfo(arg).absoluteFilePath(); + if (m_helpEngine->registeredDocumentations(). + contains(QHelpEngineCore::namespaceName(absFileName))) + return; + m_helpEngine->registerDocumentation(absFileName); + m_helpEngine->setupData(); + } else if (cmd == QLatin1String("unregister")) { + const QString &absFileName = QFileInfo(arg).absoluteFilePath(); + const QString &ns = QHelpEngineCore::namespaceName(absFileName); + if (m_helpEngine->registeredDocumentations().contains(ns)) { + CentralWidget* widget = CentralWidget::instance(); + widget->closeTabs(widget->currentSourceFileList().keys(ns)); + m_helpEngine->unregisterDocumentation(ns); + m_helpEngine->setupData(); + } } else { return; } |