From 0ad7366f9349846dbb18b97c5da54f4b767cc249 Mon Sep 17 00:00:00 2001 From: "qt-info@nokia.com" Date: Mon, 9 Nov 2009 11:43:34 +0100 Subject: Assistant: Fix bugs related to setting the current filter remotely. 1. Filter combo box now gets updated on remote setCurrentFilter. 2. Argument to remote setCurrentFilter now gets checked. If there is no such filter, we reject it. --- tools/assistant/tools/assistant/mainwindow.cpp | 21 +++++++++++---------- tools/assistant/tools/assistant/mainwindow.h | 1 + tools/assistant/tools/assistant/remotecontrol.cpp | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index de3f695..c56e7e4 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -227,16 +227,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); - m_helpEngine->setCurrentFilter(curFilter); - if (m_filterCombo) { - int idx = m_filterCombo->findText(curFilter); - if (idx >= 0) { - bool blocked = m_filterCombo->signalsBlocked(); - m_filterCombo->blockSignals(true); - m_filterCombo->setCurrentIndex(idx); - m_filterCombo->blockSignals(blocked); - } - } + if (m_helpEngine->customFilters().contains(curFilter)) + m_helpEngine->setCurrentFilter(curFilter); } if (usesDefaultCollection()) @@ -664,6 +656,8 @@ void MainWindow::setupFilterToolbar() SLOT(setupFilterCombo())); connect(m_filterCombo, SIGNAL(activated(QString)), this, SLOT(filterDocumentation(QString))); + connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), this, + SLOT(currentFilterChanged(QString))); setupFilterCombo(); } @@ -1041,4 +1035,11 @@ QString MainWindow::defaultHelpCollectionFileName() arg(QLatin1String(QT_VERSION_STR)); } +void MainWindow::currentFilterChanged(const QString &filter) +{ + const int index = m_filterCombo->findText(filter); + Q_ASSERT(index != -1); + m_filterCombo->setCurrentIndex(index); +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 6b858e9..7559fe4 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -95,6 +95,7 @@ public slots: void showSearchWidget(); void syncContents(); void activateCurrentCentralWidgetTab(); + void currentFilterChanged(const QString &filter); private slots: void insertLastPages(); diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index be1c197..474a681 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -237,6 +237,8 @@ void RemoteControl::handleCommandString(const QString &cmdString) else m_mainWindow->expandTOC(depth); } else if (cmd == QLatin1String("setcurrentfilter")) { + if (!m_helpEngine->customFilters().contains(arg)) + return; if (m_caching) { clearCache(); m_currentFilter = arg; -- cgit v0.12