summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2010-05-04 16:17:02 (GMT)
committerkh1 <qt-info@nokia.com>2010-05-04 16:17:02 (GMT)
commitd873afaa7adfc5e633191332d0674aa1977904d1 (patch)
treedeba228c84474168c8f079ebe37e6c641bc8b170 /tools/assistant
parentd494f2312d24805c6e9cf49101cf54dc8dc8bef7 (diff)
downloadQt-d873afaa7adfc5e633191332d0674aa1977904d1.zip
Qt-d873afaa7adfc5e633191332d0674aa1977904d1.tar.gz
Qt-d873afaa7adfc5e633191332d0674aa1977904d1.tar.bz2
Sync against latest Qt Creator.
Reviewed-by: ck
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/aboutdialog.cpp9
-rw-r--r--tools/assistant/tools/assistant/assistant.pro9
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp508
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h51
-rw-r--r--tools/assistant/tools/assistant/contentwindow.cpp7
-rw-r--r--tools/assistant/tools/assistant/findwidget.cpp2
-rw-r--r--tools/assistant/tools/assistant/findwidget.h5
-rw-r--r--tools/assistant/tools/assistant/globalactions.cpp2
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp64
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h101
-rw-r--r--tools/assistant/tools/assistant/helpviewer_p.h (renamed from tools/assistant/tools/assistant/helpviewer_qtb.h)109
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qtb.cpp328
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.cpp211
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.h120
-rw-r--r--tools/assistant/tools/assistant/indexwindow.cpp5
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.cpp8
-rw-r--r--tools/assistant/tools/assistant/openpagesmodel.cpp8
17 files changed, 785 insertions, 762 deletions
diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp
index a9bc352..9935a1e 100644
--- a/tools/assistant/tools/assistant/aboutdialog.cpp
+++ b/tools/assistant/tools/assistant/aboutdialog.cpp
@@ -38,6 +38,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
+#include "aboutdialog.h"
+
#include "helpviewer.h"
#include "tracer.h"
@@ -51,8 +54,6 @@
#include <QtGui/QMessageBox>
#include <QtGui/QDesktopServices>
-#include "aboutdialog.h"
-
QT_BEGIN_NAMESPACE
AboutLabel::AboutLabel(QWidget *parent)
@@ -96,8 +97,8 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name)
void AboutLabel::setSource(const QUrl &url)
{
TRACE_OBJ
- if (url.isValid() && (!AbstractHelpViewer::isLocalUrl(url)
- || !AbstractHelpViewer::canOpenPage(url.path()))) {
+ if (url.isValid() && (!HelpViewer::isLocalUrl(url)
+ || !HelpViewer::canOpenPage(url.path()))) {
if (!QDesktopServices::openUrl(url)) {
QMessageBox::warning(this, tr("Warning"),
tr("Unable to launch external application.\n"), tr("OK"));
diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro
index 50f5b7e..af306a5 100644
--- a/tools/assistant/tools/assistant/assistant.pro
+++ b/tools/assistant/tools/assistant/assistant.pro
@@ -32,6 +32,7 @@ HEADERS += aboutdialog.h \
filternamedialog.h \
helpenginewrapper.h \
helpviewer.h \
+ helpviewer_p.h \
indexwindow.h \
installdialog.h \
mainwindow.h \
@@ -47,12 +48,6 @@ HEADERS += aboutdialog.h \
globalactions.h \
openpageswidget.h \
openpagesmanager.h
-
-contains(QT_CONFIG, webkit) {
- HEADERS += helpviewer_qwv.h
-} else {
- HEADERS += helpviewer_qtb.h
- }
win32:HEADERS += remotecontrol_win.h
SOURCES += aboutdialog.cpp \
@@ -84,7 +79,7 @@ SOURCES += aboutdialog.cpp \
globalactions.cpp \
openpageswidget.cpp \
openpagesmanager.cpp
- contains(QT_CONFIG, webkit) {
+contains(QT_CONFIG, webkit) {
SOURCES += helpviewer_qwv.cpp
} else {
SOURCES += helpviewer_qtb.cpp
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index 6d61570..edf7a50 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -43,15 +43,10 @@
#include "findwidget.h"
#include "helpenginewrapper.h"
+#include "helpviewer.h"
#include "tracer.h"
#include "../shared/collectionconfiguration.h"
-#if defined(QT_NO_WEBKIT)
-#include "helpviewer_qtb.h"
-#else
-#include "helpviewer_qwv.h"
-#endif // QT_NO_WEBKIT
-
#include <QtCore/QTimer>
#include <QtGui/QKeyEvent>
@@ -75,44 +70,31 @@ namespace {
CentralWidget::CentralWidget(QWidget *parent)
: QWidget(parent)
- , findWidget(0)
- , printer(0)
+#ifndef QT_NO_PRINTER
+ , m_printer(0)
+#endif
+ , m_findWidget(new FindWidget(this))
+ , m_stackedWidget(new QStackedWidget(this))
{
TRACE_OBJ
staticCentralWidget = this;
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
vboxLayout->setMargin(0);
- m_stackedWidget = new QStackedWidget(this);
vboxLayout->addWidget(m_stackedWidget);
+ vboxLayout->addWidget(m_findWidget);
+ m_findWidget->hide();
- findWidget = new FindWidget(this);
- vboxLayout->addWidget(findWidget);
- findWidget->hide();
-
- connect(findWidget, SIGNAL(findNext()), this, SLOT(findNext()));
- connect(findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious()));
- connect(findWidget, SIGNAL(find(QString, bool)), this,
- SLOT(find(QString, bool)));
- connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab()));
-
-#if defined(QT_NO_WEBKIT)
- QPalette p = palette();
- p.setColor(QPalette::Inactive, QPalette::Highlight,
- p.color(QPalette::Active, QPalette::Highlight));
- p.setColor(QPalette::Inactive, QPalette::HighlightedText,
- p.color(QPalette::Active, QPalette::HighlightedText));
- setPalette(p);
-#endif
+ connect(m_findWidget, SIGNAL(findNext()), this, SLOT(findNext()));
+ connect(m_findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious()));
+ connect(m_findWidget, SIGNAL(find(QString, bool, bool)), this,
+ SLOT(find(QString, bool, bool)));
+ connect(m_findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab()));
}
CentralWidget::~CentralWidget()
{
TRACE_OBJ
-#ifndef QT_NO_PRINTER
- delete printer;
-#endif
-
QStringList zoomFactors;
QStringList currentPages;
for (int i = 0; i < m_stackedWidget->count(); ++i) {
@@ -128,6 +110,10 @@ CentralWidget::~CentralWidget()
helpEngine.setLastShownPages(currentPages);
helpEngine.setLastZoomFactors(zoomFactors);
helpEngine.setLastTabPage(m_stackedWidget->currentIndex());
+
+#ifndef QT_NO_PRINTER
+ delete m_printer;
+#endif
}
CentralWidget *CentralWidget::instance()
@@ -136,131 +122,113 @@ CentralWidget *CentralWidget::instance()
return staticCentralWidget;
}
-void CentralWidget::zoomIn()
+QUrl CentralWidget::currentSource() const
{
TRACE_OBJ
- currentHelpViewer()->scaleUp();
+ return currentHelpViewer()->source();
}
-void CentralWidget::zoomOut()
+QString CentralWidget::currentTitle() const
{
TRACE_OBJ
- currentHelpViewer()->scaleDown();
+ return currentHelpViewer()->title();
}
-void CentralWidget::resetZoom()
+bool CentralWidget::hasSelection() const
{
TRACE_OBJ
- currentHelpViewer()->resetScale();
+ return !currentHelpViewer()->selectedText().isEmpty();
}
-void CentralWidget::setSource(const QUrl &url)
+bool CentralWidget::isForwardAvailable() const
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- viewer->setSource(url);
- viewer->setFocus(Qt::OtherFocusReason);
+ return currentHelpViewer()->isForwardAvailable();
}
-bool CentralWidget::hasSelection() const
+bool CentralWidget::isBackwardAvailable() const
{
TRACE_OBJ
- return currentHelpViewer()->hasSelection();
+ return currentHelpViewer()->isBackwardAvailable();
}
-QUrl CentralWidget::currentSource() const
+HelpViewer* CentralWidget::viewerAt(int index) const
{
TRACE_OBJ
- return currentHelpViewer()->source();
+ return static_cast<HelpViewer*>(m_stackedWidget->widget(index));
}
-QString CentralWidget::currentTitle() const
+HelpViewer* CentralWidget::currentHelpViewer() const
{
TRACE_OBJ
- return currentHelpViewer()->documentTitle();
+ return static_cast<HelpViewer *>(m_stackedWidget->currentWidget());
}
-void CentralWidget::copySelection()
+void CentralWidget::addPage(HelpViewer *page, bool fromSearch)
{
TRACE_OBJ
- currentHelpViewer()->copy();
+ 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::showTextSearch()
+void CentralWidget::removePage(int index)
{
TRACE_OBJ
- findWidget->show();
+ const bool currentChanged = index == currentIndex();
+ m_stackedWidget->removeWidget(m_stackedWidget->widget(index));
+ if (currentChanged)
+ emit currentViewerChanged();
}
-void CentralWidget::initPrinter()
+int CentralWidget::currentIndex() const
{
TRACE_OBJ
-#ifndef QT_NO_PRINTER
- if (!printer)
- printer = new QPrinter(QPrinter::HighResolution);
-#endif
+ return m_stackedWidget->currentIndex();
}
-void CentralWidget::print()
+void CentralWidget::setCurrentPage(HelpViewer *page)
{
TRACE_OBJ
-#ifndef QT_NO_PRINTER
- HelpViewer *viewer = currentHelpViewer();
- initPrinter();
- QPrintDialog dlg(printer, this);
-#if defined(QT_NO_WEBKIT)
- if (viewer->textCursor().hasSelection())
- 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);
- }
-#endif
+ m_stackedWidget->setCurrentWidget(page);
+ emit currentViewerChanged();
}
-void CentralWidget::printPreview()
+// -- public slots
+
+void CentralWidget::copy()
{
TRACE_OBJ
-#ifndef QT_NO_PRINTER
- initPrinter();
- QPrintPreviewDialog preview(printer, this);
- connect(&preview, SIGNAL(paintRequested(QPrinter*)),
- SLOT(printPreview(QPrinter*)));
- preview.exec();
-#endif
+ currentHelpViewer()->copy();
}
-void CentralWidget::printPreview(QPrinter *p)
+void CentralWidget::home()
{
TRACE_OBJ
-#ifndef QT_NO_PRINTER
- currentHelpViewer()->print(p);
-#endif
+ currentHelpViewer()->home();
}
-void CentralWidget::pageSetup()
+void CentralWidget::zoomIn()
{
TRACE_OBJ
-#ifndef QT_NO_PRINTER
- initPrinter();
- QPageSetupDialog dlg(printer);
- dlg.exec();
-#endif
+ currentHelpViewer()->scaleUp();
}
-void CentralWidget::home()
+void CentralWidget::zoomOut()
{
TRACE_OBJ
- currentHelpViewer()->home();
+ currentHelpViewer()->scaleDown();
}
-bool CentralWidget::isForwardAvailable() const
+void CentralWidget::resetZoom()
{
TRACE_OBJ
- return currentHelpViewer()->isForwardAvailable();
+ currentHelpViewer()->resetScale();
}
void CentralWidget::forward()
@@ -269,10 +237,11 @@ void CentralWidget::forward()
currentHelpViewer()->forward();
}
-bool CentralWidget::isBackwardAvailable() const
+void CentralWidget::nextPage()
{
TRACE_OBJ
- return currentHelpViewer()->isBackwardAvailable();
+ m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() + 1)
+ % m_stackedWidget->count());
}
void CentralWidget::backward()
@@ -281,198 +250,112 @@ void CentralWidget::backward()
currentHelpViewer()->backward();
}
-void CentralWidget::connectSignals(HelpViewer *page)
+void CentralWidget::previousPage()
{
TRACE_OBJ
- connect(page, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool)));
- connect(page, SIGNAL(forwardAvailable(bool)), this,
- SIGNAL(forwardAvailable(bool)));
- connect(page, SIGNAL(backwardAvailable(bool)), this,
- SIGNAL(backwardAvailable(bool)));
- connect(page, SIGNAL(sourceChanged(QUrl)), this,
- SLOT(handleSourceChanged(QUrl)));
- connect(page, SIGNAL(highlighted(QString)), this,
- SIGNAL(highlighted(QString)));
+ m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() - 1)
+ % m_stackedWidget->count());
}
-HelpViewer* CentralWidget::viewerAt(int index) const
+void CentralWidget::print()
{
TRACE_OBJ
- return static_cast<HelpViewer*>(m_stackedWidget->widget(index));
+#ifndef QT_NO_PRINTER
+ initPrinter();
+ QPrintDialog dlg(m_printer, this);
+
+ if (!currentHelpViewer()->selectedText().isEmpty())
+ dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection);
+ dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange);
+ dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies);
+ dlg.setWindowTitle(tr("Print Document"));
+ if (dlg.exec() == QDialog::Accepted)
+ currentHelpViewer()->print(m_printer);
+#endif
}
-HelpViewer* CentralWidget::currentHelpViewer() const
+void CentralWidget::pageSetup()
{
TRACE_OBJ
- return static_cast<HelpViewer *>(m_stackedWidget->currentWidget());
+#ifndef QT_NO_PRINTER
+ initPrinter();
+ QPageSetupDialog dlg(m_printer);
+ dlg.exec();
+#endif
}
-void CentralWidget::activateTab()
+void CentralWidget::printPreview()
{
TRACE_OBJ
- currentHelpViewer()->setFocus();
+#ifndef QT_NO_PRINTER
+ initPrinter();
+ QPrintPreviewDialog preview(m_printer, this);
+ connect(&preview, SIGNAL(paintRequested(QPrinter*)),
+ SLOT(printPreview(QPrinter*)));
+ preview.exec();
+#endif
}
-bool CentralWidget::eventFilter(QObject *object, QEvent *e)
+void CentralWidget::setSource(const QUrl &url)
{
TRACE_OBJ
- if (e->type() == QEvent::KeyPress) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(e);
- switch (ke->key()) {
- default: {
- return QWidget::eventFilter(object, e);
- } break;
-
- case Qt::Key_Backspace: {
- HelpViewer *viewer = currentHelpViewer();
- if (viewer == object) {
-#if defined(QT_NO_WEBKIT)
- if (viewer->isBackwardAvailable()) {
-#else
- if (viewer->isBackwardAvailable() && !viewer->hasFocus()) {
-#endif
- viewer->backward();
- return true;
- }
- }
- } break;
- }
- }
-
- return QWidget::eventFilter(object, e);
+ HelpViewer *viewer = currentHelpViewer();
+ viewer->setSource(url);
+ viewer->setFocus(Qt::OtherFocusReason);
}
-void CentralWidget::keyPressEvent(QKeyEvent *e)
+void CentralWidget::setSourceFromSearch(const QUrl &url)
{
TRACE_OBJ
- const QString &text = e->text();
- if (text.startsWith(QLatin1Char('/'))) {
- if (!findWidget->isVisible()) {
- findWidget->showAndClear();
- } else {
- findWidget->show();
- }
- } else {
- QWidget::keyPressEvent(e);
- }
+ connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
+ SLOT(highlightSearchTerms()));
+ currentHelpViewer()->setSource(url);
+ currentHelpViewer()->setFocus(Qt::OtherFocusReason);
}
void CentralWidget::findNext()
{
TRACE_OBJ
- find(findWidget->text(), true);
+ find(m_findWidget->text(), true, false);
}
void CentralWidget::findPrevious()
{
TRACE_OBJ
- find(findWidget->text(), false);
+ find(m_findWidget->text(), false, false);
}
-void CentralWidget::find(const QString &ttf, bool forward)
+void CentralWidget::find(const QString &ttf, bool forward, bool incremental)
{
TRACE_OBJ
bool found = false;
-#if defined(QT_NO_WEBKIT)
- found = findInTextBrowser(ttf, forward);
-#else
- found = findInWebPage(ttf, forward);
-#endif
+ if (HelpViewer *viewer = currentHelpViewer()) {
+ HelpViewer::FindFlags flags = 0;
+ if (!forward)
+ flags |= HelpViewer::FindBackward;
+ if (m_findWidget->caseSensitive())
+ flags |= HelpViewer::FindCaseSensitively;
+ found = viewer->findText(ttf, flags, incremental, false);
+ }
if (!found && ttf.isEmpty())
found = true; // the line edit is empty, no need to mark it red...
- if (!findWidget->isVisible())
- findWidget->show();
- findWidget->setPalette(found);
+ if (!m_findWidget->isVisible())
+ m_findWidget->show();
+ m_findWidget->setPalette(found);
}
-bool CentralWidget::findInWebPage(const QString &ttf, bool forward)
+void CentralWidget::activateTab()
{
TRACE_OBJ
-#if !defined(QT_NO_WEBKIT)
- HelpViewer *viewer = currentHelpViewer();
- bool found = false;
- QWebPage::FindFlags options;
- if (!ttf.isEmpty()) {
- if (!forward)
- options |= QWebPage::FindBackward;
-
- if (findWidget->caseSensitive())
- options |= QWebPage::FindCaseSensitively;
-
- found = viewer->findText(ttf, options);
- findWidget->setTextWrappedVisible(false);
-
- if (!found) {
- options |= QWebPage::FindWrapsAroundDocument;
- found = viewer->findText(ttf, options);
- if (found)
- findWidget->setTextWrappedVisible(true);
- }
- }
- // force highlighting of all other matches, also when empty (clear)
- options = QWebPage::HighlightAllOccurrences;
- if (findWidget->caseSensitive())
- options |= QWebPage::FindCaseSensitively;
- viewer->findText(QLatin1String(""), options);
- viewer->findText(ttf, options);
- return found;
-
- // this needs to stay, case for active search results page
- return findInTextBrowser(ttf, forward);
-#else
- Q_UNUSED(ttf);
- Q_UNUSED(forward);
-#endif
- return false;
+ currentHelpViewer()->setFocus();
}
-bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward)
+void CentralWidget::showTextSearch()
{
TRACE_OBJ
- QTextBrowser *browser = qobject_cast<QTextBrowser*>(currentHelpViewer());
-
- if (!browser || ttf.isEmpty())
- return false;
-
- QTextDocument *doc = browser->document();
- QTextCursor cursor = browser->textCursor();
-
- if (!doc || cursor.isNull())
- return false;
-
- QTextDocument::FindFlags options;
-
- if (cursor.hasSelection()) {
- cursor.setPosition(forward ? cursor.position() : cursor.anchor(),
- QTextCursor::MoveAnchor);
- }
-
- if (!forward)
- options |= QTextDocument::FindBackward;
-
- if (findWidget->caseSensitive())
- options |= QTextDocument::FindCaseSensitively;
-
- findWidget->setTextWrappedVisible(false);
-
- bool found = true;
- QTextCursor newCursor = doc->find(ttf, cursor, options);
- if (newCursor.isNull()) {
- QTextCursor ac(doc);
- ac.movePosition(options & QTextDocument::FindBackward
- ? QTextCursor::End : QTextCursor::Start);
- newCursor = doc->find(ttf, ac, options);
- if (newCursor.isNull()) {
- found = false;
- newCursor = cursor;
- } else {
- findWidget->setTextWrappedVisible(true);
- }
- }
- browser->setTextCursor(newCursor);
- return found;
+ m_findWidget->show();
}
void CentralWidget::updateBrowserFont()
@@ -484,25 +367,41 @@ void CentralWidget::updateBrowserFont()
viewerAt(i)->setViewerFont(font);
}
-void
-CentralWidget::setSourceFromSearch(const QUrl &url)
+// -- protected
+
+void CentralWidget::keyPressEvent(QKeyEvent *e)
{
TRACE_OBJ
- setSource(url);
-#if defined(QT_NO_WEBKIT)
- highlightSearchTerms();
-#else
- connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
- SLOT(highlightSearchTerms()));
-#endif
+ const QString &text = e->text();
+ if (text.startsWith(QLatin1Char('/'))) {
+ if (!m_findWidget->isVisible()) {
+ m_findWidget->showAndClear();
+ } else {
+ m_findWidget->show();
+ }
+ } else {
+ QWidget::keyPressEvent(e);
+ }
}
-void
-CentralWidget::highlightSearchTerms()
+void CentralWidget::focusInEvent(QFocusEvent * /* event */)
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
+ // 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()
+{
+ TRACE_OBJ
QHelpSearchEngine *searchEngine =
HelpEngineWrapper::instance().searchEngine();
QList<QHelpSearchQuery> queryList = searchEngine->query();
@@ -521,91 +420,72 @@ CentralWidget::highlightSearchTerms()
}
}
-#if defined(QT_NO_WEBKIT)
- viewer->viewport()->setUpdatesEnabled(false);
-
- QTextCharFormat marker;
- marker.setForeground(Qt::red);
-
- QTextCursor firstHit;
-
- QTextCursor c = viewer->textCursor();
- c.beginEditBlock();
- foreach (const QString& term, terms) {
- c.movePosition(QTextCursor::Start);
- viewer->setTextCursor(c);
-
- while (viewer->find(term, QTextDocument::FindWholeWords)) {
- QTextCursor hit = viewer->textCursor();
- if (firstHit.isNull() || hit.position() < firstHit.position())
- firstHit = hit;
-
- hit.mergeCharFormat(marker);
- }
- }
-
- if (firstHit.isNull()) {
- firstHit = viewer->textCursor();
- firstHit.movePosition(QTextCursor::Start);
- }
- firstHit.clearSelection();
- c.endEditBlock();
- viewer->setTextCursor(firstHit);
-
- viewer->viewport()->setUpdatesEnabled(true);
-#else
- viewer->findText("", QWebPage::HighlightAllOccurrences);
- // clears existing selections
+ HelpViewer *viewer = currentHelpViewer();
foreach (const QString& term, terms)
- viewer->findText(term, QWebPage::HighlightAllOccurrences);
-
+ viewer->findText(term, 0, false, true);
disconnect(viewer, SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms()));
-#endif
}
-void CentralWidget::addPage(HelpViewer *page, bool fromSearch)
+void CentralWidget::printPreview(QPrinter *p)
{
TRACE_OBJ
- page->installEventFilter(this);
- page->setFocus(Qt::OtherFocusReason);
- connectSignals(page);
- m_stackedWidget->addWidget(page);
- if (fromSearch) {
-#if defined(QT_NO_WEBKIT)
- highlightSearchTerms();
-#else
- connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
- SLOT(highlightSearchTerms()));
+#ifndef QT_NO_PRINTER
+ currentHelpViewer()->print(p);
#endif
- }
}
-void CentralWidget::removePage(int index)
+void CentralWidget::handleSourceChanged(const QUrl &url)
{
TRACE_OBJ
- const bool currentChanged = index == currentIndex();
- m_stackedWidget->removeWidget(m_stackedWidget->widget(index));
- if (currentChanged)
- emit currentViewerChanged();
+ if (sender() == currentHelpViewer())
+ emit sourceChanged(url);
}
-void CentralWidget::setCurrentPage(HelpViewer *page)
+// -- private
+
+void CentralWidget::initPrinter()
{
TRACE_OBJ
- m_stackedWidget->setCurrentWidget(page);
- emit currentViewerChanged();
+#ifndef QT_NO_PRINTER
+ if (!m_printer)
+ m_printer = new QPrinter(QPrinter::HighResolution);
+#endif
}
-int CentralWidget::currentIndex() const
+void CentralWidget::connectSignals(HelpViewer *page)
{
- return m_stackedWidget->currentIndex();
+ TRACE_OBJ
+ connect(page, SIGNAL(copyAvailable(bool)), this,
+ SIGNAL(copyAvailable(bool)));
+ connect(page, SIGNAL(forwardAvailable(bool)), this,
+ SIGNAL(forwardAvailable(bool)));
+ connect(page, SIGNAL(backwardAvailable(bool)), this,
+ SIGNAL(backwardAvailable(bool)));
+ connect(page, SIGNAL(sourceChanged(QUrl)), this,
+ SLOT(handleSourceChanged(QUrl)));
+ connect(page, SIGNAL(highlighted(QString)), this,
+ SIGNAL(highlighted(QString)));
}
-void CentralWidget::handleSourceChanged(const QUrl &url)
+bool CentralWidget::eventFilter(QObject *object, QEvent *e)
{
- if (sender() == currentHelpViewer())
- emit sourceChanged(url);
+ TRACE_OBJ
+ if (e->type() != QEvent::KeyPress)
+ return QWidget::eventFilter(object, e);
+
+ HelpViewer *viewer = currentHelpViewer();
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*> (e);
+ if (viewer == object && keyEvent->key() == Qt::Key_Backspace) {
+ if (viewer->isBackwardAvailable()) {
+#if !defined(QT_NO_WEBKIT)
+ // this helps in case there is an html <input> field
+ if (!viewer->hasFocus())
+#endif
+ viewer->backward();
+ }
+ }
+ return QWidget::eventFilter(object, e);
}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 9b8db30..69e334a 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#ifndef CENTRALWIDGET_H
#define CENTRALWIDGET_H
@@ -55,12 +56,15 @@ class CentralWidget : public QWidget
Q_OBJECT
public:
- CentralWidget(QWidget *parent);
+ CentralWidget(QWidget *parent = 0);
~CentralWidget();
- bool hasSelection() const;
+ static CentralWidget *instance();
+
QUrl currentSource() const;
QString currentTitle() const;
+
+ bool hasSelection() const;
bool isForwardAvailable() const;
bool isBackwardAvailable() const;
@@ -69,32 +73,38 @@ public:
void addPage(HelpViewer *page, bool fromSearch = false);
void removePage(int index);
- void setCurrentPage(HelpViewer *page);
- int currentIndex() const;
- static CentralWidget *instance();
+ int currentIndex() const;
+ void setCurrentPage(HelpViewer *page);
public slots:
+ void copy();
+ void home();
+
void zoomIn();
void zoomOut();
void resetZoom();
- void copySelection();
- void showTextSearch();
+
+ void forward();
+ void nextPage();
+
+ void backward();
+ void previousPage();
+
void print();
void pageSetup();
void printPreview();
- void updateBrowserFont();
+
void setSource(const QUrl &url);
void setSourceFromSearch(const QUrl &url);
- void home();
- void forward();
- void backward();
-
- void activateTab();
void findNext();
void findPrevious();
- void find(const QString &text, bool forward);
+ void find(const QString &text, bool forward, bool incremental);
+
+ void activateTab();
+ void showTextSearch();
+ void updateBrowserFont();
signals:
void currentViewerChanged();
@@ -107,23 +117,24 @@ signals:
protected:
void keyPressEvent(QKeyEvent *);
+ void focusInEvent(QFocusEvent *event);
private slots:
- void printPreview(QPrinter *printer);
void highlightSearchTerms();
+ void printPreview(QPrinter *printer);
void handleSourceChanged(const QUrl &url);
private:
+ void initPrinter();
void connectSignals(HelpViewer *page);
bool eventFilter(QObject *object, QEvent *e);
- bool findInWebPage(const QString &ttf, bool forward);
- bool findInTextBrowser(const QString &ttf, bool forward);
- void initPrinter();
private:
+#ifndef QT_NO_PRINTER
+ QPrinter *m_printer;
+#endif
+ FindWidget *m_findWidget;
QStackedWidget *m_stackedWidget;
- FindWidget *findWidget;
- QPrinter *printer;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp
index 3af4d34..3234980 100644
--- a/tools/assistant/tools/assistant/contentwindow.cpp
+++ b/tools/assistant/tools/assistant/contentwindow.cpp
@@ -38,13 +38,14 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
#include "contentwindow.h"
+
#include "centralwidget.h"
#include "helpenginewrapper.h"
#include "helpviewer.h"
#include "openpagesmanager.h"
+#include "tracer.h"
#include <QtGui/QLayout>
#include <QtGui/QFocusEvent>
@@ -145,7 +146,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
if (contentModel) {
QHelpContentItem *itm = contentModel->contentItemAt(index);
- if (itm && AbstractHelpViewer::canOpenPage(itm->url().path()))
+ if (itm && HelpViewer::canOpenPage(itm->url().path()))
OpenPagesManager::instance()->createPage(itm->url());
}
} else if (button == Qt::LeftButton) {
@@ -171,7 +172,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
QMenu menu;
QAction *curTab = menu.addAction(tr("Open Link"));
QAction *newTab = menu.addAction(tr("Open Link in New Tab"));
- if (!AbstractHelpViewer::canOpenPage(itm->url().path()))
+ if (!HelpViewer::canOpenPage(itm->url().path()))
newTab->setEnabled(false);
menu.move(m_contentWidget->mapToGlobal(pos));
diff --git a/tools/assistant/tools/assistant/findwidget.cpp b/tools/assistant/tools/assistant/findwidget.cpp
index 60318d4..e46be61 100644
--- a/tools/assistant/tools/assistant/findwidget.cpp
+++ b/tools/assistant/tools/assistant/findwidget.cpp
@@ -203,7 +203,7 @@ void FindWidget::updateButtons()
void FindWidget::textChanged(const QString &text)
{
TRACE_OBJ
- emit find(text, true);
+ emit find(text, true, true);
}
bool FindWidget::eventFilter(QObject *object, QEvent *e)
diff --git a/tools/assistant/tools/assistant/findwidget.h b/tools/assistant/tools/assistant/findwidget.h
index cf78003..85e1959 100644
--- a/tools/assistant/tools/assistant/findwidget.h
+++ b/tools/assistant/tools/assistant/findwidget.h
@@ -67,11 +67,10 @@ public:
void setTextWrappedVisible(bool visible);
signals:
- void escapePressed();
-
void findNext();
void findPrevious();
- void find(const QString &text, bool forward);
+ void escapePressed();
+ void find(const QString &text, bool forward, bool incremental);
protected:
void hideEvent(QHideEvent* event);
diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp
index de47da0..a9cc392 100644
--- a/tools/assistant/tools/assistant/globalactions.cpp
+++ b/tools/assistant/tools/assistant/globalactions.cpp
@@ -116,7 +116,7 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png")));
m_copyAction->setShortcuts(QKeySequence::Copy);
m_copyAction->setEnabled(false);
- connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copySelection()));
+ connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copy()));
m_actionList << m_copyAction;
m_printAction = new QAction(tr("&Print..."), parent);
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index 6499139..dfcacd1 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include "helpviewer.h"
#include "helpenginewrapper.h"
#include "tracer.h"
@@ -49,18 +50,21 @@
#include <QtCore/QUrl>
#include <QtGui/QDesktopServices>
+#include <QtGui/QMouseEvent>
+
+#include <QtHelp/QHelpEngineCore>
QT_BEGIN_NAMESPACE
-const QLatin1String AbstractHelpViewer::DocPath("qthelp://com.trolltech.");
+const QString HelpViewer::DocPath = QLatin1String("qthelp://com.trolltech.");
-const QString AbstractHelpViewer::AboutBlank =
+const QString HelpViewer::AboutBlank =
QCoreApplication::translate("HelpViewer", "<title>about:blank</title>");
-const QString AbstractHelpViewer::LocalHelpFile = QLatin1String("qthelp://"
+const QString HelpViewer::LocalHelpFile = QLatin1String("qthelp://"
"com.trolltech.com.assistantinternal-1.0.0/assistant/assistant.html");
-const QString AbstractHelpViewer::PageNotFoundMessage =
+const QString HelpViewer::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>");
@@ -102,17 +106,7 @@ struct ExtensionMap {
{ 0, 0 }
};
-// -- AbstractHelpViewer
-
-AbstractHelpViewer::AbstractHelpViewer()
-{
-}
-
-AbstractHelpViewer::~AbstractHelpViewer()
-{
-}
-
-bool AbstractHelpViewer::isLocalUrl(const QUrl &url)
+bool HelpViewer::isLocalUrl(const QUrl &url)
{
TRACE_OBJ
const QString &scheme = url.scheme();
@@ -124,13 +118,13 @@ bool AbstractHelpViewer::isLocalUrl(const QUrl &url)
|| scheme == QLatin1String("about");
}
-bool AbstractHelpViewer::canOpenPage(const QString &url)
+bool HelpViewer::canOpenPage(const QString &url)
{
TRACE_OBJ
return !mimeFromUrl(url).isEmpty();
}
-QString AbstractHelpViewer::mimeFromUrl(const QUrl &url)
+QString HelpViewer::mimeFromUrl(const QUrl &url)
{
TRACE_OBJ
const QString &path = url.path();
@@ -146,7 +140,7 @@ QString AbstractHelpViewer::mimeFromUrl(const QUrl &url)
return QLatin1String("");
}
-bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url)
+bool HelpViewer::launchWithExternalApp(const QUrl &url)
{
TRACE_OBJ
if (isLocalUrl(url)) {
@@ -177,4 +171,38 @@ bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url)
return false;
}
+// -- public slots
+
+void HelpViewer::home()
+{
+ TRACE_OBJ
+ setSource(HelpEngineWrapper::instance().homePage());
+}
+
+// -- private slots
+
+void HelpViewer::setLoadFinished(bool ok)
+{
+ Q_UNUSED(ok)
+ emit sourceChanged(source());
+}
+
+// -- private
+
+bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *event)
+{
+ TRACE_OBJ
+ if (event->button() == Qt::XButton1) {
+ backward();
+ return true;
+ }
+
+ if (event->button() == Qt::XButton2) {
+ forward();
+ return true;
+ }
+
+ return false;
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index def9418..fc3d753 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -38,36 +38,69 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#ifndef HELPVIEWER_H
#define HELPVIEWER_H
+#include <QtCore/qglobal.h>
#include <QtCore/QString>
+#include <QtCore/QUrl>
+#include <QtCore/QVariant>
+#include <QtGui/QAction>
#include <QtGui/QFont>
-QT_BEGIN_NAMESPACE
+#if defined(QT_NO_WEBKIT)
+#include <QtGui/QTextBrowser>
+#else
+#include <QtWebKit/QWebView>
+#endif
-class QMouseEvent;
-class QUrl;
+QT_BEGIN_NAMESPACE
-class AbstractHelpViewer
+#if !defined(QT_NO_WEBKIT)
+class HelpViewer : public QWebView
+#else
+class HelpViewer : public QTextBrowser
+#endif
{
+ Q_OBJECT
+ class HelpViewerPrivate;
+ Q_DISABLE_COPY(HelpViewer)
+
public:
- AbstractHelpViewer();
- virtual ~AbstractHelpViewer();
+ enum FindFlag {
+ FindBackward = 0x01,
+ FindCaseSensitively = 0x02
+ };
+ Q_DECLARE_FLAGS(FindFlags, FindFlag)
+
+ HelpViewer(qreal zoom, QWidget *parent = 0);
+ ~HelpViewer();
+
+ QFont viewerFont() const;
+ void setViewerFont(const QFont &font);
+
+ void scaleUp();
+ void scaleDown();
+
+ void resetScale();
+ qreal scale() const;
- virtual QFont viewerFont() const = 0;
- virtual void setViewerFont(const QFont &font) = 0;
+ QString title() const;
+ void setTitle(const QString &title);
- virtual void scaleUp() = 0;
- virtual void scaleDown() = 0;
-
- virtual void resetScale() = 0;
- virtual qreal scale() const = 0;
+ QUrl source() const;
+ void setSource(const QUrl &url);
- virtual bool handleForwardBackwardMouseButtons(QMouseEvent *e) = 0;
+ QString selectedText() const;
+ bool isForwardAvailable() const;
+ bool isBackwardAvailable() const;
- static const QLatin1String DocPath;
+ bool findText(const QString &text, FindFlags flags, bool incremental,
+ bool fromSearch);
+
+ static const QString DocPath;
static const QString AboutBlank;
static const QString LocalHelpFile;
static const QString PageNotFoundMessage;
@@ -76,6 +109,44 @@ public:
static bool canOpenPage(const QString &url);
static QString mimeFromUrl(const QUrl &url);
static bool launchWithExternalApp(const QUrl &url);
+
+public slots:
+ void copy();
+ void home();
+
+ void forward();
+ void backward();
+
+signals:
+ void titleChanged();
+#if !defined(QT_NO_WEBKIT)
+ void copyAvailable(bool yes);
+ void sourceChanged(const QUrl &url);
+ void forwardAvailable(bool enabled);
+ void backwardAvailable(bool enabled);
+ void highlighted(const QString &link);
+#else
+ void loadFinished(bool finished);
+#endif
+
+protected:
+ void keyPressEvent(QKeyEvent *e);
+ void wheelEvent(QWheelEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+
+private slots:
+ void actionChanged();
+ void setLoadFinished(bool ok);
+
+private:
+ bool eventFilter(QObject *obj, QEvent *event);
+ void contextMenuEvent(QContextMenuEvent *event);
+ QVariant loadResource(int type, const QUrl &name);
+ bool handleForwardBackwardMouseButtons(QMouseEvent *e);
+
+private:
+ HelpViewerPrivate *d;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_p.h
index 065557e..631d65f 100644
--- a/tools/assistant/tools/assistant/helpviewer_qtb.h
+++ b/tools/assistant/tools/assistant/helpviewer_p.h
@@ -38,77 +38,74 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef HELPVIEWERQTB_H
-#define HELPVIEWERQTB_H
-#include "helpviewer.h"
+#ifndef HELPVIEWERPRIVATE_H
+#define HELPVIEWERPRIVATE_H
-#include <QtCore/QUrl>
-#include <QtCore/QVariant>
+#include "centralwidget.h"
+#include "helpviewer.h"
+#include "openpagesmanager.h"
+#include <QtCore/QObject>
#include <QtGui/QTextBrowser>
QT_BEGIN_NAMESPACE
-class HelpEngineWrapper;
-class QContextMenuEvent;
-class QKeyEvent;
-class QMouseEvent;
-
-class HelpViewer : public QTextBrowser, public AbstractHelpViewer
+class HelpViewer::HelpViewerPrivate : public QObject
{
Q_OBJECT
public:
- HelpViewer(qreal zoom = 0.0);
- ~HelpViewer();
-
- QFont viewerFont() const;
- void setViewerFont(const QFont &font);
-
- void scaleUp();
- void scaleDown();
- void resetScale();
- qreal scale() const { return zoomCount; }
-
- bool handleForwardBackwardMouseButtons(QMouseEvent *e);
-
- void setSource(const QUrl &url);
-
- inline bool hasSelection() const
- { return textCursor().hasSelection(); }
-
-signals:
- void titleChanged();
+ HelpViewerPrivate(int zoom)
+ : zoomCount(zoom)
+ , forceFont(false)
+ , lastAnchor(QString())
+
+ {}
+
+ bool hasAnchorAt(QTextBrowser *browser, const QPoint& pos)
+ {
+ lastAnchor = browser->anchorAt(pos);
+ if (lastAnchor.isEmpty())
+ return false;
+
+ lastAnchor = browser->source().resolved(lastAnchor).toString();
+ if (lastAnchor.at(0) == QLatin1Char('#')) {
+ QString src = browser->source().toString();
+ int hsh = src.indexOf(QLatin1Char('#'));
+ lastAnchor = (hsh >= 0 ? src.left(hsh) : src) + lastAnchor;
+ }
+ return true;
+ }
+
+ void openLink(bool newPage)
+ {
+ if(lastAnchor.isEmpty())
+ return;
+ if (newPage)
+ OpenPagesManager::instance()->createPage(lastAnchor);
+ else
+ CentralWidget::instance()->setSource(lastAnchor);
+ lastAnchor.clear();
+ }
+
+public slots:
+ void openLink()
+ {
+ openLink(false);
+ }
+
+ void openLinkInNewPage()
+ {
+ openLink(true);
+ }
-public Q_SLOTS:
- void home();
-
-protected:
- void wheelEvent(QWheelEvent *e);
- bool eventFilter(QObject *obj, QEvent *event);
-
-private:
- QVariant loadResource(int type, const QUrl &name);
- void openLinkInNewTab(const QString &link);
- bool hasAnchorAt(const QPoint& pos);
- void contextMenuEvent(QContextMenuEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void keyPressEvent(QKeyEvent *e);
- void mousePressEvent(QMouseEvent *e);
-
-private slots:
- void openLinkInNewTab();
-
-private:
+public:
int zoomCount;
- bool controlPressed;
- QString lastAnchor;
- HelpEngineWrapper &helpEngine;
-
bool forceFont;
+ QString lastAnchor;
};
QT_END_NAMESPACE
-#endif // HELPVIEWERQTB_H
+#endif // HELPVIEWERPRIVATE_H
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
index 32ffbc1..a73e1e1 100644
--- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
@@ -38,10 +38,12 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "helpviewer_qtb.h"
+
+#include "helpviewer.h"
#include "globalactions.h"
#include "helpenginewrapper.h"
+#include "helpviewer_p.h"
#include "openpagesmanager.h"
#include "tracer.h"
@@ -54,33 +56,40 @@
QT_BEGIN_NAMESPACE
-HelpViewer::HelpViewer(qreal zoom)
- : zoomCount(zoom)
- , controlPressed(false)
- , lastAnchor(QString())
- , helpEngine(HelpEngineWrapper::instance())
- , forceFont(false)
+HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
+ : QTextBrowser(parent)
+ , d(new HelpViewerPrivate(zoom))
{
TRACE_OBJ
+ QPalette p = palette();
+ p.setColor(QPalette::Inactive, QPalette::Highlight,
+ p.color(QPalette::Active, QPalette::Highlight));
+ p.setColor(QPalette::Inactive, QPalette::HighlightedText,
+ p.color(QPalette::Active, QPalette::HighlightedText));
+ setPalette(p);
+
installEventFilter(this);
document()->setDocumentMargin(8);
QFont font = viewerFont();
font.setPointSize(int(font.pointSize() + zoom));
setViewerFont(font);
+
connect(this, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(titleChanged()));
+ connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
}
HelpViewer::~HelpViewer()
{
TRACE_OBJ
+ delete d;
}
QFont HelpViewer::viewerFont() const
{
TRACE_OBJ
if (HelpEngineWrapper::instance().usesBrowserFont())
- return helpEngine.browserFont();
+ return HelpEngineWrapper::instance().browserFont();
return qApp->font();
}
@@ -88,186 +97,182 @@ void HelpViewer::setViewerFont(const QFont &newFont)
{
TRACE_OBJ
if (font() != newFont) {
- forceFont = true;
+ d->forceFont = true;
setFont(newFont);
- forceFont = false;
+ d->forceFont = false;
}
}
void HelpViewer::scaleUp()
{
TRACE_OBJ
- if (zoomCount < 10) {
- ++zoomCount;
- forceFont = true;
+ if (d->zoomCount < 10) {
+ d->zoomCount++;
+ d->forceFont = true;
zoomIn();
- forceFont = false;
+ d->forceFont = false;
}
}
void HelpViewer::scaleDown()
{
TRACE_OBJ
- if (zoomCount > -5) {
- --zoomCount;
- forceFont = true;
+ if (d->zoomCount > -5) {
+ d->zoomCount--;
+ d->forceFont = true;
zoomOut();
- forceFont = false;
+ d->forceFont = false;
}
}
void HelpViewer::resetScale()
{
TRACE_OBJ
- if (zoomCount != 0) {
- forceFont = true;
- zoomOut(zoomCount);
- forceFont = false;
+ if (d->zoomCount != 0) {
+ d->forceFont = true;
+ zoomOut(d->zoomCount);
+ d->forceFont = false;
}
- zoomCount = 0;
+ d->zoomCount = 0;
}
-bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
+qreal HelpViewer::scale() const
{
- if (e->button() == Qt::XButton1) {
- QTextBrowser::backward();
- return true;
- }
+ TRACE_OBJ
+ return d->zoomCount;
+}
- if (e->button() == Qt::XButton2) {
- QTextBrowser::forward();
- return true;
- }
- return false;
+QString HelpViewer::title() const
+{
+ TRACE_OBJ
+ return documentTitle();
+}
+
+void HelpViewer::setTitle(const QString &title)
+{
+ TRACE_OBJ
+ setDocumentTitle(title);
+}
+
+QUrl HelpViewer::source() const
+{
+ TRACE_OBJ
+ return QTextBrowser::source();
}
void HelpViewer::setSource(const QUrl &url)
{
TRACE_OBJ
- const QString &string = url.toString();
- if (url.isValid() && string != QLatin1String("help")) {
- if (launchWithExternalApp(url))
- return;
-
- const QUrl &resolvedUrl = helpEngine.findFile(url);
- if (resolvedUrl.isValid()) {
- QTextBrowser::setSource(resolvedUrl);
- return;
- }
- }
+ if (launchWithExternalApp(url))
+ return;
- if (string != QLatin1String("help")) {
- QTextBrowser::setSource(url);
+ QString string = url.toString();
+ const HelpEngineWrapper &engine = HelpEngineWrapper::instance();
+ const QUrl &resolvedUrl = (string == QLatin1String("help") ? LocalHelpFile :
+ engine.findFile(string));
+ QTextBrowser::setSource(resolvedUrl);
+ if (!url.isValid()) {
setHtml(string == QLatin1String("about:blank") ? AboutBlank
: PageNotFoundMessage.arg(url.toString()));
- emit sourceChanged(url);
- } else {
- QTextBrowser::setSource(LocalHelpFile);
}
+ emit loadFinished(true);
}
-QVariant HelpViewer::loadResource(int type, const QUrl &name)
+QString HelpViewer::selectedText() const
{
TRACE_OBJ
- QByteArray ba;
- if (type < 4) {
- ba = helpEngine.fileData(name);
- if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
- QImage image;
- image.loadFromData(ba, "svg");
- if (!image.isNull())
- return image;
- }
- }
- return ba;
+ return textCursor().selectedText();
}
-void HelpViewer::openLinkInNewTab()
+bool HelpViewer::isForwardAvailable() const
{
TRACE_OBJ
- if(lastAnchor.isEmpty())
- return;
-
- OpenPagesManager::instance()->createPage(QUrl(lastAnchor));
- lastAnchor.clear();
+ return QTextBrowser::isForwardAvailable();
}
-void HelpViewer::openLinkInNewTab(const QString &link)
+bool HelpViewer::isBackwardAvailable() const
{
TRACE_OBJ
- lastAnchor = link;
- openLinkInNewTab();
+ return QTextBrowser::isBackwardAvailable();
}
-bool HelpViewer::hasAnchorAt(const QPoint& pos)
+bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental,
+ bool fromSearch)
{
TRACE_OBJ
- lastAnchor = anchorAt(pos);
- if (lastAnchor.isEmpty())
+ QTextDocument *doc = document();
+ QTextCursor cursor = textCursor();
+ if (!doc || cursor.isNull())
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;
+ const int position = cursor.selectionStart();
+ if (incremental)
+ cursor.setPosition(position);
+
+ QTextDocument::FindFlags textDocFlags;
+ if (flags & HelpViewer::FindBackward)
+ textDocFlags |= QTextDocument::FindBackward;
+ if (flags & HelpViewer::FindCaseSensitively)
+ textDocFlags |= QTextDocument::FindCaseSensitively;
+
+ QTextCursor found = doc->find(text, cursor, textDocFlags);
+ if (found.isNull()) {
+ if ((flags & HelpViewer::FindBackward) == 0)
+ cursor.movePosition(QTextCursor::Start);
+ else
+ cursor.movePosition(QTextCursor::End);
+ found = doc->find(text, cursor, textDocFlags);
}
- return true;
-}
+ if (fromSearch) {
+ cursor.beginEditBlock();
+ viewport()->setUpdatesEnabled(false);
-void HelpViewer::contextMenuEvent(QContextMenuEvent *e)
-{
- TRACE_OBJ
- QMenu menu(QLatin1String(""), 0);
+ QTextCharFormat marker;
+ marker.setForeground(Qt::red);
+ cursor.movePosition(QTextCursor::Start);
+ setTextCursor(cursor);
- 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());
+ while (find(text)) {
+ QTextCursor hit = textCursor();
+ hit.mergeCharFormat(marker);
+ }
- menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this,
- SLOT(openLinkInNewTab()));
- menu.addSeparator();
+ viewport()->setUpdatesEnabled(true);
+ cursor.endEditBlock();
}
- menu.addActions(GlobalActions::instance()->actionList());
- QAction *action = menu.exec(e->globalPos());
- if (action == copyAnchorAction)
- QApplication::clipboard()->setText(link.toString());
+ bool cursorIsNull = found.isNull();
+ if (cursorIsNull) {
+ found = textCursor();
+ found.setPosition(position);
+ }
+ setTextCursor(found);
+ return !cursorIsNull;
}
-void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
+// -- public slots
+
+void HelpViewer::copy()
{
TRACE_OBJ
-#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::copy();
+}
- QTextBrowser::mouseReleaseEvent(e);
+void HelpViewer::forward()
+{
+ TRACE_OBJ
+ QTextBrowser::forward();
}
-void HelpViewer::mousePressEvent(QMouseEvent *e)
+void HelpViewer::backward()
{
-#ifdef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(e))
- return;
-#endif
- QTextBrowser::mousePressEvent(e);
+ TRACE_OBJ
+ QTextBrowser::backward();
}
+// -- protected
+
void HelpViewer::keyPressEvent(QKeyEvent *e)
{
TRACE_OBJ
@@ -280,11 +285,6 @@ void HelpViewer::keyPressEvent(QKeyEvent *e)
QTextBrowser::keyPressEvent(e);
}
-void HelpViewer::home()
-{
- TRACE_OBJ
- setSource(helpEngine.homePage());
-}
void HelpViewer::wheelEvent(QWheelEvent *e)
{
@@ -297,12 +297,92 @@ void HelpViewer::wheelEvent(QWheelEvent *e)
}
}
+void HelpViewer::mousePressEvent(QMouseEvent *e)
+{
+ TRACE_OBJ
+#ifdef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(e))
+ return;
+#endif
+ QTextBrowser::mousePressEvent(e);
+}
+
+void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
+{
+ TRACE_OBJ
+#ifndef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(e))
+ return;
+#endif
+
+ bool controlPressed = e->modifiers() & Qt::ControlModifier;
+ if ((controlPressed && d->hasAnchorAt(this, e->pos())) ||
+ (e->button() == Qt::MidButton && d->hasAnchorAt(this, e->pos()))) {
+ d->openLinkInNewPage();
+ return;
+ }
+
+ QTextBrowser::mouseReleaseEvent(e);
+}
+
+// -- private slots
+
+void HelpViewer::actionChanged()
+{
+ // stub
+ TRACE_OBJ
+}
+
+// -- private
+
bool HelpViewer::eventFilter(QObject *obj, QEvent *event)
{
TRACE_OBJ
- if (event->type() == QEvent::FontChange && !forceFont)
+ if (event->type() == QEvent::FontChange && !d->forceFont)
return true;
return QTextBrowser::eventFilter(obj, event);
}
+void HelpViewer::contextMenuEvent(QContextMenuEvent *event)
+{
+ TRACE_OBJ
+ QMenu menu(QLatin1String(""), 0);
+
+ QUrl link;
+ QAction *copyAnchorAction = 0;
+ if (d->hasAnchorAt(this, event->pos())) {
+ link = anchorAt(event->pos());
+ if (link.isRelative())
+ link = source().resolved(link);
+ menu.addAction(tr("Open Link"), d, SLOT(openLink()));
+ menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), d, SLOT(openLinkInNewPage()));
+
+ if (!link.isEmpty() && link.isValid())
+ copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
+ } else if (!selectedText().isEmpty()) {
+ menu.addAction(tr("Copy"), this, SLOT(copy()));
+ } else {
+ menu.addAction(tr("Reload"), this, SLOT(reload()));
+ }
+
+ if (copyAnchorAction == menu.exec(event->globalPos()))
+ QApplication::clipboard()->setText(link.toString());
+}
+
+QVariant HelpViewer::loadResource(int type, const QUrl &name)
+{
+ TRACE_OBJ
+ QByteArray ba;
+ if (type < 4) {
+ ba = HelpEngineWrapper::instance().fileData(name);
+ if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
+ QImage image;
+ image.loadFromData(ba, "svg");
+ if (!image.isNull())
+ return image;
+ }
+ }
+ return ba;
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
index 63816fe..4fde20f 100644
--- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "helpviewer_qwv.h"
+#include "helpviewer.h"
#include "centralwidget.h"
#include "helpenginewrapper.h"
@@ -48,17 +48,21 @@
#include <QtCore/QFileInfo>
#include <QtCore/QString>
-#include <QtCore/QStringBuilder>
#include <QtCore/QTimer>
+#include <QtGui/QApplication>
#include <QtGui/QWheelEvent>
+#include <QtHelp/QHelpEngineCore>
+
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
QT_BEGIN_NAMESPACE
+// -- HelpNetworkReply
+
class HelpNetworkReply : public QNetworkReply
{
public:
@@ -110,6 +114,8 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
return len;
}
+// -- HelpNetworkAccessManager
+
class HelpNetworkAccessManager : public QNetworkAccessManager
{
public:
@@ -131,15 +137,14 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
{
TRACE_OBJ
QString url = request.url().toString();
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
-
+ const HelpEngineWrapper &engine = HelpEngineWrapper::instance();
// TODO: For some reason the url to load is already wrong (passed from webkit)
// though the css file and the references inside should work that way. One
// possible problem might be that the css is loaded at the same level as the
// html, thus a path inside the css like (../images/foo.png) might cd out of
// the virtual folder
- if (!helpEngine.findFile(url).isValid()) {
- if (url.startsWith(AbstractHelpViewer::DocPath)) {
+ if (!engine.findFile(url).isValid()) {
+ if (url.startsWith(HelpViewer::DocPath)) {
QUrl newUrl = request.url();
if (!newUrl.path().startsWith(QLatin1String("/qdoc/"))) {
newUrl.setPath(QLatin1String("qdoc") + newUrl.path());
@@ -148,14 +153,16 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
}
}
- const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url);
- const QByteArray &data = helpEngine.findFile(url).isValid()
- ? helpEngine.fileData(url)
- : AbstractHelpViewer::PageNotFoundMessage.arg(url).toUtf8();
+ const QString &mimeType = HelpViewer::mimeFromUrl(url);
+ const QByteArray &data = engine.findFile(url).isValid() ? engine.fileData(url)
+ : HelpViewer::PageNotFoundMessage.arg(url).toUtf8();
+
return new HelpNetworkReply(request, data, mimeType.isEmpty()
? QLatin1String("application/octet-stream") : mimeType);
}
+// -- HelpPage
+
class HelpPage : public QWebPage
{
public:
@@ -188,7 +195,8 @@ HelpPage::HelpPage(QObject *parent)
QWebPage *HelpPage::createWindow(QWebPage::WebWindowType)
{
TRACE_OBJ
- HelpPage* newPage = static_cast<HelpPage*>(OpenPagesManager::instance()->createPage()->page());
+ HelpPage* newPage = static_cast<HelpPage*>(OpenPagesManager::instance()
+ ->createPage()->page());
newPage->closeNewTabIfNeeded = closeNewTabIfNeeded;
closeNewTabIfNeeded = false;
return newPage;
@@ -214,19 +222,18 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
closeNewTabIfNeeded = false;
const QUrl &url = request.url();
- if (AbstractHelpViewer::launchWithExternalApp(url)) {
+ if (HelpViewer::launchWithExternalApp(url)) {
if (closeNewTab)
- QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentTab");
+ QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentPage");
return false;
}
if (type == QWebPage::NavigationTypeLinkClicked
- && (m_keyboardModifiers & Qt::ControlModifier
- || m_pressedButtons == Qt::MidButton)) {
- OpenPagesManager::instance()->createPage(url);
- m_pressedButtons = Qt::NoButton;
- m_keyboardModifiers = Qt::NoModifier;
- return false;
+ && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)) {
+ m_pressedButtons = Qt::NoButton;
+ m_keyboardModifiers = Qt::NoModifier;
+ OpenPagesManager::instance()->createPage(url);
+ return false;
}
return true;
@@ -234,18 +241,19 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
// -- HelpViewer
-HelpViewer::HelpViewer(qreal zoom)
- : loadFinished(false)
- , helpEngine(HelpEngineWrapper::instance())
+HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
+ : QWebView(parent)
{
TRACE_OBJ
setAcceptDrops(false);
+ settings()->setAttribute(QWebSettings::JavaEnabled, false);
+ settings()->setAttribute(QWebSettings::PluginsEnabled, false);
setPage(new HelpPage(this));
page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
- action->setText(tr("Open Link in New Tab"));
+ action->setText(tr("Open Link in New Page"));
pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
@@ -257,7 +265,7 @@ HelpViewer::HelpViewer(qreal zoom)
SLOT(actionChanged()));
connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
SLOT(actionChanged()));
- connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this,
+ 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)));
@@ -275,8 +283,8 @@ HelpViewer::~HelpViewer()
QFont HelpViewer::viewerFont() const
{
TRACE_OBJ
- if (helpEngine.usesBrowserFont())
- return helpEngine.browserFont();
+ if (HelpEngineWrapper::instance().usesBrowserFont())
+ return HelpEngineWrapper::instance().browserFont();
QWebSettings *webSettings = QWebSettings::globalSettings();
return QFont(webSettings->fontFamily(QWebSettings::StandardFont),
@@ -309,57 +317,145 @@ void HelpViewer::resetScale()
setTextSizeMultiplier(1.0);
}
-bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e)
+qreal HelpViewer::scale() const
{
TRACE_OBJ
- if (e->button() == Qt::XButton1) {
- triggerPageAction(QWebPage::Back);
- return true;
- }
+ return textSizeMultiplier();
+}
- if (e->button() == Qt::XButton2) {
- triggerPageAction(QWebPage::Forward);
- return true;
- }
+QString HelpViewer::title() const
+{
+ TRACE_OBJ
+ return QWebView::title();
+}
+
+void HelpViewer::setTitle(const QString &title)
+{
+ TRACE_OBJ
+ Q_UNUSED(title)
+}
- return false;
+QUrl HelpViewer::source() const
+{
+ TRACE_OBJ
+ return url();
}
void HelpViewer::setSource(const QUrl &url)
{
TRACE_OBJ
- loadFinished = false;
load(url.toString() == QLatin1String("help") ? LocalHelpFile : url);
}
-void HelpViewer::home()
+QString HelpViewer::selectedText() const
+{
+ TRACE_OBJ
+ return QWebView::selectedText();
+}
+
+bool HelpViewer::isForwardAvailable() const
+{
+ TRACE_OBJ
+ return pageAction(QWebPage::Forward)->isEnabled();
+}
+
+bool HelpViewer::isBackwardAvailable() const
+{
+ TRACE_OBJ
+ return pageAction(QWebPage::Back)->isEnabled();
+}
+
+bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental,
+ bool fromSearch)
+{
+ TRACE_OBJ
+ Q_UNUSED((incremental && fromSearch))
+ QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
+ if (flags & FindBackward)
+ options |= QWebPage::FindBackward;
+ if (flags & FindCaseSensitively)
+ options |= QWebPage::FindCaseSensitively;
+
+ bool found = QWebView::findText(text, options);
+ options = QWebPage::HighlightAllOccurrences;
+ QWebView::findText(QLatin1String(""), options); // clear first
+ QWebView::findText(text, options); // force highlighting of all other matches
+ return found;
+}
+
+// -- public slots
+
+void HelpViewer::copy()
+{
+ TRACE_OBJ
+ triggerPageAction(QWebPage::Copy);
+}
+
+void HelpViewer::forward()
+{
+ TRACE_OBJ
+ QWebView::forward();
+}
+
+void HelpViewer::backward()
+{
+ TRACE_OBJ
+ back();
+}
+
+// -- protected
+
+void HelpViewer::keyPressEvent(QKeyEvent *e)
{
TRACE_OBJ
- setSource(helpEngine.homePage());
+ // TODO: remove this once we support multiple keysequences per command
+ if (e->key() == Qt::Key_Insert && e->modifiers() == Qt::CTRL) {
+ if (!selectedText().isEmpty())
+ copy();
+ }
+ QWebView::keyPressEvent(e);
}
-void HelpViewer::wheelEvent(QWheelEvent *e)
+void HelpViewer::wheelEvent(QWheelEvent *event)
{
TRACE_OBJ
- if (e->modifiers()& Qt::ControlModifier) {
- e->accept();
- e->delta() > 0 ? scaleUp() : scaleDown();
+ if (event->modifiers()& Qt::ControlModifier) {
+ event->accept();
+ event->delta() > 0 ? scaleUp() : scaleDown();
} else {
- QWebView::wheelEvent(e);
+ QWebView::wheelEvent(event);
}
}
-void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
+void HelpViewer::mousePressEvent(QMouseEvent *event)
+{
+ TRACE_OBJ
+#ifdef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(event))
+ return;
+#endif
+
+ if (HelpPage *currentPage = static_cast<HelpPage*> (page())) {
+ currentPage->m_pressedButtons = event->buttons();
+ currentPage->m_keyboardModifiers = event->modifiers();
+ }
+
+ QWebView::mousePressEvent(event);
+}
+
+void HelpViewer::mouseReleaseEvent(QMouseEvent *event)
{
TRACE_OBJ
#ifndef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(e))
+ if (handleForwardBackwardMouseButtons(event))
return;
#endif
- QWebView::mouseReleaseEvent(e);
+ QWebView::mouseReleaseEvent(event);
}
+// -- private slots
+
void HelpViewer::actionChanged()
{
TRACE_OBJ
@@ -372,27 +468,18 @@ void HelpViewer::actionChanged()
emit forwardAvailable(a->isEnabled());
}
-void HelpViewer::mousePressEvent(QMouseEvent *event)
+// -- private
+
+bool HelpViewer::eventFilter(QObject *obj, QEvent *event)
{
TRACE_OBJ
-#ifdef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(event))
- return;
-#endif
-
- HelpPage *currentPage = static_cast<HelpPage*>(page());
- if (currentPage) {
- currentPage->m_pressedButtons = event->buttons();
- currentPage->m_keyboardModifiers = event->modifiers();
- }
- QWebView::mousePressEvent(event);
+ return QWebView::eventFilter(obj, event);
}
-void HelpViewer::setLoadFinished(bool ok)
+void HelpViewer::contextMenuEvent(QContextMenuEvent *event)
{
TRACE_OBJ
- loadFinished = ok;
- emit sourceChanged(url());
+ QWebView::contextMenuEvent(event);
}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h
deleted file mode 100644
index 92d9e11..0000000
--- a/tools/assistant/tools/assistant/helpviewer_qwv.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Assistant of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef HELPVIEWERQWV_H
-#define HELPVIEWERQWV_H
-
-#include "helpviewer.h"
-
-#include <QtGui/QAction>
-#include <QtWebKit/QWebView>
-
-QT_BEGIN_NAMESPACE
-
-class HelpEngineWrapper;
-class QMouseEvent;
-
-class HelpViewer : public QWebView, public AbstractHelpViewer
-{
- Q_OBJECT
-
-public:
- HelpViewer(qreal zoom = 0.0);
- ~HelpViewer();
-
- QFont viewerFont() const;
- void setViewerFont(const QFont &font);
-
- void scaleUp();
- void scaleDown();
- void resetScale();
- qreal scale() const { return textSizeMultiplier(); }
-
- bool handleForwardBackwardMouseButtons(QMouseEvent *e);
-
- 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
-
- inline void copy()
- { return triggerPageAction(QWebPage::Copy); }
-
- 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(); }
-
-Q_SIGNALS:
- void copyAvailable(bool enabled);
- void forwardAvailable(bool enabled);
- void backwardAvailable(bool enabled);
- void highlighted(const QString &);
- void sourceChanged(const QUrl &);
- void titleChanged();
-
-protected:
- virtual void wheelEvent(QWheelEvent *);
- void mouseReleaseEvent(QMouseEvent *e);
- void mousePressEvent(QMouseEvent *event);
-
-private Q_SLOTS:
- void actionChanged();
- void setLoadFinished(bool ok);
-
-private:
- bool loadFinished;
- HelpEngineWrapper &helpEngine;
-};
-
-QT_END_NAMESPACE
-
-#endif // HELPVIEWERQWV_H
diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp
index 7a47e85..00f61f2 100644
--- a/tools/assistant/tools/assistant/indexwindow.cpp
+++ b/tools/assistant/tools/assistant/indexwindow.cpp
@@ -38,14 +38,15 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
#include "indexwindow.h"
+
#include "centralwidget.h"
#include "helpenginewrapper.h"
#include "helpviewer.h"
#include "openpagesmanager.h"
#include "topicchooser.h"
+#include "tracer.h"
#include <QtGui/QLayout>
#include <QtGui/QLabel>
@@ -220,7 +221,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
return;
}
- if (!AbstractHelpViewer::canOpenPage(url.path()))
+ if (!HelpViewer::canOpenPage(url.path()))
CentralWidget::instance()->setSource(url);
else
OpenPagesManager::instance()->createPage(url);
diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp
index 7a2228f..6db1879 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.cpp
+++ b/tools/assistant/tools/assistant/openpagesmanager.cpp
@@ -42,11 +42,7 @@
#include "centralwidget.h"
#include "helpenginewrapper.h"
-#if defined(QT_NO_WEBKIT)
-#include "helpviewer_qtb.h"
-#else
-#include "helpviewer_qwv.h"
-#endif // QT_NO_WEBKIT
+#include "helpviewer.h"
#include "openpagesmodel.h"
#include "openpageswidget.h"
#include "tracer.h"
@@ -172,7 +168,7 @@ void OpenPagesManager::closeCurrentPage()
HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch)
{
TRACE_OBJ
- if (AbstractHelpViewer::launchWithExternalApp(url))
+ if (HelpViewer::launchWithExternalApp(url))
return 0;
m_model->addPage(url);
diff --git a/tools/assistant/tools/assistant/openpagesmodel.cpp b/tools/assistant/tools/assistant/openpagesmodel.cpp
index 92ca1ad..2663b85 100644
--- a/tools/assistant/tools/assistant/openpagesmodel.cpp
+++ b/tools/assistant/tools/assistant/openpagesmodel.cpp
@@ -41,11 +41,7 @@
#include "openpagesmodel.h"
#include "helpenginewrapper.h"
-#if defined(QT_NO_WEBKIT)
-#include "helpviewer_qtb.h"
-#else
-#include "helpviewer_qwv.h"
-#endif // QT_NO_WEBKIT
+#include "helpviewer.h"
#include "tracer.h"
#include <QtCore/QStringList>
@@ -76,7 +72,7 @@ QVariant OpenPagesModel::data(const QModelIndex &index, int role) const
if (!index.isValid() || index.row() >= rowCount() || index.column() > 0
|| role != Qt::DisplayRole)
return QVariant();
- QString title = m_pages.at(index.row())->documentTitle();
+ QString title = m_pages.at(index.row())->title();
title.replace(QLatin1Char('&'), QLatin1String("&&"));
return title.isEmpty() ? QLatin1String("(Untitled)") : title;
}