diff options
author | ck <qt-info@nokia.com> | 2009-12-03 13:35:51 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2009-12-03 13:35:51 (GMT) |
commit | d6c21efa5b67fc55f9edfa4aabeb48adf68ee131 (patch) | |
tree | 07355aaeeef1587193885154b5faf50fcd453aff /tools | |
parent | b881d8fb99972f1bd04ab4c84843cc8d43ddbeed (diff) | |
download | Qt-d6c21efa5b67fc55f9edfa4aabeb48adf68ee131.zip Qt-d6c21efa5b67fc55f9edfa4aabeb48adf68ee131.tar.gz Qt-d6c21efa5b67fc55f9edfa4aabeb48adf68ee131.tar.bz2 |
Assistant: Encapsulate accesses to help engine.
Reviewed-by: kh1
Diffstat (limited to 'tools')
26 files changed, 1224 insertions, 772 deletions
diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index 81677c3..ca2e52e 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -31,7 +31,9 @@ HEADERS += helpviewer.h \ aboutdialog.h \ qtdocinstaller.h \ xbelsupport.h \ - ../shared/collectionconfiguration.h + ../shared/collectionconfiguration.h \ + helpenginewrapper.h \ + tracer.h win32:HEADERS += remotecontrol_win.h SOURCES += helpviewer.cpp \ main.cpp \ @@ -50,7 +52,8 @@ SOURCES += helpviewer.cpp \ aboutdialog.cpp \ qtdocinstaller.cpp \ xbelsupport.cpp \ - ../shared/collectionconfiguration.cpp + ../shared/collectionconfiguration.cpp \ + helpenginewrapper.cpp FORMS += topicchooser.ui \ preferencesdialog.ui \ filternamedialog.ui \ diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index 3c473d7..f8cad4d 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.cpp +++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp @@ -41,7 +41,7 @@ #include "bookmarkmanager.h" #include "centralwidget.h" -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include <QtGui/QMenu> #include <QtGui/QIcon> @@ -57,7 +57,6 @@ #include <QtGui/QToolButton> #include <QtGui/QPushButton> #include <QtGui/QApplication> -#include <QtHelp/QHelpEngineCore> #include <QtGui/QDialogButtonBox> #include <QtGui/QSortFilterProxyModel> @@ -624,11 +623,10 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const // BookmarkManager -BookmarkManager::BookmarkManager(QHelpEngineCore *_helpEngine) +BookmarkManager::BookmarkManager() : treeModel(new BookmarkModel(0, 1, this)) , listModel(new BookmarkModel(0, 1, this)) , renameItem(0) - , helpEngine(_helpEngine) { folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon); bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png")); @@ -663,7 +661,7 @@ void BookmarkManager::saveBookmarks() QDataStream stream(&bookmarks, QIODevice::WriteOnly); readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0); - CollectionConfiguration::setBookmarks(*helpEngine, bookmarks); + HelpEngineWrapper::instance().setBookmarks(bookmarks); } QStringList BookmarkManager::bookmarkFolders() const @@ -815,7 +813,7 @@ void BookmarkManager::setupBookmarkModels() QList<int> lastDepths; QList<QStandardItem*> parents; - QByteArray ba = CollectionConfiguration::bookmarks(*helpEngine); + QByteArray ba = HelpEngineWrapper::instance().bookmarks(); QDataStream stream(ba); while (!stream.atEnd()) { stream >> depth >> name >> type >> expanded; diff --git a/tools/assistant/tools/assistant/bookmarkmanager.h b/tools/assistant/tools/assistant/bookmarkmanager.h index c6be134..13d4b5c 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.h +++ b/tools/assistant/tools/assistant/bookmarkmanager.h @@ -168,7 +168,7 @@ class BookmarkManager : public QObject Q_OBJECT public: - BookmarkManager(QHelpEngineCore* helpEngine); + BookmarkManager(); ~BookmarkManager(); BookmarkModel* treeBookmarkModel(); @@ -208,7 +208,6 @@ private: BookmarkModel *treeModel; BookmarkModel *listModel; QStandardItem *renameItem; - QHelpEngineCore *helpEngine; QMap<QAction*, QModelIndex> map; }; diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index d1cccc1..df28d63 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "centralwidget.h" +#include "helpenginewrapper.h" #include "helpviewer.h" #include "searchwidget.h" #include "mainwindow.h" @@ -68,7 +69,6 @@ #include <QtGui/QPrintPreviewDialog> #include <QtGui/QPageSetupDialog> -#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpSearchEngine> QT_BEGIN_NAMESPACE @@ -206,14 +206,12 @@ QToolButton* FindWidget::setupToolButton(const QString &text, const QString &ico // -- -CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) +CentralWidget::CentralWidget(MainWindow *parent) : QWidget(parent) , lastTabPage(0) - , collectionFile(engine->collectionFile()) , findBar(0) , tabWidget(0) , findWidget(0) - , helpEngine(engine) , printer(0) , usesDefaultCollection(parent->usesDefaultCollection()) , m_searchWidget(0) @@ -293,10 +291,6 @@ CentralWidget::~CentralWidget() delete printer; #endif - QHelpEngineCore engine(collectionFile, 0); - if (!engine.setupData()) - return; - QStringList zoomFactors; QStringList currentPages; bool searchAttached = m_searchWidget->isAttached(); @@ -310,10 +304,11 @@ CentralWidget::~CentralWidget() } } - CollectionConfiguration::setLastTabPage(engine, lastTabPage); - CollectionConfiguration::setLastShownPages(engine, currentPages); - CollectionConfiguration::setSearchWasAttached(engine, searchAttached); - CollectionConfiguration::setLastZoomFactors(engine, zoomFactors); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + helpEngine.setLastTabPage(lastTabPage); + helpEngine.setLastShownPages(currentPages); + helpEngine.setSearchWasAttached(searchAttached); + helpEngine.setLastZoomFactors(zoomFactors); } CentralWidget *CentralWidget::instance() @@ -405,7 +400,7 @@ void CentralWidget::setSource(const QUrl &url) qobject_cast<HelpViewer*>(tabWidget->widget(lastTabPage)); if (!viewer && !lastViewer) { - viewer = new HelpViewer(helpEngine, this); + viewer = new HelpViewer(this); viewer->installEventFilter(this); lastTabPage = tabWidget->addTab(viewer, QString()); tabWidget->setCurrentIndex(lastTabPage); @@ -423,16 +418,13 @@ void CentralWidget::setSource(const QUrl &url) void CentralWidget::setupWidget() { - int option = CollectionConfiguration::startOption(*helpEngine); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + int option = helpEngine.startOption(); if (option != ShowLastPages) { QString homePage; - if (option == ShowHomePage) { - // TODO: Can this fall-back logic go into the wrapper class? - homePage = CollectionConfiguration::homePage(*helpEngine); - if (homePage.isEmpty()) - homePage = CollectionConfiguration::defaultHomePage(*helpEngine); - } - if (option == ShowBlankPage) + if (option == ShowHomePage) + homePage = helpEngine.homePage(); + else if (option == ShowBlankPage) homePage = QLatin1String("about:blank"); setSource(homePage); } else { @@ -442,8 +434,8 @@ void CentralWidget::setupWidget() void CentralWidget::setLastShownPages() { - const QStringList lastShownPageList = - CollectionConfiguration::lastShownPages(*helpEngine); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + const QStringList lastShownPageList = helpEngine.lastShownPages(); const int pageCount = lastShownPageList.count(); if (pageCount == 0) { if (usesDefaultCollection) @@ -453,8 +445,7 @@ void CentralWidget::setLastShownPages() return; } - QStringList zoomFactors = - CollectionConfiguration::lastZoomFactors(*helpEngine); + QStringList zoomFactors = helpEngine.lastZoomFactors(); while (zoomFactors.count() < pageCount) zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); @@ -463,12 +454,10 @@ void CentralWidget::setLastShownPages() for (; it != lastShownPageList.constEnd(); ++it, ++zIt) setSourceInNewTab((*it), (*zIt).toFloat()); - int tab = CollectionConfiguration::lastTabPage(*helpEngine); + int tab = helpEngine.lastTabPage(); const bool searchIsAttached = m_searchWidget->isAttached(); - const bool searchWasAttached = - CollectionConfiguration::searchWasAttached(*helpEngine); - + const bool searchWasAttached = helpEngine.searchWasAttached(); if (searchWasAttached && !searchIsAttached) --tab; else if (!searchWasAttached && searchIsAttached) @@ -639,7 +628,7 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) return; #endif - viewer = new HelpViewer(helpEngine, this); + viewer = new HelpViewer(this); viewer->installEventFilter(this); viewer->setSource(url); viewer->setFocus(Qt::OtherFocusReason); @@ -663,7 +652,7 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) HelpViewer *CentralWidget::newEmptyTab() { - HelpViewer *viewer = new HelpViewer(helpEngine, this); + HelpViewer *viewer = new HelpViewer(this); viewer->installEventFilter(this); viewer->setFocus(Qt::OtherFocusReason); #if defined(QT_NO_WEBKIT) @@ -1005,7 +994,7 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) void CentralWidget::activateSearchWidget(bool updateLastTabPage) { if (!m_searchWidget) - createSearchWidget(helpEngine->searchEngine()); + createSearchWidget(HelpEngineWrapper::instance().searchEngine()); if (!m_searchWidget->isAttached()) { tabWidget->insertTab(0, m_searchWidget, tr("Search")); @@ -1072,7 +1061,8 @@ CentralWidget::highlightSearchTerms() if (!viewer) return; - QHelpSearchEngine *searchEngine = helpEngine->searchEngine(); + QHelpSearchEngine *searchEngine = + HelpEngineWrapper::instance().searchEngine(); QList<QHelpSearchQuery> queryList = searchEngine->query(); QStringList terms; @@ -1154,8 +1144,8 @@ QMap<int, QString> CentralWidget::currentSourceFileList() const void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) { - const QLatin1String key("useBrowserFont"); - if (!CollectionConfiguration::usesBrowserFont(*helpEngine)) { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (!helpEngine.usesBrowserFont()) { *font = qApp->font(); // case for QTextBrowser and SearchWidget #if !defined(QT_NO_WEBKIT) QWebView *view = qobject_cast<QWebView*> (viewer); @@ -1166,7 +1156,7 @@ void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) } #endif } else { - *font = CollectionConfiguration::browserFont(*helpEngine); + *font = helpEngine.browserFont(); } } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index c348abf..d90968e 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -110,7 +110,7 @@ class CentralWidget : public QWidget Q_OBJECT public: - CentralWidget(QHelpEngine *engine, MainWindow *parent); + CentralWidget(MainWindow *parent); ~CentralWidget(); void setupWidget(); @@ -201,13 +201,11 @@ private: private: int lastTabPage; - QString collectionFile; QList<QAction*> globalActionList; QWidget *findBar; QTabWidget *tabWidget; FindWidget *findWidget; - QHelpEngine *helpEngine; QPrinter *printer; bool usesDefaultCollection; diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 1e3953a..17b19ba 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -41,22 +41,20 @@ #include "contentwindow.h" #include "centralwidget.h" +#include "helpenginewrapper.h" #include <QtGui/QLayout> #include <QtGui/QFocusEvent> #include <QtGui/QMenu> -#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpContentWidget> QT_BEGIN_NAMESPACE -ContentWindow::ContentWindow(QHelpEngine *helpEngine) - : m_helpEngine(helpEngine) - , m_contentWidget(0) +ContentWindow::ContentWindow() + : m_contentWidget(HelpEngineWrapper::instance().contentWidget()) , m_expandDepth(-2) { - m_contentWidget = m_helpEngine->contentWidget(); m_contentWidget->viewport()->installEventFilter(this); m_contentWidget->setContextMenuPolicy(Qt::CustomContextMenu); diff --git a/tools/assistant/tools/assistant/contentwindow.h b/tools/assistant/tools/assistant/contentwindow.h index e5512f5..6395932 100644 --- a/tools/assistant/tools/assistant/contentwindow.h +++ b/tools/assistant/tools/assistant/contentwindow.h @@ -57,7 +57,7 @@ class ContentWindow : public QWidget Q_OBJECT public: - ContentWindow(QHelpEngine *helpEngine); + ContentWindow(); ~ContentWindow(); bool syncToContent(const QUrl &url); @@ -78,8 +78,7 @@ private: bool eventFilter(QObject *o, QEvent *e); bool isPdfFile(QHelpContentItem *item) const; - QHelpEngine *m_helpEngine; - QHelpContentWidget *m_contentWidget; + QHelpContentWidget * const m_contentWidget; int m_expandDepth; }; diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp new file mode 100644 index 0000000..d399d1e --- /dev/null +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -0,0 +1,591 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "helpenginewrapper.h" +#include "../shared/collectionconfiguration.h" + +#include <QtCore/QFileInfo> +#include <QtCore/QFileSystemWatcher> +#include <QtHelp/QHelpContentModel> +#include <QtHelp/QHelpEngine> +#include <QtHelp/QHelpIndexModel> +#include <QtHelp/QHelpSearchEngine> + +QT_BEGIN_NAMESPACE + +namespace { + const QString AppFontKey(QLatin1String("appFont")); + const QString AppWritingSystemKey(QLatin1String("appWritingSystem")); + const QString BookmarksKey(QLatin1String("Bookmarks")); + const QString BrowserFontKey(QLatin1String("browserFont")); + const QString BrowserWritingSystemKey(QLatin1String("browserWritingSystem")); + const QString HomePageKey(QLatin1String("homepage")); + const QString MainWindowKey(QLatin1String("MainWindow")); + 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")). + arg(QLatin1String(QT_VERSION_STR))); +} // anonymous namespace + +HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0; + +HelpEngineWrapper &HelpEngineWrapper::instance(const QString &collectionFile) +{ + /* + * Note that this Singleton cannot be static, because it has to be + * deleted before the QApplication. + */ + if (helpEngineWrapper == 0) + helpEngineWrapper = new HelpEngineWrapper(collectionFile); + return *helpEngineWrapper; +} + +void HelpEngineWrapper::removeInstance() +{ + delete helpEngineWrapper; + helpEngineWrapper = 0; +} + +HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) + : m_helpEngine(new QHelpEngine(collectionFile, this)), + m_qchWatcher(new QFileSystemWatcher(this)) +{ + connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), + this, SIGNAL(currentFilterChanged(QString))); + connect(m_helpEngine, SIGNAL(setupFinished()), + this, SIGNAL(setupFinished())); +} + +void HelpEngineWrapper::initFileSystemWatchers() +{ + foreach(const QString &ns, m_helpEngine->registeredDocumentations()) { + const QString &docFile = m_helpEngine->documentationFileName(ns); + m_qchWatcher->addPath(docFile); + connect(m_qchWatcher, SIGNAL(fileChanged(QString)), + this, SLOT(qchFileChanged(QString))); + } + assertDocFilesWatched(); +} + +QHelpSearchEngine *HelpEngineWrapper::searchEngine() const +{ + return m_helpEngine->searchEngine(); +} + +QHelpContentModel *HelpEngineWrapper::contentModel() const +{ + return m_helpEngine->contentModel(); +} + +QHelpIndexModel *HelpEngineWrapper::indexModel() const +{ + return m_helpEngine->indexModel(); +} + +QHelpContentWidget *HelpEngineWrapper::contentWidget() +{ + return m_helpEngine->contentWidget(); +} + +QHelpIndexWidget *HelpEngineWrapper::indexWidget() +{ + return m_helpEngine->indexWidget(); +} + +const QStringList HelpEngineWrapper::registeredDocumentations() const +{ + return m_helpEngine->registeredDocumentations(); +} + +const QString HelpEngineWrapper::collectionFile() const +{ + return m_helpEngine->collectionFile(); +} + +bool HelpEngineWrapper::registerDocumentation(const QString &docFile) +{ + if (!m_helpEngine->registerDocumentation(docFile)) + return false; + m_qchWatcher->addPath(docFile); + assertDocFilesWatched(); + return true; +} + +bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) +{ + const QString &internalFile = + m_helpEngine->documentationFileName(namespaceName); + if (!m_helpEngine->unregisterDocumentation(namespaceName)) + return false; + m_qchWatcher->removePath(internalFile); + assertDocFilesWatched(); + return true; +} + +bool HelpEngineWrapper::setupData() +{ + return m_helpEngine->setupData(); +} + +bool HelpEngineWrapper::addCustomFilter(const QString &filterName, + const QStringList &attributes) +{ + return m_helpEngine->addCustomFilter(filterName, attributes); +} + +bool HelpEngineWrapper::removeCustomFilter(const QString &filterName) +{ + return m_helpEngine->removeCustomFilter(filterName); +} + +void HelpEngineWrapper::setCurrentFilter(const QString ¤tFilter) +{ + m_helpEngine->setCurrentFilter(currentFilter); +} + +const QString HelpEngineWrapper::currentFilter() const +{ + return m_helpEngine->currentFilter(); +} + +const QStringList HelpEngineWrapper::customFilters() const +{ + return m_helpEngine->customFilters(); +} + +QUrl HelpEngineWrapper::findFile(const QUrl &url) const +{ + return m_helpEngine->findFile(url); +} + +QByteArray HelpEngineWrapper::fileData(const QUrl &url) const +{ + return m_helpEngine->fileData(url); +} + +QMap<QString, QUrl> HelpEngineWrapper::linksForIdentifier(const QString &id) const +{ + return m_helpEngine->linksForIdentifier(id); +} + +const QStringList HelpEngineWrapper::filterAttributes() const +{ + return m_helpEngine->filterAttributes(); +} + +const QStringList HelpEngineWrapper::filterAttributes(const QString &filterName) const +{ + return m_helpEngine->filterAttributes(filterName); +} + +QString HelpEngineWrapper::error() const +{ + return m_helpEngine->error(); +} + +bool HelpEngineWrapper::unfilteredInserted() const +{ + return m_helpEngine->customValue(UnfilteredInsertedKey).toInt() == 1; +} + +void HelpEngineWrapper::setUnfilteredInserted() +{ + m_helpEngine->setCustomValue(UnfilteredInsertedKey, 1); +} + +const QStringList HelpEngineWrapper::qtDocInfo(const QString &component) const +{ + return m_helpEngine->customValue(VersionKey.arg(component)).toString(). + split(CollectionConfiguration::ListSeparator); +} + +void HelpEngineWrapper::setQtDocInfo(const QString &component, + const QStringList &doc) +{ + m_helpEngine->setCustomValue(VersionKey.arg(component), + doc.join(CollectionConfiguration::ListSeparator)); +} + +const QStringList HelpEngineWrapper::lastShownPages() const +{ + return CollectionConfiguration::lastShownPages(*m_helpEngine); +} + +void HelpEngineWrapper::setLastShownPages(const QStringList &lastShownPages) +{ + CollectionConfiguration::setLastShownPages(*m_helpEngine, lastShownPages); +} + +const QStringList HelpEngineWrapper::lastZoomFactors() const +{ + return CollectionConfiguration::lastZoomFactors(*m_helpEngine); +} + +void HelpEngineWrapper::setLastZoomFactors(const QStringList &lastZoomFactors) +{ + CollectionConfiguration::setLastZoomFactors(*m_helpEngine, lastZoomFactors); +} + +const QString HelpEngineWrapper::cacheDir() const +{ + return CollectionConfiguration::cacheDir(*m_helpEngine); +} + +bool HelpEngineWrapper::cacheDirIsRelativeToCollection() const +{ + return CollectionConfiguration::cacheDirIsRelativeToCollection(*m_helpEngine); +} + +void HelpEngineWrapper::setCacheDir(const QString &cacheDir, + bool relativeToCollection) +{ + CollectionConfiguration::setCacheDir(*m_helpEngine, cacheDir, + relativeToCollection); +} + +bool HelpEngineWrapper::filterFunctionalityEnabled() const +{ + return CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine); +} + +void HelpEngineWrapper::setFilterFunctionalityEnabled(bool enabled) +{ + CollectionConfiguration::setFilterFunctionalityEnabled(*m_helpEngine, + enabled); +} + +bool HelpEngineWrapper::filterToolbarVisible() const +{ + return CollectionConfiguration::filterToolbarVisible(*m_helpEngine); +} + +void HelpEngineWrapper::setFilterToolbarVisible(bool visible) +{ + CollectionConfiguration::setFilterToolbarVisible(*m_helpEngine, visible); +} + +bool HelpEngineWrapper::addressBarEnabled() const +{ + return CollectionConfiguration::addressBarEnabled(*m_helpEngine); +} + +void HelpEngineWrapper::setAddressBarEnabled(bool enabled) +{ + CollectionConfiguration::setAddressBarEnabled(*m_helpEngine, enabled); +} + +bool HelpEngineWrapper::addressBarVisible() const +{ + return CollectionConfiguration::addressBarVisible(*m_helpEngine); +} + +void HelpEngineWrapper::setAddressBarVisible(bool visible) +{ + CollectionConfiguration::setAddressBarVisible(*m_helpEngine, visible); +} + +bool HelpEngineWrapper::documentationManagerEnabled() const +{ + return CollectionConfiguration::documentationManagerEnabled(*m_helpEngine); +} + +void HelpEngineWrapper::setDocumentationManagerEnabled(bool enabled) +{ + CollectionConfiguration::setDocumentationManagerEnabled(*m_helpEngine, + enabled); +} + +const QByteArray HelpEngineWrapper::aboutMenuTexts() const +{ + return CollectionConfiguration::aboutMenuTexts(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutMenuTexts(const QByteArray &texts) +{ + CollectionConfiguration::setAboutMenuTexts(*m_helpEngine, texts); +} + +const QByteArray HelpEngineWrapper::aboutIcon() const +{ + return CollectionConfiguration::aboutIcon(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutIcon(const QByteArray &icon) +{ + CollectionConfiguration::setAboutIcon(*m_helpEngine, icon); +} + +const QByteArray HelpEngineWrapper::aboutImages() const +{ + return CollectionConfiguration::aboutImages(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutImages(const QByteArray &images) +{ + CollectionConfiguration::setAboutImages(*m_helpEngine, images); +} + +const QByteArray HelpEngineWrapper::aboutTexts() const +{ + return CollectionConfiguration::aboutTexts(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutTexts(const QByteArray &texts) +{ + CollectionConfiguration::setAboutTexts(*m_helpEngine, texts); +} + +const QString HelpEngineWrapper::windowTitle() const +{ + return CollectionConfiguration::windowTitle(*m_helpEngine); +} + +void HelpEngineWrapper::setWindowTitle(const QString &windowTitle) +{ + CollectionConfiguration::setWindowTitle(*m_helpEngine, windowTitle); +} + +const QByteArray HelpEngineWrapper::applicationIcon() const +{ + return CollectionConfiguration::applicationIcon(*m_helpEngine); +} + +void HelpEngineWrapper::setApplicationIcon(const QByteArray &icon) +{ + CollectionConfiguration::setApplicationIcon(*m_helpEngine, icon); +} + +const QByteArray HelpEngineWrapper::mainWindow() const +{ + return m_helpEngine->customValue(MainWindowKey).toByteArray(); +} + +void HelpEngineWrapper::setMainWindow(const QByteArray &mainWindow) +{ + m_helpEngine->setCustomValue(MainWindowKey, mainWindow); +} + +const QByteArray HelpEngineWrapper::mainWindowGeometry() const +{ + return m_helpEngine->customValue(MainWindowGeometryKey).toByteArray(); +} + +void HelpEngineWrapper::setMainWindowGeometry(const QByteArray &geometry) +{ + m_helpEngine->setCustomValue(MainWindowGeometryKey, geometry); +} + +const QByteArray HelpEngineWrapper::bookmarks() const +{ + return m_helpEngine->customValue(BookmarksKey).toByteArray(); +} + +void HelpEngineWrapper::setBookmarks(const QByteArray &bookmarks) +{ + m_helpEngine->setCustomValue(BookmarksKey, bookmarks); +} + +int HelpEngineWrapper::lastTabPage() const +{ + return CollectionConfiguration::lastTabPage(*m_helpEngine); +} + +void HelpEngineWrapper::setLastTabPage(int lastPage) +{ + CollectionConfiguration::setLastTabPage(*m_helpEngine, lastPage); +} + +bool HelpEngineWrapper::searchWasAttached() const +{ + return m_helpEngine->customValue(SearchWasAttachedKey).toBool(); +} + +void HelpEngineWrapper::setSearchWasAttached(bool attached) +{ + m_helpEngine->setCustomValue(SearchWasAttachedKey, attached); +} + +int HelpEngineWrapper::startOption() const +{ + return m_helpEngine->customValue(StartOptionKey, ShowLastPages).toInt(); +} + +void HelpEngineWrapper::setStartOption(int option) +{ + m_helpEngine->setCustomValue(StartOptionKey, option); +} + +const QString HelpEngineWrapper::homePage() const +{ + const QString &homePage = m_helpEngine->customValue(HomePageKey).toString(); + if (!homePage.isEmpty()) + return homePage; + return defaultHomePage(); +} + +void HelpEngineWrapper::setHomePage(const QString &page) +{ + m_helpEngine->setCustomValue(HomePageKey, page); + +} + +const QString HelpEngineWrapper::defaultHomePage() const +{ + return CollectionConfiguration::defaultHomePage(*m_helpEngine); +} + +void HelpEngineWrapper::setDefaultHomePage(const QString &page) +{ + CollectionConfiguration::setDefaultHomePage(*m_helpEngine, page); +} + +bool HelpEngineWrapper::hasFontSettings() const +{ + return m_helpEngine->customValue(UseAppFontKey).isValid(); +} + +bool HelpEngineWrapper::usesAppFont() const +{ + return m_helpEngine->customValue(UseAppFontKey).toBool(); +} + +void HelpEngineWrapper::setUseAppFont(bool useAppFont) +{ + m_helpEngine->setCustomValue(UseAppFontKey, useAppFont); +} + +bool HelpEngineWrapper::usesBrowserFont() const +{ + return m_helpEngine->customValue(UseBrowserFontKey, false).toBool(); +} + +void HelpEngineWrapper::setUseBrowserFont(bool useBrowserFont) +{ + m_helpEngine->setCustomValue(UseBrowserFontKey, useBrowserFont); +} + +const QFont HelpEngineWrapper::appFont() const +{ + return qVariantValue<QFont>(m_helpEngine->customValue(AppFontKey)); +} + +void HelpEngineWrapper::setAppFont(const QFont &font) +{ + m_helpEngine->setCustomValue(AppFontKey, font); +} + +QFontDatabase::WritingSystem HelpEngineWrapper::appWritingSystem() const +{ + return static_cast<QFontDatabase::WritingSystem>( + m_helpEngine->customValue(AppWritingSystemKey).toInt()); +} + +void HelpEngineWrapper::setAppWritingSystem(QFontDatabase::WritingSystem system) +{ + m_helpEngine->setCustomValue(AppWritingSystemKey, system); +} + +const QFont HelpEngineWrapper::browserFont() const +{ + return qVariantValue<QFont>(m_helpEngine->customValue(BrowserFontKey)); +} + +void HelpEngineWrapper::setBrowserFont(const QFont &font) +{ + m_helpEngine->setCustomValue(BrowserFontKey, font); +} + +QFontDatabase::WritingSystem HelpEngineWrapper::browserWritingSystem() const +{ + return static_cast<QFontDatabase::WritingSystem>( + m_helpEngine->customValue(BrowserWritingSystemKey).toInt()); +} + +void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem system) +{ + m_helpEngine->setCustomValue(BrowserWritingSystemKey, system); +} + + +void HelpEngineWrapper::assertDocFilesWatched() +{ + Q_ASSERT(m_qchWatcher->files().count() + == m_helpEngine->registeredDocumentations().count()); +} + +void HelpEngineWrapper::qchFileChanged(const QString &fileName) +{ + /* + * We don't use QHelpEngineCore::namespaceName(fileName), because the file + * may not exist anymore or contain a different namespace. + */ + QString ns; + foreach (const QString &curNs, m_helpEngine->registeredDocumentations()) { + if (m_helpEngine->documentationFileName(curNs) == fileName) { + ns = curNs; + break; + } + } + + /* + * We can't do an assertion here, because QFileSystemWatcher may send the + * signal more than once. + */ + if (ns.isEmpty()) + return; + + if (m_helpEngine->unregisterDocumentation(ns)) { + if (!QFileInfo(fileName).exists() + || !m_helpEngine->registerDocumentation(fileName)) { + m_qchWatcher->removePath(fileName); + emit documentationRemoved(ns); + } else { + emit documentationUpdated(ns); + } + m_helpEngine->setupData(); + } +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h new file mode 100644 index 0000000..1fc9eb6 --- /dev/null +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef HELPENGINEWRAPPER_H +#define HELPENGINEWRAPPER_H + +#include <QtCore/QMap> +#include <QtCore/QObject> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QUrl> +#include <QtGui/QFont> +#include <QtGui/QFontDatabase> + +QT_BEGIN_NAMESPACE + +class QFileSystemWatcher; +class QHelpContentModel; +class QHelpContentWidget; +class QHelpEngine; +class QHelpEngineCore; +class QHelpIndexModel; +class QHelpIndexWidget; +class QHelpSearchEngine; + +enum { + ShowHomePage = 0, + ShowBlankPage = 1, + ShowLastPages = 2 +}; + +class HelpEngineWrapper : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(HelpEngineWrapper) +public: + static HelpEngineWrapper &instance(const QString &collectionFile = QString()); + static void removeInstance(); + + void initFileSystemWatchers(); + + // Forwarded help engine member functions, possibly enriched. + QHelpSearchEngine *searchEngine() const; + QHelpContentModel *contentModel() const; + QHelpIndexModel *indexModel() const; + QHelpContentWidget *contentWidget(); + QHelpIndexWidget *indexWidget(); + bool setupData(); + const QStringList registeredDocumentations() const; + const QString collectionFile() const; + bool registerDocumentation(const QString &docFile); + bool unregisterDocumentation(const QString &namespaceName); + bool addCustomFilter(const QString &filterName, + const QStringList &attributes); + bool removeCustomFilter(const QString &filterName); + void setCurrentFilter(const QString &filterName); + const QString currentFilter() const; + const QStringList customFilters() const; + QUrl findFile(const QUrl &url) const; + QByteArray fileData(const QUrl &url) const; + QMap<QString, QUrl> linksForIdentifier(const QString &id) const; + const QStringList filterAttributes() const; + 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); + + const QString homePage() const; + void setHomePage(const QString &page); + const QString defaultHomePage() const; + void setDefaultHomePage(const QString &page); + + int lastTabPage() const; + void setLastTabPage(int lastPage); + + // TODO: Don't allow last pages and zoom factors to be set in isolation + // Perhaps also fill up missing elements automatically or assert. + const QStringList lastShownPages() const; + void setLastShownPages(const QStringList &lastShownPages); + const QStringList lastZoomFactors() const; + void setLastZoomFactors(const QStringList &lastZoomFactors); + + const QString cacheDir() const; + bool cacheDirIsRelativeToCollection() const; + void setCacheDir(const QString &cacheDir, bool relativeToCollection); + + bool filterFunctionalityEnabled() const; + void setFilterFunctionalityEnabled(bool enabled); + + bool filterToolbarVisible() const; + void setFilterToolbarVisible(bool visible); + + bool addressBarEnabled() const; + void setAddressBarEnabled(bool enabled); + + bool addressBarVisible() const; + void setAddressBarVisible(bool visible); + + bool documentationManagerEnabled() const; + void setDocumentationManagerEnabled(bool enabled); + + const QByteArray aboutMenuTexts() const; + void setAboutMenuTexts(const QByteArray &texts); + const QByteArray aboutTexts() const; + void setAboutTexts(const QByteArray &texts); + const QByteArray aboutIcon() const; + void setAboutIcon(const QByteArray &icon); + const QByteArray aboutImages() const; + void setAboutImages(const QByteArray &images); + + const QString windowTitle() const; + void setWindowTitle(const QString &windowTitle); + + const QByteArray applicationIcon() const; + void setApplicationIcon(const QByteArray &icon); + + const QByteArray mainWindow() const; + void setMainWindow(const QByteArray &mainWindow); + const QByteArray mainWindowGeometry() const; + void setMainWindowGeometry(const QByteArray &geometry); + + const QByteArray bookmarks() const; + void setBookmarks(const QByteArray &bookmarks); + + int startOption() const; + void setStartOption(int option); + + bool searchWasAttached() const; + void setSearchWasAttached(bool attached); + + bool hasFontSettings() const; + bool usesAppFont() const; + void setUseAppFont(bool useAppFont); + bool usesBrowserFont() const; + void setUseBrowserFont(bool useBrowserFont); + const QFont appFont() const; + void setAppFont(const QFont &font); + QFontDatabase::WritingSystem appWritingSystem() const; + void setAppWritingSystem(QFontDatabase::WritingSystem system); + const QFont browserFont() const; + void setBrowserFont(const QFont &font); + QFontDatabase::WritingSystem browserWritingSystem() const; + void setBrowserWritingSystem(QFontDatabase::WritingSystem system); + +signals: + + // For asynchronous doc updates triggered by external actions. + void documentationRemoved(const QString &namespaceName); + void documentationUpdated(const QString &namespaceName); + + // Forwarded from QHelpEngineCore. + void currentFilterChanged(const QString ¤tFilter); + void setupFinished(); + +private slots: + void qchFileChanged(const QString &fileName); + +private: + HelpEngineWrapper(const QString &collectionFile); + void assertDocFilesWatched(); + + static HelpEngineWrapper *helpEngineWrapper; + QHelpEngine * const m_helpEngine; + QFileSystemWatcher * const m_qchWatcher; +}; + +QT_END_NAMESPACE + +#endif // HELPENGINEWRAPPER_H diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 2756753..5f2c02b 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -41,7 +41,7 @@ #include "helpviewer.h" #include "centralwidget.h" -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include <QtCore/QDir> #include <QtCore/QEvent> @@ -56,8 +56,6 @@ #include <QtGui/QMessageBox> #include <QtGui/QDesktopServices> -#include <QtHelp/QHelpEngine> - #include <QNetworkAccessManager> #include <QNetworkReply> #include <QNetworkRequest> @@ -124,19 +122,15 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen) class HelpNetworkAccessManager : public QNetworkAccessManager { public: - HelpNetworkAccessManager(QHelpEngine *engine, QObject *parent); + HelpNetworkAccessManager(QObject *parent); protected: virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData = 0); - -private: - QHelpEngine *helpEngine; }; -HelpNetworkAccessManager::HelpNetworkAccessManager(QHelpEngine *engine, - QObject *parent) - : QNetworkAccessManager(parent), helpEngine(engine) +HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent) + : QNetworkAccessManager(parent) { } @@ -158,8 +152,9 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, mimeType = QLatin1String("text/html"); } - const QByteArray &data = helpEngine->findFile(url).isValid() - ? helpEngine->fileData(url) + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + const QByteArray &data = helpEngine.findFile(url).isValid() + ? helpEngine.fileData(url) : PageNotFoundMessage.arg(url.toString()).toUtf8(); return new HelpNetworkReply(request, data, mimeType); } @@ -167,7 +162,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, class HelpPage : public QWebPage { public: - HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent); + HelpPage(CentralWidget *central, QObject *parent); protected: virtual QWebPage *createWindow(QWebPage::WebWindowType); @@ -178,7 +173,6 @@ protected: private: CentralWidget *centralWidget; - QHelpEngine *helpEngine; bool closeNewTabIfNeeded; friend class HelpViewer; @@ -186,10 +180,9 @@ private: Qt::KeyboardModifiers m_keyboardModifiers; }; -HelpPage::HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent) +HelpPage::HelpPage(CentralWidget *central, QObject *parent) : QWebPage(parent) , centralWidget(central) - , helpEngine(engine) , closeNewTabIfNeeded(false) , m_pressedButtons(Qt::NoButton) , m_keyboardModifiers(Qt::NoModifier) @@ -248,7 +241,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, QFile tmpFile(QDir::cleanPath(fileName)); if (tmpFile.open(QIODevice::ReadWrite)) { - tmpFile.write(helpEngine->fileData(url)); + tmpFile.write(HelpEngineWrapper::instance().fileData(url)); tmpFile.close(); } QDesktopServices::openUrl(QUrl(tmpFile.fileName())); @@ -275,17 +268,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, return false; } -HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) +HelpViewer::HelpViewer(CentralWidget *parent) : QWebView(parent) - , helpEngine(engine) , parentWidget(parent) , loadFinished(false) + , helpEngine(HelpEngineWrapper::instance()) { setAcceptDrops(false); - setPage(new HelpPage(parent, helpEngine, this)); + setPage(new HelpPage(parent, this)); - page()->setNetworkAccessManager(new HelpNetworkAccessManager(engine, this)); + page()->setNetworkAccessManager(new HelpNetworkAccessManager(this)); QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); action->setText(tr("Open Link in New Tab")); @@ -392,13 +385,13 @@ void HelpViewer::setLoadFinished(bool ok) #else // !defined(QT_NO_WEBKIT) -HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) +HelpViewer::HelpViewer(CentralWidget *parent) : QTextBrowser(parent) , zoomCount(0) , controlPressed(false) , lastAnchor(QString()) - , helpEngine(engine) , parentWidget(parent) + , helpEngine(HelpEngineWrapper::instance()) { document()->setDocumentMargin(8); } @@ -410,7 +403,7 @@ void HelpViewer::setSource(const QUrl &url) if (launchedWithExternalApp(url)) return; - QUrl u = helpEngine->findFile(url); + QUrl u = helpEngine.findFile(url); if (u.isValid()) { QTextBrowser::setSource(u); return; @@ -472,7 +465,7 @@ bool HelpViewer::launchedWithExternalApp(const QUrl &url) QFile tmpFile(QDir::cleanPath(fileName)); if (tmpFile.open(QIODevice::ReadWrite)) { - tmpFile.write(helpEngine->fileData(url)); + tmpFile.write(helpEngine.fileData(url)); tmpFile.close(); } launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName())); @@ -493,7 +486,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name) { QByteArray ba; if (type < 4) { - ba = helpEngine->fileData(name); + ba = helpEngine.fileData(name); if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { QImage image; image.loadFromData(ba, "svg"); @@ -606,10 +599,7 @@ void HelpViewer::wheelEvent(QWheelEvent *e) void HelpViewer::home() { - QString homePage = CollectionConfiguration::homePage(*helpEngine); - if (homePage.isEmpty()) - homePage = CollectionConfiguration::defaultHomePage(*helpEngine); - setSource(homePage); + setSource(helpEngine.homePage()); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 350209b..64742b5 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -53,8 +53,8 @@ QT_BEGIN_NAMESPACE -class QHelpEngine; class CentralWidget; +class HelpEngineWrapper; class QPoint; class QString; @@ -69,7 +69,7 @@ class HelpViewer : public QWebView Q_OBJECT public: - HelpViewer(QHelpEngine *helpEngine, CentralWidget *parent); + HelpViewer(CentralWidget *parent); void setSource(const QUrl &url); inline QUrl source() const @@ -118,9 +118,9 @@ private Q_SLOTS: void setLoadFinished(bool ok); private: - QHelpEngine *helpEngine; CentralWidget* parentWidget; bool loadFinished; + HelpEngineWrapper &helpEngine; }; #else @@ -130,7 +130,7 @@ class HelpViewer : public QTextBrowser Q_OBJECT public: - HelpViewer(QHelpEngine *helpEngine, CentralWidget *parent); + HelpViewer(CentralWidget *parent); void setSource(const QUrl &url); void resetZoom(); @@ -165,8 +165,8 @@ private: int zoomCount; bool controlPressed; QString lastAnchor; - QHelpEngine *helpEngine; CentralWidget* parentWidget; + HelpEngineWrapper &helpEngine; }; #endif diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 6d35649..757a641 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -41,6 +41,7 @@ #include "indexwindow.h" #include "centralwidget.h" +#include "helpenginewrapper.h" #include "topicchooser.h" #include <QtGui/QLayout> @@ -51,22 +52,19 @@ #include <QtGui/QContextMenuEvent> #include <QtGui/QListWidgetItem> -#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpIndexWidget> QT_BEGIN_NAMESPACE -IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent) +IndexWindow::IndexWindow(QWidget *parent) : QWidget(parent) - , m_searchLineEdit(0) - , m_indexWidget(0) - , m_helpEngine(helpEngine) + , m_searchLineEdit(new QLineEdit) + , m_indexWidget(HelpEngineWrapper::instance().indexWidget()) { QVBoxLayout *layout = new QVBoxLayout(this); QLabel *l = new QLabel(tr("&Look for:")); layout->addWidget(l); - m_searchLineEdit = new QLineEdit(); l->setBuddy(m_searchLineEdit); connect(m_searchLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterIndices(QString))); @@ -74,11 +72,11 @@ IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent) layout->setMargin(4); layout->addWidget(m_searchLineEdit); - m_indexWidget = m_helpEngine->indexWidget(); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); m_indexWidget->installEventFilter(this); - connect(m_helpEngine->indexModel(), SIGNAL(indexCreationStarted()), this, + connect(helpEngine.indexModel(), SIGNAL(indexCreationStarted()), this, SLOT(disableSearchLineEdit())); - connect(m_helpEngine->indexModel(), SIGNAL(indexCreated()), this, + connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this, SLOT(enableSearchLineEdit())); connect(m_indexWidget, SIGNAL(linkActivated(QUrl,QString)), this, SIGNAL(linkActivated(QUrl))); diff --git a/tools/assistant/tools/assistant/indexwindow.h b/tools/assistant/tools/assistant/indexwindow.h index 5973e43..6fbb250 100644 --- a/tools/assistant/tools/assistant/indexwindow.h +++ b/tools/assistant/tools/assistant/indexwindow.h @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE class QHelpIndexWidget; -class QHelpEngine; class QModelIndex; class IndexWindow : public QWidget @@ -57,7 +56,7 @@ class IndexWindow : public QWidget Q_OBJECT public: - IndexWindow(QHelpEngine *helpEngine, QWidget *parent = 0); + IndexWindow(QWidget *parent = 0); ~IndexWindow(); void setSearchLineEditText(const QString &text); @@ -84,7 +83,6 @@ private: QLineEdit *m_searchLineEdit; QHelpIndexWidget *m_indexWidget; - QHelpEngine *m_helpEngine; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index ab7168c..4d93a41 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -57,9 +57,12 @@ #include <QtSql/QSqlDatabase> #include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include "mainwindow.h" #include "cmdlineparser.h" +// #define TRACING_REQUESTED + QT_USE_NAMESPACE #if defined(USE_STATIC_SQLITE_PLUGIN) @@ -317,8 +320,17 @@ int main(int argc, char *argv[]) qtHelpTranslator.load(QLatin1String("qt_help_") + locale, resourceDir); a.installTranslator(&qtHelpTranslator); - MainWindow w(&cmd); - w.show(); + /* + * We need to be careful here: The main window has to be deleted before + * the help engine wrapper, which has to be deleted before the + * QApplication. + */ + int retval; + MainWindow *w = new MainWindow(&cmd); + w->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - return a.exec(); + retval = a.exec(); + delete w; + delete &HelpEngineWrapper::instance(); + return retval; } diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2760f1e..226ad51 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -47,18 +47,22 @@ #include "contentwindow.h" #include "preferencesdialog.h" #include "bookmarkmanager.h" +#include "helpenginewrapper.h" #include "remotecontrol.h" #include "cmdlineparser.h" #include "aboutdialog.h" #include "searchwidget.h" #include "qtdocinstaller.h" #include "xbelsupport.h" -#include "../shared/collectionconfiguration.h" + +// #define TRACING_REQUESTED #include <QtCore/QDir> #include <QtCore/QTimer> +#include <QtCore/QDateTime> #include <QtCore/QDebug> #include <QtCore/QFileSystemWatcher> +#include <QtCore/QPair> #include <QtCore/QResource> #include <QtCore/QByteArray> #include <QtCore/QTextStream> @@ -81,7 +85,7 @@ #include <QtGui/QToolButton> #include <QtGui/QFileDialog> -#include <QtHelp/QHelpEngine> +#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpSearchEngine> #include <QtHelp/QHelpContentModel> #include <QtHelp/QHelpIndexModel> @@ -95,29 +99,31 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) , m_cmdLine(cmdLine) , m_progressWidget(0) , m_qtDocInstaller(0) - , m_qchWatcher(new QFileSystemWatcher(this)) , m_connectedInitSignals(false) { + setToolButtonStyle(Qt::ToolButtonFollowStyle); + QString collectionFile; if (usesDefaultCollection()) { MainWindow::collectionFileDirectory(true); - m_helpEngine = new QHelpEngine(MainWindow::defaultHelpCollectionFileName(), - this); + collectionFile = MainWindow::defaultHelpCollectionFileName(); } else { - m_helpEngine = new QHelpEngine(cmdLine->collectionFile(), this); + collectionFile = cmdLine->collectionFile(); } + HelpEngineWrapper &helpEngineWrapper = + HelpEngineWrapper::instance(collectionFile); - m_centralWidget = new CentralWidget(m_helpEngine, this); + m_centralWidget = new CentralWidget(this); setCentralWidget(m_centralWidget); - m_indexWindow = new IndexWindow(m_helpEngine); + m_indexWindow = new IndexWindow(this); QDockWidget *indexDock = new QDockWidget(tr("Index"), this); indexDock->setObjectName(QLatin1String("IndexWindow")); indexDock->setWidget(m_indexWindow); addDockWidget(Qt::LeftDockWidgetArea, indexDock); - m_contentWindow = new ContentWindow(m_helpEngine); + m_contentWindow = new ContentWindow; QDockWidget *contentDock = new QDockWidget(tr("Contents"), this); contentDock->setObjectName(QLatin1String("ContentWindow")); contentDock->setWidget(m_contentWindow); @@ -128,7 +134,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) bookmarkDock->setWidget(setupBookmarkWidget()); addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); - QHelpSearchEngine *searchEngine = m_helpEngine->searchEngine(); + QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); @@ -153,11 +159,9 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) connect(m_bookmarkManager, SIGNAL(bookmarksChanged()), this, SLOT(updateBookmarkMenu())); - const QString windowTitle = - CollectionConfiguration::windowTitle(*m_helpEngine); + const QString windowTitle = helpEngineWrapper.windowTitle(); setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); - QByteArray iconArray = - CollectionConfiguration::applicationIcon(*m_helpEngine); + QByteArray iconArray = helpEngineWrapper.applicationIcon(); if (iconArray.size() > 0) { QPixmap pix; pix.loadFromData(iconArray); @@ -171,11 +175,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) // Show the widget here, otherwise the restore geometry and state won't work // on x11. show(); - QByteArray ba(CollectionConfiguration::mainWindow(*m_helpEngine)); + QByteArray ba(helpEngineWrapper.mainWindow()); if (!ba.isEmpty()) restoreState(ba); - ba = CollectionConfiguration::mainWindowGeometry(*m_helpEngine); + ba = helpEngineWrapper.mainWindowGeometry(); if (!ba.isEmpty()) { restoreGeometry(ba); } else { @@ -185,15 +189,13 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) resize(QSize(800, 600)); } - if (!CollectionConfiguration::hasFontSettings(*m_helpEngine)) { - CollectionConfiguration::setUseAppFont(*m_helpEngine, false); - CollectionConfiguration::setUseBrowserFont(*m_helpEngine, false); - CollectionConfiguration::setAppFont(*m_helpEngine, qApp->font()); - CollectionConfiguration::setAppWritingSystem(*m_helpEngine, - QFontDatabase::Latin); - CollectionConfiguration::setBrowserFont(*m_helpEngine, qApp->font()); - CollectionConfiguration::setBrowserWritingSystem(*m_helpEngine, - QFontDatabase::Latin); + if (!helpEngineWrapper.hasFontSettings()) { + helpEngineWrapper.setUseAppFont(false); + helpEngineWrapper.setUseBrowserFont(false); + helpEngineWrapper.setAppFont(qApp->font()); + helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); + helpEngineWrapper.setBrowserFont(qApp->font()); + helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); } else { updateApplicationFont(); } @@ -202,7 +204,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) QTimer::singleShot(0, this, SLOT(insertLastPages())); if (m_cmdLine->enableRemoteControl()) - (void)new RemoteControl(this, m_helpEngine, m_qchWatcher); + (void)new RemoteControl(this); if (m_cmdLine->contents() == CmdLineParser::Show) showContents(); @@ -233,8 +235,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); - if (m_helpEngine->customFilters().contains(curFilter)) - m_helpEngine->setCurrentFilter(curFilter); + if (helpEngineWrapper.customFilters().contains(curFilter)) + helpEngineWrapper.setCurrentFilter(curFilter); } if (usesDefaultCollection()) @@ -242,12 +244,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) else checkInitState(); - foreach(const QString &ns, m_helpEngine->registeredDocumentations()) { - const QString &docFile = m_helpEngine->documentationFileName(ns); - m_qchWatcher->addPath(docFile); - connect(m_qchWatcher, SIGNAL(fileChanged(QString)), this, - SLOT(qchFileChanged(QString))); - } + helpEngineWrapper.initFileSystemWatchers(); + connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), + this, SLOT(documentationRemoved(QString))); + connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), + this, SLOT(documentationUpdated(QString))); } setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); } @@ -266,21 +267,20 @@ bool MainWindow::usesDefaultCollection() const void MainWindow::closeEvent(QCloseEvent *e) { m_bookmarkManager->saveBookmarks(); - CollectionConfiguration::setMainWindow(*m_helpEngine, saveState()); - CollectionConfiguration::setMainWindowGeometry(*m_helpEngine, - saveGeometry()); - + HelpEngineWrapper::instance().setMainWindow(saveState()); + HelpEngineWrapper::instance().setMainWindowGeometry(saveGeometry()); QMainWindow::closeEvent(e); } bool MainWindow::initHelpDB() { - if (!m_helpEngine->setupData()) + HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance(); + if (!helpEngineWrapper.setupData()) return false; bool assistantInternalDocRegistered = false; QString intern(QLatin1String("com.trolltech.com.assistantinternal-")); - foreach (const QString &ns, m_helpEngine->registeredDocumentations()) { + foreach (const QString &ns, helpEngineWrapper.registeredDocumentations()) { if (ns.startsWith(intern)) { intern = ns; assistantInternalDocRegistered = true; @@ -288,8 +288,7 @@ bool MainWindow::initHelpDB() } } - const QString &collectionFile = m_helpEngine->collectionFile(); - + const QString &collectionFile = helpEngineWrapper.collectionFile(); QFileInfo fi(collectionFile); QString helpFile; QTextStream(&helpFile) << fi.absolutePath() << QDir::separator() @@ -306,62 +305,52 @@ bool MainWindow::initHelpDB() file.close(); } - QHelpEngineCore hc(fi.absoluteFilePath()); - hc.setupData(); - const QString internalFile = hc.documentationFileName(intern); - if (hc.unregisterDocumentation(intern)) - m_qchWatcher->removePath(internalFile); - if (hc.registerDocumentation(helpFile)) - m_qchWatcher->addPath(helpFile); + helpEngineWrapper.unregisterDocumentation(intern); + helpEngineWrapper.registerDocumentation(helpFile); needsSetup = true; } - if (!CollectionConfiguration::unfilteredInserted(*m_helpEngine)) { - { - QHelpEngineCore hc(collectionFile); - hc.setupData(); - hc.addCustomFilter(tr("Unfiltered"), QStringList()); - CollectionConfiguration::setUnfilteredInserted(hc); - } - - m_helpEngine->blockSignals(true); - m_helpEngine->setCurrentFilter(tr("Unfiltered")); - m_helpEngine->blockSignals(false); + if (!helpEngineWrapper.unfilteredInserted()) { + helpEngineWrapper.addCustomFilter(tr("Unfiltered"), QStringList()); + helpEngineWrapper.setUnfilteredInserted(); + helpEngineWrapper.setCurrentFilter(tr("Unfiltered")); needsSetup = true; } - if (needsSetup) { - m_helpEngine->setupData(); - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); - } + if (needsSetup) + helpEngineWrapper.setupData(); return true; } void MainWindow::lookForNewQtDocumentation() { - m_qtDocInstaller = - new QtDocInstaller(m_helpEngine->collectionFile(), m_qchWatcher); - connect(m_qtDocInstaller, SIGNAL(errorMessage(QString)), this, - SLOT(displayInstallationError(QString))); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + QStringList docs; + docs << QLatin1String("assistant") + << QLatin1String("designer") + << QLatin1String("linguist") + << QLatin1String("qmake") + << QLatin1String("qt"); + QList<QtDocInstaller::DocInfo> qtDocInfos; + foreach (const QString &doc, docs) + qtDocInfos.append(QtDocInstaller::DocInfo(doc, helpEngine.qtDocInfo(doc))); + + m_qtDocInstaller = new QtDocInstaller(qtDocInfos); connect(m_qtDocInstaller, SIGNAL(docsInstalled(bool)), this, SLOT(qtDocumentationInstalled(bool))); - - if (CollectionConfiguration::qtDocInfo(*m_helpEngine, QLatin1String("qt")). - count() != 2) + connect(m_qtDocInstaller, SIGNAL(qchFileNotFound(QString)), this, + SLOT(resetQtDocInfo(QString))); + connect(m_qtDocInstaller, SIGNAL(registerDocumentation(QString, QString)), + this, SLOT(registerDocumentation(QString, QString))); + if (helpEngine.qtDocInfo(QLatin1String("qt")).count() != 2) statusBar()->showMessage(tr("Looking for Qt Documentation...")); m_qtDocInstaller->installDocs(); } -void MainWindow::displayInstallationError(const QString &errorMessage) -{ - QMessageBox::warning(this, tr("Qt Assistant"), errorMessage); -} - void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) { if (newDocsInstalled) - m_helpEngine->setupData(); + HelpEngineWrapper::instance().setupData(); statusBar()->clearMessage(); checkInitState(); } @@ -371,19 +360,20 @@ void MainWindow::checkInitState() if (!m_cmdLine->enableRemoteControl()) return; - if (m_helpEngine->contentModel()->isCreatingContents() - || m_helpEngine->indexModel()->isCreatingIndex()) { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (helpEngine.contentModel()->isCreatingContents() + || helpEngine.indexModel()->isCreatingIndex()) { if (!m_connectedInitSignals) { - connect(m_helpEngine->contentModel(), SIGNAL(contentsCreated()), + connect(helpEngine.contentModel(), SIGNAL(contentsCreated()), this, SLOT(checkInitState())); - connect(m_helpEngine->indexModel(), SIGNAL(indexCreated()), this, + connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this, SLOT(checkInitState())); m_connectedInitSignals = true; } } else { if (m_connectedInitSignals) { - disconnect(m_helpEngine->contentModel(), 0, this, 0); - disconnect(m_helpEngine->indexModel(), 0, this, 0); + disconnect(helpEngine.contentModel(), 0, this, 0); + disconnect(helpEngine.indexModel(), 0, this, 0); } emit initDone(); } @@ -663,7 +653,8 @@ QMenu *MainWindow::toolBarMenu() void MainWindow::setupFilterToolbar() { - if (!CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine)) + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (!helpEngine.filterFunctionalityEnabled()) return; m_filterCombo = new QComboBox(this); @@ -676,15 +667,15 @@ void MainWindow::setupFilterToolbar() this)); filterToolBar->addWidget(m_filterCombo); - if (!CollectionConfiguration::filterToolbarVisible(*m_helpEngine)) + if (!helpEngine.filterToolbarVisible()) filterToolBar->hide(); toolBarMenu()->addAction(filterToolBar->toggleViewAction()); - connect(m_helpEngine, SIGNAL(setupFinished()), this, - SLOT(setupFilterCombo())); + connect(&helpEngine, SIGNAL(setupFinished()), this, + SLOT(setupFilterCombo()), Qt::QueuedConnection); connect(m_filterCombo, SIGNAL(activated(QString)), this, SLOT(filterDocumentation(QString))); - connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), this, + connect(&helpEngine, SIGNAL(currentFilterChanged(QString)), this, SLOT(currentFilterChanged(QString))); setupFilterCombo(); @@ -692,7 +683,8 @@ void MainWindow::setupFilterToolbar() void MainWindow::setupAddressToolbar() { - if (!CollectionConfiguration::addressBarEnabled(*m_helpEngine)) + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (!helpEngine.addressBarEnabled()) return; m_addressLineEdit = new QLineEdit(this); @@ -704,7 +696,7 @@ void MainWindow::setupAddressToolbar() this)); addressToolBar->addWidget(m_addressLineEdit); - if (!CollectionConfiguration::addressBarVisible(*m_helpEngine)) + if (!helpEngine.addressBarVisible()) addressToolBar->hide(); toolBarMenu()->addAction(addressToolBar->toggleViewAction()); @@ -719,30 +711,28 @@ void MainWindow::setupAddressToolbar() void MainWindow::updateAboutMenuText() { - if (m_helpEngine) { - QByteArray ba = CollectionConfiguration::aboutMenuTexts(*m_helpEngine); - if (ba.size() > 0) { - QString lang; - QString str; - QString trStr; - QString currentLang = QLocale::system().name(); - int i = currentLang.indexOf(QLatin1Char('_')); - if (i > -1) - currentLang = currentLang.left(i); - QDataStream s(&ba, QIODevice::ReadOnly); - while (!s.atEnd()) { - s >> lang; - s >> str; - if (lang == QLatin1String("default") && trStr.isEmpty()) { - trStr = str; - } else if (lang == currentLang) { - trStr = str; - break; - } + QByteArray ba = HelpEngineWrapper::instance().aboutMenuTexts(); + if (ba.size() > 0) { + QString lang; + QString str; + QString trStr; + QString currentLang = QLocale::system().name(); + int i = currentLang.indexOf(QLatin1Char('_')); + if (i > -1) + currentLang = currentLang.left(i); + QDataStream s(&ba, QIODevice::ReadOnly); + while (!s.atEnd()) { + s >> lang; + s >> str; + if (lang == QLatin1String("default") && trStr.isEmpty()) { + trStr = str; + } else if (lang == currentLang) { + trStr = str; + break; } - if (!trStr.isEmpty()) - m_aboutAction->setText(trStr); } + if (!trStr.isEmpty()) + m_aboutAction->setText(trStr); } } @@ -796,7 +786,7 @@ void MainWindow::showTopicChooser(const QMap<QString, QUrl> &links, void MainWindow::showPreferences() { - PreferencesDialog dia(m_helpEngine, m_qchWatcher, this); + PreferencesDialog dia(this); connect(&dia, SIGNAL(updateApplicationFont()), this, SLOT(updateApplicationFont())); @@ -832,26 +822,25 @@ void MainWindow::addNewBookmark(const QString &title, const QString &url) void MainWindow::showAboutDialog() { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QByteArray contents; - if (m_helpEngine) { - QByteArray ba = CollectionConfiguration::aboutTexts(*m_helpEngine); - if (!ba.isEmpty()) { - QString lang; - QByteArray cba; - QString currentLang = QLocale::system().name(); - int i = currentLang.indexOf(QLatin1Char('_')); - if (i > -1) - currentLang = currentLang.left(i); - QDataStream s(&ba, QIODevice::ReadOnly); - while (!s.atEnd()) { - s >> lang; - s >> cba; - if (lang == QLatin1String("default") && contents.isEmpty()) { - contents = cba; - } else if (lang == currentLang) { - contents = cba; - break; - } + QByteArray ba = helpEngine.aboutTexts(); + if (!ba.isEmpty()) { + QString lang; + QByteArray cba; + QString currentLang = QLocale::system().name(); + int i = currentLang.indexOf(QLatin1Char('_')); + if (i > -1) + currentLang = currentLang.left(i); + QDataStream s(&ba, QIODevice::ReadOnly); + while (!s.atEnd()) { + s >> lang; + s >> cba; + if (lang == QLatin1String("default") && contents.isEmpty()) { + contents = cba; + } else if (lang == currentLang) { + contents = cba; + break; } } } @@ -860,9 +849,8 @@ void MainWindow::showAboutDialog() QByteArray iconArray; if (!contents.isEmpty()) { - iconArray = CollectionConfiguration::aboutIcon(*m_helpEngine); - QByteArray resources = - CollectionConfiguration::aboutImages(*m_helpEngine); + iconArray = helpEngine.aboutIcon(); + QByteArray resources = helpEngine.aboutImages(); QPixmap pix; pix.loadFromData(iconArray); aboutDia.setText(QString::fromUtf8(contents), resources); @@ -990,20 +978,22 @@ void MainWindow::showSearchWidget() void MainWindow::updateApplicationFont() { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QFont font = qApp->font(); - if (CollectionConfiguration::usesAppFont(*m_helpEngine)) - font = CollectionConfiguration::appFont(*m_helpEngine); + if (helpEngine.usesAppFont()) + font = helpEngine.appFont(); qApp->setFont(font, "QWidget"); } void MainWindow::setupFilterCombo() { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QString curFilter = m_filterCombo->currentText(); if (curFilter.isEmpty()) - curFilter = m_helpEngine->currentFilter(); + curFilter = helpEngine.currentFilter(); m_filterCombo->clear(); - m_filterCombo->addItems(m_helpEngine->customFilters()); + m_filterCombo->addItems(helpEngine.customFilters()); int idx = m_filterCombo->findText(curFilter); if (idx < 0) idx = 0; @@ -1012,7 +1002,7 @@ void MainWindow::setupFilterCombo() void MainWindow::filterDocumentation(const QString &customFilter) { - m_helpEngine->setCurrentFilter(customFilter); + HelpEngineWrapper::instance().setCurrentFilter(customFilter); } void MainWindow::expandTOC(int depth) @@ -1055,7 +1045,7 @@ void MainWindow::indexingFinished() QWidget* MainWindow::setupBookmarkWidget() { - m_bookmarkManager = new BookmarkManager(m_helpEngine); + m_bookmarkManager = new BookmarkManager; m_bookmarkWidget = new BookmarkWidget(m_bookmarkManager, this); connect(m_bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark())); return m_bookmarkWidget; @@ -1135,33 +1125,45 @@ void MainWindow::currentFilterChanged(const QString &filter) m_filterCombo->setCurrentIndex(index); } -void MainWindow::qchFileChanged(const QString &fileName) +void MainWindow::documentationRemoved(const QString &namespaceName) { - /* - * We don't use QHelpEngineCore::namespaceName(fileName), because the file - * may not exist anymore or contain a different namespace. - */ - QString ns; - foreach (const QString &curNs, m_helpEngine->registeredDocumentations()) { - if (m_helpEngine->documentationFileName(curNs) == fileName) { - ns = curNs; - break; - } - } + CentralWidget* widget = CentralWidget::instance(); + widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); +} + +void MainWindow::documentationUpdated(const QString &namespaceName) +{ + // TODO: Check whether the documents still exists and if they do, reload. + CentralWidget* widget = CentralWidget::instance(); + widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); +} - /* - * We can't do an assertion here, because QFileSystemWatcher may send the - * signal more than once. - */ +void MainWindow::resetQtDocInfo(const QString &component) +{ + HelpEngineWrapper::instance().setQtDocInfo(component, + QStringList(QDateTime().toString(Qt::ISODate))); +} + +void MainWindow::registerDocumentation(const QString &component, + const QString &absFileName) +{ + QString ns = QHelpEngineCore::namespaceName(absFileName); if (ns.isEmpty()) return; - CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(ns)); - if (m_helpEngine->unregisterDocumentation(ns) && - (!QFileInfo(fileName).exists() - || !m_helpEngine->registerDocumentation(fileName))) - m_qchWatcher->removePath(fileName); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (helpEngine.registeredDocumentations().contains(ns)) + helpEngine.unregisterDocumentation(ns); + if (!helpEngine.registerDocumentation(absFileName)) { + QMessageBox::warning(this, tr("Qt Assistant"), + tr("Could not register file '%1': %2"). + arg(absFileName).arg(helpEngine.error())); + } else { + QStringList docInfo; + docInfo << QFileInfo(absFileName).lastModified().toString(Qt::ISODate) + << absFileName; + helpEngine.setQtDocInfo(component, docInfo); + } } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 6a0ab58..65eadd7 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -117,10 +117,13 @@ private slots: void lookForNewQtDocumentation(); void indexingStarted(); void indexingFinished(); - void displayInstallationError(const QString &errorMessage); void qtDocumentationInstalled(bool newDocsInstalled); + void registerDocumentation(const QString &component, + const QString &absFileName); + void resetQtDocInfo(const QString &component); void checkInitState(); - void qchFileChanged(const QString &fileName); + void documentationRemoved(const QString &namespaceName); + void documentationUpdated(const QString &namespaceName); void updateBookmarkMenu(); void showBookmark(QAction *action); @@ -143,7 +146,6 @@ private: void hideBookmarks(); void hideSearch(); - QHelpEngine *m_helpEngine; CentralWidget *m_centralWidget; IndexWindow *m_indexWindow; ContentWindow *m_contentWindow; @@ -179,7 +181,6 @@ private: QWidget *m_progressWidget; QtDocInstaller *m_qtDocInstaller; - QFileSystemWatcher * const m_qchWatcher; bool m_connectedInitSignals; }; diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index 10d6dd9..2f282b1 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -45,7 +45,7 @@ #include "fontpanel.h" #include "centralwidget.h" #include "aboutdialog.h" -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include <QtCore/QtAlgorithms> #include <QtCore/QFileSystemWatcher> @@ -62,13 +62,11 @@ QT_BEGIN_NAMESPACE -PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, - QFileSystemWatcher *qchWatcher, QWidget *parent) +PreferencesDialog::PreferencesDialog(QWidget *parent) : QDialog(parent) - , m_helpEngine(helpEngine) , m_appFontChanged(false) , m_browserFontChanged(false) - , m_qchWatcher(qchWatcher) + , helpEngine(HelpEngineWrapper::instance()) { m_ui.setupUi(this); @@ -77,10 +75,8 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, connect(m_ui.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); - m_hideFiltersTab = - !CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine); - m_hideDocsTab = - !CollectionConfiguration::documentationManagerEnabled(*m_helpEngine); + m_hideFiltersTab = !helpEngine.filterFunctionalityEnabled(); + m_hideDocsTab = !helpEngine.documentationManagerEnabled(); if (!m_hideFiltersTab) { m_ui.attributeWidget->header()->hide(); @@ -109,7 +105,7 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, connect(m_ui.docRemoveButton, SIGNAL(clicked()), this, SLOT(removeDocumentation())); - m_docsBackup = m_helpEngine->registeredDocumentations(); + m_docsBackup = helpEngine.registeredDocumentations(); m_ui.registeredDocsListWidget->addItems(m_docsBackup); } else { m_ui.tabWidget->removeTab(m_ui.tabWidget->indexOf(m_ui.docsTab)); @@ -122,21 +118,15 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, PreferencesDialog::~PreferencesDialog() { if (m_appFontChanged) { - CollectionConfiguration::setAppFont(*m_helpEngine, - m_appFontPanel->selectedFont()); - CollectionConfiguration::setUseAppFont(*m_helpEngine, - m_appFontPanel->isChecked()); - CollectionConfiguration::setAppWritingSystem(*m_helpEngine, - m_appFontPanel->writingSystem()); + helpEngine.setAppFont(m_appFontPanel->selectedFont()); + helpEngine.setUseAppFont(m_appFontPanel->isChecked()); + helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem()); } if (m_browserFontChanged) { - CollectionConfiguration::setBrowserFont(*m_helpEngine, - m_browserFontPanel->selectedFont()); - CollectionConfiguration::setUseBrowserFont(*m_helpEngine, - m_browserFontPanel->isChecked()); - CollectionConfiguration::setBrowserWritingSystem(*m_helpEngine, - m_browserFontPanel->writingSystem()); + helpEngine.setBrowserFont(m_browserFontPanel->selectedFont()); + helpEngine.setUseBrowserFont(m_browserFontPanel->isChecked()); + helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem()); } if (m_appFontChanged || m_browserFontChanged) { @@ -147,10 +137,10 @@ PreferencesDialog::~PreferencesDialog() QString homePage = m_ui.homePageLineEdit->text(); if (homePage.isEmpty()) homePage = QLatin1String("help"); - CollectionConfiguration::setHomePage(*m_helpEngine, homePage); + helpEngine.setHomePage(homePage); int option = m_ui.helpStartComboBox->currentIndex(); - CollectionConfiguration::setStartOption(*m_helpEngine, option); + helpEngine.setStartOption(option); } void PreferencesDialog::showDialog() @@ -161,18 +151,13 @@ void PreferencesDialog::showDialog() void PreferencesDialog::updateFilterPage() { - if (!m_helpEngine) - return; - m_ui.filterWidget->clear(); m_ui.attributeWidget->clear(); - QHelpEngineCore help(m_helpEngine->collectionFile(), 0); - help.setupData(); m_filterMapBackup.clear(); - const QStringList filters = help.customFilters(); + const QStringList filters = helpEngine.customFilters(); foreach (const QString &filter, filters) { - QStringList atts = help.filterAttributes(filter); + QStringList atts = helpEngine.filterAttributes(filter); m_filterMapBackup.insert(filter, atts); if (!m_filterMap.contains(filter)) m_filterMap.insert(filter, atts); @@ -180,10 +165,10 @@ void PreferencesDialog::updateFilterPage() m_ui.filterWidget->addItems(m_filterMap.keys()); - foreach (const QString &a, help.filterAttributes()) + foreach (const QString &a, helpEngine.filterAttributes()) new QTreeWidgetItem(m_ui.attributeWidget, QStringList() << a); - if (m_filterMap.keys().count()) + if (!m_filterMap.keys().isEmpty()) m_ui.filterWidget->setCurrentRow(0); } @@ -273,14 +258,11 @@ void PreferencesDialog::addDocumentationLocal() continue; } - if (m_helpEngine->registerDocumentation(fileName)) { - m_qchWatcher->addPath(fileName); - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); + if (helpEngine.registerDocumentation(fileName)) { + m_ui.registeredDocsListWidget->addItem(nameSpace); + m_regDocs.append(nameSpace); + m_unregDocs.removeAll(nameSpace); } - m_ui.registeredDocsListWidget->addItem(nameSpace); - m_regDocs.append(nameSpace); - m_unregDocs.removeAll(nameSpace); } if (!invalidFiles.isEmpty() || !alreadyRegistered.isEmpty()) { @@ -372,26 +354,21 @@ void PreferencesDialog::applyChanges() if (filtersWereChanged) { foreach (const QString &filter, m_removedFilters) - m_helpEngine->removeCustomFilter(filter); + helpEngine.removeCustomFilter(filter); QMapIterator<QString, QStringList> it(m_filterMap); while (it.hasNext()) { it.next(); - m_helpEngine->addCustomFilter(it.key(), it.value()); + helpEngine.addCustomFilter(it.key(), it.value()); } } CentralWidget::instance()->closeTabs(m_TabsToClose); - foreach (const QString &doc, m_unregDocs) { - const QString docFile = m_helpEngine->documentationFileName(doc); - if (m_helpEngine->unregisterDocumentation(doc)) - m_qchWatcher->removePath(docFile); - } - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); + foreach (const QString &doc, m_unregDocs) + helpEngine.unregisterDocumentation(doc); - if (filtersWereChanged || m_regDocs.count() || m_unregDocs.count()) - m_helpEngine->setupData(); + if (filtersWereChanged || !m_regDocs.isEmpty() || !m_unregDocs.isEmpty()) + helpEngine.setupData(); accept(); } @@ -411,26 +388,23 @@ void PreferencesDialog::updateFontSettingsPage() const QString customSettings(tr("Use custom settings")); m_appFontPanel->setTitle(customSettings); - QFont font = CollectionConfiguration::appFont(*m_helpEngine); + QFont font = helpEngine.appFont(); m_appFontPanel->setSelectedFont(font); - QFontDatabase::WritingSystem system = - CollectionConfiguration::appWritingSystem(*m_helpEngine); + QFontDatabase::WritingSystem system = helpEngine.appWritingSystem(); m_appFontPanel->setWritingSystem(system); - m_appFontPanel->setChecked(CollectionConfiguration:: - usesAppFont(*m_helpEngine)); + m_appFontPanel->setChecked(helpEngine.usesAppFont()); m_browserFontPanel->setTitle(customSettings); - font = CollectionConfiguration::browserFont(*m_helpEngine); + font = helpEngine.browserFont(); m_browserFontPanel->setSelectedFont(font); - system = CollectionConfiguration::browserWritingSystem(*m_helpEngine); + system = helpEngine.browserWritingSystem(); m_browserFontPanel->setWritingSystem(system); - m_browserFontPanel->setChecked(CollectionConfiguration:: - usesBrowserFont(*m_helpEngine)); + m_browserFontPanel->setChecked(helpEngine.usesBrowserFont()); connect(m_appFontPanel, SIGNAL(toggled(bool)), this, SLOT(appFontSettingToggled(bool))); @@ -476,12 +450,9 @@ void PreferencesDialog::browserFontSettingChanged(int index) void PreferencesDialog::updateOptionsPage() { - QString homePage = CollectionConfiguration::homePage(*m_helpEngine); - if (homePage.isEmpty()) - homePage = CollectionConfiguration::defaultHomePage(*m_helpEngine); - m_ui.homePageLineEdit->setText(homePage); + m_ui.homePageLineEdit->setText(helpEngine.homePage()); - int option = CollectionConfiguration::startOption(*m_helpEngine); + int option = helpEngine.startOption(); m_ui.helpStartComboBox->setCurrentIndex(option); connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage())); @@ -505,8 +476,7 @@ void PreferencesDialog::setCurrentPage() void PreferencesDialog::setDefaultPage() { - QString homePage = CollectionConfiguration::defaultHomePage(*m_helpEngine); - m_ui.homePageLineEdit->setText(homePage); + m_ui.homePageLineEdit->setText(helpEngine.defaultHomePage()); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h index 7abf431..1554a9f 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.h +++ b/tools/assistant/tools/assistant/preferencesdialog.h @@ -48,22 +48,15 @@ QT_BEGIN_NAMESPACE class FontPanel; +class HelpEngineWrapper; class QFileSystemWatcher; -class QHelpEngineCore; - -enum { - ShowHomePage = 0, - ShowBlankPage = 1, - ShowLastPages = 2 -}; class PreferencesDialog : public QDialog { Q_OBJECT public: - PreferencesDialog(QHelpEngineCore *helpEngine, - QFileSystemWatcher *qchWatcher, QWidget *parent = 0); + PreferencesDialog(QWidget *parent = 0); ~PreferencesDialog(); void showDialog(); @@ -95,7 +88,6 @@ private: void updateOptionsPage(); Ui::PreferencesDialogClass m_ui; - QHelpEngineCore *m_helpEngine; bool m_hideFiltersTab; bool m_hideDocsTab; QMap<QString, QStringList> m_filterMapBackup; @@ -109,7 +101,7 @@ private: FontPanel *m_browserFontPanel; bool m_appFontChanged; bool m_browserFontChanged; - QFileSystemWatcher * const m_qchWatcher; + HelpEngineWrapper &helpEngine; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/qtdocinstaller.cpp b/tools/assistant/tools/assistant/qtdocinstaller.cpp index 3f82786..3675aec 100644 --- a/tools/assistant/tools/assistant/qtdocinstaller.cpp +++ b/tools/assistant/tools/assistant/qtdocinstaller.cpp @@ -44,17 +44,14 @@ #include <QtCore/QDateTime> #include <QtCore/QFileSystemWatcher> #include <QtHelp/QHelpEngineCore> -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include "qtdocinstaller.h" QT_BEGIN_NAMESPACE -QtDocInstaller::QtDocInstaller(const QString &collectionFile, - QFileSystemWatcher *qchWatcher) - : m_qchWatcher(qchWatcher) +QtDocInstaller::QtDocInstaller(const QList<DocInfo> &docInfos) + : m_abort(false), m_docInfos(docInfos) { - m_abort = false; - m_collectionFile = collectionFile; } QtDocInstaller::~QtDocInstaller() @@ -74,87 +71,51 @@ void QtDocInstaller::installDocs() void QtDocInstaller::run() { - QHelpEngineCore *helpEngine = new QHelpEngineCore(m_collectionFile); - helpEngine->setupData(); - bool changes = false; - - QStringList docs; - docs << QLatin1String("assistant") - << QLatin1String("designer") - << QLatin1String("linguist") - << QLatin1String("qmake") - << QLatin1String("qt"); + m_qchDir = QLibraryInfo::location(QLibraryInfo::DocumentationPath) + + QDir::separator() + QLatin1String("qch"); + m_qchFiles = m_qchDir.entryList(QStringList() << QLatin1String("*.qch")); - foreach (const QString &doc, docs) { - changes |= installDoc(doc, helpEngine); + bool changes = false; + foreach (const DocInfo &docInfo, m_docInfos) { + changes |= installDoc(docInfo); m_mutex.lock(); if (m_abort) { - delete helpEngine; m_mutex.unlock(); return; } m_mutex.unlock(); } - delete helpEngine; emit docsInstalled(changes); } -bool QtDocInstaller::installDoc(const QString &name, QHelpEngineCore *helpEngine) +bool QtDocInstaller::installDoc(const DocInfo &docInfo) { - QStringList lst = CollectionConfiguration::qtDocInfo(*helpEngine, name); - + const QString &component = docInfo.first; + const QStringList &info = docInfo.second; QDateTime dt; - if (!lst.isEmpty() && !lst.first().isEmpty()) - dt = QDateTime::fromString(lst.first(), Qt::ISODate); + if (!info.isEmpty() && !info.first().isEmpty()) + dt = QDateTime::fromString(info.first(), Qt::ISODate); QString qchFile; - if (lst.count() == 2) - qchFile = lst.last(); - - QDir dir(QLibraryInfo::location(QLibraryInfo::DocumentationPath) - + QDir::separator() + QLatin1String("qch")); + if (info.count() == 2) + qchFile = info.last(); - const QStringList files = dir.entryList(QStringList() << QLatin1String("*.qch")); - if (files.isEmpty()) { - CollectionConfiguration::setQtDocInfo(*helpEngine, name, - QStringList(QDateTime().toString(Qt::ISODate))); + if (m_qchFiles.isEmpty()) { + emit qchFileNotFound(component); return false; } - foreach (const QString &f, files) { - if (f.startsWith(name)) { - QFileInfo fi(dir.absolutePath() + QDir::separator() + f); + foreach (const QString &f, m_qchFiles) { + if (f.startsWith(component)) { + QFileInfo fi(m_qchDir.absolutePath() + QDir::separator() + f); if (dt.isValid() && fi.lastModified().toTime_t() == dt.toTime_t() && qchFile == fi.absoluteFilePath()) return false; - - QString namespaceName = QHelpEngineCore::namespaceName(fi.absoluteFilePath()); - if (namespaceName.isEmpty()) - continue; - - if (helpEngine->registeredDocumentations().contains(namespaceName)) { - const QString docFile = - helpEngine->documentationFileName(namespaceName); - if (helpEngine->unregisterDocumentation(namespaceName)) - m_qchWatcher->removePath(docFile); - } - - if (!helpEngine->registerDocumentation(fi.absoluteFilePath())) { - emit errorMessage( - tr("The file %1 could not be registered successfully!\n\nReason: %2") - .arg(fi.absoluteFilePath()).arg(helpEngine->error())); - } else { - m_qchWatcher->addPath(fi.absoluteFilePath()); - } - - Q_ASSERT(m_qchWatcher->files().count() - == helpEngine->registeredDocumentations().count()); - - CollectionConfiguration::setQtDocInfo(*helpEngine, name, - QStringList() << fi.lastModified().toString(Qt::ISODate) - << fi.absoluteFilePath()); + emit registerDocumentation(component, fi.absoluteFilePath()); return true; } } + + emit qchFileNotFound(component); return false; } diff --git a/tools/assistant/tools/assistant/qtdocinstaller.h b/tools/assistant/tools/assistant/qtdocinstaller.h index 0d503fd..c64a5c3 100644 --- a/tools/assistant/tools/assistant/qtdocinstaller.h +++ b/tools/assistant/tools/assistant/qtdocinstaller.h @@ -42,36 +42,41 @@ #ifndef QTDOCINSTALLER #define QTDOCINSTALLER -#include <QtCore/QThread> +#include <QtCore/QDir> #include <QtCore/QMutex> +#include <QtCore/QPair> +#include <QtCore/QStringList> +#include <QtCore/QThread> QT_BEGIN_NAMESPACE -class QFileSystemWatcher; -class QHelpEngineCore; +class HelpEngineWrapper; class QtDocInstaller : public QThread { Q_OBJECT public: - QtDocInstaller(const QString &collectionFile, QFileSystemWatcher *qchWatcher); + typedef QPair<QString, QStringList> DocInfo; + QtDocInstaller(const QList<DocInfo> &docInfos); ~QtDocInstaller(); void installDocs(); signals: - void errorMessage(const QString &msg); + void qchFileNotFound(const QString &component); + void registerDocumentation(const QString &component, + const QString &absFileName); void docsInstalled(bool newDocsInstalled); private: void run(); - bool installDoc(const QString &name, - QHelpEngineCore *helpEngine); + bool installDoc(const DocInfo &docInfo); bool m_abort; - QString m_collectionFile; QMutex m_mutex; - QFileSystemWatcher * const m_qchWatcher; + QStringList m_qchFiles; + QDir m_qchDir; + QList<DocInfo> m_docInfos; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index ef13885..f4ae3b4 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -42,6 +42,7 @@ #include "remotecontrol.h" #include "mainwindow.h" #include "centralwidget.h" +#include "helpenginewrapper.h" #include <QtCore/QFile> #include <QtCore/QFileInfo> @@ -106,16 +107,14 @@ void StdInListenerWin::run() } #endif -RemoteControl::RemoteControl(MainWindow *mainWindow, QHelpEngine *helpEngine, - QFileSystemWatcher *qchWatcher) +RemoteControl::RemoteControl(MainWindow *mainWindow) : QObject(mainWindow) , m_mainWindow(mainWindow) - , m_helpEngine(helpEngine) , m_debug(false) , m_caching(true) , m_syncContents(false) , m_expandTOC(-2) - , m_qchWatcher(qchWatcher) + , helpEngine(HelpEngineWrapper::instance()) { connect(m_mainWindow, SIGNAL(initDone()), this, SLOT(applyCache())); @@ -248,7 +247,7 @@ void RemoteControl::handleActivateKeywordCommand(const QString &arg) } else { m_mainWindow->setIndexString(arg); if (!arg.isEmpty()) - m_helpEngine->indexWidget()->activateCurrentItem(); + helpEngine.indexWidget()->activateCurrentItem(); } } @@ -258,8 +257,7 @@ void RemoteControl::handleActivateIdentifierCommand(const QString &arg) clearCache(); m_activateIdentifier = arg; } else { - const QMap<QString, QUrl> &links = - m_helpEngine->linksForIdentifier(arg); + const QMap<QString, QUrl> &links = helpEngine.linksForIdentifier(arg); if (!links.isEmpty()) CentralWidget::instance()->setSource(links.constBegin().value()); } @@ -282,12 +280,12 @@ void RemoteControl::handleExpandTocCommand(const QString &arg) void RemoteControl::handleSetCurrentFilterCommand(const QString &arg) { - if (m_helpEngine->customFilters().contains(arg)) { + if (helpEngine.customFilters().contains(arg)) { if (m_caching) { clearCache(); m_currentFilter = arg; } else { - m_helpEngine->setCurrentFilter(arg); + helpEngine.setCurrentFilter(arg); } } } @@ -295,29 +293,22 @@ void RemoteControl::handleSetCurrentFilterCommand(const QString &arg) void RemoteControl::handleRegisterCommand(const QString &arg) { const QString &absFileName = QFileInfo(arg).absoluteFilePath(); - if (m_helpEngine->registeredDocumentations(). + if (helpEngine.registeredDocumentations(). contains(QHelpEngineCore::namespaceName(absFileName))) return; - if (m_helpEngine->registerDocumentation(absFileName)) { - m_qchWatcher->addPath(absFileName); - m_helpEngine->setupData(); - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); - } + if (helpEngine.registerDocumentation(absFileName)) + helpEngine.setupData(); } void RemoteControl::handleUnregisterCommand(const QString &arg) { const QString &absFileName = QFileInfo(arg).absoluteFilePath(); const QString &ns = QHelpEngineCore::namespaceName(absFileName); - if (m_helpEngine->registeredDocumentations().contains(ns)) { + if (helpEngine.registeredDocumentations().contains(ns)) { CentralWidget* widget = CentralWidget::instance(); widget->closeTabs(widget->currentSourceFileList().keys(ns)); - const QString docFile = m_helpEngine->documentationFileName(ns); - if (m_helpEngine->unregisterDocumentation(ns)) { - m_qchWatcher->removePath(docFile); - m_helpEngine->setupData(); - } + if (helpEngine.unregisterDocumentation(ns)) + helpEngine.setupData(); } } @@ -327,14 +318,14 @@ void RemoteControl::applyCache() CentralWidget::instance()->setSource(m_setSource); } else if (!m_activateKeyword.isEmpty()) { m_mainWindow->setIndexString(m_activateKeyword); - m_helpEngine->indexWidget()->activateCurrentItem(); + helpEngine.indexWidget()->activateCurrentItem(); } else if (!m_activateIdentifier.isEmpty()) { QMap<QString, QUrl> links = - m_helpEngine->linksForIdentifier(m_activateIdentifier); - if (links.count()) + helpEngine.linksForIdentifier(m_activateIdentifier); + if (!links.isEmpty()) CentralWidget::instance()->setSource(links.constBegin().value()); } else if (!m_currentFilter.isEmpty()) { - m_helpEngine->setCurrentFilter(m_currentFilter); + helpEngine.setCurrentFilter(m_currentFilter); } if (m_syncContents) diff --git a/tools/assistant/tools/assistant/remotecontrol.h b/tools/assistant/tools/assistant/remotecontrol.h index 6f7eb5f..5d74996 100644 --- a/tools/assistant/tools/assistant/remotecontrol.h +++ b/tools/assistant/tools/assistant/remotecontrol.h @@ -48,17 +48,15 @@ QT_BEGIN_NAMESPACE +class HelpEngineWrapper; class MainWindow; -class QFileSystemWatcher; -class QHelpEngine; class RemoteControl : public QObject { Q_OBJECT public: - RemoteControl(MainWindow *mainWindow, QHelpEngine *helpEngine, - QFileSystemWatcher *qchWatcher); + RemoteControl(MainWindow *mainWindow); private slots: void receivedData(); @@ -81,7 +79,6 @@ private: private: MainWindow *m_mainWindow; - QHelpEngine *m_helpEngine; bool m_debug; bool m_caching; @@ -91,7 +88,7 @@ private: QString m_activateIdentifier; int m_expandTOC; QString m_currentFilter; - QFileSystemWatcher * const m_qchWatcher; + HelpEngineWrapper &helpEngine; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/tracer.h b/tools/assistant/tools/assistant/tracer.h index 913c961..3d8b647 100644 --- a/tools/assistant/tools/assistant/tracer.h +++ b/tools/assistant/tools/assistant/tracer.h @@ -65,6 +65,7 @@ private: QT_END_NAMESPACE +// #define TRACING_REQUESTED #ifdef TRACING_REQUESTED #define TRACE_OBJ Tracer traceObj__(Q_FUNC_INFO); #else diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp index 2eb2b96..467ee88 100644 --- a/tools/assistant/tools/qcollectiongenerator/main.cpp +++ b/tools/assistant/tools/qcollectiongenerator/main.cpp @@ -467,8 +467,7 @@ int main(int argc, char *argv[]) } if (!config.currentFilter().isEmpty()) { - CollectionConfiguration::setCurrentFilter(helpEngine, - config.currentFilter()); + helpEngine.setCurrentFilter(config.currentFilter()); } if (!config.cacheDirectory().isEmpty()) { diff --git a/tools/assistant/tools/shared/collectionconfiguration.cpp b/tools/assistant/tools/shared/collectionconfiguration.cpp index d0650e4..ba643c9 100644 --- a/tools/assistant/tools/shared/collectionconfiguration.cpp +++ b/tools/assistant/tools/shared/collectionconfiguration.cpp @@ -46,30 +46,21 @@ QT_BEGIN_NAMESPACE namespace { - const QString ListSeparator(QLatin1String("|")); - const QString AboutIconKey(QLatin1String("AboutIcon")); const QString AboutImagesKey(QLatin1String("AboutImages")); const QString AboutMenuTextsKey(QLatin1String("AboutMenuTexts")); const QString AboutTextsKey(QLatin1String("AboutTexts")); - const QString AppFontKey(QLatin1String("appFont")); const QString ApplicationIconKey(QLatin1String("ApplicationIcon")); - const QString AppWritingSystemKey(QLatin1String("appWritingSystem")); - const QString BookmarksKey(QLatin1String("Bookmarks")); - const QString BrowserFontKey(QLatin1String("browserFont")); - const QString BrowserWritingSystemKey(QLatin1String("browserWritingSystem")); const QString CacheDirKey(QLatin1String("CacheDirectory")); const QString CacheDirRelativeToCollectionKey(QLatin1String("CacheDirRelativeToCollection")); const QString CreationTimeKey(QLatin1String("CreationTime")); - const QString CurrentFilterKey(QLatin1String("CurrentFilter")); const QString DefaultHomePageKey(QLatin1String("defaultHomepage")); const QString DocUpdatePendingKey(QLatin1String("DocUpdate")); const QString EnableAddressBarKey(QLatin1String("EnableAddressBar")); const QString EnableDocManagerKey(QLatin1String("EnableDocumentationManager")); const QString EnableFilterKey(QLatin1String("EnableFilterFunctionality")); - const QString FilterToolbarHiddenKey(QLatin1String("HideFilterFunctionality")); const QString HideAddressBarKey(QLatin1String("HideAddressBar")); - const QString HomePageKey(QLatin1String("homepage")); + const QString FilterToolbarHiddenKey(QLatin1String("HideFilterFunctionality")); const QString LastPageKey(QLatin1String("LastTabPage")); const QString LastShownPagesKey(QLatin1String("LastShownPages")); const QString LastZoomFactorsKey(QLatin1String( @@ -79,19 +70,11 @@ namespace { "LastPagesZoomTextBrowser" #endif )); - const QString MainWindowKey(QLatin1String("MainWindow")); - 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")). - arg(QLatin1String(QT_VERSION_STR))); const QString WindowTitleKey(QLatin1String("WindowTitle")); } // anonymous namespace const QString CollectionConfiguration::DefaultZoomFactor(QLatin1String("0.0")); +const QString CollectionConfiguration::ListSeparator(QLatin1String("|")); uint CollectionConfiguration::creationTime(const QHelpEngineCore &helpEngine) { @@ -109,84 +92,18 @@ const QString CollectionConfiguration::windowTitle(const QHelpEngineCore &helpEn } void CollectionConfiguration::setWindowTitle(QHelpEngineCore &helpEngine, - const QString &windowTitle) + const QString &windowTitle) { helpEngine.setCustomValue(WindowTitleKey, windowTitle); } - -int CollectionConfiguration::lastTabPage(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(LastPageKey, 1).toInt(); -} - -void CollectionConfiguration::setLastTabPage(QHelpEngineCore &helpEngine, int lastPage) -{ - helpEngine.setCustomValue(LastPageKey, lastPage); -} - - -const QStringList CollectionConfiguration::lastShownPages(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(LastShownPagesKey).toString(). - split(ListSeparator, QString::SkipEmptyParts); -} - -void CollectionConfiguration::setLastShownPages(QHelpEngineCore &helpEngine, - const QStringList &lastShownPages) -{ - helpEngine. - setCustomValue(LastShownPagesKey, lastShownPages.join(ListSeparator)); -} - -const QStringList CollectionConfiguration::lastZoomFactors(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(LastZoomFactorsKey).toString(). - split(ListSeparator, QString::SkipEmptyParts); -} - -void CollectionConfiguration::setLastZoomFactors(QHelpEngineCore &helpEngine, - const QStringList &lastZoomFactors) -{ - helpEngine.setCustomValue(LastZoomFactorsKey, lastZoomFactors.join(ListSeparator)); -} - -const QString CollectionConfiguration::currentFilter(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(CurrentFilterKey).toString(); -} - -void CollectionConfiguration::setCurrentFilter(QHelpEngineCore &helpEngine, - const QString ¤tFilter) -{ - helpEngine.setCustomValue(CurrentFilterKey, currentFilter); -} - -const QString CollectionConfiguration::cacheDir(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(CacheDirKey).toString(); -} - -bool CollectionConfiguration::cacheDirIsRelativeToCollection(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(CacheDirRelativeToCollectionKey).toBool(); -} - -void CollectionConfiguration::setCacheDir(QHelpEngineCore &helpEngine, - const QString &cacheDir, bool relativeToCollection) -{ - helpEngine.setCustomValue(CacheDirKey, cacheDir); - helpEngine.setCustomValue(CacheDirRelativeToCollectionKey, - relativeToCollection); -} - bool CollectionConfiguration::filterFunctionalityEnabled(const QHelpEngineCore &helpEngine) { return helpEngine.customValue(EnableFilterKey, true).toBool(); } void CollectionConfiguration::setFilterFunctionalityEnabled(QHelpEngineCore &helpEngine, - bool enabled) + bool enabled) { helpEngine.setCustomValue(EnableFilterKey, enabled); } @@ -197,7 +114,7 @@ bool CollectionConfiguration::filterToolbarVisible(const QHelpEngineCore &helpEn } void CollectionConfiguration::setFilterToolbarVisible(QHelpEngineCore &helpEngine, - bool visible) + bool visible) { helpEngine.setCustomValue(FilterToolbarHiddenKey, !visible); } @@ -224,6 +141,24 @@ void CollectionConfiguration::setAddressBarVisible(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(HideAddressBarKey, !visible); } +const QString CollectionConfiguration::cacheDir(const QHelpEngineCore &helpEngine) +{ + return helpEngine.customValue(CacheDirKey).toString(); +} + +bool CollectionConfiguration::cacheDirIsRelativeToCollection(const QHelpEngineCore &helpEngine) +{ + return helpEngine.customValue(CacheDirRelativeToCollectionKey).toBool(); +} + +void CollectionConfiguration::setCacheDir(QHelpEngineCore &helpEngine, + const QString &cacheDir, bool relativeToCollection) +{ + helpEngine.setCustomValue(CacheDirKey, cacheDir); + helpEngine.setCustomValue(CacheDirRelativeToCollectionKey, + relativeToCollection); +} + bool CollectionConfiguration::documentationManagerEnabled(const QHelpEngineCore &helpEngine) { return helpEngine.customValue(EnableDocManagerKey, true).toBool(); @@ -302,30 +237,6 @@ void CollectionConfiguration::setDefaultHomePage(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(DefaultHomePageKey, page); } -const QString CollectionConfiguration::homePage(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(HomePageKey).toString(); -} - -void CollectionConfiguration::setHomePage(QHelpEngineCore &helpEngine, - const QString &page) -{ - helpEngine.setCustomValue(HomePageKey, page); -} - -int CollectionConfiguration::startOption(const QHelpEngineCore &helpEngine) -{ - // TODO: After moving to helpengine wrapper, put LastPages in that header file - // and use it here as default value. - return helpEngine.customValue(StartOptionKey).toInt(); -} - -void CollectionConfiguration::setStartOption(QHelpEngineCore &helpEngine, - int option) -{ - helpEngine.setCustomValue(StartOptionKey, option); -} - bool CollectionConfiguration::docUpdatePending(const QHelpEngineCore &helpEngine) { return helpEngine.customValue(DocUpdatePendingKey, false).toBool(); @@ -337,145 +248,41 @@ void CollectionConfiguration::setDocUpdatePending(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(DocUpdatePendingKey, pending); } -const QByteArray CollectionConfiguration::bookmarks(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(BookmarksKey).toByteArray(); -} - -void CollectionConfiguration::setBookmarks(QHelpEngineCore &helpEngine, - const QByteArray &bookmarks) -{ - helpEngine.setCustomValue(BookmarksKey, bookmarks); -} - -const QByteArray CollectionConfiguration::mainWindow(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(MainWindowKey).toByteArray(); -} - -void CollectionConfiguration::setMainWindow(QHelpEngineCore &helpEngine, - const QByteArray &mainWindow) -{ - helpEngine.setCustomValue(MainWindowKey, mainWindow); -} - -const QByteArray CollectionConfiguration::mainWindowGeometry(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(MainWindowGeometryKey).toByteArray(); -} - -void CollectionConfiguration::setMainWindowGeometry(QHelpEngineCore &helpEngine, - const QByteArray &geometry) -{ - helpEngine.setCustomValue(MainWindowGeometryKey, geometry); -} - -bool CollectionConfiguration::usesAppFont(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(UseAppFontKey).toBool(); -} - -void CollectionConfiguration::setUseAppFont(QHelpEngineCore &helpEngine, - bool useAppFont) -{ - helpEngine.setCustomValue(UseAppFontKey, useAppFont); -} - -bool CollectionConfiguration::usesBrowserFont(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(UseBrowserFontKey, false).toBool(); -} - -void CollectionConfiguration::setUseBrowserFont(QHelpEngineCore &helpEngine, - bool useBrowserFont) -{ - helpEngine.setCustomValue(UseBrowserFontKey, useBrowserFont); -} - -const QFont CollectionConfiguration::appFont(const QHelpEngineCore &helpEngine) -{ - return qVariantValue<QFont>(helpEngine.customValue(AppFontKey)); -} - -void CollectionConfiguration::setAppFont(QHelpEngineCore &helpEngine, - const QFont &font) -{ - helpEngine.setCustomValue(AppFontKey, font); -} - -QFontDatabase::WritingSystem CollectionConfiguration::appWritingSystem(const QHelpEngineCore &helpEngine) -{ - return static_cast<QFontDatabase::WritingSystem>( - helpEngine.customValue(AppWritingSystemKey).toInt()); -} - -void CollectionConfiguration::setAppWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system) -{ - helpEngine.setCustomValue(AppWritingSystemKey, system); -} - -const QFont CollectionConfiguration::browserFont(const QHelpEngineCore &helpEngine) -{ - return qVariantValue<QFont>(helpEngine.customValue(BrowserFontKey)); -} - -void CollectionConfiguration::setBrowserFont(QHelpEngineCore &helpEngine, - const QFont &font) -{ - helpEngine.setCustomValue(BrowserFontKey, font); -} - -QFontDatabase::WritingSystem CollectionConfiguration::browserWritingSystem(const QHelpEngineCore &helpEngine) -{ - return static_cast<QFontDatabase::WritingSystem>( - helpEngine.customValue(BrowserWritingSystemKey).toInt()); -} - -void CollectionConfiguration::setBrowserWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system) -{ - helpEngine.setCustomValue(BrowserWritingSystemKey, system); -} - -bool CollectionConfiguration::unfilteredInserted(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(UnfilteredInsertedKey).toInt() == 1; -} - -void CollectionConfiguration::setUnfilteredInserted(QHelpEngineCore &helpEngine) +const QStringList CollectionConfiguration::lastShownPages(const QHelpEngineCore &helpEngine) { - helpEngine.setCustomValue(UnfilteredInsertedKey, 1); + return helpEngine.customValue(LastShownPagesKey).toString(). + split(ListSeparator, QString::SkipEmptyParts); } -const QStringList CollectionConfiguration::qtDocInfo(const QHelpEngineCore &helpEngine, - const QString &component) +void CollectionConfiguration::setLastShownPages(QHelpEngineCore &helpEngine, + const QStringList &lastShownPages) { - return helpEngine.customValue(VersionKey.arg(component)).toString(). - split(ListSeparator); + helpEngine.setCustomValue(LastShownPagesKey, + lastShownPages.join(ListSeparator)); } -void CollectionConfiguration::setQtDocInfo(QHelpEngineCore &helpEngine, - const QString &component, const QStringList &doc) +const QStringList CollectionConfiguration::lastZoomFactors(const QHelpEngineCore &helpEngine) { - helpEngine.setCustomValue(VersionKey.arg(component), - doc.join(ListSeparator)); + return helpEngine.customValue(LastZoomFactorsKey).toString(). + split(ListSeparator, QString::SkipEmptyParts); } -bool CollectionConfiguration::searchWasAttached(const QHelpEngineCore &helpEngine) +void CollectionConfiguration::setLastZoomFactors(QHelpEngineCore &helpEngine, + const QStringList &lastZoomFactors) { - return helpEngine.customValue(SearchWasAttachedKey).toBool(); + helpEngine.setCustomValue(LastZoomFactorsKey, + lastZoomFactors.join(ListSeparator)); } -void CollectionConfiguration::setSearchWasAttached(QHelpEngineCore &helpEngine, - bool attached) +int CollectionConfiguration::lastTabPage(const QHelpEngineCore &helpEngine) { - helpEngine.setCustomValue(SearchWasAttachedKey, attached); + return helpEngine.customValue(LastPageKey, 1).toInt(); } -bool CollectionConfiguration::hasFontSettings(const QHelpEngineCore &helpEngine) +void CollectionConfiguration::setLastTabPage(QHelpEngineCore &helpEngine, + int lastPage) { - return helpEngine.customValue(UseAppFontKey).isValid(); + helpEngine.setCustomValue(LastPageKey, lastPage); } bool CollectionConfiguration::isNewer(const QHelpEngineCore &newer, @@ -489,9 +296,7 @@ void CollectionConfiguration::copyConfiguration(const QHelpEngineCore &source, { setCreationTime(target, creationTime(source)); setWindowTitle(target, windowTitle(source)); - setLastShownPages(target, lastShownPages(source)); - setLastZoomFactors(target, lastZoomFactors(source)); - setCurrentFilter(target, currentFilter(source)); + target.setCurrentFilter(source.currentFilter()); setCacheDir(target, cacheDir(source), cacheDirIsRelativeToCollection(source)); setFilterFunctionalityEnabled(target, filterFunctionalityEnabled(source)); setFilterToolbarVisible(target, filterToolbarVisible(source)); diff --git a/tools/assistant/tools/shared/collectionconfiguration.h b/tools/assistant/tools/shared/collectionconfiguration.h index 48d2803..4e77abe 100644 --- a/tools/assistant/tools/shared/collectionconfiguration.h +++ b/tools/assistant/tools/shared/collectionconfiguration.h @@ -46,8 +46,6 @@ #include <QtCore/QCoreApplication> #include <QtCore/QString> #include <QtCore/QStringList> -#include <QtGui/QFont> -#include <QtGui/QFontDatabase> QT_BEGIN_NAMESPACE @@ -56,29 +54,18 @@ class QHelpEngineCore; class CollectionConfiguration { public: - static int lastTabPage(const QHelpEngineCore &helpEngine); - static void setLastTabPage(QHelpEngineCore &helpEngine, int lastPage); - - static const QStringList lastShownPages(const QHelpEngineCore &helpEngine); - static void setLastShownPages(QHelpEngineCore &helpEngine, - const QStringList &lastShownPages); - - - // TODO: Don't allow last pages and zoom factors to be set in isolation - // Perhaps also fill up missing elements automatically or assert. - static const QStringList lastZoomFactors(const QHelpEngineCore &helpEngine); - static void setLastZoomFactors(QHelpEngineCore &helpEngine, - const QStringList &lastZoomFactors); - - static const QString currentFilter(const QHelpEngineCore &helpEngine); - static void setCurrentFilter(QHelpEngineCore &helpEngine, - const QString ¤tFilter); + static const QString windowTitle(const QHelpEngineCore &helpEngine); + static void setWindowTitle(QHelpEngineCore &helpEngine, + const QString &windowTitle); static const QString cacheDir(const QHelpEngineCore &helpEngine); static bool cacheDirIsRelativeToCollection(const QHelpEngineCore &helpEngine); static void setCacheDir(QHelpEngineCore &helpEngine, const QString &cacheDir, bool relativeToCollection); + static uint creationTime(const QHelpEngineCore &helpEngine); + static void setCreationTime(QHelpEngineCore &helpEngine, uint time); + static bool filterFunctionalityEnabled(const QHelpEngineCore &helpEngine); static void setFilterFunctionalityEnabled(QHelpEngineCore &helpEngine, bool enabled); @@ -93,12 +80,6 @@ public: static bool addressBarVisible(const QHelpEngineCore &helpEngine); static void setAddressBarVisible(QHelpEngineCore &helpEngine, bool visible); - static uint creationTime(const QHelpEngineCore &helpEngine); - static void setCreationTime(QHelpEngineCore &helpEngine, uint time); - - static const QString windowTitle(const QHelpEngineCore &helpEngine); - static void setWindowTitle(QHelpEngineCore &helpEngine, - const QString &windowTitle); static bool documentationManagerEnabled(const QHelpEngineCore &helpEngine); static void setDocumentationManagerEnabled(QHelpEngineCore &helpEngine, @@ -108,12 +89,6 @@ public: static void setApplicationIcon(QHelpEngineCore &helpEngine, const QByteArray &icon); - static const QString homePage(const QHelpEngineCore &helpEngine); - static void setHomePage(QHelpEngineCore &helpEngine, const QString &page); - - static int startOption(const QHelpEngineCore &helpEngine); - static void setStartOption(QHelpEngineCore &helpEngine, int option); - // TODO: Encapsulate encoding from/to QByteArray here static const QByteArray aboutMenuTexts(const QHelpEngineCore &helpEngine); static void setAboutMenuTexts(QHelpEngineCore &helpEngine, @@ -139,58 +114,25 @@ public: static bool docUpdatePending(const QHelpEngineCore &helpEngine); static void setDocUpdatePending(QHelpEngineCore &helpEngine, bool pending); - // TODO: Put these GUI-specific functions in the help engine wrapper - static const QByteArray bookmarks(const QHelpEngineCore &helpEngine); - static void setBookmarks(QHelpEngineCore &helpEngine, - const QByteArray &bookmarks); - - static const QByteArray mainWindow(const QHelpEngineCore &helpEngine); - static void setMainWindow(QHelpEngineCore &helpEngine, - const QByteArray &mainWindow); - - static const QByteArray mainWindowGeometry(const QHelpEngineCore &helpEngine); - static void setMainWindowGeometry(QHelpEngineCore &helpEngine, - const QByteArray &geometry); - - static bool usesAppFont(const QHelpEngineCore &helpEngine); - static void setUseAppFont(QHelpEngineCore &helpEngine, bool useAppFont); - - static bool usesBrowserFont(const QHelpEngineCore &helpEngine); - static void setUseBrowserFont(QHelpEngineCore &helpEngine, - bool useBrowserFont); - - static const QFont appFont(const QHelpEngineCore &helpEngine); - static void setAppFont(QHelpEngineCore &helpEngine, const QFont &font); - - static QFontDatabase::WritingSystem appWritingSystem(const QHelpEngineCore &helpEngine); - static void setAppWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system); - - static const QFont browserFont(const QHelpEngineCore &helpEngine); - static void setBrowserFont(QHelpEngineCore &helpEngine, const QFont &font); - - static QFontDatabase::WritingSystem browserWritingSystem(const QHelpEngineCore &helpEngine); - static void setBrowserWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system); - - static bool unfilteredInserted(const QHelpEngineCore &helpEngine); - static void setUnfilteredInserted(QHelpEngineCore &helpEngine); - - static const QStringList qtDocInfo(const QHelpEngineCore &helpEngine, - const QString &component); - static void setQtDocInfo(QHelpEngineCore &helpEngine, - const QString &component, const QStringList &doc); + // TODO: Don't allow last pages and zoom factors to be set in isolation + // Perhaps also fill up missing elements automatically or assert. + static const QStringList lastShownPages(const QHelpEngineCore &helpEngine); + static void setLastShownPages(QHelpEngineCore &helpEngine, + const QStringList &lastShownPages); + static const QStringList lastZoomFactors(const QHelpEngineCore &helpEngine); + static void setLastZoomFactors(QHelpEngineCore &helPEngine, + const QStringList &lastZoomFactors); - static bool searchWasAttached(const QHelpEngineCore &helpEngine); - static void setSearchWasAttached(QHelpEngineCore &helpEngine, bool attached); + static int lastTabPage(const QHelpEngineCore &helpEngine); + static void setLastTabPage(QHelpEngineCore &helpEngine, int lastPage); - static bool hasFontSettings(const QHelpEngineCore &helpEngine); static bool isNewer(const QHelpEngineCore &newer, const QHelpEngineCore &older); static void copyConfiguration(const QHelpEngineCore &source, QHelpEngineCore &target); static const QString DefaultZoomFactor; + static const QString ListSeparator; }; QT_END_NAMESPACE |