Implement tabless help mode, behaves now like edit mode.

This commit is contained in:
kh1
2010-03-30 17:44:28 +02:00
parent a8801d15c5
commit edcefd69ad
19 changed files with 563 additions and 1803 deletions

View File

@@ -28,6 +28,7 @@
**************************************************************************/ **************************************************************************/
#include "centralwidget.h" #include "centralwidget.h"
#include "helpmanager.h" #include "helpmanager.h"
#include "helpviewer.h" #include "helpviewer.h"
#include "topicchooser.h" #include "topicchooser.h"
@@ -35,88 +36,36 @@
#include <QtCore/QEvent> #include <QtCore/QEvent>
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QMenu> #include <QtGui/QKeyEvent>
#include <QtGui/QLabel>
#include <QtGui/QLayout> #include <QtGui/QLayout>
#include <QtGui/QPrinter>
#include <QtGui/QLineEdit>
#include <QtGui/QCheckBox>
#include <QtGui/QTabBar>
#include <QtGui/QTabWidget>
#include <QtGui/QToolButton>
#include <QtGui/QMouseEvent>
#include <QtGui/QFocusEvent>
#include <QtGui/QMainWindow>
#include <QtGui/QSpacerItem>
#include <QtGui/QTextCursor>
#include <QtGui/QPrintDialog>
#include <QtGui/QApplication>
#include <QtGui/QTextDocumentFragment>
#include <QtGui/QPrintPreviewDialog>
#include <QtGui/QPageSetupDialog> #include <QtGui/QPageSetupDialog>
#include <QtGui/QPrinter>
#include <QtGui/QPrintDialog>
#include <QtGui/QPrintPreviewDialog>
#include <QtGui/QStackedWidget>
#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngineCore>
#include <QtHelp/QHelpSearchEngine>
#include <coreplugin/coreconstants.h>
using namespace Help::Internal; using namespace Help::Internal;
namespace { CentralWidget *gStaticCentralWidget = 0;
HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget,
const QPoint &point) // -- CentralWidget
{
QTabBar *tabBar = qFindChild<QTabBar*>(widget);
for (int i = 0; i < tabBar->count(); ++i) {
if (tabBar->tabRect(i).contains(point))
return qobject_cast<HelpViewer*>(widget->widget(i));
}
return 0;
}
Help::Internal::CentralWidget *staticCentralWidget = 0;
}
CentralWidget::CentralWidget(QWidget *parent) CentralWidget::CentralWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, findBar(0)
, tabWidget(0)
, printer(0) , printer(0)
, m_stackedWidget(0)
{ {
lastTabPage = 0; Q_ASSERT(!gStaticCentralWidget);
globalActionList.clear(); gStaticCentralWidget = this;
tabWidget = new QTabWidget;
tabWidget->setDocumentMode(true);
tabWidget->setMovable(true);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
connect(tabWidget, SIGNAL(currentChanged(int)), this,
SLOT(currentPageChanged(int)));
QToolButton *newTabButton = new QToolButton(this);
newTabButton->setAutoRaise(true);
newTabButton->setToolTip(tr("Add new page"));
newTabButton->setIcon(QIcon(
#ifdef Q_OS_MAC
QLatin1String(":/trolltech/assistant/images/mac/addtab.png")));
#else
QLatin1String(":/trolltech/assistant/images/win/addtab.png")));
#endif
tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner);
connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab()));
QVBoxLayout *vboxLayout = new QVBoxLayout(this); QVBoxLayout *vboxLayout = new QVBoxLayout(this);
vboxLayout->setMargin(0); vboxLayout->setMargin(0);
vboxLayout->addWidget(tabWidget); m_stackedWidget = new QStackedWidget(this);
vboxLayout->addWidget(m_stackedWidget);
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
if (tabBar) {
tabBar->installEventFilter(this);
tabBar->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this,
SLOT(showTabBarContextMenu(QPoint)));
}
staticCentralWidget = this;
} }
CentralWidget::~CentralWidget() CentralWidget::~CentralWidget()
@@ -125,210 +74,186 @@ CentralWidget::~CentralWidget()
delete printer; delete printer;
#endif #endif
QString zoomCount; QString zoomFactors;
QString currentPages; QString currentPages;
for (int i = 0; i < tabWidget->count(); ++i) { for (int i = 0; i < m_stackedWidget->count(); ++i) {
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i)); const HelpViewer * const viewer = viewerAt(i);
if (viewer && viewer->source().isValid()) { const QUrl &source = viewer->source();
currentPages += (viewer->source().toString() + QLatin1Char('|')); if (source.isValid()) {
zoomCount += QString::number(viewer->zoom()) + QLatin1Char('|'); currentPages += source.toString() + QLatin1Char('|');
zoomFactors += QString::number(viewer->scale()) + QLatin1Char('|');
} }
} }
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); QHelpEngineCore *engine = &HelpManager::helpEngineCore();
engine->setCustomValue(QLatin1String("LastTabPage"), lastTabPage);
engine->setCustomValue(QLatin1String("LastShownPages"), currentPages); engine->setCustomValue(QLatin1String("LastShownPages"), currentPages);
engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomCount); engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors);
engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex());
} }
CentralWidget *CentralWidget::instance() CentralWidget *CentralWidget::instance()
{ {
return staticCentralWidget; Q_ASSERT(gStaticCentralWidget);
return gStaticCentralWidget;
} }
void CentralWidget::newTab() bool CentralWidget::hasSelection() const
{ {
HelpViewer* viewer = currentHelpViewer(); if (HelpViewer* viewer = currentHelpViewer())
#if !defined(QT_NO_WEBKIT) return !viewer->selectedText().isEmpty();
if (viewer && viewer->hasLoadFinished()) return false;
#else }
bool CentralWidget::isForwardAvailable() const
{
const HelpViewer* viewer = currentHelpViewer();
if (viewer) if (viewer)
#endif return viewer->isForwardAvailable();
setSourceInNewTab(viewer->source());
return false;
}
bool CentralWidget::isBackwardAvailable() const
{
const HelpViewer* viewer = currentHelpViewer();
if (viewer)
return viewer->isBackwardAvailable();
return false;
}
HelpViewer* CentralWidget::viewerAt(int index) const
{
return qobject_cast<HelpViewer*> (m_stackedWidget->widget(index));
}
HelpViewer* CentralWidget::currentHelpViewer() const
{
return qobject_cast<HelpViewer*> (m_stackedWidget->currentWidget());
}
void CentralWidget::addPage(HelpViewer *page, bool fromSearch)
{
page->installEventFilter(this);
page->setFocus(Qt::OtherFocusReason);
connectSignals(page);
m_stackedWidget->addWidget(page);
if (fromSearch) {
connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms()));
}
}
void CentralWidget::removePage(int index)
{
const bool currentChanged = (index == currentIndex());
m_stackedWidget->removeWidget(m_stackedWidget->widget(index));
if (currentChanged)
emit currentViewerChanged();
}
int CentralWidget::currentIndex() const
{
return m_stackedWidget->currentIndex();
}
void CentralWidget::setCurrentPage(HelpViewer *page)
{
m_stackedWidget->setCurrentWidget(page);
emit currentViewerChanged();
}
bool CentralWidget::find(const QString &txt, Find::IFindSupport::FindFlags flags,
bool incremental)
{
return currentHelpViewer()->findText(txt, flags, incremental, false);
}
// -- public slots
void CentralWidget::copy()
{
if (HelpViewer* viewer = currentHelpViewer())
viewer->copy();
}
void CentralWidget::home()
{
if (HelpViewer* viewer = currentHelpViewer())
viewer->home();
} }
void CentralWidget::zoomIn() void CentralWidget::zoomIn()
{ {
HelpViewer* viewer = currentHelpViewer(); HelpViewer* viewer = currentHelpViewer();
if (viewer) if (viewer)
viewer->zoomIn(); viewer->scaleUp();
} }
void CentralWidget::zoomOut() void CentralWidget::zoomOut()
{ {
HelpViewer* viewer = currentHelpViewer(); HelpViewer* viewer = currentHelpViewer();
if (viewer) if (viewer)
viewer->zoomOut(); viewer->scaleDown();
}
void CentralWidget::nextPage()
{
int index = tabWidget->currentIndex() + 1;
if (index >= tabWidget->count())
index = 0;
tabWidget->setCurrentIndex(index);
} }
void CentralWidget::resetZoom() void CentralWidget::resetZoom()
{ {
HelpViewer* viewer = currentHelpViewer(); HelpViewer* viewer = currentHelpViewer();
if (viewer) if (viewer)
viewer->resetZoom(); viewer->resetScale();
}
void CentralWidget::forward()
{
if (HelpViewer* viewer = currentHelpViewer())
viewer->forward();
}
void CentralWidget::nextPage()
{
m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() + 1)
% m_stackedWidget->count());
}
void CentralWidget::backward()
{
if (HelpViewer* viewer = currentHelpViewer())
viewer->backward();
} }
void CentralWidget::previousPage() void CentralWidget::previousPage()
{ {
int index = tabWidget->currentIndex() -1; m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() - 1)
if (index < 0) % m_stackedWidget->count());
index = tabWidget->count() -1;
tabWidget->setCurrentIndex(index);
}
void CentralWidget::closeTab()
{
closeTab(tabWidget->currentIndex());
}
void CentralWidget::closeTab(int index)
{
HelpViewer* viewer = helpViewerAtIndex(index);
if (!viewer || tabWidget->count() == 1)
return;
emit viewerAboutToBeRemoved(index);
tabWidget->removeTab(index);
emit viewerRemoved(index);
QTimer::singleShot(0, viewer, SLOT(deleteLater()));
}
void CentralWidget::setSource(const QUrl &url)
{
HelpViewer* viewer = currentHelpViewer();
HelpViewer* lastViewer =
qobject_cast<HelpViewer*>(tabWidget->widget(lastTabPage));
if (!viewer && !lastViewer) {
viewer = new HelpViewer(this, this);
viewer->installEventFilter(this);
lastTabPage = tabWidget->addTab(viewer, QString());
tabWidget->setCurrentIndex(lastTabPage);
connectSignals();
qApp->processEvents();
} else {
viewer = lastViewer;
}
viewer->setSource(url);
currentPageChanged(lastTabPage);
viewer->setFocus(Qt::OtherFocusReason);
tabWidget->setCurrentIndex(lastTabPage);
tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle()));
}
void CentralWidget::setLastShownPages()
{
const QHelpEngineCore &engine = HelpManager::helpEngineCore();
QString value = engine.customValue(QLatin1String("LastShownPages"),
QString()).toString();
const QStringList lastShownPageList = value.split(QLatin1Char('|'),
QString::SkipEmptyParts);
const int pageCount = lastShownPageList.count();
QString homePage = engine.customValue(QLatin1String("DefaultHomePage"),
QLatin1String("about:blank")).toString();
int option = engine.customValue(QLatin1String("StartOption"), 2).toInt();
if (option == 0 || option == 1 || pageCount <= 0) {
if (option == 0) {
homePage = engine.customValue(QLatin1String("HomePage"),
homePage).toString();
} else if (option == 1) {
homePage = QLatin1String("about:blank");
}
setSource(homePage);
return;
}
value = engine.customValue(QLatin1String("LastShownPagesZoom"),
QString()).toString();
QVector<QString> zoomVector = value.split(QLatin1Char('|'),
QString::SkipEmptyParts).toVector();
const int zoomCount = zoomVector.count();
zoomVector.insert(zoomCount, pageCount - zoomCount, QLatin1String("0"));
QVector<QString>::const_iterator zIt = zoomVector.constBegin();
QStringList::const_iterator it = lastShownPageList.constBegin();
for (; it != lastShownPageList.constEnd(); ++it, ++zIt)
setSourceInNewTab((*it), (*zIt).toInt());
int tab = engine.customValue(QLatin1String("LastTabPage"), 0).toInt();
tabWidget->setCurrentIndex(tab);
}
bool CentralWidget::hasSelection() const
{
const HelpViewer* viewer = currentHelpViewer();
return viewer ? viewer->hasSelection() : false;
}
QUrl CentralWidget::currentSource() const
{
const HelpViewer* viewer = currentHelpViewer();
if (viewer)
return viewer->source();
return QUrl();
}
QString CentralWidget::currentTitle() const
{
const HelpViewer* viewer = currentHelpViewer();
if (viewer)
return viewer->documentTitle();
return QString();
}
void CentralWidget::initPrinter()
{
#ifndef QT_NO_PRINTER
if (!printer)
printer = new QPrinter(QPrinter::HighResolution);
#endif
} }
void CentralWidget::print() void CentralWidget::print()
{ {
#ifndef QT_NO_PRINTER #ifndef QT_NO_PRINTER
HelpViewer* viewer = currentHelpViewer(); if (HelpViewer* viewer = currentHelpViewer()) {
if (!viewer) initPrinter();
return;
initPrinter(); QPrintDialog *dlg = new QPrintDialog(printer, this);
dlg->setWindowTitle(tr("Print Document"));
if (!viewer->selectedText().isEmpty())
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
dlg->addEnabledOption(QAbstractPrintDialog::PrintPageRange);
dlg->addEnabledOption(QAbstractPrintDialog::PrintCollateCopies);
QPrintDialog *dlg = new QPrintDialog(printer, this); if (dlg->exec() == QDialog::Accepted)
#if defined(QT_NO_WEBKIT) viewer->print(printer);
if (viewer->textCursor().hasSelection()) delete dlg;
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
#endif
dlg->addEnabledOption(QAbstractPrintDialog::PrintPageRange);
dlg->addEnabledOption(QAbstractPrintDialog::PrintCollateCopies);
dlg->setWindowTitle(tr("Print Document"));
if (dlg->exec() == QDialog::Accepted) {
viewer->print(printer);
} }
delete dlg; #endif
}
void CentralWidget::pageSetup()
{
#ifndef QT_NO_PRINTER
initPrinter();
QPageSetupDialog dlg(printer);
dlg.exec();
#endif #endif
} }
@@ -343,6 +268,76 @@ void CentralWidget::printPreview()
#endif #endif
} }
void CentralWidget::setSource(const QUrl &url)
{
if (HelpViewer* viewer = currentHelpViewer()) {
viewer->setSource(url);
viewer->setFocus(Qt::OtherFocusReason);
}
}
void CentralWidget::setSourceFromSearch(const QUrl &url)
{
if (HelpViewer* viewer = currentHelpViewer()) {
connect(viewer, SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms()));
viewer->setSource(url);
viewer->setFocus(Qt::OtherFocusReason);
}
}
void CentralWidget::showTopicChooser(const QMap<QString, QUrl> &links,
const QString &keyword)
{
TopicChooser tc(this, keyword, links);
if (tc.exec() == QDialog::Accepted)
setSource(tc.link());
}
// -- protected
void CentralWidget::focusInEvent(QFocusEvent * /* event */)
{
// If we have a current help viewer then this is the 'focus proxy',
// otherwise it's the central widget. This is needed, so an embedding
// program can just set the focus to the central widget and it does
// The Right Thing(TM)
QObject *receiver = m_stackedWidget;
if (HelpViewer *viewer = currentHelpViewer())
receiver = viewer;
QTimer::singleShot(1, receiver, SLOT(setFocus()));
}
// -- private slots
void CentralWidget::highlightSearchTerms()
{
if (HelpViewer *viewer = currentHelpViewer()) {
QHelpSearchEngine *searchEngine =
HelpManager::instance().helpEngine().searchEngine();
QList<QHelpSearchQuery> queryList = searchEngine->query();
QStringList terms;
foreach (const QHelpSearchQuery &query, queryList) {
switch (query.fieldName) {
default: break;
case QHelpSearchQuery::ALL: {
case QHelpSearchQuery::PHRASE:
case QHelpSearchQuery::DEFAULT:
case QHelpSearchQuery::ATLEAST:
foreach (QString term, query.wordList)
terms.append(term.remove(QLatin1String("\"")));
}
}
}
foreach (const QString& term, terms)
viewer->findText(term, 0, false, true);
disconnect(viewer, SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms()));
}
}
void CentralWidget::printPreview(QPrinter *p) void CentralWidget::printPreview(QPrinter *p)
{ {
#ifndef QT_NO_PRINTER #ifndef QT_NO_PRINTER
@@ -354,368 +349,44 @@ void CentralWidget::printPreview(QPrinter *p)
#endif #endif
} }
void CentralWidget::pageSetup() void CentralWidget::handleSourceChanged(const QUrl &url)
{
if (sender() == currentHelpViewer())
emit sourceChanged(url);
}
// -- private
void CentralWidget::initPrinter()
{ {
#ifndef QT_NO_PRINTER #ifndef QT_NO_PRINTER
initPrinter(); if (!printer)
QPageSetupDialog dlg(printer); printer = new QPrinter(QPrinter::HighResolution);
dlg.exec();
#endif #endif
} }
void CentralWidget::home() void CentralWidget::connectSignals(HelpViewer *page)
{ {
HelpViewer* viewer = currentHelpViewer(); connect(page, SIGNAL(sourceChanged(QUrl)), this, SLOT(handleSourceChanged(QUrl)));
if (viewer) connect(page, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool)));
viewer->home(); connect(page, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool)));
}
bool CentralWidget::isForwardAvailable() const
{
const HelpViewer* viewer = currentHelpViewer();
if (viewer)
return viewer->isForwardAvailable();
return false;
}
void CentralWidget::forward()
{
HelpViewer* viewer = currentHelpViewer();
if (viewer)
viewer->forward();
}
bool CentralWidget::isBackwardAvailable() const
{
const HelpViewer* viewer = currentHelpViewer();
if (viewer)
return viewer->isBackwardAvailable();
return false;
}
void CentralWidget::backward()
{
HelpViewer* viewer = currentHelpViewer();
if (viewer)
viewer->backward();
}
QList<QAction*> CentralWidget::globalActions() const
{
return globalActionList;
}
void CentralWidget::setGlobalActions(const QList<QAction*> &actions)
{
globalActionList = actions;
}
void CentralWidget::setSourceInNewTab(const QUrl &url, int zoom)
{
HelpViewer* viewer = new HelpViewer(this, this);
viewer->installEventFilter(this);
viewer->setZoom(zoom);
viewer->setSource(url);
viewer->setFocus(Qt::OtherFocusReason);
#if defined(QT_NO_WEBKIT)
QFont font = viewer->font();
font.setPointSize(font.pointSize() + int(zoom));
viewer->setFont(font);
#endif
tabWidget->setCurrentIndex(tabWidget->addTab(viewer,
quoteTabTitle(viewer->documentTitle())));
connectSignals();
}
HelpViewer *CentralWidget::newEmptyTab()
{
HelpViewer* viewer = new HelpViewer(this, this);
viewer->installEventFilter(this);
viewer->setFocus(Qt::OtherFocusReason);
#if defined(QT_NO_WEBKIT)
viewer->setDocumentTitle(tr("unknown"));
#endif
tabWidget->setCurrentIndex(tabWidget->addTab(viewer, tr("unknown")));
connectSignals();
return viewer;
}
void CentralWidget::connectSignals()
{
const HelpViewer* viewer = currentHelpViewer();
if (viewer) {
connect(viewer, SIGNAL(copyAvailable(bool)), this,
SIGNAL(copyAvailable(bool)));
connect(viewer, SIGNAL(forwardAvailable(bool)), this,
SIGNAL(forwardAvailable(bool)));
connect(viewer, SIGNAL(backwardAvailable(bool)), this,
SIGNAL(backwardAvailable(bool)));
connect(viewer, SIGNAL(sourceChanged(QUrl)), this,
SIGNAL(sourceChanged(QUrl)));
connect(viewer, SIGNAL(highlighted(QString)), this,
SIGNAL(highlighted(QString)));
connect(viewer, SIGNAL(sourceChanged(QUrl)), this,
SLOT(setTabTitle(QUrl)));
}
}
HelpViewer *CentralWidget::helpViewerAtIndex(int index) const
{
return qobject_cast<HelpViewer*>(tabWidget->widget(index));
}
int CentralWidget::indexOf(HelpViewer *viewer) const
{
if (!viewer)
return -1;
return tabWidget->indexOf(viewer);
}
HelpViewer *CentralWidget::currentHelpViewer() const
{
return qobject_cast<HelpViewer*>(tabWidget->currentWidget());
}
void CentralWidget::activateTab(bool onlyHelpViewer)
{
if (currentHelpViewer()) {
currentHelpViewer()->setFocus();
} else {
int idx = 0;
if (onlyHelpViewer)
idx = lastTabPage;
tabWidget->setCurrentIndex(idx);
tabWidget->currentWidget()->setFocus();
}
}
void CentralWidget::setTabTitle(const QUrl& url)
{
Q_UNUSED(url)
#if !defined(QT_NO_WEBKIT)
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
for (int i = 0; i < tabBar->count(); ++i) {
HelpViewer* view = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (view) {
tabWidget->setTabText(i,
quoteTabTitle(view->documentTitle().trimmed()));
}
}
#else
if (HelpViewer* viewer = currentHelpViewer()) {
tabWidget->setTabText(lastTabPage,
quoteTabTitle(viewer->documentTitle().trimmed()));
}
#endif
}
void CentralWidget::currentPageChanged(int index)
{
lastTabPage = index;
tabWidget->setTabsClosable(tabWidget->count() > 1);
tabWidget->cornerWidget(Qt::TopLeftCorner)->setEnabled(true);
emit currentViewerChanged(index);
}
void CentralWidget::showTabBarContextMenu(const QPoint &point)
{
HelpViewer* viewer = helpViewerFromTabPosition(tabWidget, point);
if (!viewer)
return;
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
QMenu menu(QLatin1String(""), tabBar);
QAction *newPage = menu.addAction(tr("Add New Page"));
bool enableAction = tabBar->count() > 1;
QAction *closePage = menu.addAction(tr("Close This Page"));
closePage->setEnabled(enableAction);
QAction *closePages = menu.addAction(tr("Close Other Pages"));
closePages->setEnabled(enableAction);
menu.addSeparator();
QAction *newBookmark = menu.addAction(tr("Add Bookmark for this Page..."));
const QString &url = viewer->source().toString();
if (url.isEmpty() || url == QLatin1String("about:blank"))
newBookmark->setEnabled(false);
QAction *pickedAction = menu.exec(tabBar->mapToGlobal(point));
if (pickedAction == newPage)
setSourceInNewTab(viewer->source());
if (pickedAction == closePage) {
tabWidget->removeTab(tabWidget->indexOf(viewer));
QTimer::singleShot(0, viewer, SLOT(deleteLater()));
}
if (pickedAction == closePages) {
int currentPage = tabWidget->indexOf(viewer);
for (int i = tabBar->count() -1; i >= 0; --i) {
viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (i != currentPage && viewer) {
tabWidget->removeTab(i);
QTimer::singleShot(0, viewer, SLOT(deleteLater()));
if (i < currentPage)
--currentPage;
}
}
}
if (pickedAction == newBookmark)
emit addNewBookmark(viewer->documentTitle(), url);
}
// If we have a current help viewer then this is the 'focus proxy', otherwise
// it's the tab widget itself. This is needed, so an embedding program can just
// set the focus to the central widget and it does TheRightThing(TM)
void CentralWidget::focusInEvent(QFocusEvent * /* event */)
{
QObject *receiver = tabWidget;
if (currentHelpViewer())
receiver = currentHelpViewer();
QTimer::singleShot(1, receiver, SLOT(setFocus()));
} }
bool CentralWidget::eventFilter(QObject *object, QEvent *e) bool CentralWidget::eventFilter(QObject *object, QEvent *e)
{ {
if (e->type() == QEvent::KeyPress){ if (e->type() != QEvent::KeyPress)
if ((static_cast<QKeyEvent*>(e))->key() == Qt::Key_Backspace) { return QWidget::eventFilter(object, e);
HelpViewer *viewer = currentHelpViewer();
if (viewer == object) { HelpViewer *viewer = currentHelpViewer();
if (viewer->isBackwardAvailable()) { QKeyEvent *keyEvent = static_cast<QKeyEvent*> (e);
if (viewer == object && keyEvent->key() == Qt::Key_Backspace) {
if (viewer->isBackwardAvailable()) {
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
// this helps in case there is an html <input> field // this helps in case there is an html <input> field
if (!viewer->hasFocus()) if (!viewer->hasFocus())
#endif #endif
viewer->backward(); viewer->backward();
}
return true;
}
}
}
if (qobject_cast<QTabBar*>(object)) {
bool dblClick = e->type() == QEvent::MouseButtonDblClick;
if((e->type() == QEvent::MouseButtonRelease) || dblClick) {
if (tabWidget->count() <= 1)
return QWidget::eventFilter(object, e);
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e);
HelpViewer *viewer = helpViewerFromTabPosition(tabWidget,
mouseEvent->pos());
if (viewer) {
if ((mouseEvent->button() == Qt::MidButton) || dblClick) {
tabWidget->removeTab(tabWidget->indexOf(viewer));
QTimer::singleShot(0, viewer, SLOT(deleteLater()));
currentPageChanged(tabWidget->currentIndex());
return true;
}
}
} }
} }
return QWidget::eventFilter(object, e); return QWidget::eventFilter(object, e);
} }
bool CentralWidget::find(const QString &txt, QTextDocument::FindFlags findFlags,
bool incremental)
{
HelpViewer* viewer = currentHelpViewer();
#if !defined(QT_NO_WEBKIT)
Q_UNUSED(incremental)
if (viewer) {
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
if (findFlags & QTextDocument::FindBackward)
options |= QWebPage::FindBackward;
if (findFlags & QTextDocument::FindCaseSensitively)
options |= QWebPage::FindCaseSensitively;
bool found = viewer->findText(txt, options);
options = QWebPage::HighlightAllOccurrences;
viewer->findText(QLatin1String(""), options); // clear first
viewer->findText(txt, options); // force highlighting of all other matches
return found;
}
return false;
#else
QTextCursor cursor;
QTextDocument *doc = 0;
QTextBrowser *browser = 0;
if (viewer) {
doc = viewer->document();
cursor = viewer->textCursor();
browser = qobject_cast<QTextBrowser*>(viewer);
}
/*
if (tabWidget->currentWidget() == m_searchWidget) {
QTextBrowser* browser = qFindChild<QTextBrowser*>(m_searchWidget);
if (browser) {
doc = browser->document();
cursor = browser->textCursor();
}
}
*/
if (!browser || !doc || cursor.isNull())
return false;
if (incremental)
cursor.setPosition(cursor.selectionStart());
QTextCursor found = doc->find(txt, cursor, findFlags);
if (found.isNull()) {
if ((findFlags&QTextDocument::FindBackward) == 0)
cursor.movePosition(QTextCursor::Start);
else
cursor.movePosition(QTextCursor::End);
found = doc->find(txt, cursor, findFlags);
if (found.isNull()) {
return false;
}
}
if (!found.isNull()) {
viewer->setTextCursor(found);
}
return true;
#endif
}
void CentralWidget::showTopicChooser(const QMap<QString, QUrl> &links,
const QString &keyword)
{
TopicChooser tc(this, keyword, links);
if (tc.exec() == QDialog::Accepted)
setSource(tc.link());
}
void CentralWidget::copy()
{
HelpViewer* viewer = currentHelpViewer();
if (viewer)
viewer->copy();
}
void CentralWidget::activateTab(int index)
{
tabWidget->setCurrentIndex(index);
}
QString CentralWidget::quoteTabTitle(const QString &title) const
{
QString s = title;
return s.replace(QLatin1Char('&'), QLatin1String("&&"));
}

View File

@@ -30,29 +30,19 @@
#ifndef CENTRALWIDGET_H #ifndef CENTRALWIDGET_H
#define CENTRALWIDGET_H #define CENTRALWIDGET_H
#include <QtCore/QUrl> #include <find/ifindsupport.h>
#include <QtCore/QPoint>
#include <QtCore/QObject>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QTextDocument>
QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QEvent)
QT_FORWARD_DECLARE_CLASS(QAction)
class QEvent; QT_FORWARD_DECLARE_CLASS(QStackedWidget)
class QLabel; QT_FORWARD_DECLARE_CLASS(QFocusEvent)
class QAction;
class QCheckBox;
class QLineEdit;
class QToolButton;
class QTabWidget;
class QFocusEvent;
QT_END_NAMESPACE
class HelpViewer;
namespace Help { namespace Help {
namespace Internal { namespace Internal {
class HelpViewer;
class PrintHelper; class PrintHelper;
class CentralWidget : public QWidget class CentralWidget : public QWidget
@@ -63,82 +53,71 @@ public:
CentralWidget(QWidget *parent = 0); CentralWidget(QWidget *parent = 0);
~CentralWidget(); ~CentralWidget();
bool hasSelection() const;
QUrl currentSource() const;
QString currentTitle() const;
bool isForwardAvailable() const;
bool isBackwardAvailable() const;
QList<QAction*> globalActions() const;
void setGlobalActions(const QList<QAction*> &actions);
HelpViewer *currentHelpViewer() const;
void activateTab(bool onlyHelpViewer = false);
bool find(const QString &txt, QTextDocument::FindFlags findFlags, bool incremental);
void setLastShownPages();
HelpViewer *helpViewerAtIndex(int index) const;
int indexOf(HelpViewer *viewer) const;
static CentralWidget *instance(); static CentralWidget *instance();
bool hasSelection() const;
bool isForwardAvailable() const;
bool isBackwardAvailable() const;
HelpViewer *viewerAt(int index) const;
HelpViewer *currentHelpViewer() const;
void addPage(HelpViewer *page, bool fromSearch = false);
void removePage(int index);
int currentIndex() const;
void setCurrentPage(HelpViewer *page);
bool find(const QString &txt, Find::IFindSupport::FindFlags findFlags,
bool incremental);
public slots: public slots:
void copy();
void home();
void zoomIn(); void zoomIn();
void zoomOut(); void zoomOut();
void nextPage();
void resetZoom(); void resetZoom();
void forward();
void nextPage();
void backward();
void previousPage(); void previousPage();
void print(); void print();
void pageSetup(); void pageSetup();
void printPreview(); void printPreview();
void setSource(const QUrl &url); void setSource(const QUrl &url);
void setSourceInNewTab(const QUrl &url, int zoom = 0); void setSourceFromSearch(const QUrl &url);
HelpViewer *newEmptyTab(); void showTopicChooser(const QMap<QString, QUrl> &links, const QString &key);
void home();
void forward();
void backward();
void showTopicChooser(const QMap<QString, QUrl> &links,
const QString &keyword);
void copy();
void activateTab(int index);
protected: protected:
void focusInEvent(QFocusEvent *event); void focusInEvent(QFocusEvent *event);
signals: signals:
void currentViewerChanged(int index); void currentViewerChanged();
void copyAvailable(bool yes);
void sourceChanged(const QUrl &url); void sourceChanged(const QUrl &url);
void highlighted(const QString &link);
void forwardAvailable(bool available); void forwardAvailable(bool available);
void backwardAvailable(bool available); void backwardAvailable(bool available);
void addNewBookmark(const QString &title, const QString &url);
void viewerAboutToBeRemoved(int index);
void viewerRemoved(int index);
private slots: private slots:
void newTab(); void highlightSearchTerms();
void closeTab();
void closeTab(int index);
void setTabTitle(const QUrl& url);
void currentPageChanged(int index);
void showTabBarContextMenu(const QPoint &point);
void printPreview(QPrinter *printer); void printPreview(QPrinter *printer);
void handleSourceChanged(const QUrl &url);
private: private:
void connectSignals();
bool eventFilter(QObject *object, QEvent *e);
void initPrinter(); void initPrinter();
QString quoteTabTitle(const QString &title) const; void connectSignals(HelpViewer *page);
bool eventFilter(QObject *object, QEvent *e);
private: private:
int lastTabPage;
QList<QAction*> globalActionList;
QWidget *findBar;
QTabWidget* tabWidget;
QPrinter *printer; QPrinter *printer;
QStackedWidget *m_stackedWidget;
}; };
} // namespace Internal } // namespace Internal
} // namespace Help } // namespace Help
#endif // CENTRALWIDGET_H #endif // CENTRALWIDGET_H

View File

@@ -41,25 +41,23 @@
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#if defined(QT_NO_WEBKIT)
#include <QtGui/QApplication> #include <QtGui/QApplication>
#else
#include <QtWebKit/QWebSettings>
#endif
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngineCore>
#if !defined(QT_NO_WEBKIT)
#include <QtWebKit/QWebSettings>
#endif
using namespace Help::Internal; using namespace Help::Internal;
GeneralSettingsPage::GeneralSettingsPage() GeneralSettingsPage::GeneralSettingsPage()
{ {
m_font = qApp->font();
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
QWebSettings* webSettings = QWebSettings::globalSettings(); QWebSettings* webSettings = QWebSettings::globalSettings();
m_font.setFamily(webSettings->fontFamily(QWebSettings::StandardFont));
m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize)); m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize));
#else
m_font = qApp->font();
#endif #endif
} }
@@ -168,13 +166,8 @@ void GeneralSettingsPage::apply()
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); QHelpEngineCore *engine = &HelpManager::helpEngineCore();
engine->setCustomValue(QLatin1String("font"), newFont); engine->setCustomValue(QLatin1String("font"), newFont);
#if !defined(QT_NO_WEBKIT) if (newFont != m_font)
QWebSettings* webSettings = QWebSettings::globalSettings(); emit fontChanged();
webSettings->setFontFamily(QWebSettings::StandardFont, m_font.family());
webSettings->setFontSize(QWebSettings::DefaultFontSize, m_font.pointSize());
#else
emit fontChanged();
#endif
QString homePage = m_ui.homePageLineEdit->text(); QString homePage = m_ui.homePageLineEdit->text();
if (homePage.isEmpty()) if (homePage.isEmpty())

View File

@@ -6,33 +6,46 @@ include(../../qtcreatorplugin.pri)
include(help_dependencies.pri) include(help_dependencies.pri)
CONFIG += help CONFIG += help
DEFINES += QT_CLUCENE_SUPPORT \ DEFINES += QT_CLUCENE_SUPPORT HELP_LIBRARY
HELP_LIBRARY
HEADERS += helpplugin.h \ HEADERS += \
centralwidget.h \
docsettingspage.h \ docsettingspage.h \
filtersettingspage.h \ filtersettingspage.h \
helpconstants.h \
helpmode.h \
centralwidget.h \
searchwidget.h \
helpfindsupport.h \
help_global.h \
helpindexfilter.h \
generalsettingspage.h \ generalsettingspage.h \
xbelsupport.h \ help_global.h \
helpmanager.h helpconstants.h \
helpfindsupport.h \
helpindexfilter.h \
helpmanager.h \
helpmode.h \
helpplugin.h \
helpviewer.h \
helpviewer_p.h \
openpagesmanager.h \
openpagesmodel.h \
openpageswidget.h \
searchwidget.h \
xbelsupport.h
SOURCES += helpplugin.cpp \ SOURCES += \
centralwidget.cpp \
docsettingspage.cpp \ docsettingspage.cpp \
filtersettingspage.cpp \ filtersettingspage.cpp \
helpmode.cpp \ generalsettingspage.cpp \
centralwidget.cpp \
searchwidget.cpp \
helpfindsupport.cpp \ helpfindsupport.cpp \
helpindexfilter.cpp \ helpindexfilter.cpp \
generalsettingspage.cpp \ helpmanager.cpp \
xbelsupport.cpp \ helpmode.cpp \
helpmanager.cpp helpplugin.cpp \
helpviewer.cpp \
helpviewer_qtb.cpp \
helpviewer_qwv.cpp \
openpagesmanager.cpp \
openpagesmodel.cpp \
openpageswidget.cpp \
searchwidget.cpp \
xbelsupport.cpp
FORMS += docsettingspage.ui \ FORMS += docsettingspage.ui \
filtersettingspage.ui \ filtersettingspage.ui \

View File

@@ -51,7 +51,7 @@ bool HelpFindSupport::isEnabled() const
Find::IFindSupport::FindFlags HelpFindSupport::supportedFindFlags() const Find::IFindSupport::FindFlags HelpFindSupport::supportedFindFlags() const
{ {
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
| Find::IFindSupport::FindWholeWords; | Find::IFindSupport::FindWholeWords;
} }
QString HelpFindSupport::currentFindString() const QString HelpFindSupport::currentFindString() const
@@ -60,11 +60,7 @@ QString HelpFindSupport::currentFindString() const
HelpViewer *viewer = m_centralWidget->currentHelpViewer(); HelpViewer *viewer = m_centralWidget->currentHelpViewer();
if (!viewer) if (!viewer)
return QString(); return QString();
#if !defined(QT_NO_WEBKIT)
return viewer->selectedText(); return viewer->selectedText();
#else
return viewer->textCursor().selectedText();
#endif
} }
QString HelpFindSupport::completedFindString() const QString HelpFindSupport::completedFindString() const
@@ -72,95 +68,58 @@ QString HelpFindSupport::completedFindString() const
return QString(); return QString();
} }
Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_centralWidget, return NotFound); QTC_ASSERT(m_centralWidget, return NotFound);
findFlags &= ~Find::IFindSupport::FindBackward; findFlags &= ~Find::IFindSupport::FindBackward;
return m_centralWidget->find(txt, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags), true) return m_centralWidget->find(txt, findFlags, true) ? Found : NotFound;
? Found : NotFound;
} }
Find::IFindSupport::Result HelpFindSupport::findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_centralWidget, return NotFound); QTC_ASSERT(m_centralWidget, return NotFound);
return m_centralWidget->find(txt, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags), false) return m_centralWidget->find(txt, findFlags, false) ? Found : NotFound;
? Found : NotFound;
} }
// -- HelpViewerFindSupport
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer) HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
: m_viewer(viewer) : m_viewer(viewer)
{ {
} }
Find::IFindSupport::FindFlags HelpViewerFindSupport::supportedFindFlags() const Find::IFindSupport::FindFlags HelpViewerFindSupport::supportedFindFlags() const
{ {
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
| Find::IFindSupport::FindWholeWords; | Find::IFindSupport::FindWholeWords;
} }
QString HelpViewerFindSupport::currentFindString() const QString HelpViewerFindSupport::currentFindString() const
{ {
QTC_ASSERT(m_viewer, return QString()); QTC_ASSERT(m_viewer, return QString());
#if !defined(QT_NO_WEBKIT)
return m_viewer->selectedText(); return m_viewer->selectedText();
#else
return QString();
#endif
} }
Find::IFindSupport::Result HelpViewerFindSupport::findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpViewerFindSupport::findIncremental(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_viewer, return NotFound); QTC_ASSERT(m_viewer, return NotFound);
findFlags &= ~Find::IFindSupport::FindBackward; findFlags &= ~Find::IFindSupport::FindBackward;
return find(txt, findFlags, true) ? Found : NotFound; return find(txt, findFlags, true) ? Found : NotFound;
} }
Find::IFindSupport::Result HelpViewerFindSupport::findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpViewerFindSupport::findStep(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_viewer, return NotFound); QTC_ASSERT(m_viewer, return NotFound);
return find(txt, findFlags, false) ? Found : NotFound; return find(txt, findFlags, false) ? Found : NotFound;
} }
bool HelpViewerFindSupport::find(const QString &txt, Find::IFindSupport::FindFlags findFlags, bool incremental) bool HelpViewerFindSupport::find(const QString &txt,
Find::IFindSupport::FindFlags findFlags, bool incremental)
{ {
QTC_ASSERT(m_viewer, return false); QTC_ASSERT(m_viewer, return false);
#if !defined(QT_NO_WEBKIT) return m_viewer->findText(txt, findFlags, incremental, false);
Q_UNUSED(incremental)
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
if (findFlags & Find::IFindSupport::FindBackward)
options |= QWebPage::FindBackward;
if (findFlags & Find::IFindSupport::FindCaseSensitively)
options |= QWebPage::FindCaseSensitively;
bool found = m_viewer->findText(txt, options);
options = QWebPage::HighlightAllOccurrences;
m_viewer->findText(QLatin1String(""), options); // clear first
m_viewer->findText(txt, options); // force highlighting of all other matches
return found;
#else
QTextCursor cursor = m_viewer->textCursor();
QTextDocument *doc = m_viewer->document();
QTextBrowser *browser = qobject_cast<QTextBrowser*>(m_viewer);
if (!browser || !doc || cursor.isNull())
return false;
if (incremental)
cursor.setPosition(cursor.selectionStart());
QTextCursor found = doc->find(txt, cursor, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
if (found.isNull()) {
if ((findFlags&Find::IFindSupport::FindBackward) == 0)
cursor.movePosition(QTextCursor::Start);
else
cursor.movePosition(QTextCursor::End);
found = doc->find(txt, cursor, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
if (found.isNull()) {
return false;
}
}
if (!found.isNull()) {
m_viewer->setTextCursor(found);
}
return true;
#endif
} }

View File

@@ -34,12 +34,11 @@
#include <find/ifindsupport.h> #include <find/ifindsupport.h>
class HelpViewer;
namespace Help { namespace Help {
namespace Internal { namespace Internal {
class HelpViewer;
class HelpFindSupport : public Find::IFindSupport class HelpFindSupport : public Find::IFindSupport
{ {
Q_OBJECT Q_OBJECT

View File

@@ -26,6 +26,7 @@
** contact the sales department at http://qt.nokia.com/contact. ** contact the sales department at http://qt.nokia.com/contact.
** **
**************************************************************************/ **************************************************************************/
#include "helpplugin.h" #include "helpplugin.h"
#include "bookmarkmanager.h" #include "bookmarkmanager.h"
@@ -41,6 +42,8 @@
#include "helpmode.h" #include "helpmode.h"
#include "helpviewer.h" #include "helpviewer.h"
#include "indexwindow.h" #include "indexwindow.h"
#include "openpagesmanager.h"
#include "openpagesmodel.h"
#include "searchwidget.h" #include "searchwidget.h"
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
@@ -83,6 +86,7 @@
# include <QtWebKit/QWebSettings> # include <QtWebKit/QWebSettings>
#endif #endif
using namespace Core::Constants;
using namespace Help; using namespace Help;
using namespace Help::Internal; using namespace Help::Internal;
@@ -137,88 +141,94 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
} }
addAutoReleasedObject(m_helpManager = new HelpManager(this)); addAutoReleasedObject(m_helpManager = new HelpManager(this));
addAutoReleasedObject(m_openPagesManager = new OpenPagesManager(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()); addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage());
connect(m_docSettingsPage, SIGNAL(documentationChanged()), m_filterSettingsPage, connect(m_docSettingsPage, SIGNAL(documentationChanged()), m_filterSettingsPage,
SLOT(updateFilterPage())); SLOT(updateFilterPage()));
connect(m_generalSettingsPage, SIGNAL(fontChanged()), this, SLOT(fontChanged())); connect(m_generalSettingsPage, SIGNAL(fontChanged()), this,
connect(m_helpManager, SIGNAL(helpRequested(QString)), this, SLOT(handleHelpRequest(QString))); SLOT(fontChanged()));
connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this, SLOT(setupHelpEngineIfNeeded())); connect(m_helpManager, SIGNAL(helpRequested(QString)), this,
connect(m_docSettingsPage, SIGNAL(documentationChanged()), this, SLOT(setupHelpEngineIfNeeded())); SLOT(handleHelpRequest(QString)));
connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this,
SLOT(setupHelpEngineIfNeeded()));
connect(m_docSettingsPage, SIGNAL(documentationChanged()), this,
SLOT(setupHelpEngineIfNeeded()));
m_splitter = new Core::MiniSplitter; m_splitter = new Core::MiniSplitter;
m_centralWidget = new Help::Internal::CentralWidget(); m_centralWidget = new Help::Internal::CentralWidget();
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
SLOT(updateSideBarSource(QUrl)));
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 = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")), tr("Home"), this); QAction *action = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")),
tr("Home"), this);
Core::ActionManager *am = m_core->actionManager(); Core::ActionManager *am = m_core->actionManager();
Core::Command *cmd = am->registerAction(homeAction, QLatin1String("Help.Home"), globalcontext); Core::Command *cmd = am->registerAction(action, QLatin1String("Help.Home"),
connect(homeAction, SIGNAL(triggered()), m_centralWidget, SLOT(home())); globalcontext);
actionList << homeAction; connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
QAction *previousAction = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")), action = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
tr("Previous Page"), this); tr("Previous Page"), this);
cmd = am->registerAction(previousAction, QLatin1String("Help.Previous"), modecontext); cmd = am->registerAction(action, QLatin1String("Help.Previous"), modecontext);
cmd->setDefaultKeySequence(QKeySequence::Back); cmd->setDefaultKeySequence(QKeySequence::Back);
previousAction->setEnabled(m_centralWidget->isBackwardAvailable()); action->setEnabled(m_centralWidget->isBackwardAvailable());
connect(previousAction, SIGNAL(triggered()), m_centralWidget, SLOT(backward())); connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(backward()));
connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), previousAction, SLOT(setEnabled(bool))); connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), action,
actionList << previousAction; SLOT(setEnabled(bool)));
QAction *nextAction = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), tr("Next Page"), action = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), tr("Next Page"),
this); this);
cmd = am->registerAction(nextAction, QLatin1String("Help.Next"), modecontext); cmd = am->registerAction(action, QLatin1String("Help.Next"), modecontext);
cmd->setDefaultKeySequence(QKeySequence::Forward); cmd->setDefaultKeySequence(QKeySequence::Forward);
nextAction->setEnabled(m_centralWidget->isForwardAvailable()); action->setEnabled(m_centralWidget->isForwardAvailable());
connect(nextAction, SIGNAL(triggered()), m_centralWidget, SLOT(forward())); connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(forward()));
connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), nextAction, SLOT(setEnabled(bool))); connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), action,
actionList << nextAction; SLOT(setEnabled(bool)));
QAction *addBookmarkAction = new QAction(QIcon(QLatin1String(IMAGEPATH "bookmark.png")), action = new QAction(QIcon(QLatin1String(IMAGEPATH "bookmark.png")),
tr("Add Bookmark"), this); tr("Add Bookmark"), this);
cmd = am->registerAction(addBookmarkAction, QLatin1String("Help.AddBookmark"), cmd = am->registerAction(action, 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())); connect(action, 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); action = new QAction(tr("Index"), this);
cmd = am->registerAction(indexAction, QLatin1String("Help.Index"), globalcontext); cmd = am->registerAction(action, QLatin1String("Help.Index"), globalcontext);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP); am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
connect(indexAction, SIGNAL(triggered()), this, SLOT(activateIndex())); connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
QAction *contentsAction = new QAction(tr("Contents"), this); action = new QAction(tr("Contents"), this);
cmd = am->registerAction(contentsAction, QLatin1String("Help.Contents"), globalcontext); cmd = am->registerAction(action, QLatin1String("Help.Contents"), globalcontext);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP); am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
connect(contentsAction, SIGNAL(triggered()), this, SLOT(activateContents())); connect(action, SIGNAL(triggered()), this, SLOT(activateContents()));
QAction *contextAction = new QAction(tr("Context Help"), this); action = new QAction(tr("Context Help"), this);
cmd = am->registerAction(contextAction, QLatin1String("Help.Context"), globalcontext); cmd = am->registerAction(action, QLatin1String("Help.Context"), globalcontext);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP); am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1)); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
connect(contextAction, SIGNAL(triggered()), this, SLOT(activateContext())); connect(action, SIGNAL(triggered()), this, SLOT(activateContext()));
#ifndef Q_WS_MAC #ifndef Q_WS_MAC
QAction *sep = new QAction(this); action = new QAction(this);
sep->setSeparator(true); action->setSeparator(true);
cmd = am->registerAction(sep, QLatin1String("Help.Separator"), globalcontext); cmd = am->registerAction(action, QLatin1String("Help.Separator"), globalcontext);
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP); am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
actionList << sep;
#endif #endif
QAction *printAction = new QAction(this); action = new QAction(this);
am->registerAction(printAction, Core::Constants::PRINT, modecontext); am->registerAction(action, Core::Constants::PRINT, modecontext);
connect(printAction, SIGNAL(triggered()), m_centralWidget, SLOT(print())); connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(print()));
QAction *copyAction = new QAction(this); action = new QAction(this);
cmd = am->registerAction(copyAction, Core::Constants::COPY, modecontext); cmd = am->registerAction(action, Core::Constants::COPY, modecontext);
connect(copyAction, SIGNAL(triggered()), m_centralWidget, SLOT(copy())); connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(copy()));
copyAction->setText(cmd->action()->text()); action->setText(cmd->action()->text());
copyAction->setIcon(cmd->action()->icon()); action->setIcon(cmd->action()->icon());
actionList << copyAction;
if (Core::ActionContainer *advancedMenu = if (Core::ActionContainer *advancedMenu =
am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) { am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
@@ -255,7 +265,6 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
mainWidgetLayout->setSpacing(0); mainWidgetLayout->setSpacing(0);
mainWidgetLayout->addWidget(createToolBar()); mainWidgetLayout->addWidget(createToolBar());
mainWidgetLayout->addWidget(m_centralWidget); mainWidgetLayout->addWidget(m_centralWidget);
m_centralWidget->setGlobalActions(actionList);
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter(); HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
addAutoReleasedObject(helpIndexFilter); addAutoReleasedObject(helpIndexFilter);
@@ -320,24 +329,10 @@ void HelpPlugin::extensionsInitialized()
m_helpManager->verifyDocumenation(); m_helpManager->verifyDocumenation();
m_helpManager->registerDocumentation(filesToRegister); 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." const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR) "%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
.arg(IDE_VERSION_RELEASE); .arg(IDE_VERSION_RELEASE);
engine->setCustomValue(QLatin1String("DefaultHomePage"), url); engine->setCustomValue(QLatin1String("DefaultHomePage"), url);
connectCentralWidget();
connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox())); connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox()));
} }
@@ -357,42 +352,46 @@ void HelpPlugin::setupUi()
IndexWindow *indexWindow = new IndexWindow(); IndexWindow *indexWindow = new IndexWindow();
indexWindow->setWindowTitle(tr("Index")); indexWindow->setWindowTitle(tr("Index"));
m_indexItem = new Core::SideBarItem(indexWindow); 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,
connect(indexWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); SLOT(setSource(QUrl)));
connect(indexWindow, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
m_centralWidget, SLOT(showTopicChooser(QMap<QString, QUrl>, QString)));
QMap<QString, Core::Command*> shortcutMap; QMap<QString, Core::Command*> shortcutMap;
QShortcut *shortcut = new QShortcut(m_splitter); QShortcut *shortcut = new QShortcut(m_splitter);
shortcut->setWhatsThis(tr("Activate Index in Help mode")); shortcut->setWhatsThis(tr("Activate Index in Help mode"));
Core::Command* cmd = am->registerShortcut(shortcut, QLatin1String("Help.IndexShortcut"), Core::Command* cmd = am->registerShortcut(shortcut,
modecontext); QLatin1String("Help.IndexShortcut"), modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_I)); cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex())); connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex()));
shortcutMap.insert(indexWindow->windowTitle(), cmd); shortcutMap.insert(indexWindow->windowTitle(), cmd);
ContentWindow *contentWindow = new ContentWindow(); ContentWindow *contentWindow = new ContentWindow();
contentWindow->setWindowTitle(tr("Contents")); contentWindow->setWindowTitle(tr("Contents"));
m_contentItem = new Core::SideBarItem(contentWindow); m_contentItem = new Core::SideBarItem(contentWindow);
connect(contentWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); connect(contentWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
shortcut = new QShortcut(m_splitter); shortcut = new QShortcut(m_splitter);
shortcut->setWhatsThis(tr("Activate Contents in Help mode")); shortcut->setWhatsThis(tr("Activate Contents in Help mode"));
cmd = am->registerShortcut(shortcut, QLatin1String("Help.ContentsShortcut"), modecontext); cmd = am->registerShortcut(shortcut, QLatin1String("Help.ContentsShortcut"),
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_T)); modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents())); connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents()));
shortcutMap.insert(contentWindow->windowTitle(), cmd); shortcutMap.insert(contentWindow->windowTitle(), cmd);
SearchWidget *searchWidget = new SearchWidget(); SearchWidget *searchWidget = new SearchWidget();
searchWidget->setWindowTitle(tr("Search")); searchWidget->setWindowTitle(tr("Search"));
m_searchItem = new Core::SideBarItem(searchWidget); m_searchItem = new Core::SideBarItem(searchWidget);
connect(searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), m_centralWidget, connect(searchWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSourceInNewTab(QUrl))); SLOT(setSourceFromSearch(QUrl)));
connect(searchWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget, SLOT(setSource(QUrl)));
// TODO: enable and find a proper keysequence as this is ambiguous // TODO: enable and find a proper keysequence as this is ambiguous
// shortcut = new QShortcut(m_splitter); // shortcut = new QShortcut(m_splitter);
// shortcut->setWhatsThis(tr("Activate Search in Help mode")); // shortcut->setWhatsThis(tr("Activate Search in Help mode"));
// cmd = am->registerShortcut(shortcut, QLatin1String("Help.SearchShortcut"), modecontext); // cmd = am->registerShortcut(shortcut, QLatin1String("Help.SearchShortcut"),
// modecontext);
// cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_S)); // cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_S));
// connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch())); // connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
// shortcutMap.insert(searchWidget->windowTitle(), cmd); // shortcutMap.insert(searchWidget->windowTitle(), cmd);
@@ -401,20 +400,35 @@ void HelpPlugin::setupUi()
BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager, 0, false); BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager, 0, false);
bookmarkWidget->setWindowTitle(tr("Bookmarks")); bookmarkWidget->setWindowTitle(tr("Bookmarks"));
m_bookmarkItem = new Core::SideBarItem(bookmarkWidget); m_bookmarkItem = new Core::SideBarItem(bookmarkWidget);
connect(bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark())); connect(bookmarkWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
connect(bookmarkWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); SLOT(setSource(QUrl)));
// TODO: enable and find a proper keysequence as this is ambiguous // TODO: enable and find a proper keysequence as this is ambiguous
// shortcut = new QShortcut(m_splitter); // shortcut = new QShortcut(m_splitter);
// shortcut->setWhatsThis(tr("Activate Bookmarks in Help mode")); // shortcut->setWhatsThis(tr("Activate Bookmarks in Help mode"));
// cmd = am->registerShortcut(shortcut, QLatin1String("Help.BookmarkShortcut"), modecontext); // cmd = am->registerShortcut(shortcut, QLatin1String("Help.BookmarkShortcut"),
// modecontext);
// cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_B)); // cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_B));
// connect(shortcut, SIGNAL(activated()), this, SLOT(activateBookmarks())); // connect(shortcut, SIGNAL(activated()), this, SLOT(activateBookmarks()));
// shortcutMap.insert(bookmarkWidget->windowTitle(), cmd); // shortcutMap.insert(bookmarkWidget->windowTitle(), cmd);
QWidget *openPagesWidget = OpenPagesManager::instance().openPagesWidget();
openPagesWidget->setWindowTitle(tr("Open Pages"));
m_openPagesItem = new Core::SideBarItem(openPagesWidget);
shortcut = new QShortcut(m_splitter);
shortcut->setWhatsThis(tr("Activate Open Pages in Help mode"));
cmd = am->registerShortcut(shortcut, QLatin1String("Help.PagesShortcut"),
modecontext);
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
connect(shortcut, SIGNAL(activated()), this, SLOT(activateOpenPages()));
shortcutMap.insert(openPagesWidget->windowTitle(), cmd);
QList<Core::SideBarItem*> itemList; QList<Core::SideBarItem*> itemList;
itemList << m_contentItem << m_indexItem << m_searchItem << m_bookmarkItem; itemList << m_contentItem << m_indexItem << m_searchItem << m_bookmarkItem
m_sideBar = new Core::SideBar(itemList, QList<Core::SideBarItem*>() << m_indexItem); << m_openPagesItem;
m_sideBar = new Core::SideBar(itemList, QList<Core::SideBarItem*>()
<< m_indexItem << m_openPagesItem);
m_sideBar->setShortcutMap(shortcutMap); m_sideBar->setShortcutMap(shortcutMap);
m_splitter->setOpaqueResize(false); m_splitter->setOpaqueResize(false);
@@ -433,9 +447,9 @@ void HelpPlugin::resetFilter()
QHelpEngineCore *core = &m_helpManager->helpEngineCore(); QHelpEngineCore *core = &m_helpManager->helpEngineCore();
if (core->customValue(weAddedFilterKey).toInt() == 1) { 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 = core->customValue(previousFilterNameKey).toString(); const QString &filter = core->customValue(previousFilterNameKey).toString();
if (!previousFilter.isEmpty()) if (!filter.isEmpty())
core->removeCustomFilter(previousFilter); core->removeCustomFilter(filter);
} }
// potentially remove a filter with new name // potentially remove a filter with new name
@@ -447,21 +461,6 @@ void HelpPlugin::resetFilter()
(&m_helpManager->helpEngine())->setCurrentFilter(filterName); (&m_helpManager->helpEngine())->setCurrentFilter(filterName);
} }
void HelpPlugin::connectCentralWidget()
{
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
SLOT(updateSideBarSource(QUrl)));
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
SLOT(updateSideBarSource()));
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
SLOT(updateViewerComboBoxIndex(int)));
connect(m_centralWidget, SIGNAL(viewerAboutToBeRemoved(int)), this,
SLOT(removeViewerFromComboBox(int)));
connect(m_centralWidget, SIGNAL(addNewBookmark(QString, QString)), this,
SLOT(addNewBookmark(QString, QString)));
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this, SLOT(rebuildViewerComboBox()));
}
void HelpPlugin::createRightPaneContextViewer() void HelpPlugin::createRightPaneContextViewer()
{ {
if (m_helpViewerForSideBar) if (m_helpViewerForSideBar)
@@ -508,7 +507,7 @@ void HelpPlugin::createRightPaneContextViewer()
rightPaneStyledBar->setLayout(hboxLayout); rightPaneStyledBar->setLayout(hboxLayout);
rightPaneLayout->addWidget(rightPaneStyledBar); rightPaneLayout->addWidget(rightPaneStyledBar);
m_helpViewerForSideBar = new HelpViewer(0, rightPaneSideBar); m_helpViewerForSideBar = new HelpViewer(qreal(0.0), rightPaneSideBar);
rightPaneLayout->addWidget(m_helpViewerForSideBar); rightPaneLayout->addWidget(m_helpViewerForSideBar);
rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(rightPaneSideBar)); rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(rightPaneSideBar));
rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar); rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar);
@@ -575,7 +574,7 @@ void HelpPlugin::modeChanged(Core::IMode *mode)
setupUi(); setupUi();
resetFilter(); resetFilter();
m_helpManager->setupGuiHelpEngine(); m_helpManager->setupGuiHelpEngine();
m_centralWidget->setLastShownPages(); OpenPagesManager::instance().setupInitialPages();
qApp->restoreOverrideCursor(); qApp->restoreOverrideCursor();
} else if (mode == m_mode && !m_firstModeChange) { } else if (mode == m_mode && !m_firstModeChange) {
@@ -587,9 +586,11 @@ void HelpPlugin::modeChanged(Core::IMode *mode)
void HelpPlugin::updateSideBarSource() void HelpPlugin::updateSideBarSource()
{ {
const QUrl &url = m_centralWidget->currentSource(); if (HelpViewer *viewer = m_centralWidget->currentHelpViewer()) {
if (url.isValid()) const QUrl &url = viewer->source();
updateSideBarSource(url); if (url.isValid())
updateSideBarSource(url);
}
} }
void HelpPlugin::updateSideBarSource(const QUrl &newUrl) void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
@@ -598,25 +599,26 @@ void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
m_helpViewerForSideBar->setSource(newUrl); m_helpViewerForSideBar->setSource(newUrl);
} }
void HelpPlugin::updateCloseButton()
{
m_closeButton->setEnabled(OpenPagesManager::instance().pageCount() > 1);
}
void HelpPlugin::fontChanged() void HelpPlugin::fontChanged()
{ {
#if defined(QT_NO_WEBKIT) if (!m_helpViewerForSideBar)
QFont font = qApp->font(); createRightPaneContextViewer();
const QHelpEngineCore &engine = m_helpManager->helpEngineCore(); const QHelpEngineCore &engine = m_helpManager->helpEngineCore();
font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"), QFont font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
font)); m_helpViewerForSideBar->viewerFont()));
if (m_helpViewerForSideBar) m_helpViewerForSideBar->setFont(font);
m_helpViewerForSideBar->setFont(font); const int count = OpenPagesManager::instance().pageCount();
for (int i = 0; i < count; ++i) {
if (m_centralWidget) { if (HelpViewer *viewer = CentralWidget::instance()->viewerAt(i))
int i = 0; viewer->setViewerFont(font);
while (HelpViewer* viewer = m_centralWidget->helpViewerAtIndex(i++)) {
if (viewer->font() != font)
viewer->setFont(font);
}
} }
#endif
} }
void HelpPlugin::setupHelpEngineIfNeeded() void HelpPlugin::setupHelpEngineIfNeeded()
@@ -625,31 +627,6 @@ void HelpPlugin::setupHelpEngineIfNeeded()
m_helpManager->setupGuiHelpEngine(); m_helpManager->setupGuiHelpEngine();
} }
void HelpPlugin::rebuildViewerComboBox()
{
m_documentsCombo->clear();
int i = 0;
while (HelpViewer *viewer = m_centralWidget->helpViewerAtIndex(i++))
m_documentsCombo->addItem(viewer->documentTitle());
int index = m_centralWidget->indexOf(m_centralWidget->currentHelpViewer());
if (index >= 0)
m_documentsCombo->setCurrentIndex(index);
}
void HelpPlugin::removeViewerFromComboBox(int index)
{
if (index >= 0)
m_documentsCombo->removeItem(index);
}
void HelpPlugin::updateViewerComboBoxIndex(int index)
{
if (index >= 0)
m_documentsCombo->setCurrentIndex(index);
}
HelpViewer* HelpPlugin::viewerForContextMode() HelpViewer* HelpPlugin::viewerForContextMode()
{ {
using namespace Core; using namespace Core;
@@ -689,7 +666,7 @@ HelpViewer* HelpPlugin::viewerForContextMode()
} else { } else {
activateHelpMode(); activateHelpMode();
if (!viewer) if (!viewer)
viewer = m_centralWidget->newEmptyTab(); viewer = OpenPagesManager::instance().createPage();
} }
return viewer; return viewer;
} }
@@ -751,6 +728,12 @@ void HelpPlugin::activateSearch()
m_sideBar->activateItem(m_searchItem); m_sideBar->activateItem(m_searchItem);
} }
void HelpPlugin::activateOpenPages()
{
activateHelpMode();
m_sideBar->activateItem(m_openPagesItem);
}
QToolBar *HelpPlugin::createToolBar() QToolBar *HelpPlugin::createToolBar()
{ {
QToolBar *toolWidget = new QToolBar; QToolBar *toolWidget = new QToolBar;
@@ -770,20 +753,26 @@ QToolBar *HelpPlugin::createToolBar()
QHBoxLayout *layout = new QHBoxLayout(w); QHBoxLayout *layout = new QHBoxLayout(w);
layout->setMargin(0); layout->setMargin(0);
layout->addSpacing(10); layout->addSpacing(10);
m_documentsCombo = new QComboBox; layout->addWidget(OpenPagesManager::instance().openPagesComboBox());
m_documentsCombo->setMinimumContentsLength(40);
layout->addWidget(m_documentsCombo);
connect(m_documentsCombo, SIGNAL(activated(int)), m_centralWidget,
SLOT(activateTab(int)));
layout->addWidget(new QLabel(tr("Filtered by:"))); layout->addWidget(new QLabel(tr("Filtered by:")));
m_filterComboBox = new QComboBox; m_filterComboBox = new QComboBox;
m_filterComboBox->setMinimumContentsLength(20); m_filterComboBox->setMinimumContentsLength(20);
layout->addWidget(m_filterComboBox); layout->addWidget(m_filterComboBox);
connect(m_filterComboBox, SIGNAL(activated(QString)), this, connect(m_filterComboBox, SIGNAL(activated(QString)), this,
SLOT(filterDocumentation(QString))); SLOT(filterDocumentation(QString)));
connect(m_filterComboBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(updateSideBarSource()));
m_closeButton = new QToolButton();
m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
m_closeButton->setToolTip(tr("Close current Page"));
connect(m_closeButton, SIGNAL(clicked()), &OpenPagesManager::instance(),
SLOT(closeCurrentPage()));
connect(&OpenPagesManager::instance(), SIGNAL(pagesChanged()), this,
SLOT(updateCloseButton()));
layout->addStretch();
layout->addWidget(m_closeButton);
return toolWidget; return toolWidget;
} }
@@ -809,21 +798,21 @@ void HelpPlugin::filterDocumentation(const QString &customFilter)
void HelpPlugin::addBookmark() void HelpPlugin::addBookmark()
{ {
addNewBookmark(m_centralWidget->currentTitle(), HelpViewer *viewer = m_centralWidget->currentHelpViewer();
m_centralWidget->currentSource().toString());
}
void HelpPlugin::addNewBookmark(const QString &title, const QString &url) const QString &url = viewer->source().toString();
{ if (url.isEmpty() || url == Help::Constants::AboutBlank)
if (url.isEmpty() || url == QLatin1String("about:blank"))
return; return;
BookmarkManager *manager = &HelpManager::bookmarkManager(); BookmarkManager *manager = &HelpManager::bookmarkManager();
manager->showBookmarkDialog(m_centralWidget, title, url); manager->showBookmarkDialog(m_centralWidget, viewer->title(), url);
} }
void HelpPlugin::handleHelpRequest(const QString &address) void HelpPlugin::handleHelpRequest(const QString &address)
{ {
if (HelpViewer::launchWithExternalApp(address))
return;
if (m_helpManager->helpEngineCore().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")) {

View File

@@ -26,6 +26,7 @@
** contact the sales department at http://qt.nokia.com/contact. ** contact the sales department at http://qt.nokia.com/contact.
** **
**************************************************************************/ **************************************************************************/
#ifndef HELPPLUGIN_H #ifndef HELPPLUGIN_H
#define HELPPLUGIN_H #define HELPPLUGIN_H
@@ -33,14 +34,11 @@
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QStringList> #include <QtCore/QStringList>
QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QAction)
class QAction; QT_FORWARD_DECLARE_CLASS(QComboBox)
class QComboBox; QT_FORWARD_DECLARE_CLASS(QToolBar)
class QToolBar; QT_FORWARD_DECLARE_CLASS(QToolButton)
class QUrl; QT_FORWARD_DECLARE_CLASS(QUrl)
QT_END_NAMESPACE
class HelpViewer;
namespace Core { namespace Core {
class ICore; class ICore;
@@ -57,8 +55,10 @@ namespace Internal {
class CentralWidget; class CentralWidget;
class DocSettingsPage; class DocSettingsPage;
class FilterSettingsPage; class FilterSettingsPage;
class HelpMode;
class GeneralSettingsPage; class GeneralSettingsPage;
class HelpMode;
class HelpViewer;
class OpenPagesManager;
class SearchWidget; class SearchWidget;
class HelpPlugin : public ExtensionSystem::IPlugin class HelpPlugin : public ExtensionSystem::IPlugin
@@ -78,14 +78,16 @@ public slots:
private slots: private slots:
void modeChanged(Core::IMode *mode); void modeChanged(Core::IMode *mode);
void activateContext(); void activateContext();
void activateIndex(); void activateIndex();
void activateContents(); void activateContents();
void activateSearch(); void activateSearch();
void activateOpenPages();
void addBookmark();
void updateFilterComboBox(); void updateFilterComboBox();
void filterDocumentation(const QString &customFilter); void filterDocumentation(const QString &customFilter);
void addBookmark();
void addNewBookmark(const QString &title, const QString &url);
void switchToHelpMode(); void switchToHelpMode();
void switchToHelpMode(const QUrl &source); void switchToHelpMode(const QUrl &source);
@@ -96,18 +98,14 @@ private slots:
void updateSideBarSource(const QUrl &newUrl); void updateSideBarSource(const QUrl &newUrl);
void fontChanged(); void fontChanged();
void updateCloseButton();
void setupHelpEngineIfNeeded(); void setupHelpEngineIfNeeded();
void rebuildViewerComboBox();
void removeViewerFromComboBox(int index);
void updateViewerComboBoxIndex(int index);
private: private:
void setupUi(); void setupUi();
void resetFilter(); void resetFilter();
void activateHelpMode(); void activateHelpMode();
QToolBar *createToolBar(); QToolBar *createToolBar();
void connectCentralWidget();
HelpViewer* viewerForContextMode(); HelpViewer* viewerForContextMode();
void createRightPaneContextViewer(); void createRightPaneContextViewer();
@@ -122,18 +120,21 @@ private:
Core::SideBarItem *m_indexItem; Core::SideBarItem *m_indexItem;
Core::SideBarItem *m_searchItem; Core::SideBarItem *m_searchItem;
Core::SideBarItem *m_bookmarkItem; Core::SideBarItem *m_bookmarkItem;
Core::SideBarItem *m_openPagesItem;
DocSettingsPage *m_docSettingsPage; DocSettingsPage *m_docSettingsPage;
FilterSettingsPage *m_filterSettingsPage; FilterSettingsPage *m_filterSettingsPage;
GeneralSettingsPage *m_generalSettingsPage; GeneralSettingsPage *m_generalSettingsPage;
QComboBox *m_documentsCombo;
QComboBox *m_filterComboBox; QComboBox *m_filterComboBox;
Core::SideBar *m_sideBar; Core::SideBar *m_sideBar;
bool m_firstModeChange; bool m_firstModeChange;
HelpManager *m_helpManager; HelpManager *m_helpManager;
OpenPagesManager *m_openPagesManager;
Core::MiniSplitter *m_splitter; Core::MiniSplitter *m_splitter;
QToolButton *m_closeButton;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -29,6 +29,7 @@
#include "searchwidget.h" #include "searchwidget.h"
#include "helpmanager.h" #include "helpmanager.h"
#include "openpagesmanager.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
@@ -109,7 +110,7 @@ void SearchWidget::showEvent(QShowEvent *event)
connect(queryWidget, SIGNAL(search()), this, SLOT(search())); connect(queryWidget, SIGNAL(search()), this, SLOT(search()));
connect(resultWidget, SIGNAL(requestShowLink(QUrl)), this, connect(resultWidget, SIGNAL(requestShowLink(QUrl)), this,
SIGNAL(requestShowLink(QUrl))); SIGNAL(linkActivated(QUrl)));
connect(searchEngine, SIGNAL(searchingStarted()), this, connect(searchEngine, SIGNAL(searchingStarted()), this,
SLOT(searchingStarted())); SLOT(searchingStarted()));
@@ -179,71 +180,47 @@ bool SearchWidget::eventFilter(QObject* o, QEvent *e)
bool controlPressed = me->modifiers() & Qt::ControlModifier; bool controlPressed = me->modifiers() & Qt::ControlModifier;
if((me->button() == Qt::LeftButton && controlPressed) if((me->button() == Qt::LeftButton && controlPressed)
|| (me->button() == Qt::MidButton)) { || (me->button() == Qt::MidButton)) {
emit requestShowLinkInNewTab(link); OpenPagesManager::instance().createPageFromSearch(link);
} }
} }
} }
return QWidget::eventFilter(o,e); return QWidget::eventFilter(o,e);
} }
void SearchWidget::keyPressEvent(QKeyEvent *keyEvent)
{
if (keyEvent->key() == Qt::Key_Escape)
emit escapePressed();
}
void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
{ {
QMenu menu;
QPoint point = contextMenuEvent->globalPos();
QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget);
if (!browser) if (!browser)
return; return;
point = browser->mapFromGlobal(point); QPoint point = browser->mapFromGlobal(contextMenuEvent->globalPos());
if (!browser->rect().contains(point, true)) if (!browser->rect().contains(point, true))
return; return;
QAction *openLink = 0;
QAction *openLinkInNewTab = 0;
QAction *copyAnchorAction = 0;
QMenu menu;
QUrl link = browser->anchorAt(point); QUrl link = browser->anchorAt(point);
if (!link.isEmpty() && link.isValid()) {
QKeySequence keySeq(QKeySequence::Copy); if (link.isRelative())
QAction *copyAction = menu.addAction(tr("&Copy") + QLatin1String("\t") + link = browser->source().resolved(link);
keySeq.toString(QKeySequence::NativeText)); openLink = menu.addAction(tr("Open Link"));
copyAction->setEnabled(QTextCursor(browser->textCursor()).hasSelection()); openLinkInNewTab = menu.addAction(tr("Open Link as New Page"));
copyAnchorAction = menu.addAction(tr("Copy Link"));
QAction *copyAnchorAction = menu.addAction(tr("Copy &Link Location")); } else if (browser->textCursor().hasSelection()) {
copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid()); menu.addAction(tr("Copy"), browser, SLOT(copy()));
} else {
keySeq = QKeySequence(Qt::CTRL); menu.addAction(tr("Reload"), browser, SLOT(reload()));
QAction *newTabAction = menu.addAction(tr("Open Link in New Tab") + }
QLatin1String("\t") + keySeq.toString(QKeySequence::NativeText) +
QLatin1String("LMB"));
newTabAction->setEnabled(!link.isEmpty() && link.isValid());
menu.addSeparator();
keySeq = QKeySequence::SelectAll;
QAction *selectAllAction = menu.addAction(tr("Select All") +
QLatin1String("\t") + keySeq.toString(QKeySequence::NativeText));
QAction *usedAction = menu.exec(mapToGlobal(contextMenuEvent->pos())); QAction *usedAction = menu.exec(mapToGlobal(contextMenuEvent->pos()));
if (usedAction == copyAction) { if (usedAction == openLink) {
QTextCursor cursor = browser->textCursor(); browser->selectAll();
if (!cursor.isNull() && cursor.hasSelection()) { } else if (usedAction == openLinkInNewTab) {
QString selectedText = cursor.selectedText(); OpenPagesManager::instance().createPageFromSearch(link);
QMimeData *data = new QMimeData(); } else if (usedAction == copyAnchorAction) {
data->setText(selectedText);
QApplication::clipboard()->setMimeData(data);
}
}
else if (usedAction == copyAnchorAction) {
QApplication::clipboard()->setText(link.toString()); QApplication::clipboard()->setText(link.toString());
} }
else if (usedAction == newTabAction) {
emit requestShowLinkInNewTab(link);
}
else if (usedAction == selectAllAction) {
browser->selectAll();
}
} }

View File

@@ -56,9 +56,7 @@ public:
void resetZoom(); void resetZoom();
signals: signals:
void requestShowLink(const QUrl &url); void linkActivated(const QUrl &link);
void requestShowLinkInNewTab(const QUrl &url);
void escapePressed();
protected: protected:
void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);
@@ -74,7 +72,6 @@ private slots:
private: private:
bool eventFilter(QObject* o, QEvent *e); bool eventFilter(QObject* o, QEvent *e);
void keyPressEvent(QKeyEvent *keyEvent);
void contextMenuEvent(QContextMenuEvent *contextMenuEvent); void contextMenuEvent(QContextMenuEvent *contextMenuEvent);
private: private:

View File

@@ -31,6 +31,7 @@
#include "centralwidget.h" #include "centralwidget.h"
#include "helpmanager.h" #include "helpmanager.h"
#include "openpagesmanager.h"
#include <QtGui/QMenu> #include <QtGui/QMenu>
#include <QtGui/QIcon> #include <QtGui/QIcon>
@@ -50,6 +51,7 @@
#include <QtGui/QDialogButtonBox> #include <QtGui/QDialogButtonBox>
#include <QtGui/QSortFilterProxyModel> #include <QtGui/QSortFilterProxyModel>
using namespace Help::Internal;
BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title, BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
const QString &url, QWidget *parent) const QString &url, QWidget *parent)
@@ -360,7 +362,7 @@ void BookmarkWidget::activated(const QModelIndex &index)
QString data = index.data(Qt::UserRole + 10).toString(); QString data = index.data(Qt::UserRole + 10).toString();
if (data != QLatin1String("Folder")) if (data != QLatin1String("Folder"))
emit requestShowLink(data); emit linkActivated(data);
} }
void BookmarkWidget::customContextMenuRequested(const QPoint &point) void BookmarkWidget::customContextMenuRequested(const QPoint &point)
@@ -394,10 +396,10 @@ void BookmarkWidget::customContextMenuRequested(const QPoint &point)
return; return;
if (pickedAction == showItem) { if (pickedAction == showItem) {
emit requestShowLink(data); emit linkActivated(data);
} }
else if (pickedAction == showItemNewTab) { else if (pickedAction == showItemNewTab) {
Help::Internal::CentralWidget::instance()->setSourceInNewTab(data); OpenPagesManager::instance().createPage(data);
} }
else if (pickedAction == removeItem) { else if (pickedAction == removeItem) {
bookmarkManager->removeBookmarkItem(treeView, bookmarkManager->removeBookmarkItem(treeView,
@@ -540,13 +542,9 @@ bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
if (index.isValid()) { if (index.isValid()) {
QString data = index.data(Qt::UserRole + 10).toString(); QString data = index.data(Qt::UserRole + 10).toString();
if (!data.isEmpty() && data != QLatin1String("Folder")) if (!data.isEmpty() && data != QLatin1String("Folder"))
emit requestShowLink(data); emit linkActivated(data);
} }
} break; } break;
case Qt::Key_Escape: {
emit escapePressed();
} break;
} }
} else if (e->type() == QEvent::MouseButtonRelease) { } else if (e->type() == QEvent::MouseButtonRelease) {
if (index.isValid()) { if (index.isValid()) {
@@ -556,7 +554,7 @@ bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
|| (me->button() == Qt::MidButton)) { || (me->button() == Qt::MidButton)) {
QString data = index.data(Qt::UserRole + 10).toString(); QString data = index.data(Qt::UserRole + 10).toString();
if (!data.isEmpty() && data != QLatin1String("Folder")) if (!data.isEmpty() && data != QLatin1String("Folder"))
Help::Internal::CentralWidget::instance()->setSourceInNewTab(data); OpenPagesManager::instance().createPage(data);
} }
} }
} }

View File

@@ -115,8 +115,7 @@ public:
signals: signals:
void addBookmark(); void addBookmark();
void requestShowLink(const QUrl &url); void linkActivated(const QUrl &url);
void escapePressed();
private slots: private slots:
void removeClicked(); void removeClicked();

View File

@@ -29,8 +29,8 @@
#include "contentwindow.h" #include "contentwindow.h"
#include "centralwidget.h"
#include "helpmanager.h" #include "helpmanager.h"
#include "openpagesmanager.h"
#include <QtGui/QLayout> #include <QtGui/QLayout>
#include <QtGui/QFocusEvent> #include <QtGui/QFocusEvent>
@@ -39,6 +39,8 @@
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpContentWidget> #include <QtHelp/QHelpContentWidget>
using namespace Help::Internal;
ContentWindow::ContentWindow() ContentWindow::ContentWindow()
: m_contentWidget(0) : m_contentWidget(0)
, m_expandDepth(-2) , m_expandDepth(-2)
@@ -110,15 +112,12 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
if (contentModel) { if (contentModel) {
QHelpContentItem *itm = contentModel->contentItemAt(index); QHelpContentItem *itm = contentModel->contentItemAt(index);
if (itm && !isPdfFile(itm)) if (itm && !isPdfFile(itm))
Help::Internal::CentralWidget::instance()->setSourceInNewTab(itm->url()); OpenPagesManager::instance().createPage(itm->url());
} }
} else if (button == Qt::LeftButton) { } else if (button == Qt::LeftButton) {
itemClicked(index); itemClicked(index);
} }
} }
} else if (o == m_contentWidget && e->type() == QEvent::KeyPress) {
if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Escape)
emit escapePressed();
} }
return QWidget::eventFilter(o, e); return QWidget::eventFilter(o, e);
} }
@@ -135,7 +134,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
QMenu menu; QMenu menu;
QAction *curTab = menu.addAction(tr("Open Link")); QAction *curTab = menu.addAction(tr("Open Link"));
QAction *newTab = menu.addAction(tr("Open Link in New Tab")); QAction *newTab = menu.addAction(tr("Open Link as New Page"));
if (isPdfFile(itm)) if (isPdfFile(itm))
newTab->setEnabled(false); newTab->setEnabled(false);
@@ -145,7 +144,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
if (curTab == action) if (curTab == action)
emit linkActivated(itm->url()); emit linkActivated(itm->url());
else if (newTab == action) else if (newTab == action)
Help::Internal::CentralWidget::instance()->setSourceInNewTab(itm->url()); OpenPagesManager::instance().createPage(itm->url());
} }
void ContentWindow::itemClicked(const QModelIndex &index) void ContentWindow::itemClicked(const QModelIndex &index)

View File

@@ -54,7 +54,6 @@ public:
signals: signals:
void linkActivated(const QUrl &link); void linkActivated(const QUrl &link);
void escapePressed();
private slots: private slots:
void showContextMenu(const QPoint &pos); void showContextMenu(const QPoint &pos);

View File

@@ -8,7 +8,6 @@ HEADERS += \
$$PWD/bookmarkmanager.h \ $$PWD/bookmarkmanager.h \
$$PWD/contentwindow.h \ $$PWD/contentwindow.h \
$$PWD/filternamedialog.h \ $$PWD/filternamedialog.h \
$$PWD/helpviewer.h \
$$PWD/indexwindow.h \ $$PWD/indexwindow.h \
$$PWD/topicchooser.h \ $$PWD/topicchooser.h \
$$PWD/../namespace_global.h $$PWD/../namespace_global.h
@@ -17,7 +16,6 @@ SOURCES += \
$$PWD/bookmarkmanager.cpp \ $$PWD/bookmarkmanager.cpp \
$$PWD/contentwindow.cpp \ $$PWD/contentwindow.cpp \
$$PWD/filternamedialog.cpp \ $$PWD/filternamedialog.cpp \
$$PWD/helpviewer.cpp \
$$PWD/indexwindow.cpp \ $$PWD/indexwindow.cpp \
$$PWD/topicchooser.cpp $$PWD/topicchooser.cpp

View File

@@ -1,635 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "helpviewer.h"
#include "centralwidget.h"
#include "helpmanager.h"
#include <QtCore/QDir>
#include <QtCore/QEvent>
#include <QtCore/QVariant>
#include <QtCore/QByteArray>
#include <QtCore/QTimer>
#include <QtGui/QMenu>
#include <QtGui/QKeyEvent>
#include <QtGui/QClipboard>
#include <QtGui/QApplication>
#include <QtGui/QMessageBox>
#include <QtGui/QDesktopServices>
#include <QtHelp/QHelpEngineCore>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
static QString PageNotFoundMessage =
QCoreApplication::translate("HelpViewer", "<title>Error 404...</title><div "
"align=\"center\"><br><br><h1>The page could not be found</h1><br><h3>'%1'"
"</h3></div>");
#if !defined(QT_NO_WEBKIT)
class HelpNetworkReply : public QNetworkReply
{
public:
HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData,
const QString &mimeType);
virtual void abort();
virtual qint64 bytesAvailable() const
{ return data.length() + QNetworkReply::bytesAvailable(); }
protected:
virtual qint64 readData(char *data, qint64 maxlen);
private:
QByteArray data;
qint64 origLen;
};
HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request,
const QByteArray &fileData, const QString &mimeType)
: data(fileData), origLen(fileData.length())
{
setRequest(request);
setOpenMode(QIODevice::ReadOnly);
setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
QTimer::singleShot(0, this, SIGNAL(readyRead()));
}
void HelpNetworkReply::abort()
{
// nothing to do
}
qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
{
qint64 len = qMin(qint64(data.length()), maxlen);
if (len) {
qMemCopy(buffer, data.constData(), len);
data.remove(0, len);
}
if (!data.length())
QTimer::singleShot(0, this, SIGNAL(finished()));
return len;
}
class HelpNetworkAccessManager : public QNetworkAccessManager
{
public:
HelpNetworkAccessManager(QObject *parent);
protected:
virtual QNetworkReply *createRequest(Operation op,
const QNetworkRequest &request, QIODevice *outgoingData = 0);
};
HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
: QNetworkAccessManager(parent)
{
}
QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
const QNetworkRequest &request, QIODevice * /*outgoingData*/)
{
const QUrl& url = request.url();
QString mimeType = url.toString();
if (mimeType.endsWith(QLatin1String(".svg"))
|| mimeType.endsWith(QLatin1String(".svgz"))) {
mimeType = QLatin1String("image/svg+xml");
} else if (mimeType.endsWith(QLatin1String(".css"))) {
mimeType = QLatin1String("text/css");
} else if (mimeType.endsWith(QLatin1String(".js"))) {
mimeType = QLatin1String("text/javascript");
} else if (mimeType.endsWith(QLatin1String(".txt"))) {
mimeType = QLatin1String("text/plain");
} else {
mimeType = QLatin1String("text/html");
}
const QHelpEngineCore &engine = Help::HelpManager::helpEngineCore();
const QByteArray &data = engine.findFile(url).isValid()
? engine.fileData(url) : PageNotFoundMessage.arg(url.toString()).toUtf8();
return new HelpNetworkReply(request, data, mimeType);
}
class HelpPage : public QWebPage
{
friend class HelpViewer;
public:
HelpPage(Help::Internal::CentralWidget *central, QObject *parent);
protected:
virtual QWebPage *createWindow(QWebPage::WebWindowType);
virtual bool acceptNavigationRequest(QWebFrame *frame,
const QNetworkRequest &request, NavigationType type);
private:
Help::Internal::CentralWidget *centralWidget;
Qt::MouseButtons m_pressedButtons;
Qt::KeyboardModifiers m_keyboardModifiers;
};
HelpPage::HelpPage(Help::Internal::CentralWidget *central, QObject *parent)
: QWebPage(parent)
, centralWidget(central)
, m_pressedButtons(Qt::NoButton)
, m_keyboardModifiers(Qt::NoModifier)
{
}
QWebPage *HelpPage::createWindow(QWebPage::WebWindowType)
{
return centralWidget->newEmptyTab()->page();
}
static bool isLocalUrl(const QUrl &url)
{
const QString scheme = url.scheme();
if (scheme.isEmpty()
|| scheme == QLatin1String("file")
|| scheme == QLatin1String("qrc")
|| scheme == QLatin1String("data")
|| scheme == QLatin1String("qthelp")
|| scheme == QLatin1String("about"))
return true;
return false;
}
bool HelpPage::acceptNavigationRequest(QWebFrame *,
const QNetworkRequest &request, QWebPage::NavigationType type)
{
const QUrl &url = request.url();
if (isLocalUrl(url)) {
const QString& path = url.path();
if (path.endsWith(QLatin1String(".pdf"))) {
const int lastDash = path.lastIndexOf(QChar('/'));
QString fileName = QDir::tempPath() + QDir::separator();
if (lastDash < 0)
fileName += path;
else
fileName += path.mid(lastDash + 1, path.length());
QFile tmpFile(QDir::cleanPath(fileName));
if (tmpFile.open(QIODevice::ReadWrite)) {
tmpFile.write(Help::HelpManager::helpEngineCore().fileData(url));
tmpFile.close();
}
QDesktopServices::openUrl(QUrl(tmpFile.fileName()));
return false;
}
if (type == QWebPage::NavigationTypeLinkClicked
&& (m_keyboardModifiers & Qt::ControlModifier
|| m_pressedButtons == Qt::MidButton)) {
HelpViewer* viewer = centralWidget->newEmptyTab();
if (viewer)
centralWidget->setSource(url);
m_pressedButtons = Qt::NoButton;
m_keyboardModifiers = Qt::NoModifier;
return false;
}
return true;
}
QDesktopServices::openUrl(url);
return false;
}
HelpViewer::HelpViewer(Help::Internal::CentralWidget *central, QWidget *parent)
: QWebView(parent)
, parentWidget(central)
, multiTabsAllowed(true)
, loadFinished(false)
{
setPage(new HelpPage(central, this));
settings()->setAttribute(QWebSettings::PluginsEnabled, false);
settings()->setAttribute(QWebSettings::JavaEnabled, false);
page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
action->setText(tr("Open Link in New Tab"));
if (!central) {
multiTabsAllowed = false;
action->setVisible(false);
}
pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false);
connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(pageAction(QWebPage::Back), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this,
SIGNAL(highlighted(QString)));
connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
setAcceptDrops(false);
}
void HelpViewer::setSource(const QUrl &url)
{
loadFinished = false;
if (!homeUrl.isValid())
homeUrl = url;
load(url);
}
void HelpViewer::resetZoom()
{
setTextSizeMultiplier(1.0);
}
void HelpViewer::zoomIn(int range)
{
setTextSizeMultiplier(qMin(2.0, textSizeMultiplier() + range / 10.0));
}
void HelpViewer::zoomOut(int range)
{
setTextSizeMultiplier(qMax(0.5, textSizeMultiplier() - range / 10.0));
}
int HelpViewer::zoom() const
{
qreal zoom = textSizeMultiplier() * 10.0;
return (zoom < 10.0 ? zoom * -1.0 : zoom - 10.0);
}
void HelpViewer::home()
{
const QHelpEngineCore &engine = Help::HelpManager::helpEngineCore();
QString homepage = engine.customValue(QLatin1String("HomePage"),
QLatin1String("")).toString();
if (homepage.isEmpty()) {
homepage = engine.customValue(QLatin1String("DefaultHomePage"),
QLatin1String("about:blank")).toString();
}
setSource(homepage);
}
// TODO: remove this once we support multiple keysequences per command
void HelpViewer::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Insert && e->modifiers() == Qt::CTRL) {
if (hasSelection())
copy();
}
QWebView::keyPressEvent(e);
}
void HelpViewer::wheelEvent(QWheelEvent *e)
{
if (e->modifiers() & Qt::ControlModifier) {
const int delta = e->delta();
if (delta > 0)
zoomIn(delta / 120);
else if (delta < 0)
zoomOut(-delta / 120);
e->accept();
return;
}
QWebView::wheelEvent(e);
}
bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
{
if (e->button() == Qt::XButton1) {
triggerPageAction(QWebPage::Back);
return true;
}
if (e->button() == Qt::XButton2) {
triggerPageAction(QWebPage::Forward);
return true;
}
return false;
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
#ifndef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
return;
#endif
QWebView::mouseReleaseEvent(e);
}
void HelpViewer::actionChanged()
{
QAction *a = qobject_cast<QAction *>(sender());
if (a == pageAction(QWebPage::Copy))
emit copyAvailable(a->isEnabled());
else if (a == pageAction(QWebPage::Back))
emit backwardAvailable(a->isEnabled());
else if (a == pageAction(QWebPage::Forward))
emit forwardAvailable(a->isEnabled());
}
void HelpViewer::mousePressEvent(QMouseEvent *event)
{
HelpPage *currentPage = static_cast<HelpPage*>(page());
if ((currentPage != 0) && multiTabsAllowed) {
currentPage->m_pressedButtons = event->buttons();
currentPage->m_keyboardModifiers = event->modifiers();
}
#ifdef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(event))
return;
#endif
QWebView::mousePressEvent(event);
}
void HelpViewer::setLoadFinished(bool ok)
{
loadFinished = ok;
emit sourceChanged(url());
}
#else // !defined(QT_NO_WEBKIT)
HelpViewer::HelpViewer(Help::Internal::CentralWidget *central, QWidget *parent)
: QTextBrowser(parent)
, zoomCount(0)
, controlPressed(false)
, lastAnchor(QString())
, parentWidget(central)
{
document()->setDocumentMargin(8);
}
void HelpViewer::setSource(const QUrl &url)
{
bool help = url.toString() == QLatin1String("help");
if (url.isValid() && !help) {
if (launchedWithExternalApp(url))
return;
QUrl u = Help::HelpManager::helpEngineCore().findFile(url);
if (u.isValid()) {
if (!homeUrl.isValid())
homeUrl = url;
QTextBrowser::setSource(u);
return;
}
}
if (help) {
QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com."
"assistantinternal_1.0.0/assistant/assistant.html")));
} else {
QTextBrowser::setSource(url);
setHtml(PageNotFoundMessage.arg(url.toString()));
emit sourceChanged(url);
}
}
void HelpViewer::resetZoom()
{
if (zoomCount == 0)
return;
QTextBrowser::zoomOut(zoomCount);
zoomCount = 0;
}
void HelpViewer::zoomIn(int range)
{
if (zoomCount == 10)
return;
QTextBrowser::zoomIn(range);
zoomCount++;
}
void HelpViewer::zoomOut(int range)
{
if (zoomCount == -5)
return;
QTextBrowser::zoomOut(range);
zoomCount--;
}
bool HelpViewer::launchedWithExternalApp(const QUrl &url)
{
bool isPdf = url.path().endsWith(QLatin1String("pdf"));
if (url.scheme() == QLatin1String("http")
|| url.scheme() == QLatin1String("ftp")
|| url.scheme() == QLatin1String("mailto") || isPdf) {
bool launched = false;
if (isPdf && url.scheme() == QLatin1String("qthelp")) {
QString fileName = url.toString();
fileName = QDir::tempPath() + QDir::separator() + fileName.right
(fileName.length() - fileName.lastIndexOf(QChar('/')));
QFile tmpFile(QDir::cleanPath(fileName));
if (tmpFile.open(QIODevice::ReadWrite)) {
tmpFile.write(Help::HelpManager::helpEngineCore().fileData(url));
tmpFile.close();
}
launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName()));
} else {
launched = QDesktopServices::openUrl(url);
}
if (!launched) {
QMessageBox::information(this, tr("Help"),
tr("Unable to launch external application.\n"), tr("OK"));
}
return true;
}
return false;
}
QVariant HelpViewer::loadResource(int type, const QUrl &name)
{
QByteArray ba;
if (type < 4) {
ba = Help::HelpManager::helpEngineCore().fileData(name);
if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
QImage image;
image.loadFromData(ba, "svg");
if (!image.isNull())
return image;
}
}
return ba;
}
void HelpViewer::openLinkInNewTab()
{
if (lastAnchor.isEmpty())
return;
parentWidget->setSourceInNewTab(QUrl(lastAnchor));
lastAnchor.clear();
}
void HelpViewer::openLinkInNewTab(const QString &link)
{
lastAnchor = link;
openLinkInNewTab();
}
bool HelpViewer::hasAnchorAt(const QPoint& pos)
{
lastAnchor = anchorAt(pos);
if (lastAnchor.isEmpty())
return false;
lastAnchor = source().resolved(lastAnchor).toString();
if (lastAnchor.at(0) == QLatin1Char('#')) {
QString src = source().toString();
int hsh = src.indexOf(QLatin1Char('#'));
lastAnchor = (hsh>=0 ? src.left(hsh) : src) + lastAnchor;
}
return true;
}
void HelpViewer::contextMenuEvent(QContextMenuEvent *e)
{
QMenu menu(QLatin1String(""), 0);
QUrl link;
QAction *copyAnchorAction = 0;
if (hasAnchorAt(e->pos())) {
link = anchorAt(e->pos());
if (link.isRelative())
link = source().resolved(link);
copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid());
menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this,
SLOT(openLinkInNewTab()));
menu.addSeparator();
}
menu.addActions(parentWidget->globalActions());
QAction *action = menu.exec(e->globalPos());
if (action == copyAnchorAction)
QApplication::clipboard()->setText(link.toString());
}
bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
{
if (e->button() == Qt::XButton1) {
QTextBrowser::backward();
return true;
}
if (e->button() == Qt::XButton2) {
QTextBrowser::forward();
return true;
}
return false;
}
void HelpViewer::mousePressEvent(QMouseEvent *e)
{
#ifdef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
return;
#endif
QTextBrowser::mousePressEvent(e);
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
#ifndef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
return;
#endif
controlPressed = e->modifiers() & Qt::ControlModifier;
if ((controlPressed && hasAnchorAt(e->pos())) ||
(e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) {
openLinkInNewTab();
return;
}
QTextBrowser::mouseReleaseEvent(e);
}
void HelpViewer::keyPressEvent(QKeyEvent *e)
{
if ((e->key() == Qt::Key_Home && e->modifiers() != Qt::NoModifier)
|| (e->key() == Qt::Key_End && e->modifiers() != Qt::NoModifier)) {
QKeyEvent* event = new QKeyEvent(e->type(), e->key(), Qt::NoModifier,
e->text(), e->isAutoRepeat(), e->count());
e = event;
}
QTextBrowser::keyPressEvent(e);
}
void HelpViewer::home()
{
const QHelpEngineCore &engine = Help::HelpManager::helpEngineCore();
QString homepage = engine.customValue(QLatin1String("HomePage"),
QLatin1String("")).toString();
if (homepage.isEmpty()) {
homepage = engine.customValue(QLatin1String("DefaultHomePage"),
QLatin1String("about:blank")).toString();
}
setSource(homepage);
}
void HelpViewer::wheelEvent(QWheelEvent *e)
{
if (e->modifiers() == Qt::CTRL) {
e->accept();
(e->delta() > 0) ? zoomIn() : zoomOut();
} else {
e->ignore();
QTextBrowser::wheelEvent(e);
}
}
#endif // !defined(QT_NO_WEBKIT)

View File

@@ -1,176 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef HELPVIEWER_H
#define HELPVIEWER_H
#include <QtCore/QUrl>
#include <QtCore/QVariant>
#include <QtGui/QTextBrowser>
#include <QtGui/QAction>
#if !defined(QT_NO_WEBKIT)
#include <QWebView>
#endif
QT_BEGIN_NAMESPACE
class QPoint;
class QString;
class QKeyEvent;
class QMouseEvent;
class QContextMenuEvent;
QT_END_NAMESPACE
namespace Help {
namespace Internal {
class CentralWidget;
} // namespace Internal
} // namespace Help
#if !defined(QT_NO_WEBKIT)
class HelpViewer : public QWebView
{
Q_OBJECT
public:
HelpViewer(Help::Internal::CentralWidget *central, QWidget *parent);
void setSource(const QUrl &url);
inline QUrl source() const
{ return url(); }
inline QString documentTitle() const
{ return title(); }
inline bool hasSelection() const
{ return !selectedText().isEmpty(); } // ### this is suboptimal
void zoomIn(int range = 1);
void zoomOut(int range = 1);
void resetZoom();
int zoom() const;
void setZoom(int zoom) { zoomIn(zoom); }
inline bool isForwardAvailable() const
{ return pageAction(QWebPage::Forward)->isEnabled(); }
inline bool isBackwardAvailable() const
{ return pageAction(QWebPage::Back)->isEnabled(); }
inline bool hasLoadFinished() const
{ return loadFinished; }
public Q_SLOTS:
void home();
void backward() { back(); }
void copy() { triggerPageAction(QWebPage::Copy); }
Q_SIGNALS:
void copyAvailable(bool enabled);
void forwardAvailable(bool enabled);
void backwardAvailable(bool enabled);
void highlighted(const QString &);
void sourceChanged(const QUrl &);
protected:
void keyPressEvent(QKeyEvent *e);
void wheelEvent(QWheelEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *event);
private Q_SLOTS:
void actionChanged();
void setLoadFinished(bool ok);
private:
bool handleForwardBackwardMouseButtons(QMouseEvent *e);
Help::Internal::CentralWidget* parentWidget;
QUrl homeUrl;
bool multiTabsAllowed;
bool loadFinished;
};
#else
class HelpViewer : public QTextBrowser
{
Q_OBJECT
public:
HelpViewer(Help::Internal::CentralWidget *central, QWidget *parent);
void setSource(const QUrl &url);
void zoomIn(int range = 1);
void zoomOut(int range = 1);
void resetZoom();
int zoom() const { return zoomCount; }
void setZoom(int zoom) { zoomCount = zoom; }
inline bool hasSelection() const
{ return textCursor().hasSelection(); }
bool launchedWithExternalApp(const QUrl &url);
public Q_SLOTS:
void home();
protected:
void wheelEvent(QWheelEvent *e);
private:
QVariant loadResource(int type, const QUrl &name);
void openLinkInNewTab(const QString &link);
bool hasAnchorAt(const QPoint& pos);
void contextMenuEvent(QContextMenuEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
private slots:
void openLinkInNewTab();
private:
bool handleForwardBackwardMouseButtons(QMouseEvent *e);
int zoomCount;
bool controlPressed;
QString lastAnchor;
Help::Internal::CentralWidget* parentWidget;
QUrl homeUrl;
};
#endif
#endif

View File

@@ -28,8 +28,10 @@
**************************************************************************/ **************************************************************************/
#include "centralwidget.h" #include "centralwidget.h"
#include "helpmanager.h" #include "helpmanager.h"
#include "indexwindow.h" #include "indexwindow.h"
#include "openpagesmanager.h"
#include "topicchooser.h" #include "topicchooser.h"
#include <QtGui/QLayout> #include <QtGui/QLayout>
@@ -43,6 +45,8 @@
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexWidget> #include <QtHelp/QHelpIndexWidget>
using namespace Help::Internal;
IndexWindow::IndexWindow() IndexWindow::IndexWindow()
: m_searchLineEdit(0) : m_searchLineEdit(0)
, m_indexWidget(0) , m_indexWidget(0)
@@ -108,9 +112,6 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e)
if (idx.isValid()) if (idx.isValid())
m_indexWidget->setCurrentIndex(idx); m_indexWidget->setCurrentIndex(idx);
break; break;
case Qt::Key_Escape:
emit escapePressed();
break;
default: ; // stop complaining default: ; // stop complaining
} }
} else if (obj == m_searchLineEdit } else if (obj == m_searchLineEdit
@@ -124,7 +125,7 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e)
if (idx.isValid()) { if (idx.isValid()) {
QMenu menu; QMenu menu;
QAction *curTab = menu.addAction(tr("Open Link")); QAction *curTab = menu.addAction(tr("Open Link"));
QAction *newTab = menu.addAction(tr("Open Link in New Tab")); QAction *newTab = menu.addAction(tr("Open Link as New Page"));
menu.move(m_indexWidget->mapToGlobal(ctxtEvent->pos())); menu.move(m_indexWidget->mapToGlobal(ctxtEvent->pos()));
QAction *action = menu.exec(); QAction *action = menu.exec();
@@ -194,6 +195,6 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive)) if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive))
Help::Internal::CentralWidget::instance()->setSource(url); Help::Internal::CentralWidget::instance()->setSource(url);
else else
Help::Internal::CentralWidget::instance()->setSourceInNewTab(url); OpenPagesManager::instance().createPage(url);
} }
} }

View File

@@ -59,7 +59,6 @@ signals:
void linkActivated(const QUrl &link); void linkActivated(const QUrl &link);
void linksActivated(const QMap<QString, QUrl> &links, void linksActivated(const QMap<QString, QUrl> &links,
const QString &keyword); const QString &keyword);
void escapePressed();
private slots: private slots:
void filterIndices(const QString &filter); void filterIndices(const QString &filter);