diff options
author | ck <qt-info@nokia.com> | 2010-02-02 13:07:38 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2010-02-02 13:07:38 (GMT) |
commit | 0a2daeed026eca14bafe8463c7d0e629fd196c59 (patch) | |
tree | e5b1437d8cc29b0b3d900445d3d07738c5dd8255 /tools/assistant | |
parent | f063786144477336c462b06642fc3725c060311d (diff) | |
download | Qt-0a2daeed026eca14bafe8463c7d0e629fd196c59.zip Qt-0a2daeed026eca14bafe8463c7d0e629fd196c59.tar.gz Qt-0a2daeed026eca14bafe8463c7d0e629fd196c59.tar.bz2 |
Assistant: Treat "unfiltered" filter in a apecial way.
- Don't put the translated string into the help engine.
- Don't let it be edited by users.
Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
4 files changed, 30 insertions, 29 deletions
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 9785710..ddc056a 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE namespace { + const QString Unfiltered; const QString AppFontKey(QLatin1String("appFont")); const QString AppWritingSystemKey(QLatin1String("appWritingSystem")); const QString BookmarksKey(QLatin1String("Bookmarks")); @@ -67,7 +68,6 @@ namespace { const QString MainWindowGeometryKey(QLatin1String("MainWindowGeometry")); const QString SearchWasAttachedKey(QLatin1String("SearchWasAttached")); const QString StartOptionKey(QLatin1String("StartOption")); - const QString UnfilteredInsertedKey(QLatin1String("UnfilteredFilterInserted")); const QString UseAppFontKey(QLatin1String("useAppFont")); const QString UseBrowserFontKey(QLatin1String("useBrowserFont")); const QString VersionKey(QString(QLatin1String("qtVersion%1$$$%2")). @@ -114,6 +114,8 @@ private: QMap<QString, RecentSignal> m_recentQchUpdates; }; +const QString HelpEngineWrapper::TrUnfiltered = tr("Unfiltered"); + HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0; HelpEngineWrapper &HelpEngineWrapper::instance(const QString &collectionFile) @@ -144,7 +146,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) connect(d, SIGNAL(documentationUpdated(QString)), this, SIGNAL(documentationUpdated(QString))); connect(d->m_helpEngine, SIGNAL(currentFilterChanged(QString)), - this, SIGNAL(currentFilterChanged(QString))); + this, SLOT(handleCurrentFilterChanged(QString))); connect(d->m_helpEngine, SIGNAL(setupFinished()), this, SIGNAL(setupFinished())); } @@ -242,19 +244,25 @@ bool HelpEngineWrapper::removeCustomFilter(const QString &filterName) void HelpEngineWrapper::setCurrentFilter(const QString ¤tFilter) { TRACE_OBJ - d->m_helpEngine->setCurrentFilter(currentFilter); + const QString &filter + = currentFilter == TrUnfiltered ? Unfiltered : currentFilter; + d->m_helpEngine->setCurrentFilter(filter); } const QString HelpEngineWrapper::currentFilter() const { TRACE_OBJ - return d->m_helpEngine->currentFilter(); + const QString &filter = d->m_helpEngine->currentFilter(); + return filter == Unfiltered ? TrUnfiltered : filter; } const QStringList HelpEngineWrapper::customFilters() const { TRACE_OBJ - return d->m_helpEngine->customFilters(); + QStringList filters = d->m_helpEngine->customFilters(); + filters.removeOne(Unfiltered); + filters.prepend(TrUnfiltered); + return filters; } QUrl HelpEngineWrapper::findFile(const QUrl &url) const @@ -293,18 +301,6 @@ QString HelpEngineWrapper::error() const return d->m_helpEngine->error(); } -bool HelpEngineWrapper::unfilteredInserted() const -{ - TRACE_OBJ - return d->m_helpEngine->customValue(UnfilteredInsertedKey).toInt() == 1; -} - -void HelpEngineWrapper::setUnfilteredInserted() -{ - TRACE_OBJ - d->m_helpEngine->setCustomValue(UnfilteredInsertedKey, 1); -} - const QStringList HelpEngineWrapper::qtDocInfo(const QString &component) const { TRACE_OBJ @@ -679,6 +675,13 @@ void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem sys d->m_helpEngine->setCustomValue(BrowserWritingSystemKey, system); } +void HelpEngineWrapper::handleCurrentFilterChanged(const QString &filter) +{ + const QString &filterToReport + = filter == Unfiltered ? TrUnfiltered : filter; + emit currentFilterChanged(filterToReport); +} + TimeoutForwarder::TimeoutForwarder(const QString &fileName) : m_fileName(fileName) @@ -698,6 +701,8 @@ HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile m_qchWatcher(new QFileSystemWatcher(this)) { TRACE_OBJ + if (!m_helpEngine->customFilters().contains(Unfiltered)) + m_helpEngine->addCustomFilter(Unfiltered, QStringList()); initFileSystemWatchers(); } diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h index ea7b762..a30fab8 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -101,10 +101,6 @@ public: const QStringList filterAttributes(const QString &filterName) const; QString error() const; - // Access to a collection's custom values. - bool unfilteredInserted() const; - void setUnfilteredInserted(); - const QStringList qtDocInfo(const QString &component) const; void setQtDocInfo(const QString &component, const QStringList &doc); @@ -185,6 +181,8 @@ public: QFontDatabase::WritingSystem browserWritingSystem() const; void setBrowserWritingSystem(QFontDatabase::WritingSystem system); + static const QString TrUnfiltered; + signals: // For asynchronous doc updates triggered by external actions. @@ -195,6 +193,9 @@ signals: void currentFilterChanged(const QString ¤tFilter); void setupFinished(); +private slots: + void handleCurrentFilterChanged(const QString &filter); + private: HelpEngineWrapper(const QString &collectionFile); ~HelpEngineWrapper(); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index ac33fc5..cfd0fee 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -315,13 +315,6 @@ bool MainWindow::initHelpDB() needsSetup = true; } - if (!helpEngineWrapper.unfilteredInserted()) { - helpEngineWrapper.addCustomFilter(tr("Unfiltered"), QStringList()); - helpEngineWrapper.setUnfilteredInserted(); - helpEngineWrapper.setCurrentFilter(tr("Unfiltered")); - needsSetup = true; - } - if (needsSetup) helpEngineWrapper.setupData(); return true; diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index fb41590..f0ef054 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -160,8 +160,10 @@ void PreferencesDialog::updateFilterPage() m_ui.attributeWidget->clear(); m_filterMapBackup.clear(); - const QStringList filters = helpEngine.customFilters(); + const QStringList &filters = helpEngine.customFilters(); foreach (const QString &filter, filters) { + if (filter == HelpEngineWrapper::TrUnfiltered) + continue; QStringList atts = helpEngine.filterAttributes(filter); m_filterMapBackup.insert(filter, atts); if (!m_filterMap.contains(filter)) |