diff options
author | ck <qt-info@nokia.com> | 2009-12-09 11:23:13 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2009-12-09 11:23:13 (GMT) |
commit | 5b2cdd7cdeec0bb77e331d6ef78ecf3b678b0764 (patch) | |
tree | 7ef85adc9daad5e51b980e23efe3477039e09330 /tools/assistant | |
parent | c8711dea20e854ba3100742a7018afae79e991df (diff) | |
download | Qt-5b2cdd7cdeec0bb77e331d6ef78ecf3b678b0764.zip Qt-5b2cdd7cdeec0bb77e331d6ef78ecf3b678b0764.tar.gz Qt-5b2cdd7cdeec0bb77e331d6ef78ecf3b678b0764.tar.bz2 |
Assistant: Try to reload open pages on doc file update.
Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
5 files changed, 23 insertions, 10 deletions
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index d148095..638b8d2 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -1179,13 +1179,25 @@ CentralWidget::highlightSearchTerms() } -void CentralWidget::closeTabs(const QList<int> &indices) +void CentralWidget::closeOrReloadTabs(const QList<int> &indices, bool tryReload) { TRACE_OBJ QList<int> sortedIndices = indices; qSort(sortedIndices); - for (int i = sortedIndices.count(); --i >= 0;) - closeTabAt(sortedIndices.at(i)); + for (int i = sortedIndices.count(); --i >= 0;) { + const int tab = sortedIndices.at(i); + bool close = true; + if (tryReload) { + HelpViewer *viewer = + qobject_cast<HelpViewer*>(tabWidget->widget(tab)); + if (HelpEngineWrapper::instance().findFile(viewer->url()).isValid()) { + viewer->reload(); + close = false; + } + } + if (close) + closeTabAt(tab); + } if (availableHelpViewer() == 0) setSource(QUrl(QLatin1String("about:blank"))); } @@ -1202,7 +1214,7 @@ QMap<int, QString> CentralWidget::currentSourceFileList() const { TRACE_OBJ QMap<int, QString> sourceList; - for (int i = 1; i < tabWidget->count(); ++i) { + for (int i = 0; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) sourceList.insert(i, viewer->source().host()); diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index d90968e..c6e9fc8 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -135,7 +135,7 @@ public: int availableHelpViewer() const; bool enableTabCloseAction() const; - void closeTabs(const QList<int> &indices); + void closeOrReloadTabs(const QList<int> &indices, bool tryReload); void closeTabAt(int index); QMap<int, QString> currentSourceFileList() const; diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index ce4ab7f..163d9b9 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -1186,15 +1186,16 @@ void MainWindow::documentationRemoved(const QString &namespaceName) { TRACE_OBJ CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); + widget->closeOrReloadTabs(widget->currentSourceFileList(). + keys(namespaceName), false); } void MainWindow::documentationUpdated(const QString &namespaceName) { TRACE_OBJ - // TODO: Check whether the documents still exists and if they do, reload. CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); + widget->closeOrReloadTabs(widget->currentSourceFileList(). + keys(namespaceName), true); } void MainWindow::resetQtDocInfo(const QString &component) diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index aac26f1..7141ec5 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -374,7 +374,7 @@ void PreferencesDialog::applyChanges() } } - CentralWidget::instance()->closeTabs(m_TabsToClose); + CentralWidget::instance()->closeOrReloadTabs(m_TabsToClose, false); foreach (const QString &doc, m_unregDocs) helpEngine.unregisterDocumentation(doc); diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index f8eef4c..1f02ef9 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -324,7 +324,7 @@ void RemoteControl::handleUnregisterCommand(const QString &arg) const QString &ns = QHelpEngineCore::namespaceName(absFileName); if (helpEngine.registeredDocumentations().contains(ns)) { CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(ns)); + widget->closeOrReloadTabs(widget->currentSourceFileList().keys(ns), false); if (helpEngine.unregisterDocumentation(ns)) helpEngine.setupData(); } |