Rewrite of the whole help modul initialization.

We now do as much as possible lazy initialisation, e.g only start the
full text search indexer if we really access the search widget. Also
moved the QFutur progress into the search widget. Changed all ctors to
be called without an argument, since we share the help engines from
help manager all over the place. Make use of the fact that we only need
to call setupData on the gui engine if we access the help mode, otherwise
all data is fetched thru the core engine whichs setupData is really fast.
This commit is contained in:
kh1
2010-03-23 18:11:43 +01:00
parent c3326eb627
commit 6ac6be5db2
19 changed files with 415 additions and 615 deletions

View File

@@ -55,7 +55,7 @@
#include <QtGui/QPrintPreviewDialog> #include <QtGui/QPrintPreviewDialog>
#include <QtGui/QPageSetupDialog> #include <QtGui/QPageSetupDialog>
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngineCore>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
@@ -75,7 +75,7 @@ namespace {
Help::Internal::CentralWidget *staticCentralWidget = 0; Help::Internal::CentralWidget *staticCentralWidget = 0;
} }
CentralWidget::CentralWidget(QHelpEngine *engine, QWidget *parent) CentralWidget::CentralWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, findBar(0) , findBar(0)
, tabWidget(0) , tabWidget(0)

View File

@@ -46,7 +46,6 @@ class QCheckBox;
class QLineEdit; class QLineEdit;
class QToolButton; class QToolButton;
class QTabWidget; class QTabWidget;
class QHelpEngine;
class QFocusEvent; class QFocusEvent;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -61,7 +60,7 @@ class CentralWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
CentralWidget(QHelpEngine *engine, QWidget *parent = 0); CentralWidget(QWidget *parent = 0);
~CentralWidget(); ~CentralWidget();
bool hasSelection() const; bool hasSelection() const;

View File

@@ -125,8 +125,14 @@ void DocSettingsPage::removeDocumentation()
void DocSettingsPage::apply() void DocSettingsPage::apply()
{ {
emit dialogAccepted(); HelpManager* manager = &HelpManager::instance();
emit documentationChanged(); manager->unregisterDocumentation(m_filesToUnregister.keys());
manager->registerDocumentation(m_filesToRegister.values());
if (manager->guiEngineNeedsUpdate()) {
// emit this signal to the help plugin, since we don't want
// to force gui help engine setup if we are not in help mode
emit documentationChanged();
}
m_filesToRegister.clear(); m_filesToRegister.clear();
m_filesToUnregister.clear(); m_filesToUnregister.clear();
@@ -137,16 +143,6 @@ bool DocSettingsPage::matches(const QString &s) const
return m_searchKeywords.contains(s, Qt::CaseInsensitive); return m_searchKeywords.contains(s, Qt::CaseInsensitive);
} }
QStringList DocSettingsPage::docsToRegister() const
{
return m_filesToRegister.values();
}
QStringList DocSettingsPage::docsToUnregister() const
{
return m_filesToUnregister.keys();
}
bool DocSettingsPage::eventFilter(QObject *object, QEvent *event) bool DocSettingsPage::eventFilter(QObject *object, QEvent *event)
{ {
if (object != m_ui.docsListWidget) if (object != m_ui.docsListWidget)

View File

@@ -54,11 +54,7 @@ public:
void finish() {} void finish() {}
virtual bool matches(const QString &s) const; virtual bool matches(const QString &s) const;
QStringList docsToRegister() const;
QStringList docsToUnregister() const;
signals: signals:
void dialogAccepted();
void documentationChanged(); void documentationChanged();
private slots: private slots:

View File

@@ -178,12 +178,6 @@ void FilterSettingsPage::removeFilter()
} }
void FilterSettingsPage::apply() void FilterSettingsPage::apply()
{
// This is handled via HelpPlugin::checkForHelpChanges, which is connected
// to DocSettingsPage::apply.
}
bool FilterSettingsPage::applyChanges()
{ {
bool changed = m_filterMap.count() != m_filterMapBackup.count(); bool changed = m_filterMap.count() != m_filterMapBackup.count();
if (!changed) { if (!changed) {
@@ -216,10 +210,11 @@ bool FilterSettingsPage::applyChanges()
FilterMap::const_iterator it; FilterMap::const_iterator it;
for (it = m_filterMap.constBegin(); it != m_filterMap.constEnd(); ++it) for (it = m_filterMap.constBegin(); it != m_filterMap.constEnd(); ++it)
engine->addCustomFilter(it.key(), it.value()); engine->addCustomFilter(it.key(), it.value());
return true;
}
return false; // emit this signal to the help plugin, since we don't want
// to force gui help engine setup if we are not in help mode
emit filtersChanged();
}
} }
bool FilterSettingsPage::matches(const QString &s) const bool FilterSettingsPage::matches(const QString &s) const

View File

@@ -54,7 +54,8 @@ public:
void finish() {} void finish() {}
virtual bool matches(const QString &s) const; virtual bool matches(const QString &s) const;
bool applyChanges(); signals:
void filtersChanged();
private slots: private slots:
void updateAttributes(QListWidgetItem *item); void updateAttributes(QListWidgetItem *item);

View File

@@ -52,8 +52,7 @@
using namespace Help::Internal; using namespace Help::Internal;
GeneralSettingsPage::GeneralSettingsPage(BookmarkManager *bookmarkManager) GeneralSettingsPage::GeneralSettingsPage()
: m_bookmarkManager(bookmarkManager)
{ {
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
QWebSettings* webSettings = QWebSettings::globalSettings(); QWebSettings* webSettings = QWebSettings::globalSettings();
@@ -134,11 +133,6 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
} }
void GeneralSettingsPage::apply() void GeneralSettingsPage::apply()
{
emit dialogAccepted();
}
bool GeneralSettingsPage::applyChanges()
{ {
QFont newFont; QFont newFont;
const QString &family = m_ui.familyComboBox->currentFont().family(); const QString &family = m_ui.familyComboBox->currentFont().family();
@@ -168,7 +162,6 @@ bool GeneralSettingsPage::applyChanges()
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); QHelpEngineCore *engine = &HelpManager::helpEngineCore();
engine->setCustomValue(QLatin1String("font"), newFont); engine->setCustomValue(QLatin1String("font"), newFont);
bool needsUpdate = newFont != m_font;
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
QWebSettings* webSettings = QWebSettings::globalSettings(); QWebSettings* webSettings = QWebSettings::globalSettings();
@@ -182,17 +175,14 @@ bool GeneralSettingsPage::applyChanges()
if (homePage.isEmpty()) if (homePage.isEmpty())
homePage = QLatin1String("about:blank"); homePage = QLatin1String("about:blank");
engine->setCustomValue(QLatin1String("HomePage"), homePage); engine->setCustomValue(QLatin1String("HomePage"), homePage);
needsUpdate |= homePage != m_homePage;
const int startOption = m_ui.helpStartComboBox->currentIndex(); const int startOption = m_ui.helpStartComboBox->currentIndex();
engine->setCustomValue(QLatin1String("StartOption"), startOption); engine->setCustomValue(QLatin1String("StartOption"), startOption);
needsUpdate |= startOption != m_startOption;
const int helpOption = m_ui.contextHelpComboBox->currentIndex(); const int helpOption = m_ui.contextHelpComboBox->currentIndex();
engine->setCustomValue(QLatin1String("ContextHelpOption"), helpOption); engine->setCustomValue(QLatin1String("ContextHelpOption"), helpOption);
needsUpdate |= helpOption != m_helpOption;
return needsUpdate; // no need to call setup on the gui engine since we use only core engine
} }
void GeneralSettingsPage::setCurrentPage() void GeneralSettingsPage::setCurrentPage()
@@ -226,8 +216,8 @@ void GeneralSettingsPage::importBookmarks()
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
XbelReader reader(m_bookmarkManager->treeBookmarkModel(), const BookmarkManager &manager = HelpManager::bookmarkManager();
m_bookmarkManager->listBookmarkModel()); XbelReader reader(manager.treeBookmarkModel(), manager.listBookmarkModel());
if (reader.readFromFile(&file)) if (reader.readFromFile(&file))
return; return;
} }
@@ -249,7 +239,7 @@ void GeneralSettingsPage::exportBookmarks()
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::WriteOnly)) { if (file.open(QIODevice::WriteOnly)) {
XbelWriter writer(m_bookmarkManager->treeBookmarkModel()); XbelWriter writer(HelpManager::bookmarkManager().treeBookmarkModel());
writer.writeToFile(&file); writer.writeToFile(&file);
} }
} }

View File

@@ -33,8 +33,6 @@
#include "ui_generalsettingspage.h" #include "ui_generalsettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h> #include <coreplugin/dialogs/ioptionspage.h>
class BookmarkManager;
namespace Help { namespace Help {
namespace Internal { namespace Internal {
@@ -45,7 +43,7 @@ class GeneralSettingsPage : public Core::IOptionsPage
Q_OBJECT Q_OBJECT
public: public:
GeneralSettingsPage(BookmarkManager *bookmarkManager); GeneralSettingsPage();
QString id() const; QString id() const;
virtual QString displayName() const; virtual QString displayName() const;
@@ -57,11 +55,8 @@ public:
void finish() {} void finish() {}
virtual bool matches(const QString &s) const; virtual bool matches(const QString &s) const;
bool applyChanges();
signals: signals:
void fontChanged(); void fontChanged();
void dialogAccepted();
private slots: private slots:
void setCurrentPage(); void setCurrentPage();
@@ -86,8 +81,6 @@ private:
QString m_searchKeywords; QString m_searchKeywords;
Ui::GeneralSettingsPage m_ui; Ui::GeneralSettingsPage m_ui;
BookmarkManager *m_bookmarkManager;
}; };
} // Internal } // Internal

View File

@@ -188,3 +188,12 @@ QHelpEngineCore& HelpManager::helpEngineCore()
} }
return *m_coreEngine; return *m_coreEngine;
} }
BookmarkManager& HelpManager::bookmarkManager()
{
if (!m_bookmarkManager) {
m_bookmarkManager = new BookmarkManager;
m_bookmarkManager->setupBookmarkModels();
}
return *m_bookmarkManager;
}

View File

@@ -53,7 +53,6 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/minisplitter.h> #include <coreplugin/minisplitter.h>
#include <coreplugin/modemanager.h> #include <coreplugin/modemanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/rightpane.h> #include <coreplugin/rightpane.h>
#include <coreplugin/sidebar.h> #include <coreplugin/sidebar.h>
#include <coreplugin/uniqueidmanager.h> #include <coreplugin/uniqueidmanager.h>
@@ -64,21 +63,19 @@
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QFuture>
#include <QtCore/QLibraryInfo> #include <QtCore/QLibraryInfo>
#include <QtCore/QTranslator> #include <QtCore/QTranslator>
#include <QtCore/qplugin.h> #include <QtCore/qplugin.h>
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QMessageBox>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
#include <QtGui/QShortcut> #include <QtGui/QShortcut>
#include <QtGui/QSplitter> #include <QtGui/QSplitter>
#include <QtGui/QToolBar> #include <QtGui/QToolBar>
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpSearchEngine> #include <QtHelp/QHelpEngineCore>
#if defined(QT_NO_WEBKIT) #if defined(QT_NO_WEBKIT)
# include <QtGui/QApplication> # include <QtGui/QApplication>
@@ -89,6 +86,7 @@
using namespace Help; using namespace Help;
using namespace Help::Internal; using namespace Help::Internal;
#define IMAGEPATH ":/help/images/"
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
# define DOCPATH "/../Resources/doc/" # define DOCPATH "/../Resources/doc/"
#else #else
@@ -96,20 +94,16 @@ using namespace Help::Internal;
#endif #endif
HelpPlugin::HelpPlugin() HelpPlugin::HelpPlugin()
: m_core(0), : m_mode(0),
m_helpEngine(0), m_core(0),
m_contentWidget(0),
m_indexWidget(0),
m_centralWidget(0), m_centralWidget(0),
m_helpViewerForSideBar(0), m_helpViewerForSideBar(0),
m_mode(0),
m_contentItem(0), m_contentItem(0),
m_indexItem(0), m_indexItem(0),
m_searchItem(0), m_searchItem(0),
m_bookmarkItem(0), m_bookmarkItem(0),
m_progress(0), m_sideBar(0),
isInitialised(false), m_firstModeChange(true)
firstModeChange(true)
{ {
} }
@@ -142,133 +136,79 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
qApp->installTranslator(qhelptr); qApp->installTranslator(qhelptr);
} }
#ifndef QT_NO_WEBKIT addAutoReleasedObject(m_helpManager = new HelpManager(this));
QWebSettings *webSettings = QWebSettings::globalSettings();
const QFont applicationFont = QApplication::font();
webSettings->setFontFamily(QWebSettings::StandardFont, applicationFont.family());
//webSettings->setFontSize(QWebSettings::DefaultFontSize, applicationFont.pointSize());
#endif
addAutoReleasedObject(helpManager = new HelpManager(this));
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage()); addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage()); addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage());
connect(m_docSettingsPage, SIGNAL(documentationChanged()), connect(m_docSettingsPage, SIGNAL(documentationChanged()), m_filterSettingsPage,
m_filterSettingsPage, SLOT(updateFilterPage())); SLOT(updateFilterPage()));
connect(m_docSettingsPage, SIGNAL(dialogAccepted()), this, connect(m_generalSettingsPage, SIGNAL(fontChanged()), this, SLOT(fontChanged()));
SLOT(checkForHelpChanges())); connect(m_helpManager, SIGNAL(helpRequested(QString)), this, SLOT(handleHelpRequest(QString)));
connect(helpManager, SIGNAL(registerDocumentation()), this, connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this, SLOT(setupHelpEngineIfNeeded()));
SLOT(slotRegisterDocumentation())); connect(m_docSettingsPage, SIGNAL(documentationChanged()), this, SLOT(setupHelpEngineIfNeeded()));
// force a block here to avoid the expensive indexing restart signal, etc... m_splitter = new Core::MiniSplitter;
m_helpEngine = new QHelpEngine("", this); m_centralWidget = new Help::Internal::CentralWidget();
m_helpEngine->blockSignals(true);
m_contentWidget = new ContentWindow(m_helpEngine);
m_contentWidget->setWindowTitle(tr("Contents"));
m_indexWidget = new IndexWindow(m_helpEngine);
m_indexWidget->setWindowTitle(tr("Index"));
m_searchWidget = new SearchWidget(m_helpEngine->searchEngine());
m_searchWidget->setWindowTitle(tr("Search"));
m_bookmarkManager = new BookmarkManager(m_helpEngine);
m_bookmarkWidget = new BookmarkWidget(m_bookmarkManager, 0, false);
m_bookmarkWidget->setWindowTitle(tr("Bookmarks"));
connect(m_bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark()));
Core::ActionManager *am = m_core->actionManager();
Core::Command *cmd;
QList<QAction*> actionList;
// Add Home, Previous and Next actions (used in the toolbar) // Add Home, Previous and Next actions (used in the toolbar)
QAction *homeAction = QAction *homeAction = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")), tr("Home"), this);
new QAction(QIcon(QLatin1String(":/help/images/home.png")), tr("Home"), Core::ActionManager *am = m_core->actionManager();
this); Core::Command *cmd = am->registerAction(homeAction, QLatin1String("Help.Home"), globalcontext);
cmd = am->registerAction(homeAction, QLatin1String("Help.Home"), globalcontext); connect(homeAction, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
actionList << homeAction;
QAction *previousAction = QAction *previousAction = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
new QAction(QIcon(QLatin1String(":/help/images/previous.png")),
tr("Previous Page"), this); tr("Previous Page"), this);
cmd = am->registerAction(previousAction, QLatin1String("Help.Previous"), cmd = am->registerAction(previousAction, QLatin1String("Help.Previous"), modecontext);
modecontext);
cmd->setDefaultKeySequence(QKeySequence::Back); cmd->setDefaultKeySequence(QKeySequence::Back);
previousAction->setEnabled(m_centralWidget->isBackwardAvailable());
connect(previousAction, SIGNAL(triggered()), m_centralWidget, SLOT(backward()));
connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), previousAction, SLOT(setEnabled(bool)));
actionList << previousAction;
QAction *nextAction = QAction *nextAction = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), tr("Next Page"),
new QAction(QIcon(QLatin1String(":/help/images/next.png")), tr("Next Page"),
this); this);
cmd = am->registerAction(nextAction, QLatin1String("Help.Next"), modecontext); cmd = am->registerAction(nextAction, QLatin1String("Help.Next"), modecontext);
cmd->setDefaultKeySequence(QKeySequence::Forward); cmd->setDefaultKeySequence(QKeySequence::Forward);
nextAction->setEnabled(m_centralWidget->isForwardAvailable());
connect(nextAction, SIGNAL(triggered()), m_centralWidget, SLOT(forward()));
connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), nextAction, SLOT(setEnabled(bool)));
actionList << nextAction;
QAction *addBookmarkAction = QAction *addBookmarkAction = new QAction(QIcon(QLatin1String(IMAGEPATH "bookmark.png")),
new QAction(QIcon(QLatin1String(":/help/images/bookmark.png")),
tr("Add Bookmark"), this); tr("Add Bookmark"), this);
cmd = am->registerAction(addBookmarkAction, QLatin1String("Help.AddBookmark"), cmd = am->registerAction(addBookmarkAction, QLatin1String("Help.AddBookmark"),
modecontext); modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_M)); cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_M));
connect(addBookmarkAction, SIGNAL(triggered()), this, SLOT(addBookmark()));
// Add Index, Contents, and Context menu items and a separator to the Help menu // Add Index, Contents, and Context menu items and a separator to the Help menu
QAction *indexAction = new QAction(tr("Index"), this); QAction *indexAction = new QAction(tr("Index"), this);
cmd = am->registerAction(indexAction, QLatin1String("Help.Index"), cmd = am->registerAction(indexAction, QLatin1String("Help.Index"), globalcontext);
globalcontext); am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, connect(indexAction, SIGNAL(triggered()), this, SLOT(activateIndex()));
Core::Constants::G_HELP_HELP);
QAction *contentsAction = new QAction(tr("Contents"), this); QAction *contentsAction = new QAction(tr("Contents"), this);
cmd = am->registerAction(contentsAction, QLatin1String("Help.Contents"), cmd = am->registerAction(contentsAction, QLatin1String("Help.Contents"), globalcontext);
globalcontext); am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, connect(contentsAction, SIGNAL(triggered()), this, SLOT(activateContents()));
Core::Constants::G_HELP_HELP);
QAction *searchAction = new QAction(tr("Search"), this);
cmd = am->registerAction(searchAction, QLatin1String("Help.Search"),
globalcontext);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd,
Core::Constants::G_HELP_HELP);
QAction *contextAction = new QAction(tr("Context Help"), this); QAction *contextAction = new QAction(tr("Context Help"), this);
cmd = am->registerAction(contextAction, QLatin1String("Help.Context"), cmd = am->registerAction(contextAction, QLatin1String("Help.Context"), globalcontext);
globalcontext); am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1)); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, connect(contextAction, SIGNAL(triggered()), this, SLOT(activateContext()));
Core::Constants::G_HELP_HELP);
#ifndef Q_WS_MAC #ifndef Q_WS_MAC
QAction *sep = new QAction(this); QAction *sep = new QAction(this);
sep->setSeparator(true); sep->setSeparator(true);
cmd = am->registerAction(sep, QLatin1String("Help.Separator"), globalcontext); cmd = am->registerAction(sep, QLatin1String("Help.Separator"), globalcontext);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
Core::Constants::G_HELP_HELP); actionList << sep;
#endif #endif
m_centralWidget = new Help::Internal::CentralWidget(m_helpEngine);
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(m_centralWidget);
agg->add(new HelpFindSupport(m_centralWidget));
QWidget *mainWidget = new QWidget;
QVBoxLayout *mainWidgetLayout = new QVBoxLayout(mainWidget);
mainWidgetLayout->setMargin(0);
mainWidgetLayout->setSpacing(0);
mainWidgetLayout->addWidget(createToolBar());
mainWidgetLayout->addWidget(m_centralWidget);
m_contentItem = new Core::SideBarItem(m_contentWidget);
m_indexItem = new Core::SideBarItem(m_indexWidget);
m_searchItem = new Core::SideBarItem(m_searchWidget);
m_bookmarkItem = new Core::SideBarItem(m_bookmarkWidget);
QList<Core::SideBarItem*> itemList;
itemList << m_contentItem << m_indexItem << m_searchItem << m_bookmarkItem;
m_sideBar = new Core::SideBar(itemList, QList<Core::SideBarItem*>() << m_indexItem);
QSplitter *splitter = new Core::MiniSplitter;
splitter->setOpaqueResize(false);
splitter->addWidget(m_sideBar);
splitter->addWidget(mainWidget);
splitter->setStretchFactor(0, 0);
splitter->setStretchFactor(1, 1);
splitter->setSizes(QList<int>() << 300 << 300);
m_mode = new HelpMode(splitter, m_centralWidget);
m_mode->setContext(QList<int>() << modecontext);
addAutoReleasedObject(m_mode);
QAction *printAction = new QAction(this); QAction *printAction = new QAction(this);
am->registerAction(printAction, Core::Constants::PRINT, modecontext); am->registerAction(printAction, Core::Constants::PRINT, modecontext);
connect(printAction, SIGNAL(triggered()), m_centralWidget, SLOT(print())); connect(printAction, SIGNAL(triggered()), m_centralWidget, SLOT(print()));
@@ -278,86 +218,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
connect(copyAction, SIGNAL(triggered()), m_centralWidget, SLOT(copy())); connect(copyAction, SIGNAL(triggered()), m_centralWidget, SLOT(copy()));
copyAction->setText(cmd->action()->text()); copyAction->setText(cmd->action()->text());
copyAction->setIcon(cmd->action()->icon()); copyAction->setIcon(cmd->action()->icon());
actionList << copyAction;
QMap<QString, Core::Command*> shortcutMap;
QShortcut *shortcut = new QShortcut(splitter);
shortcut->setWhatsThis(tr("Activate Index in Help mode"));
cmd = am->registerShortcut(shortcut, QLatin1String("Help.IndexShortcut"),
modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_I));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex()));
shortcutMap.insert(m_indexWidget->windowTitle(), cmd);
shortcut = new QShortcut(splitter);
shortcut->setWhatsThis(tr("Activate Contents in Help mode"));
cmd = am->registerShortcut(shortcut, QLatin1String("Help.ContentsShortcut"),
modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_T));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents()));
shortcutMap.insert(m_contentWidget->windowTitle(), cmd);
shortcut = new QShortcut(splitter);
shortcut->setWhatsThis(tr("Activate Search in Help mode"));
cmd = am->registerShortcut(shortcut, QLatin1String("Help.SearchShortcut"),
modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_S));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
shortcutMap.insert(m_searchWidget->windowTitle(), cmd);
shortcutMap.insert(m_bookmarkWidget->windowTitle(), 0);
m_sideBar->setShortcutMap(shortcutMap);
connect(homeAction, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
connect(previousAction, SIGNAL(triggered()), m_centralWidget, SLOT(backward()));
connect(nextAction, SIGNAL(triggered()), m_centralWidget, SLOT(forward()));
connect(addBookmarkAction, SIGNAL(triggered()), this, SLOT(addBookmark()));
connect(m_contentWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(m_indexWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)),
m_centralWidget, SLOT(setSourceInNewTab(QUrl)));
connect(m_bookmarkWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget,
SLOT(setSource(const QUrl&)));
connect(m_centralWidget, SIGNAL(backwardAvailable(bool)),
previousAction, SLOT(setEnabled(bool)));
connect(m_centralWidget, SIGNAL(forwardAvailable(bool)),
nextAction, SLOT(setEnabled(bool)));
connect(m_centralWidget, SIGNAL(addNewBookmark(QString, QString)), this,
SLOT(addNewBookmark(QString, QString)));
QList<QAction*> actionList;
actionList << previousAction
<< nextAction
<< homeAction
#ifndef Q_WS_MAC
<< sep
#endif
<< copyAction;
m_centralWidget->setGlobalActions(actionList);
connect(contextAction, SIGNAL(triggered()), this, SLOT(activateContext()));
connect(indexAction, SIGNAL(triggered()), this, SLOT(activateIndex()));
connect(contentsAction, SIGNAL(triggered()), this, SLOT(activateContents()));
connect(searchAction, SIGNAL(triggered()), this, SLOT(activateSearch()));
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(modeChanged(Core::IMode*)));
connect(m_contentWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(m_indexWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(m_indexWidget, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
m_centralWidget, SLOT(showTopicChooser(QMap<QString, QUrl>, QString)));
previousAction->setEnabled(m_centralWidget->isBackwardAvailable());
nextAction->setEnabled(m_centralWidget->isForwardAvailable());
QDesktopServices::setUrlHandler("qthelp", this, "handleHelpRequest");
if (Core::ActionContainer *advancedMenu = if (Core::ActionContainer *advancedMenu =
am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) { am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
@@ -384,11 +245,17 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT); advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
} }
generalSettingsPage = new GeneralSettingsPage(m_bookmarkManager); Aggregation::Aggregate *agg = new Aggregation::Aggregate;
addAutoReleasedObject(generalSettingsPage); agg->add(m_centralWidget);
connect(generalSettingsPage, SIGNAL(fontChanged()), this, SLOT(fontChanged())); agg->add(new HelpFindSupport(m_centralWidget));
connect(generalSettingsPage, SIGNAL(dialogAccepted()), this, m_mainWidget = new QWidget;
SLOT(checkForGeneralChanges())); QVBoxLayout *mainWidgetLayout = new QVBoxLayout(m_mainWidget);
mainWidgetLayout->setMargin(0);
mainWidgetLayout->setSpacing(0);
mainWidgetLayout->addWidget(createToolBar());
mainWidgetLayout->addWidget(m_centralWidget);
m_centralWidget->setGlobalActions(actionList);
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter(); HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
addAutoReleasedObject(helpIndexFilter); addAutoReleasedObject(helpIndexFilter);
connect(helpIndexFilter, SIGNAL(linkActivated(QUrl)), this, connect(helpIndexFilter, SIGNAL(linkActivated(QUrl)), this,
@@ -396,96 +263,203 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
connect(helpIndexFilter, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)), connect(helpIndexFilter, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
this, SLOT(switchToHelpMode(QMap<QString, QUrl>, QString))); this, SLOT(switchToHelpMode(QMap<QString, QUrl>, QString)));
QDesktopServices::setUrlHandler("qthelp", this, "handleHelpRequest");
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(modeChanged(Core::IMode*)));
addAutoReleasedObject(m_mode = new HelpMode(m_splitter, m_centralWidget));
m_mode->setContext(QList<int>() << modecontext);
return true; return true;
} }
QHelpEngine* HelpPlugin::helpEngine() const void HelpPlugin::extensionsInitialized()
{ {
return m_helpEngine; const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
} .arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
void HelpPlugin::setFilesToRegister(const QStringList &files) QHelpEngineCore *engine = &m_helpManager->helpEngineCore();
{ const QStringList &filters = engine->customFilters();
filesToRegister += files; foreach (const QString &filter, filters) {
} if (filterRegExp.exactMatch(filter) && filter != filterInternal)
engine->removeCustomFilter(filter);
void HelpPlugin::slotRegisterDocumentation()
{
if (isInitialised) {
if (registerDocumentation())
m_helpEngine->setupData();
} }
const QString &docInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
foreach (const QString &ns, engine->registeredDocumentations()) {
if (ns.startsWith(QLatin1String("com.nokia.qtcreator."))
&& ns != docInternal)
m_helpManager->unregisterDocumentation(QStringList() << ns);
}
QStringList filesToRegister;
// Explicitly register qml.qch if located in creator directory. This is only
// needed for the creator-qml package, were we want to ship the documentation
// without a qt development version.
const QString &appPath = QCoreApplication::applicationDirPath();
filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qml.qch"))));
// we might need to register creators inbuild help
filesToRegister.append(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qtcreator.qch")));
// this comes from the installer
const QLatin1String key("AddedDocs");
const QString &addedDocs = engine->customValue(key).toString();
if (!addedDocs.isEmpty()) {
engine->removeCustomValue(key);
filesToRegister += addedDocs.split(QLatin1Char(';'));
}
updateFilterComboBox();
m_helpManager->verifyDocumenation();
m_helpManager->registerDocumentation(filesToRegister);
#if !defined(QT_NO_WEBKIT)
QWebSettings* webSettings = QWebSettings::globalSettings();
QFont font(QApplication::font().family(),
webSettings->fontSize(QWebSettings::DefaultFontSize));
font = qVariantValue<QFont>(engine->customValue(QLatin1String("font"),
font));
webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
#endif
const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
.arg(IDE_VERSION_RELEASE);
engine->setCustomValue(QLatin1String("DefaultHomePage"), url);
connectCentralWidget();
connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox()));
}
void HelpPlugin::shutdown()
{
if (m_sideBar)
m_sideBar->saveSettings(m_core->settings(), QLatin1String("HelpSideBar"));
}
void HelpPlugin::setupUi()
{
// side bar widgets and shortcuts
QList<int> modecontext;
Core::ActionManager *am = m_core->actionManager();
modecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP);
IndexWindow *indexWindow = new IndexWindow();
indexWindow->setWindowTitle(tr("Index"));
m_indexItem = new Core::SideBarItem(indexWindow);
connect(indexWindow, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)), m_centralWidget,
SLOT(showTopicChooser(QMap<QString, QUrl>, QString)));
connect(indexWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget, SLOT(setSource(QUrl)));
QMap<QString, Core::Command*> shortcutMap;
QShortcut *shortcut = new QShortcut(m_splitter);
shortcut->setWhatsThis(tr("Activate Index in Help mode"));
Core::Command* cmd = am->registerShortcut(shortcut, QLatin1String("Help.IndexShortcut"),
modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_I));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex()));
shortcutMap.insert(indexWindow->windowTitle(), cmd);
ContentWindow *contentWindow = new ContentWindow();
contentWindow->setWindowTitle(tr("Contents"));
m_contentItem = new Core::SideBarItem(contentWindow);
connect(contentWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget, SLOT(setSource(QUrl)));
shortcut = new QShortcut(m_splitter);
shortcut->setWhatsThis(tr("Activate Contents in Help mode"));
cmd = am->registerShortcut(shortcut, QLatin1String("Help.ContentsShortcut"), modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_T));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents()));
shortcutMap.insert(contentWindow->windowTitle(), cmd);
SearchWidget *searchWidget = new SearchWidget();
searchWidget->setWindowTitle(tr("Search"));
m_searchItem = new Core::SideBarItem(searchWidget);
connect(searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), m_centralWidget,
SLOT(setSourceInNewTab(QUrl)));
connect(searchWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget, SLOT(setSource(QUrl)));
// TODO: enable and find a proper keysequence as this is ambiguous
// shortcut = new QShortcut(m_splitter);
// shortcut->setWhatsThis(tr("Activate Search in Help mode"));
// cmd = am->registerShortcut(shortcut, QLatin1String("Help.SearchShortcut"), modecontext);
// cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_S));
// connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
// shortcutMap.insert(searchWidget->windowTitle(), cmd);
BookmarkManager *manager = &HelpManager::bookmarkManager();
BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager, 0, false);
bookmarkWidget->setWindowTitle(tr("Bookmarks"));
m_bookmarkItem = new Core::SideBarItem(bookmarkWidget);
connect(bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark()));
connect(bookmarkWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget, SLOT(setSource(QUrl)));
// TODO: enable and find a proper keysequence as this is ambiguous
// shortcut = new QShortcut(m_splitter);
// shortcut->setWhatsThis(tr("Activate Bookmarks in Help mode"));
// cmd = am->registerShortcut(shortcut, QLatin1String("Help.BookmarkShortcut"), modecontext);
// cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_B));
// connect(shortcut, SIGNAL(activated()), this, SLOT(activateBookmarks()));
// shortcutMap.insert(bookmarkWidget->windowTitle(), cmd);
QList<Core::SideBarItem*> itemList;
itemList << m_contentItem << m_indexItem << m_searchItem << m_bookmarkItem;
m_sideBar = new Core::SideBar(itemList, QList<Core::SideBarItem*>() << m_indexItem);
m_sideBar->setShortcutMap(shortcutMap);
m_splitter->setOpaqueResize(false);
m_splitter->addWidget(m_sideBar);
m_splitter->addWidget(m_mainWidget);
m_splitter->setStretchFactor(0, 0);
m_splitter->setStretchFactor(1, 1);
m_splitter->setSizes(QList<int>() << 300 << 300);
m_sideBar->readSettings(m_core->settings(), QLatin1String("HelpSideBar"));
} }
void HelpPlugin::resetFilter() void HelpPlugin::resetFilter()
{ {
const QLatin1String weAddedFilterKey("UnfilteredFilterInserted"); const QLatin1String weAddedFilterKey("UnfilteredFilterInserted");
const QLatin1String previousFilterNameKey("UnfilteredFilterName"); const QLatin1String previousFilterNameKey("UnfilteredFilterName");
if (m_helpEngine->customValue(weAddedFilterKey).toInt() == 1) {
QHelpEngineCore *core = &m_helpManager->helpEngineCore();
if (core->customValue(weAddedFilterKey).toInt() == 1) {
// we added a filter at some point, remove previously added filter // we added a filter at some point, remove previously added filter
const QString &previousFilter = const QString &previousFilter = core->customValue(previousFilterNameKey).toString();
m_helpEngine->customValue(previousFilterNameKey).toString();
if (!previousFilter.isEmpty()) if (!previousFilter.isEmpty())
m_helpEngine->removeCustomFilter(previousFilter); core->removeCustomFilter(previousFilter);
} }
// potentially remove a filter with new name // potentially remove a filter with new name
const QString filterName = tr("Unfiltered"); const QString filterName = tr("Unfiltered");
m_helpEngine->removeCustomFilter(filterName); core->removeCustomFilter(filterName);
m_helpEngine->addCustomFilter(filterName, QStringList()); core->addCustomFilter(filterName, QStringList());
m_helpEngine->setCustomValue(weAddedFilterKey, 1); core->setCustomValue(weAddedFilterKey, 1);
m_helpEngine->setCustomValue(previousFilterNameKey, filterName); core->setCustomValue(previousFilterNameKey, filterName);
m_helpEngine->setCurrentFilter(filterName); (&m_helpManager->helpEngine())->setCurrentFilter(filterName);
} }
bool HelpPlugin::verifiyDocumentation() void HelpPlugin::connectCentralWidget()
{ {
QStringList nameSpacesToUnregister; connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
const QStringList &registeredDocs = m_helpEngine->registeredDocumentations(); SLOT(updateSideBarSource(QUrl)));
foreach (const QString &nameSpace, registeredDocs) { connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
const QString &file = m_helpEngine->documentationFileName(nameSpace); SLOT(updateSideBarSource()));
if (!QFileInfo(file).exists()) connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
nameSpacesToUnregister.append(nameSpace); SLOT(updateViewerComboBoxIndex(int)));
} connect(m_centralWidget, SIGNAL(viewerAboutToBeRemoved(int)), this,
SLOT(removeViewerFromComboBox(int)));
if (!nameSpacesToUnregister.isEmpty()) connect(m_centralWidget, SIGNAL(addNewBookmark(QString, QString)), this,
return unregisterDocumentation(nameSpacesToUnregister); SLOT(addNewBookmark(QString, QString)));
return false; connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this, SLOT(rebuildViewerComboBox()));
}
bool HelpPlugin::registerDocumentation()
{
bool needsSetup = false;
foreach (const QString &file, filesToRegister) {
const QString &nameSpace = m_helpEngine->namespaceName(file);
if (nameSpace.isEmpty())
continue;
if (!m_helpEngine->registeredDocumentations().contains(nameSpace)) {
if (m_helpEngine->registerDocumentation(file)) {
needsSetup = true;
} else {
qWarning() << "Error registering namespace '" << nameSpace
<< "' from file '" << file << "':" << m_helpEngine->error();
}
}
}
filesToRegister.clear();
return needsSetup;
}
bool HelpPlugin::unregisterDocumentation(const QStringList &nameSpaces)
{
bool needsSetup = false;
foreach (const QString &nameSpace, nameSpaces) {
const QString &file = m_helpEngine->documentationFileName(nameSpace);
if (m_helpEngine->unregisterDocumentation(nameSpace)) {
needsSetup = true;
} else {
qWarning() << "Error unregistering namespace '" << nameSpace
<< "' from file '" << file << "': " << m_helpEngine->error();
}
}
return needsSetup;
} }
void HelpPlugin::createRightPaneContextViewer() void HelpPlugin::createRightPaneContextViewer()
@@ -496,13 +470,10 @@ void HelpPlugin::createRightPaneContextViewer()
QAction *switchToHelp = new QAction(tr("Go to Help Mode"), this); QAction *switchToHelp = new QAction(tr("Go to Help Mode"), this);
connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode())); connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode()));
QAction *next = new QAction(QIcon(QLatin1String(":/help/images/next.png")), QAction *next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")),
tr("Next"), this); tr("Next"), this);
connect(next, SIGNAL(triggered()), this, SLOT(rightPaneForward())); QAction *previous = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
QAction *previous = new QAction(QIcon(QLatin1String(":/help/images/previous.png")),
tr("Previous"), this); tr("Previous"), this);
connect(previous, SIGNAL(triggered()), this, SLOT(rightPaneBackward()));
// Dummy layout to align the close button to the right // Dummy layout to align the close button to the right
QHBoxLayout *hboxLayout = new QHBoxLayout(); QHBoxLayout *hboxLayout = new QHBoxLayout();
@@ -549,39 +520,19 @@ void HelpPlugin::createRightPaneContextViewer()
<< m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR), this)); << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR), this));
#if defined(QT_NO_WEBKIT) #if defined(QT_NO_WEBKIT)
QFont font = m_helpViewerForSideBar->font(); m_helpViewerForSideBar->setFont(qVariantValue<QFont>(m_helpManager->helpEngineCore()
font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"), .customValue(QLatin1String("font"), QApplication::font())));
font));
m_helpViewerForSideBar->setFont(font);
#endif #endif
QAction *copyActionSideBar = new QAction(this); QAction *copy = new QAction(this);
Core::Command *cmd = m_core->actionManager()->registerAction(copyActionSideBar, Core::Command *cmd = m_core->actionManager()->registerAction(copy, Core::Constants::COPY,
Core::Constants::COPY, QList<int>() QList<int>() << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR));
<< m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR)); copy->setText(cmd->action()->text());
connect(copyActionSideBar, SIGNAL(triggered()), this, SLOT(copyFromSideBar())); copy->setIcon(cmd->action()->icon());
copyActionSideBar->setText(cmd->action()->text());
copyActionSideBar->setIcon(cmd->action()->icon());
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this, connect(copy, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(copy()));
SLOT(updateSideBarSource(QUrl))); connect(next, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(forward()));
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this, connect(previous, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(backward()));
SLOT(updateSideBarSource()));
}
void HelpPlugin::copyFromSideBar()
{
m_helpViewerForSideBar->copy();
}
void HelpPlugin::rightPaneBackward()
{
m_helpViewerForSideBar->backward();
}
void HelpPlugin::rightPaneForward()
{
m_helpViewerForSideBar->forward();
} }
void HelpPlugin::activateHelpMode() void HelpPlugin::activateHelpMode()
@@ -613,134 +564,23 @@ void HelpPlugin::slotHideRightPane()
Core::RightPaneWidget::instance()->setShown(false); Core::RightPaneWidget::instance()->setShown(false);
} }
void HelpPlugin::extensionsInitialized()
{
m_sideBar->readSettings(m_core->settings(), QLatin1String("HelpSideBar"));
m_helpEngine->setCollectionFile(HelpManager::collectionFilePath());
m_helpEngine->setAutoSaveFilter(false);
const QString &docInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
bool assistantInternalDocRegistered = false;
const QStringList &docs = m_helpEngine->registeredDocumentations();
foreach (const QString &ns, docs) {
if (ns == docInternal) {
assistantInternalDocRegistered = true;
} else if (ns.startsWith(QLatin1String("com.nokia.qtcreator."))) {
m_helpEngine->unregisterDocumentation(ns);
}
}
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
const QStringList &filters = m_helpEngine->customFilters();
foreach (const QString &filter, filters) {
if (filterRegExp.exactMatch(filter) && filter != filterInternal)
m_helpEngine->removeCustomFilter(filter);
}
// Explicitly register qml.qch if located in creator directory. This is only
// needed for the creator-qml package, were we want to ship the documentation
// without a qt development version.
const QString &appPath = QCoreApplication::applicationDirPath();
filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qml.qch"))));
// we might need to register creators inbuild help
if (!assistantInternalDocRegistered) {
filesToRegister.append(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qtcreator.qch")));
}
// this comes from the installer
const QLatin1String key("AddedDocs");
const QString &addedDocs = m_helpEngine->customValue(key).toString();
if (!addedDocs.isEmpty()) {
m_helpEngine->removeCustomValue(key);
filesToRegister += addedDocs.split(QLatin1Char(';'));
}
verifiyDocumentation();
registerDocumentation();
m_bookmarkManager->setupBookmarkModels();
#if !defined(QT_NO_WEBKIT)
QWebSettings* webSettings = QWebSettings::globalSettings();
QFont font(webSettings->fontFamily(QWebSettings::StandardFont),
webSettings->fontSize(QWebSettings::DefaultFontSize));
font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"),
font));
webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
#endif
const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
.arg(IDE_VERSION_RELEASE);
m_helpEngine->setCustomValue(QLatin1String("DefaultHomePage"), url);
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
SLOT(rebuildViewerComboBox()));
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
SLOT(updateViewerComboBoxIndex(int)));
connect(m_centralWidget, SIGNAL(viewerAboutToBeRemoved(int)), this,
SLOT(removeViewerFromComboBox(int)));
// explicit disconnect the full text search indexer, we connect and start
// it later once we really need it, e.g. the full text search is opened...
disconnect(m_helpEngine, SIGNAL(setupFinished()), m_helpEngine->searchEngine(),
SLOT(indexDocumentation()));
connect(m_helpEngine, SIGNAL(setupFinished()), this,
SLOT(updateFilterComboBox()));
connect(m_helpEngine->searchEngine(), SIGNAL(indexingStarted()), this,
SLOT(indexingStarted()));
connect(m_helpEngine->searchEngine(), SIGNAL(indexingFinished()), this,
SLOT(indexingFinished()));
isInitialised = true; // helper for slotRegisterDocumentation()
m_helpEngine->blockSignals(false); // blocked in initialize()
}
void HelpPlugin::shutdown()
{
m_sideBar->saveSettings(m_core->settings(), QLatin1String("HelpSideBar"));
m_bookmarkManager->saveBookmarks();
delete m_bookmarkManager;
}
void HelpPlugin::setIndexFilter(const QString &filter)
{
m_indexWidget->setSearchLineEditText(filter);
}
QString HelpPlugin::indexFilter() const
{
return m_indexWidget->searchLineEditText();
}
void HelpPlugin::modeChanged(Core::IMode *mode) void HelpPlugin::modeChanged(Core::IMode *mode)
{ {
if (mode == m_mode && firstModeChange) { if (mode == m_mode && m_firstModeChange) {
firstModeChange = false; m_firstModeChange = false;
qApp->processEvents(); qApp->processEvents();
qApp->setOverrideCursor(Qt::WaitCursor); qApp->setOverrideCursor(Qt::WaitCursor);
setupUi();
resetFilter(); resetFilter();
m_helpEngine->setupData(); m_helpManager->setupGuiHelpEngine();
connect(m_helpEngine, SIGNAL(setupFinished()), m_helpEngine->searchEngine(),
SLOT(indexDocumentation()));
QMetaObject::invokeMethod(m_helpEngine, "setupFinished", Qt::QueuedConnection);
m_centralWidget->setLastShownPages(); m_centralWidget->setLastShownPages();
qApp->restoreOverrideCursor();
} else if (mode == m_mode && !m_firstModeChange) {
qApp->setOverrideCursor(Qt::WaitCursor);
m_helpManager->setupGuiHelpEngine();
qApp->restoreOverrideCursor(); qApp->restoreOverrideCursor();
} }
} }
@@ -762,7 +602,8 @@ void HelpPlugin::fontChanged()
{ {
#if defined(QT_NO_WEBKIT) #if defined(QT_NO_WEBKIT)
QFont font = qApp->font(); QFont font = qApp->font();
font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"), const QHelpEngineCore &engine = m_helpManager->helpEngineCore();
font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
font)); font));
if (m_helpViewerForSideBar) if (m_helpViewerForSideBar)
@@ -778,6 +619,12 @@ void HelpPlugin::fontChanged()
#endif #endif
} }
void HelpPlugin::setupHelpEngineIfNeeded()
{
if (Core::ICore::instance()->modeManager()->currentMode() == m_mode)
m_helpManager->setupGuiHelpEngine();
}
void HelpPlugin::rebuildViewerComboBox() void HelpPlugin::rebuildViewerComboBox()
{ {
m_documentsCombo->clear(); m_documentsCombo->clear();
@@ -803,36 +650,14 @@ void HelpPlugin::updateViewerComboBoxIndex(int index)
m_documentsCombo->setCurrentIndex(index); m_documentsCombo->setCurrentIndex(index);
} }
void HelpPlugin::indexingStarted()
{
Q_ASSERT(!m_progress);
m_progress = new QFutureInterface<void>();
Core::ICore::instance()->progressManager() ->addTask(m_progress->future(),
tr("Indexing"), QLatin1String("Help.Indexer"));
m_progress->setProgressRange(0, 2);
m_progress->setProgressValueAndText(1, tr("Indexing Documentation..."));
m_progress->reportStarted();
m_watcher.setFuture(m_progress->future());
connect(&m_watcher, SIGNAL(canceled()), m_helpEngine->searchEngine(),
SLOT(cancelIndexing()));
}
void HelpPlugin::indexingFinished()
{
m_progress->reportFinished();
delete m_progress;
m_progress = NULL;
}
HelpViewer* HelpPlugin::viewerForContextMode() HelpViewer* HelpPlugin::viewerForContextMode()
{ {
using namespace Core; using namespace Core;
bool showSideBySide = false; bool showSideBySide = false;
const QHelpEngineCore &engine = m_helpManager->helpEngineCore();
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current(); RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
switch (m_helpEngine->customValue(QLatin1String("ContextHelpOption"), 0).toInt()) { switch (engine.customValue(QLatin1String("ContextHelpOption"), 0).toInt()) {
case 0: { case 0: {
// side by side if possible // side by side if possible
if (IEditor *editor = EditorManager::instance()->currentEditor()) { if (IEditor *editor = EditorManager::instance()->currentEditor()) {
@@ -887,7 +712,7 @@ void HelpPlugin::activateContext()
// Find out what to show // Find out what to show
if (IContext *context = m_core->currentContextObject()) { if (IContext *context = m_core->currentContextObject()) {
id = context->contextHelpId(); id = context->contextHelpId();
links = HelpManager::helpEngineCore().linksForIdentifier(id); links = m_helpManager->helpEngineCore().linksForIdentifier(id);
} }
if (HelpViewer* viewer = viewerForContextMode()) { if (HelpViewer* viewer = viewerForContextMode()) {
@@ -935,8 +760,6 @@ QToolBar *HelpPlugin::createToolBar()
toolWidget->addAction(am->command(QLatin1String("Help.Next"))->action()); toolWidget->addAction(am->command(QLatin1String("Help.Next"))->action());
toolWidget->addSeparator(); toolWidget->addSeparator();
toolWidget->addAction(am->command(QLatin1String("Help.AddBookmark"))->action()); toolWidget->addAction(am->command(QLatin1String("Help.AddBookmark"))->action());
//int size = toolWidget->style()->pixelMetric(QStyle::PM_SmallIconSize);
//toolWidget->setIconSize(QSize(size, size));
toolWidget->setMovable(false); toolWidget->setMovable(false);
toolWidget->addSeparator(); toolWidget->addSeparator();
@@ -967,35 +790,21 @@ QToolBar *HelpPlugin::createToolBar()
void HelpPlugin::updateFilterComboBox() void HelpPlugin::updateFilterComboBox()
{ {
const QHelpEngine &engine = m_helpManager->helpEngine();
QString curFilter = m_filterComboBox->currentText(); QString curFilter = m_filterComboBox->currentText();
if (curFilter.isEmpty()) if (curFilter.isEmpty())
curFilter = m_helpEngine->currentFilter(); curFilter = engine.currentFilter();
m_filterComboBox->clear(); m_filterComboBox->clear();
m_filterComboBox->addItems(m_helpEngine->customFilters()); m_filterComboBox->addItems(engine.customFilters());
int idx = m_filterComboBox->findText(curFilter); int idx = m_filterComboBox->findText(curFilter);
if (idx < 0) if (idx < 0)
idx = 0; idx = 0;
m_filterComboBox->setCurrentIndex(idx); m_filterComboBox->setCurrentIndex(idx);
} }
void HelpPlugin::checkForHelpChanges()
{
bool changed = unregisterDocumentation(m_docSettingsPage->docsToUnregister());
filesToRegister += m_docSettingsPage->docsToRegister();
changed |= registerDocumentation();
if (changed)
m_helpEngine->setupData();
}
void HelpPlugin::checkForGeneralChanges()
{
if (generalSettingsPage->applyChanges())
m_helpEngine->setupData();
}
void HelpPlugin::filterDocumentation(const QString &customFilter) void HelpPlugin::filterDocumentation(const QString &customFilter)
{ {
m_helpEngine->setCurrentFilter(customFilter); (&m_helpManager->helpEngine())->setCurrentFilter(customFilter);
} }
void HelpPlugin::addBookmark() void HelpPlugin::addBookmark()
@@ -1009,12 +818,13 @@ void HelpPlugin::addNewBookmark(const QString &title, const QString &url)
if (url.isEmpty() || url == QLatin1String("about:blank")) if (url.isEmpty() || url == QLatin1String("about:blank"))
return; return;
m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, url); BookmarkManager *manager = &HelpManager::bookmarkManager();
manager->showBookmarkDialog(m_centralWidget, title, url);
} }
void HelpPlugin::handleHelpRequest(const QString &address) void HelpPlugin::handleHelpRequest(const QString &address)
{ {
if (m_helpEngine->findFile(address).isValid()) { if (m_helpManager->helpEngineCore().findFile(address).isValid()) {
const QUrl url(address); const QUrl url(address);
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) { if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
if (HelpViewer* viewer = viewerForContextMode()) if (HelpViewer* viewer = viewerForContextMode())

View File

@@ -30,29 +30,22 @@
#define HELPPLUGIN_H #define HELPPLUGIN_H
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <QtCore/QFutureInterface>
#include <QtCore/QFutureWatcher>
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QStringList> #include <QtCore/QStringList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAction; class QAction;
class QComboBox; class QComboBox;
class QHelpEngine;
class QToolBar; class QToolBar;
class QUrl; class QUrl;
QT_END_NAMESPACE QT_END_NAMESPACE
class IndexWindow;
class ContentWindow;
class BookmarkManager;
class BookmarkWidget;
class HelpViewer; class HelpViewer;
namespace Core { namespace Core {
class ICore; class ICore;
class IMode; class IMode;
class MiniSplitter;
class SideBar; class SideBar;
class SideBarItem; class SideBarItem;
} // Core } // Core
@@ -80,16 +73,7 @@ public:
void extensionsInitialized(); void extensionsInitialized();
void shutdown(); void shutdown();
// Necessary to get the unfiltered list in the help index filter
void setIndexFilter(const QString &filter);
QString indexFilter() const;
QHelpEngine* helpEngine() const;
void setFilesToRegister(const QStringList &files);
public slots: public slots:
void slotRegisterDocumentation();
void handleHelpRequest(const QString &url); void handleHelpRequest(const QString &url);
private slots: private slots:
@@ -98,55 +82,41 @@ private slots:
void activateIndex(); void activateIndex();
void activateContents(); void activateContents();
void activateSearch(); void activateSearch();
void checkForHelpChanges();
void checkForGeneralChanges();
void updateFilterComboBox(); void updateFilterComboBox();
void filterDocumentation(const QString &customFilter); void filterDocumentation(const QString &customFilter);
void addBookmark(); void addBookmark();
void addNewBookmark(const QString &title, const QString &url); void addNewBookmark(const QString &title, const QString &url);
void rightPaneBackward();
void rightPaneForward();
void switchToHelpMode(); void switchToHelpMode();
void switchToHelpMode(const QUrl &source); void switchToHelpMode(const QUrl &source);
void switchToHelpMode(const QMap<QString, QUrl> &urls, const QString &keyword); void switchToHelpMode(const QMap<QString, QUrl> &urls, const QString &keyword);
void slotHideRightPane(); void slotHideRightPane();
void copyFromSideBar();
void updateSideBarSource(); void updateSideBarSource();
void updateSideBarSource(const QUrl &newUrl); void updateSideBarSource(const QUrl &newUrl);
void fontChanged(); void fontChanged();
void setupHelpEngineIfNeeded();
void rebuildViewerComboBox(); void rebuildViewerComboBox();
void removeViewerFromComboBox(int index); void removeViewerFromComboBox(int index);
void updateViewerComboBoxIndex(int index); void updateViewerComboBoxIndex(int index);
void indexingStarted();
void indexingFinished();
private: private:
void setupUi();
void resetFilter(); void resetFilter();
bool verifiyDocumentation(); void activateHelpMode();
bool registerDocumentation(); QToolBar *createToolBar();
bool unregisterDocumentation(const QStringList &nameSpaces); void connectCentralWidget();
HelpViewer* viewerForContextMode();
void createRightPaneContextViewer();
private: private:
QToolBar *createToolBar(); HelpMode *m_mode;
void createRightPaneContextViewer();
void activateHelpMode();
HelpViewer* viewerForContextMode();
Core::ICore *m_core; Core::ICore *m_core;
QHelpEngine *m_helpEngine; QWidget *m_mainWidget;
ContentWindow *m_contentWidget;
IndexWindow *m_indexWidget;
BookmarkWidget *m_bookmarkWidget;
BookmarkManager *m_bookmarkManager;
SearchWidget *m_searchWidget;
CentralWidget *m_centralWidget; CentralWidget *m_centralWidget;
HelpViewer *m_helpViewerForSideBar; HelpViewer *m_helpViewerForSideBar;
HelpMode *m_mode;
Core::SideBarItem *m_contentItem; Core::SideBarItem *m_contentItem;
Core::SideBarItem *m_indexItem; Core::SideBarItem *m_indexItem;
@@ -155,20 +125,15 @@ private:
DocSettingsPage *m_docSettingsPage; DocSettingsPage *m_docSettingsPage;
FilterSettingsPage *m_filterSettingsPage; FilterSettingsPage *m_filterSettingsPage;
GeneralSettingsPage *generalSettingsPage; GeneralSettingsPage *m_generalSettingsPage;
QComboBox *m_documentsCombo; QComboBox *m_documentsCombo;
QComboBox *m_filterComboBox; QComboBox *m_filterComboBox;
Core::SideBar *m_sideBar; Core::SideBar *m_sideBar;
HelpManager *helpManager; bool m_firstModeChange;
QStringList filesToRegister; HelpManager *m_helpManager;
Core::MiniSplitter *m_splitter;
QFutureWatcher<void> m_watcher;
QFutureInterface<void> *m_progress;
bool isInitialised;
bool firstModeChange;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -28,6 +28,10 @@
**************************************************************************/ **************************************************************************/
#include "searchwidget.h" #include "searchwidget.h"
#include "helpmanager.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QString> #include <QtCore/QString>
@@ -40,39 +44,18 @@
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QTextBrowser> #include <QtGui/QTextBrowser>
#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpSearchEngine> #include <QtHelp/QHelpSearchEngine>
#include <QtHelp/QHelpSearchQueryWidget> #include <QtHelp/QHelpSearchQueryWidget>
#include <QtHelp/QHelpSearchResultWidget> #include <QtHelp/QHelpSearchResultWidget>
using namespace Help::Internal; using namespace Help::Internal;
SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) SearchWidget::SearchWidget()
: QWidget(parent) : zoomCount(0)
, zoomCount(0) , m_progress(0)
, searchEngine(engine) , searchEngine(0)
{ {
QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setMargin(4);
resultWidget = searchEngine->resultWidget();
QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget();
vLayout->addWidget(queryWidget);
vLayout->addWidget(resultWidget);
setFocusProxy(queryWidget);
connect(queryWidget, SIGNAL(search()), this, SLOT(search()));
connect(resultWidget, SIGNAL(requestShowLink(QUrl)), this,
SIGNAL(requestShowLink(QUrl)));
connect(searchEngine, SIGNAL(searchingStarted()), this,
SLOT(searchingStarted()));
connect(searchEngine, SIGNAL(searchingFinished(int)), this,
SLOT(searchingFinished(int)));
QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget);
browser->viewport()->installEventFilter(this);
} }
SearchWidget::~SearchWidget() SearchWidget::~SearchWidget()
@@ -109,6 +92,43 @@ void SearchWidget::resetZoom()
} }
} }
void SearchWidget::showEvent(QShowEvent *event)
{
if (!event->spontaneous() && !searchEngine) {
QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setMargin(4);
searchEngine = (&HelpManager::helpEngine())->searchEngine();
resultWidget = searchEngine->resultWidget();
QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget();
vLayout->addWidget(queryWidget);
vLayout->addWidget(resultWidget);
setFocusProxy(queryWidget);
connect(queryWidget, SIGNAL(search()), this, SLOT(search()));
connect(resultWidget, SIGNAL(requestShowLink(QUrl)), this,
SIGNAL(requestShowLink(QUrl)));
connect(searchEngine, SIGNAL(searchingStarted()), this,
SLOT(searchingStarted()));
connect(searchEngine, SIGNAL(searchingFinished(int)), this,
SLOT(searchingFinished(int)));
QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget);
browser->viewport()->installEventFilter(this);
connect(searchEngine, SIGNAL(indexingStarted()), this,
SLOT(indexingStarted()));
connect(searchEngine, SIGNAL(indexingFinished()), this,
SLOT(indexingFinished()));
QMetaObject::invokeMethod(&HelpManager::helpEngine(), "setupFinished",
Qt::QueuedConnection);
}
}
void SearchWidget::search() const void SearchWidget::search() const
{ {
QList<QHelpSearchQuery> query = searchEngine->queryWidget()->query(); QList<QHelpSearchQuery> query = searchEngine->queryWidget()->query();
@@ -126,6 +146,28 @@ void SearchWidget::searchingFinished(int hits)
qApp->restoreOverrideCursor(); qApp->restoreOverrideCursor();
} }
void SearchWidget::indexingStarted()
{
Q_ASSERT(!m_progress);
m_progress = new QFutureInterface<void>();
Core::ICore::instance()->progressManager() ->addTask(m_progress->future(),
tr("Indexing"), QLatin1String("Help.Indexer"));
m_progress->setProgressRange(0, 2);
m_progress->setProgressValueAndText(1, tr("Indexing Documentation..."));
m_progress->reportStarted();
m_watcher.setFuture(m_progress->future());
connect(&m_watcher, SIGNAL(canceled()), searchEngine, SLOT(cancelIndexing()));
}
void SearchWidget::indexingFinished()
{
m_progress->reportFinished();
delete m_progress;
m_progress = NULL;
}
bool SearchWidget::eventFilter(QObject* o, QEvent *e) bool SearchWidget::eventFilter(QObject* o, QEvent *e)
{ {
QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget);

View File

@@ -30,18 +30,15 @@
#ifndef SEARCHWIDGET_H #ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H #define SEARCHWIDGET_H
#include <QtCore/QUrl> #include <QtCore/QFutureInterface>
#include <QtCore/QPoint> #include <QtCore/QFutureWatcher>
#include <QtGui/QWidget> #include <QtGui/QWidget>
QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QHelpSearchEngine)
QT_FORWARD_DECLARE_CLASS(QHelpSearchResultWidget)
class QMouseEvent; QT_FORWARD_DECLARE_CLASS(QMouseEvent)
class QHelpSearchEngine; QT_FORWARD_DECLARE_CLASS(QUrl)
class QHelpSearchResultWidget;
QT_END_NAMESPACE
namespace Help { namespace Help {
namespace Internal { namespace Internal {
@@ -51,7 +48,7 @@ class SearchWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
SearchWidget(QHelpSearchEngine *engine, QWidget *parent = 0); SearchWidget();
~SearchWidget(); ~SearchWidget();
void zoomIn(); void zoomIn();
@@ -63,11 +60,18 @@ signals:
void requestShowLinkInNewTab(const QUrl &url); void requestShowLinkInNewTab(const QUrl &url);
void escapePressed(); void escapePressed();
protected:
void showEvent(QShowEvent *event);
private slots: private slots:
void search() const; void search() const;
void searchingStarted(); void searchingStarted();
void searchingFinished(int hits); void searchingFinished(int hits);
void indexingStarted();
void indexingFinished();
private: private:
bool eventFilter(QObject* o, QEvent *e); bool eventFilter(QObject* o, QEvent *e);
void keyPressEvent(QKeyEvent *keyEvent); void keyPressEvent(QKeyEvent *keyEvent);
@@ -75,6 +79,10 @@ private:
private: private:
int zoomCount; int zoomCount;
QFutureWatcher<void> m_watcher;
QFutureInterface<void> *m_progress;
QHelpSearchEngine *searchEngine; QHelpSearchEngine *searchEngine;
QHelpSearchResultWidget *resultWidget; QHelpSearchResultWidget *resultWidget;
}; };

View File

@@ -605,11 +605,11 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const
// #pragma mark -- BookmarkManager // #pragma mark -- BookmarkManager
BookmarkManager::BookmarkManager(QHelpEngineCore* _helpEngine) : BookmarkManager::BookmarkManager()
m_folderIcon(QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon)), : m_folderIcon(QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon))
m_bookmarkIcon(QLatin1String(":/help/images/bookmark.png")), , m_bookmarkIcon(QLatin1String(":/help/images/bookmark.png"))
treeModel(new BookmarkModel(0, 1, this)), , treeModel(new BookmarkModel(0, 1, this))
listModel(new BookmarkModel(0, 1, this)) , listModel(new BookmarkModel(0, 1, this))
{ {
connect(treeModel, SIGNAL(itemChanged(QStandardItem*)), this, connect(treeModel, SIGNAL(itemChanged(QStandardItem*)), this,
SLOT(itemChanged(QStandardItem*))); SLOT(itemChanged(QStandardItem*)));

View File

@@ -51,7 +51,6 @@ class QLineEdit;
class QTreeView; class QTreeView;
class QToolButton; class QToolButton;
class QStandardItem; class QStandardItem;
class QHelpEngineCore;
class QAbstractItemModel; class QAbstractItemModel;
class QSortFilterProxyModel; class QSortFilterProxyModel;
@@ -158,7 +157,7 @@ class BookmarkManager : public QObject
Q_OBJECT Q_OBJECT
public: public:
BookmarkManager(QHelpEngineCore *helpEngine); BookmarkManager();
~BookmarkManager(); ~BookmarkManager();
BookmarkModel *treeBookmarkModel() const; BookmarkModel *treeBookmarkModel() const;

View File

@@ -39,7 +39,7 @@
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpContentWidget> #include <QtHelp/QHelpContentWidget>
ContentWindow::ContentWindow(QHelpEngine *helpEngine) ContentWindow::ContentWindow()
: m_contentWidget(0) : m_contentWidget(0)
, m_expandDepth(-2) , m_expandDepth(-2)
{ {

View File

@@ -36,7 +36,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QHelpEngine;
class QHelpContentItem; class QHelpContentItem;
class QHelpContentWidget; class QHelpContentWidget;
@@ -47,7 +46,7 @@ class ContentWindow : public QWidget
Q_OBJECT Q_OBJECT
public: public:
ContentWindow(QHelpEngine *helpEngine); ContentWindow();
~ContentWindow(); ~ContentWindow();
bool syncToContent(const QUrl &url); bool syncToContent(const QUrl &url);

View File

@@ -43,9 +43,8 @@
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexWidget> #include <QtHelp/QHelpIndexWidget>
IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent) IndexWindow::IndexWindow()
: QWidget(parent) : m_searchLineEdit(0)
, m_searchLineEdit(0)
, m_indexWidget(0) , m_indexWidget(0)
{ {
QVBoxLayout *layout = new QVBoxLayout(this); QVBoxLayout *layout = new QVBoxLayout(this);

View File

@@ -37,7 +37,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QHelpIndexWidget; class QHelpIndexWidget;
class QHelpEngine;
class QModelIndex; class QModelIndex;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -47,7 +46,7 @@ class IndexWindow : public QWidget
Q_OBJECT Q_OBJECT
public: public:
IndexWindow(QHelpEngine *helpEngine, QWidget *parent = 0); IndexWindow();
~IndexWindow(); ~IndexWindow();
void setSearchLineEditText(const QString &text); void setSearchLineEditText(const QString &text);