summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/tools/assistant/aboutdialog.cpp9
-rw-r--r--tools/assistant/tools/assistant/assistant.pro22
-rw-r--r--tools/assistant/tools/assistant/assistant_images.qrc6
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp1028
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h94
-rw-r--r--tools/assistant/tools/assistant/contentwindow.cpp12
-rw-r--r--tools/assistant/tools/assistant/doc/assistant.qdocconf2
-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.cpp163
-rw-r--r--tools/assistant/tools/assistant/globalactions.h91
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp12
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h3
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp93
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h105
-rw-r--r--tools/assistant/tools/assistant/helpviewer_p.h149
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qtb.cpp343
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.cpp236
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.h122
-rw-r--r--tools/assistant/tools/assistant/images/closebutton.pngbin0 -> 288 bytes
-rw-r--r--tools/assistant/tools/assistant/images/darkclosebutton.pngbin0 -> 319 bytes
-rw-r--r--tools/assistant/tools/assistant/indexwindow.cpp8
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp492
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h27
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.cpp306
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.h104
-rw-r--r--tools/assistant/tools/assistant/openpagesmodel.cpp119
-rw-r--r--tools/assistant/tools/assistant/openpagesmodel.h76
-rw-r--r--tools/assistant/tools/assistant/openpageswidget.cpp196
-rw-r--r--tools/assistant/tools/assistant/openpageswidget.h (renamed from tools/assistant/tools/assistant/helpviewer_qtb.h)81
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.cpp15
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.h1
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.cpp10
-rw-r--r--tools/configure/configureapp.cpp32
-rw-r--r--tools/designer/data/ui4.xsd2
-rw-r--r--tools/qdoc3/doc/qdoc-manual.qdocconf2
-rw-r--r--tools/qdoc3/test/assistant.qdocconf6
-rw-r--r--tools/qdoc3/test/designer.qdocconf4
-rw-r--r--tools/qdoc3/test/linguist.qdocconf6
-rw-r--r--tools/qdoc3/test/qmake.qdocconf6
-rw-r--r--tools/qdoc3/test/qt-build-docs.qdocconf10
-rw-r--r--tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf10
-rw-r--r--tools/qdoc3/test/qt-html-templates.qdocconf2
-rw-r--r--tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf8
-rw-r--r--tools/qdoc3/test/qt.qdocconf10
-rw-r--r--tools/qdoc3/test/qt_zh_CN.qdocconf10
-rw-r--r--tools/qtconfig/mainwindow.cpp2
47 files changed, 2353 insertions, 1689 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 eb8cc51..af306a5 100644
--- a/tools/assistant/tools/assistant/assistant.pro
+++ b/tools/assistant/tools/assistant/assistant.pro
@@ -12,6 +12,8 @@ DESTDIR = ../../../../bin
target.path = $$[QT_INSTALL_BINS]
INSTALLS += target
DEPENDPATH += ../shared
+DEPENDPATH += .
+INCLUDEPATH += .
# ## Work around a qmake issue when statically linking to
# ## not-yet-installed plugins
@@ -30,6 +32,7 @@ HEADERS += aboutdialog.h \
filternamedialog.h \
helpenginewrapper.h \
helpviewer.h \
+ helpviewer_p.h \
indexwindow.h \
installdialog.h \
mainwindow.h \
@@ -40,12 +43,11 @@ HEADERS += aboutdialog.h \
topicchooser.h \
tracer.h \
xbelsupport.h \
- ../shared/collectionconfiguration.h
-contains(QT_CONFIG, webkit) {
- HEADERS += helpviewer_qwv.h
-} else {
- HEADERS += helpviewer_qtb.h
- }
+ ../shared/collectionconfiguration.h \
+ openpagesmodel.h \
+ globalactions.h \
+ openpageswidget.h \
+ openpagesmanager.h
win32:HEADERS += remotecontrol_win.h
SOURCES += aboutdialog.cpp \
@@ -72,8 +74,12 @@ SOURCES += aboutdialog.cpp \
searchwidget.cpp \
topicchooser.cpp \
xbelsupport.cpp \
- ../shared/collectionconfiguration.cpp
- contains(QT_CONFIG, webkit) {
+ ../shared/collectionconfiguration.cpp \
+ openpagesmodel.cpp \
+ globalactions.cpp \
+ openpageswidget.cpp \
+ openpagesmanager.cpp
+contains(QT_CONFIG, webkit) {
SOURCES += helpviewer_qwv.cpp
} else {
SOURCES += helpviewer_qtb.cpp
diff --git a/tools/assistant/tools/assistant/assistant_images.qrc b/tools/assistant/tools/assistant/assistant_images.qrc
index 34918c0..b4f2523 100644
--- a/tools/assistant/tools/assistant/assistant_images.qrc
+++ b/tools/assistant/tools/assistant/assistant_images.qrc
@@ -1,11 +1,10 @@
<RCC>
- <qresource prefix="/trolltech/assistant" >
+ <qresource prefix="/trolltech/assistant">
<file>images/trolltech-logo.png</file>
<file>images/assistant-128.png</file>
<file>images/assistant.png</file>
<file>images/wrap.png</file>
<file>images/bookmark.png</file>
-#mac
<file>images/mac/addtab.png</file>
<file>images/mac/book.png</file>
<file>images/mac/closetab.png</file>
@@ -19,7 +18,6 @@
<file>images/mac/zoomin.png</file>
<file>images/mac/zoomout.png</file>
<file>images/mac/resetzoom.png</file>
-#win
<file>images/win/addtab.png</file>
<file>images/win/book.png</file>
<file>images/win/closetab.png</file>
@@ -33,5 +31,7 @@
<file>images/win/zoomin.png</file>
<file>images/win/zoomout.png</file>
<file>images/win/resetzoom.png</file>
+ <file>images/closebutton.png</file>
+ <file>images/darkclosebutton.png</file>
</qresource>
</RCC>
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index 131fb85..b6fa159 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -38,156 +38,82 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
#include "centralwidget.h"
+
#include "findwidget.h"
#include "helpenginewrapper.h"
-#include "searchwidget.h"
-#include "mainwindow.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/QApplication>
#include <QtGui/QKeyEvent>
-#include <QtGui/QLayout>
-#include <QtGui/QMenu>
-#include <QtGui/QPrinter>
-#include <QtGui/QTabBar>
-#include <QtGui/QTabWidget>
-#include <QtGui/QTextBrowser>
-#include <QtGui/QToolButton>
#include <QtGui/QPageSetupDialog>
#include <QtGui/QPrintDialog>
#include <QtGui/QPrintPreviewDialog>
+#include <QtGui/QPrinter>
+#include <QtGui/QStackedWidget>
+#include <QtGui/QTextBrowser>
+#include <QtGui/QVBoxLayout>
#include <QtHelp/QHelpSearchEngine>
QT_BEGIN_NAMESPACE
namespace {
- HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget,
- const QPoint &point)
- {
- TRACE_OBJ
- 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;
- }
CentralWidget *staticCentralWidget = 0;
}
// -- CentralWidget
-CentralWidget::CentralWidget(MainWindow *parent)
+CentralWidget::CentralWidget(QWidget *parent)
: QWidget(parent)
- , lastTabPage(0)
- , tabWidget(0)
- , findWidget(0)
- , printer(0)
- , usesDefaultCollection(parent->usesDefaultCollection())
- , m_searchWidget(0)
+#ifndef QT_NO_PRINTER
+ , m_printer(0)
+#endif
+ , m_findWidget(new FindWidget(this))
+ , m_stackedWidget(new QStackedWidget(this))
{
TRACE_OBJ
- globalActionList.clear();
staticCentralWidget = this;
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
- QString resourcePath = QLatin1String(":/trolltech/assistant/images/");
vboxLayout->setMargin(0);
- tabWidget = new QTabWidget(this);
-#ifndef Q_OS_MAC
- resourcePath.append(QLatin1String("win"));
-#else
- resourcePath.append(QLatin1String("mac"));
- tabWidget->setDocumentMode(true);
-#endif
-
- 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(resourcePath + QLatin1String("/addtab.png")));
-
- tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner);
- connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab()));
-
- QToolButton *closeTabButton = new QToolButton(this);
- closeTabButton->setEnabled(false);
- closeTabButton->setAutoRaise(true);
- closeTabButton->setToolTip(tr("Close current page"));
- closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png")));
-
- tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner);
- connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab()));
-
- vboxLayout->addWidget(tabWidget);
-
- 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()));
-
- QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
- if (tabBar) {
- tabBar->installEventFilter(this);
- tabBar->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this,
- SLOT(showTabBarContextMenu(QPoint)));
- }
+ vboxLayout->addWidget(m_stackedWidget);
+ vboxLayout->addWidget(m_findWidget);
+ m_findWidget->hide();
-#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;
- bool searchAttached = m_searchWidget->isAttached();
-
- int i = searchAttached ? 1 : 0;
- for (; i < tabWidget->count(); ++i) {
- HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
- if (viewer && viewer->source().isValid()) {
- currentPages << viewer->source().toString();
+ for (int i = 0; i < m_stackedWidget->count(); ++i) {
+ const HelpViewer * const viewer = viewerAt(i);
+ const QUrl &source = viewer->source();
+ if (source.isValid()) {
+ currentPages << source.toString();
zoomFactors << QString::number(viewer->scale());
}
}
HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- helpEngine.setLastTabPage(tabWidget->currentIndex());
helpEngine.setLastShownPages(currentPages);
- helpEngine.setSearchWasAttached(searchAttached);
helpEngine.setLastZoomFactors(zoomFactors);
+ helpEngine.setLastTabPage(m_stackedWidget->currentIndex());
+
+#ifndef QT_NO_PRINTER
+ delete m_printer;
+#endif
}
CentralWidget *CentralWidget::instance()
@@ -196,808 +122,286 @@ CentralWidget *CentralWidget::instance()
return staticCentralWidget;
}
-void CentralWidget::newTab()
+QUrl CentralWidget::currentSource() const
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
-#if !defined(QT_NO_WEBKIT)
- if (viewer && viewer->hasLoadFinished())
-#else
- if (viewer)
-#endif
- setSourceInNewTab(viewer->source());
+ return currentHelpViewer()->source();
}
-void CentralWidget::zoomIn()
+QString CentralWidget::currentTitle() const
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->scaleUp();
-
- if (tabWidget->currentWidget() == m_searchWidget)
- m_searchWidget->zoomIn();
+ return currentHelpViewer()->title();
}
-void CentralWidget::zoomOut()
+bool CentralWidget::hasSelection() const
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->scaleDown();
-
- if (tabWidget->currentWidget() == m_searchWidget)
- m_searchWidget->zoomOut();
+ return !currentHelpViewer()->selectedText().isEmpty();
}
-void CentralWidget::nextPage()
+bool CentralWidget::isForwardAvailable() const
{
TRACE_OBJ
- int index = tabWidget->currentIndex() + 1;
- if (index >= tabWidget->count())
- index = 0;
- tabWidget->setCurrentIndex(index);
+ return currentHelpViewer()->isForwardAvailable();
}
-void CentralWidget::resetZoom()
+bool CentralWidget::isBackwardAvailable() const
{
TRACE_OBJ
- if (HelpViewer *viewer = currentHelpViewer())
- viewer->resetScale();
-
- if (tabWidget->currentWidget() == m_searchWidget)
- m_searchWidget->resetZoom();
+ return currentHelpViewer()->isBackwardAvailable();
}
-void CentralWidget::previousPage()
+HelpViewer* CentralWidget::viewerAt(int index) const
{
TRACE_OBJ
- int index = tabWidget->currentIndex() -1;
- if (index < 0)
- index = tabWidget->count() -1;
- tabWidget->setCurrentIndex(index);
+ return static_cast<HelpViewer*>(m_stackedWidget->widget(index));
}
-void CentralWidget::closeTab()
+HelpViewer* CentralWidget::currentHelpViewer() const
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (!viewer|| tabWidget->count() == 1)
- return;
-
- tabWidget->removeTab(tabWidget->indexOf(viewer));
- QTimer::singleShot(0, viewer, SLOT(deleteLater()));
+ return static_cast<HelpViewer *>(m_stackedWidget->currentWidget());
}
-void CentralWidget::setSource(const QUrl &url)
+void CentralWidget::addPage(HelpViewer *page, bool fromSearch)
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- HelpViewer *lastViewer =
- qobject_cast<HelpViewer*>(tabWidget->widget(lastTabPage));
-
- if (!viewer && !lastViewer) {
- viewer = new HelpViewer(this);
- viewer->installEventFilter(this);
- lastTabPage = tabWidget->addTab(viewer, QString());
- tabWidget->setCurrentIndex(lastTabPage);
- connectSignals();
- } else {
- viewer = lastViewer;
+ page->installEventFilter(this);
+ page->setFocus(Qt::OtherFocusReason);
+ connectSignals(page);
+ m_stackedWidget->addWidget(page);
+ if (fromSearch) {
+ connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
+ SLOT(highlightSearchTerms()));
}
+}
- viewer->setSource(url);
- currentPageChanged(lastTabPage);
- viewer->setFocus(Qt::OtherFocusReason);
- tabWidget->setCurrentIndex(lastTabPage);
- tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle()));
+void CentralWidget::removePage(int index)
+{
+ TRACE_OBJ
+ const bool currentChanged = index == currentIndex();
+ m_stackedWidget->removeWidget(m_stackedWidget->widget(index));
+ if (currentChanged)
+ emit currentViewerChanged();
}
-void CentralWidget::setupWidget()
+int CentralWidget::currentIndex() const
{
TRACE_OBJ
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- int option = helpEngine.startOption();
- if (option != ShowLastPages) {
- QString homePage;
- if (option == ShowHomePage)
- homePage = helpEngine.homePage();
- else if (option == ShowBlankPage)
- homePage = QLatin1String("about:blank");
- setSource(homePage);
- } else {
- setLastShownPages();
- }
+ return m_stackedWidget->currentIndex();
}
-void CentralWidget::setLastShownPages()
+void CentralWidget::setCurrentPage(HelpViewer *page)
{
TRACE_OBJ
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- const QStringList &lastShownPageList = helpEngine.lastShownPages();
- const int pageCount = lastShownPageList.count();
- if (pageCount == 0) {
- if (usesDefaultCollection)
- setSource(QUrl(QLatin1String("help")));
- else
- setSource(QUrl(QLatin1String("about:blank")));
- return;
- }
- QStringList zoomFactors = helpEngine.lastZoomFactors();
- while (zoomFactors.count() < pageCount)
- zoomFactors.append(CollectionConfiguration::DefaultZoomFactor);
-
- const bool searchIsAttached = m_searchWidget->isAttached();
- const bool searchWasAttached = helpEngine.searchWasAttached();
- int tabToShow = helpEngine.lastTabPage();
- if (searchWasAttached && !searchIsAttached && tabToShow != 0)
- --tabToShow;
- else if (!searchWasAttached && searchIsAttached)
- ++tabToShow;
-
- for (int curTab = 0; curTab < pageCount; ++curTab) {
- const QString &curFile = lastShownPageList.at(curTab);
- if (helpEngine.findFile(curFile).isValid()
- || curFile == QLatin1String("about:blank")) {
- setSourceInNewTab(curFile, zoomFactors.at(curTab).toFloat());
- } else if (curTab + searchIsAttached <= tabToShow)
- --tabToShow;
- }
+ m_stackedWidget->setCurrentWidget(page);
+ emit currentViewerChanged();
+}
+
+// -- public slots
- tabWidget->setCurrentIndex(tabToShow);
+void CentralWidget::copy()
+{
+ TRACE_OBJ
+ currentHelpViewer()->copy();
}
-bool CentralWidget::hasSelection() const
+void CentralWidget::home()
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- return viewer ? viewer->hasSelection() : false;
+ currentHelpViewer()->home();
}
-QUrl CentralWidget::currentSource() const
+void CentralWidget::zoomIn()
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->source();
+ currentHelpViewer()->scaleUp();
+}
- return QUrl();
+void CentralWidget::zoomOut()
+{
+ TRACE_OBJ
+ currentHelpViewer()->scaleDown();
}
-QString CentralWidget::currentTitle() const
+void CentralWidget::resetZoom()
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->documentTitle();
+ currentHelpViewer()->resetScale();
+}
- return QString();
+void CentralWidget::forward()
+{
+ TRACE_OBJ
+ currentHelpViewer()->forward();
}
-void CentralWidget::copySelection()
+void CentralWidget::nextPage()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->copy();
+ m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() + 1)
+ % m_stackedWidget->count());
}
-void CentralWidget::showTextSearch()
+void CentralWidget::backward()
{
TRACE_OBJ
- findWidget->show();
+ currentHelpViewer()->backward();
}
-void CentralWidget::initPrinter()
+void CentralWidget::previousPage()
{
TRACE_OBJ
-#ifndef QT_NO_PRINTER
- if (!printer)
- printer = new QPrinter(QPrinter::HighResolution);
-#endif
+ m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() - 1)
+ % m_stackedWidget->count());
}
void CentralWidget::print()
{
TRACE_OBJ
#ifndef QT_NO_PRINTER
- HelpViewer *viewer = currentHelpViewer();
- if (!viewer)
- return;
-
initPrinter();
+ QPrintDialog dlg(m_printer, this);
- QPrintDialog dlg(printer, this);
-#if defined(QT_NO_WEBKIT)
- if (viewer->textCursor().hasSelection())
+ if (!currentHelpViewer()->selectedText().isEmpty())
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);
- }
+ if (dlg.exec() == QDialog::Accepted)
+ currentHelpViewer()->print(m_printer);
#endif
}
-void CentralWidget::printPreview()
+void CentralWidget::pageSetup()
{
TRACE_OBJ
#ifndef QT_NO_PRINTER
initPrinter();
- QPrintPreviewDialog preview(printer, this);
- connect(&preview, SIGNAL(paintRequested(QPrinter*)),
- SLOT(printPreview(QPrinter*)));
- preview.exec();
-#endif
-}
-
-void CentralWidget::printPreview(QPrinter *p)
-{
- TRACE_OBJ
-#ifndef QT_NO_PRINTER
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->print(p);
+ QPageSetupDialog dlg(m_printer);
+ dlg.exec();
#endif
}
-void CentralWidget::pageSetup()
+void CentralWidget::printPreview()
{
TRACE_OBJ
#ifndef QT_NO_PRINTER
initPrinter();
- QPageSetupDialog dlg(printer);
- dlg.exec();
+ QPrintPreviewDialog preview(m_printer, this);
+ connect(&preview, SIGNAL(paintRequested(QPrinter*)),
+ SLOT(printPreview(QPrinter*)));
+ preview.exec();
#endif
}
-bool CentralWidget::isHomeAvailable() const
-{
- TRACE_OBJ
- return currentHelpViewer() ? true : false;
-}
-
-void CentralWidget::home()
-{
- TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->home();
-}
-
-bool CentralWidget::isForwardAvailable() const
-{
- TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->isForwardAvailable();
-
- return false;
-}
-
-void CentralWidget::forward()
+void CentralWidget::setSource(const QUrl &url)
{
TRACE_OBJ
HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->forward();
-}
-
-bool CentralWidget::isBackwardAvailable() const
-{
- TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->isBackwardAvailable();
-
- return false;
+ viewer->setSource(url);
+ viewer->setFocus(Qt::OtherFocusReason);
}
-void CentralWidget::backward()
+void CentralWidget::setSourceFromSearch(const QUrl &url)
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->backward();
+ connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
+ SLOT(highlightSearchTerms()));
+ currentHelpViewer()->setSource(url);
+ currentHelpViewer()->setFocus(Qt::OtherFocusReason);
}
-
-QList<QAction*> CentralWidget::globalActions() const
+void CentralWidget::findNext()
{
TRACE_OBJ
- return globalActionList;
+ find(m_findWidget->text(), true, false);
}
-void CentralWidget::setGlobalActions(const QList<QAction*> &actions)
+void CentralWidget::findPrevious()
{
TRACE_OBJ
- globalActionList = actions;
+ find(m_findWidget->text(), false, false);
}
-void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom)
+void CentralWidget::find(const QString &ttf, bool forward, bool incremental)
{
TRACE_OBJ
+ bool found = false;
if (HelpViewer *viewer = currentHelpViewer()) {
- if (viewer->launchWithExternalApp(url))
- return;
+ HelpViewer::FindFlags flags = 0;
+ if (!forward)
+ flags |= HelpViewer::FindBackward;
+ if (m_findWidget->caseSensitive())
+ flags |= HelpViewer::FindCaseSensitively;
+ found = viewer->findText(ttf, flags, incremental, false);
}
- HelpViewer *viewer = new HelpViewer(this, zoom);
- viewer->installEventFilter(this);
- viewer->setSource(url);
- viewer->setFocus(Qt::OtherFocusReason);
- tabWidget->setCurrentIndex(tabWidget->addTab(viewer,
- quoteTabTitle(viewer->documentTitle())));
- connectSignals();
-}
-
-HelpViewer *CentralWidget::newEmptyTab()
-{
- TRACE_OBJ
- HelpViewer *viewer = new HelpViewer(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()
-{
- TRACE_OBJ
- 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)));
- connect(viewer, SIGNAL(printRequested()), this, SLOT(print()));
- }
-}
-
-HelpViewer* CentralWidget::viewerAt(int index) const
-{
- TRACE_OBJ
- return qobject_cast<HelpViewer*>(tabWidget->widget(index));
-}
+ if (!found && ttf.isEmpty())
+ found = true; // the line edit is empty, no need to mark it red...
-HelpViewer* CentralWidget::currentHelpViewer() const
-{
- TRACE_OBJ
- return qobject_cast<HelpViewer*>(tabWidget->currentWidget());
+ if (!m_findWidget->isVisible())
+ m_findWidget->show();
+ m_findWidget->setPalette(found);
}
-void CentralWidget::activateTab(bool onlyHelpViewer)
+void CentralWidget::activateTab()
{
TRACE_OBJ
- if (currentHelpViewer()) {
- currentHelpViewer()->setFocus();
- } else {
- int idx = 0;
- if (onlyHelpViewer)
- idx = lastTabPage;
- tabWidget->setCurrentIndex(idx);
- tabWidget->currentWidget()->setFocus();
- }
+ currentHelpViewer()->setFocus();
}
-void CentralWidget::setTabTitle(const QUrl &url)
-{
- TRACE_OBJ
- Q_UNUSED(url)
-#if !defined(QT_NO_WEBKIT)
- QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
- for (int tab = 0; tab < tabBar->count(); ++tab) {
- HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(tab));
- if (viewer) {
- tabWidget->setTabText(tab,
- quoteTabTitle(viewer->documentTitle().trimmed()));
- }
- }
-#else
- HelpViewer *viewer = currentHelpViewer();
- if (viewer) {
- tabWidget->setTabText(lastTabPage,
- quoteTabTitle(viewer->documentTitle().trimmed()));
- }
-#endif
-}
-
-void CentralWidget::currentPageChanged(int index)
+void CentralWidget::showTextSearch()
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- lastTabPage = index;
-
- QWidget *widget = tabWidget->cornerWidget(Qt::TopRightCorner);
- widget->setEnabled(viewer && enableTabCloseAction());
-
- widget = tabWidget->cornerWidget(Qt::TopLeftCorner);
- widget->setEnabled(viewer ? true : false);
-
- emit currentViewerChanged();
+ m_findWidget->show();
}
-void CentralWidget::showTabBarContextMenu(const QPoint &point)
+void CentralWidget::updateBrowserFont()
{
TRACE_OBJ
- 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 = enableTabCloseAction();
- 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 addBookmark(viewer->documentTitle(), viewer->source().toString());
+ const int count = m_stackedWidget->count();
+ const QFont &font = viewerAt(count - 1)->viewerFont();
+ for (int i = 0; i < count; ++i)
+ viewerAt(i)->setViewerFont(font);
}
-bool CentralWidget::eventFilter(QObject *object, QEvent *e)
-{
- 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;
- }
- }
-
- if (qobject_cast<QTabBar*>(object)) {
- const bool dblClick = e->type() == QEvent::MouseButtonDblClick;
- if ((e->type() == QEvent::MouseButtonRelease) || dblClick) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e);
- HelpViewer *viewer = helpViewerFromTabPosition(tabWidget,
- mouseEvent->pos());
- if (viewer) {
- if ((mouseEvent->button() == Qt::MidButton) || dblClick) {
- if (availableHelpViewer() > 1) {
- tabWidget->removeTab(tabWidget->indexOf(viewer));
- QTimer::singleShot(0, viewer, SLOT(deleteLater()));
- currentPageChanged(tabWidget->currentIndex());
- return true;
- }
- }
- }
- }
- }
-
- return QWidget::eventFilter(object, e);
-}
+// -- protected
void CentralWidget::keyPressEvent(QKeyEvent *e)
{
TRACE_OBJ
const QString &text = e->text();
if (text.startsWith(QLatin1Char('/'))) {
- if (!findWidget->isVisible()) {
- findWidget->showAndClear();
+ if (!m_findWidget->isVisible()) {
+ m_findWidget->showAndClear();
} else {
- findWidget->show();
+ m_findWidget->show();
}
} else {
QWidget::keyPressEvent(e);
}
}
-void CentralWidget::findNext()
-{
- TRACE_OBJ
- find(findWidget->text(), true);
-}
-
-void CentralWidget::findPrevious()
-{
- TRACE_OBJ
- find(findWidget->text(), false);
-}
-
-void CentralWidget::find(const QString &ttf, bool forward)
-{
- TRACE_OBJ
- bool found = false;
-#if defined(QT_NO_WEBKIT)
- found = findInTextBrowser(ttf, forward);
-#else
- found = findInWebPage(ttf, forward);
-#endif
-
- 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);
-}
-
-bool CentralWidget::findInWebPage(const QString &ttf, bool forward)
-{
- TRACE_OBJ
-#if !defined(QT_NO_WEBKIT)
- if (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;
-}
-
-bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward)
-{
- TRACE_OBJ
- QTextBrowser *browser = qobject_cast<QTextBrowser*>(currentHelpViewer());
- if (tabWidget->currentWidget() == m_searchWidget)
- browser = qFindChild<QTextBrowser*>(m_searchWidget);
-
- 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;
-}
-
-void CentralWidget::updateBrowserFont()
-{
- TRACE_OBJ
- const bool searchAttached = searchWidgetAttached();
- if (searchAttached) {
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- m_searchWidget->setFont(helpEngine.usesBrowserFont()
- ? helpEngine.browserFont() : qApp->font());
- }
-
- const int count = tabWidget->count();
- if (HelpViewer* viewer = viewerAt(count - 1)) {
- const QFont &font = viewer->viewerFont();
- for (int i = searchAttached ? 1 : 0; i < count; ++i)
- viewerAt(i)->setViewerFont(font);
- }
-}
-
-bool CentralWidget::searchWidgetAttached() const
-{
- TRACE_OBJ
- return m_searchWidget && m_searchWidget->isAttached();
-}
-
-void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
-{
- TRACE_OBJ
- if (m_searchWidget)
- return;
-
- m_searchWidget = new SearchWidget(searchEngine, this);
- connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this,
- SLOT(setSourceFromSearch(QUrl)));
- connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this,
- SLOT(setSourceFromSearchInNewTab(QUrl)));
-
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- m_searchWidget->setFont(!helpEngine.usesBrowserFont() ? qApp->font()
- : helpEngine.browserFont());
-}
-
-void CentralWidget::activateSearchWidget(bool updateLastTabPage)
-{
- TRACE_OBJ
- if (!m_searchWidget)
- createSearchWidget(HelpEngineWrapper::instance().searchEngine());
-
- if (!m_searchWidget->isAttached()) {
- tabWidget->insertTab(0, m_searchWidget, tr("Search"));
- m_searchWidget->setAttached(true);
-
- if (updateLastTabPage)
- lastTabPage++;
- }
-
- tabWidget->setCurrentWidget(m_searchWidget);
- m_searchWidget->setFocus();
-}
-
-void CentralWidget::removeSearchWidget()
-{
- TRACE_OBJ
- if (searchWidgetAttached()) {
- tabWidget->removeTab(0);
- m_searchWidget->setAttached(false);
- }
-}
-
-int CentralWidget::availableHelpViewer() const
-{
- TRACE_OBJ
- int count = tabWidget->count();
- if (searchWidgetAttached())
- count--;
- return count;
-}
-
-bool CentralWidget::enableTabCloseAction() const
+void CentralWidget::focusInEvent(QFocusEvent * /* event */)
{
TRACE_OBJ
- int minTabCount = 1;
- if (searchWidgetAttached())
- minTabCount = 2;
-
- return (tabWidget->count() > minTabCount);
-}
-
-QString CentralWidget::quoteTabTitle(const QString &title) const
-{
- TRACE_OBJ
- QString s = title;
- return s.replace(QLatin1Char('&'), QLatin1String("&&"));
-}
-
-void
-CentralWidget::setSourceFromSearch(const QUrl &url)
-{
- TRACE_OBJ
- setSource(url);
-#if defined(QT_NO_WEBKIT)
- highlightSearchTerms();
-#else
- connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
- SLOT(highlightSearchTerms()));
-#endif
+ // 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()));
}
-void
-CentralWidget::setSourceFromSearchInNewTab(const QUrl &url)
-{
- TRACE_OBJ
- setSourceInNewTab(url);
-#if defined(QT_NO_WEBKIT)
- highlightSearchTerms();
-#else
- connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
- SLOT(highlightSearchTerms()));
-#endif
-}
+// -- private slots
-void
-CentralWidget::highlightSearchTerms()
+void CentralWidget::highlightSearchTerms()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (!viewer)
- return;
-
QHelpSearchEngine *searchEngine =
HelpEngineWrapper::instance().searchEngine();
QList<QHelpSearchQuery> queryList = searchEngine->query();
@@ -1016,91 +420,73 @@ 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()));
+}
+
+void CentralWidget::printPreview(QPrinter *p)
+{
+ TRACE_OBJ
+#ifndef QT_NO_PRINTER
+ currentHelpViewer()->print(p);
#endif
}
+void CentralWidget::handleSourceChanged(const QUrl &url)
+{
+ TRACE_OBJ
+ if (sender() == currentHelpViewer())
+ emit sourceChanged(url);
+}
+
+// -- private
-void CentralWidget::closeOrReloadTabs(const QList<int> &indices, bool tryReload)
+void CentralWidget::initPrinter()
{
TRACE_OBJ
- QList<int> sortedIndices = indices;
- qSort(sortedIndices);
- for (int i = sortedIndices.count(); --i >= 0;) {
- const int tab = sortedIndices.at(i);
- bool close = true;
- if (tryReload) {
- HelpViewer *viewer =
- qobject_cast<HelpViewer*>(tabWidget->widget(tab));
- if (HelpEngineWrapper::instance().findFile(viewer->source()).isValid()) {
- viewer->reload();
- close = false;
- }
- }
- if (close)
- closeTabAt(tab);
- }
- if (availableHelpViewer() == 0)
- setSource(QUrl(QLatin1String("about:blank")));
+#ifndef QT_NO_PRINTER
+ if (!m_printer)
+ m_printer = new QPrinter(QPrinter::HighResolution);
+#endif
}
-void CentralWidget::closeTabAt(int index)
+void CentralWidget::connectSignals(HelpViewer *page)
{
TRACE_OBJ
- HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(index));
- tabWidget->removeTab(index);
- QTimer::singleShot(0, viewer, SLOT(deleteLater()));
+ 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)));
+ connect(page, SIGNAL(printRequested()), this, SLOT(print()));
}
-QMap<int, QString> CentralWidget::currentSourceFileList() const
+bool CentralWidget::eventFilter(QObject *object, QEvent *e)
{
TRACE_OBJ
- QMap<int, QString> sourceList;
- for (int i = 0; i < tabWidget->count(); ++i) {
- HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
- if (viewer && viewer->source().isValid())
- sourceList.insert(i, viewer->source().host());
+ 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 sourceList;
+ 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 f286ff7..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
@@ -48,70 +49,62 @@ QT_BEGIN_NAMESPACE
class FindWidget;
class HelpViewer;
-class MainWindow;
-class QHelpSearchEngine;
-class QTabWidget;
-class SearchWidget;
+class QStackedWidget;
class CentralWidget : public QWidget
{
Q_OBJECT
public:
- CentralWidget(MainWindow *parent);
+ CentralWidget(QWidget *parent = 0);
~CentralWidget();
- void setupWidget();
- bool hasSelection() const;
+ static CentralWidget *instance();
+
QUrl currentSource() const;
QString currentTitle() const;
- bool isHomeAvailable() const;
+
+ bool hasSelection() const;
bool isForwardAvailable() const;
bool isBackwardAvailable() const;
- QList<QAction*> globalActions() const;
- void setGlobalActions(const QList<QAction*> &actions);
HelpViewer *viewerAt(int index) const;
HelpViewer *currentHelpViewer() const;
- bool searchWidgetAttached() const;
- void createSearchWidget(QHelpSearchEngine *searchEngine);
- void activateSearchWidget(bool updateLastTabPage = false);
- void removeSearchWidget();
-
- int availableHelpViewer() const;
- bool enableTabCloseAction() const;
+ void addPage(HelpViewer *page, bool fromSearch = false);
+ void removePage(int index);
- void closeOrReloadTabs(const QList<int> &indices, bool tryReload);
- void closeTabAt(int index);
- QMap<int, QString> currentSourceFileList() const;
-
- static CentralWidget *instance();
+ int currentIndex() const;
+ void setCurrentPage(HelpViewer *page);
public slots:
+ void copy();
+ void home();
+
void zoomIn();
void zoomOut();
- void nextPage();
void resetZoom();
+
+ void forward();
+ void nextPage();
+
+ void backward();
void previousPage();
- void copySelection();
- void showTextSearch();
+
void print();
void pageSetup();
void printPreview();
- void updateBrowserFont();
- void setSource(const QUrl &url);
- void setSourceInNewTab(const QUrl &url, qreal zoom = 0.0);
- HelpViewer *newEmptyTab();
- void home();
- void forward();
- void backward();
- void activateTab(bool onlyHelpViewer = false);
+ void setSource(const QUrl &url);
+ void setSourceFromSearch(const QUrl &url);
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();
@@ -124,37 +117,24 @@ signals:
protected:
void keyPressEvent(QKeyEvent *);
+ void focusInEvent(QFocusEvent *event);
private slots:
- void newTab();
- void closeTab();
- void setTabTitle(const QUrl& url);
- void currentPageChanged(int index);
- void showTabBarContextMenu(const QPoint &point);
- void printPreview(QPrinter *printer);
- void setSourceFromSearch(const QUrl &url);
- void setSourceFromSearchInNewTab(const QUrl &url);
void highlightSearchTerms();
+ void printPreview(QPrinter *printer);
+ void handleSourceChanged(const QUrl &url);
private:
- void connectSignals();
- bool eventFilter(QObject *object, QEvent *e);
- bool findInWebPage(const QString &ttf, bool forward);
- bool findInTextBrowser(const QString &ttf, bool forward);
void initPrinter();
- QString quoteTabTitle(const QString &title) const;
- void setLastShownPages();
+ void connectSignals(HelpViewer *page);
+ bool eventFilter(QObject *object, QEvent *e);
private:
- int lastTabPage;
- QList<QAction*> globalActionList;
-
- QTabWidget *tabWidget;
- FindWidget *findWidget;
- QPrinter *printer;
- bool usesDefaultCollection;
-
- SearchWidget *m_searchWidget;
+#ifndef QT_NO_PRINTER
+ QPrinter *m_printer;
+#endif
+ FindWidget *m_findWidget;
+ QStackedWidget *m_stackedWidget;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp
index 8afa1df..d966cf0 100644
--- a/tools/assistant/tools/assistant/contentwindow.cpp
+++ b/tools/assistant/tools/assistant/contentwindow.cpp
@@ -38,12 +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>
@@ -146,8 +148,8 @@ 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()))
- CentralWidget::instance()->setSourceInNewTab(itm->url());
+ if (itm && HelpViewer::canOpenPage(itm->url().path()))
+ OpenPagesManager::instance()->createPage(itm->url());
}
} else if (button == Qt::LeftButton) {
itemClicked(index);
@@ -172,7 +174,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));
@@ -181,7 +183,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
if (curTab == action)
emit linkActivated(itm->url());
else if (newTab == action)
- CentralWidget::instance()->setSourceInNewTab(itm->url());
+ OpenPagesManager::instance()->createPage(itm->url());
}
void ContentWindow::itemClicked(const QModelIndex &index)
diff --git a/tools/assistant/tools/assistant/doc/assistant.qdocconf b/tools/assistant/tools/assistant/doc/assistant.qdocconf
index 3b4b5f8..491f159 100644
--- a/tools/assistant/tools/assistant/doc/assistant.qdocconf
+++ b/tools/assistant/tools/assistant/doc/assistant.qdocconf
@@ -12,5 +12,5 @@ HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \
"<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \
"<td width=\"30%\" align=\"left\">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \
"<td width=\"40%\" align=\"center\">Trademarks</td>\n" \
- "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.7.0</div></td>\n" \
+ "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.8.0</div></td>\n" \
"</tr></table></div></address>"
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
new file mode 100644
index 0000000..a9cc392
--- /dev/null
+++ b/tools/assistant/tools/assistant/globalactions.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** 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 Assistant module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "globalactions.h"
+
+#include "centralwidget.h"
+#include "tracer.h"
+
+#include <QtGui/QAction>
+
+GlobalActions *GlobalActions::instance(QObject *parent)
+{
+ Q_ASSERT(!m_instance != !parent);
+ if (!m_instance)
+ m_instance = new GlobalActions(parent);
+ return m_instance;
+}
+
+GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
+{
+ TRACE_OBJ
+
+ // TODO: Put resource path in misc class
+ QString resourcePath = QLatin1String(":/trolltech/assistant/images/");
+#ifdef Q_OS_MAC
+ resourcePath.append(QLatin1String("mac"));
+#else
+ resourcePath.append(QLatin1String("win"));
+#endif
+ CentralWidget *centralWidget = CentralWidget::instance();
+
+ m_backAction = new QAction(tr("&Back"), parent);
+ m_backAction->setEnabled(false);
+ m_backAction->setShortcuts(QKeySequence::Back);
+ m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png")));
+ connect(m_backAction, SIGNAL(triggered()), centralWidget, SLOT(backward()));
+ m_actionList << m_backAction;
+
+ m_nextAction = new QAction(tr("&Forward"), parent);
+ m_nextAction->setPriority(QAction::LowPriority);
+ m_nextAction->setEnabled(false);
+ m_nextAction->setShortcuts(QKeySequence::Forward);
+ m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png")));
+ connect(m_nextAction, SIGNAL(triggered()), centralWidget, SLOT(forward()));
+ m_actionList << m_nextAction;
+
+ m_homeAction = new QAction(tr("&Home"), parent);
+ m_homeAction->setShortcut(tr("ALT+Home"));
+ m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png")));
+ connect(m_homeAction, SIGNAL(triggered()), centralWidget, SLOT(home()));
+ m_actionList << m_homeAction;
+
+ QAction *separator = new QAction(parent);
+ separator->setSeparator(true);
+ m_actionList << separator;
+
+ m_zoomInAction = new QAction(tr("Zoom &in"), parent);
+ m_zoomInAction->setPriority(QAction::LowPriority);
+ m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png")));
+ m_zoomInAction->setShortcut(QKeySequence::ZoomIn);
+ connect(m_zoomInAction, SIGNAL(triggered()), centralWidget, SLOT(zoomIn()));
+ m_actionList << m_zoomInAction;
+
+ m_zoomOutAction = new QAction(tr("Zoom &out"), parent);
+ m_zoomOutAction->setPriority(QAction::LowPriority);
+ m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png")));
+ m_zoomOutAction->setShortcut(QKeySequence::ZoomOut);
+ connect(m_zoomOutAction, SIGNAL(triggered()), centralWidget, SLOT(zoomOut()));
+ m_actionList << m_zoomOutAction;
+
+ separator = new QAction(parent);
+ separator->setSeparator(true);
+ m_actionList << separator;
+
+ m_copyAction = new QAction(tr("&Copy selected Text"), parent);
+ m_copyAction->setPriority(QAction::LowPriority);
+ m_copyAction->setIconText("&Copy");
+ m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png")));
+ m_copyAction->setShortcuts(QKeySequence::Copy);
+ m_copyAction->setEnabled(false);
+ connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copy()));
+ m_actionList << m_copyAction;
+
+ m_printAction = new QAction(tr("&Print..."), parent);
+ m_printAction->setPriority(QAction::LowPriority);
+ m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png")));
+ m_printAction->setShortcut(QKeySequence::Print);
+ connect(m_printAction, SIGNAL(triggered()), centralWidget, SLOT(print()));
+ m_actionList << m_printAction;
+
+ m_findAction = new QAction(tr("&Find in Text..."), parent);
+ m_findAction->setIconText(tr("&Find"));
+ m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png")));
+ m_findAction->setShortcuts(QKeySequence::Find);
+ connect(m_findAction, SIGNAL(triggered()), centralWidget, SLOT(showTextSearch()));
+ m_actionList << m_findAction;
+
+#ifdef Q_WS_X11
+ m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon()));
+ m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon()));
+ m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon()));
+ m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon()));
+ m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon()));
+ m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon()));
+ m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon()));
+ m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon()));
+#endif
+}
+
+void GlobalActions::updateActions()
+{
+ TRACE_OBJ
+ CentralWidget *centralWidget = CentralWidget::instance();
+ m_copyAction->setEnabled(centralWidget->hasSelection());
+ m_nextAction->setEnabled(centralWidget->isForwardAvailable());
+ m_backAction->setEnabled(centralWidget->isBackwardAvailable());
+}
+
+void GlobalActions::setCopyAvailable(bool available)
+{
+ TRACE_OBJ
+ m_copyAction->setEnabled(available);
+}
+
+GlobalActions *GlobalActions::m_instance = 0;
diff --git a/tools/assistant/tools/assistant/globalactions.h b/tools/assistant/tools/assistant/globalactions.h
new file mode 100644
index 0000000..e53e08f
--- /dev/null
+++ b/tools/assistant/tools/assistant/globalactions.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** 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 Assistant module 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 GLOBALACTION_H
+#define GLOBALACTION_H
+
+#include <QtCore/QList>
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QAction;
+
+class GlobalActions : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(GlobalActions)
+public:
+ static GlobalActions *instance(QObject *parent = 0);
+
+ QList<QAction *> actionList() const { return m_actionList; }
+ QAction *backAction() const { return m_backAction; }
+ QAction *nextAction() const { return m_nextAction; }
+ QAction *homeAction() const { return m_homeAction; }
+ QAction *zoomInAction() const { return m_zoomInAction; }
+ QAction *zoomOutAction() const { return m_zoomOutAction; }
+ QAction *copyAction() const { return m_copyAction; }
+ QAction *printAction() const { return m_printAction; }
+ QAction *findAction() const { return m_findAction; }
+
+ Q_SLOT void updateActions();
+ Q_SLOT void setCopyAvailable(bool available);
+
+private:
+ GlobalActions(QObject *parent);
+
+ static GlobalActions *m_instance;
+
+ QAction *m_backAction;
+ QAction *m_nextAction;
+ QAction *m_homeAction;
+ QAction *m_zoomInAction;
+ QAction *m_zoomOutAction;
+ QAction *m_copyAction;
+ QAction *m_printAction;
+ QAction *m_findAction;
+
+ QList<QAction *> m_actionList;
+};
+
+QT_END_NAMESPACE
+
+#endif // GLOBALACTION_H
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index 9748702..60b83f7 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -569,18 +569,6 @@ void HelpEngineWrapper::setLastTabPage(int lastPage)
CollectionConfiguration::setLastTabPage(*d->m_helpEngine, lastPage);
}
-bool HelpEngineWrapper::searchWasAttached() const
-{
- TRACE_OBJ
- return d->m_helpEngine->customValue(SearchWasAttachedKey).toBool();
-}
-
-void HelpEngineWrapper::setSearchWasAttached(bool attached)
-{
- TRACE_OBJ
- d->m_helpEngine->setCustomValue(SearchWasAttachedKey, attached);
-}
-
int HelpEngineWrapper::startOption() const
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
index c1041b6..f1a381a 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.h
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -170,9 +170,6 @@ public:
int startOption() const;
void setStartOption(int option);
- bool searchWasAttached() const;
- void setSearchWasAttached(bool attached);
-
bool hasFontSettings() const;
bool usesAppFont() const;
void setUseAppFont(bool useAppFont);
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index 6499139..81870a9 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -38,7 +38,10 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include "helpviewer.h"
+#include "helpviewer_p.h"
+
#include "helpenginewrapper.h"
#include "tracer.h"
@@ -48,19 +51,23 @@
#include <QtCore/QTemporaryFile>
#include <QtCore/QUrl>
+#include <QtGui/QComboBox>
#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 +109,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 +121,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 +143,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 +174,64 @@ 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;
+}
+
+bool HelpViewer::openPagesListRequested(const QMouseEvent *event) const
+{
+ return event->buttons() == Qt::RightButton
+ && event->modifiers() == Qt::ControlModifier;
+}
+
+bool HelpViewer::openPagesListRequested(const QContextMenuEvent *event) const
+{
+ return event->reason() == QContextMenuEvent::Mouse
+ && event->modifiers() == Qt::ControlModifier;
+}
+
+void HelpViewer::showOpenPagesList(const QPoint &pos)
+{
+ QComboBox * const openPagesBox = d->openPagesBox(this);
+ openPagesBox->move(pos);
+ openPagesBox->setCurrentIndex(CentralWidget::instance()->currentIndex());
+ openPagesBox->showPopup();
+}
+
+HelpViewer::~HelpViewer()
+{
+ TRACE_OBJ
+ delete d;
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index def9418..1f897d9 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,48 @@ 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);
+ void printRequested();
+#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);
+ bool openPagesListRequested(const QMouseEvent *event) const;
+ bool openPagesListRequested(const QContextMenuEvent *event) const;
+ void showOpenPagesList(const QPoint &pos);
+
+private:
+ HelpViewerPrivate *d;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer_p.h b/tools/assistant/tools/assistant/helpviewer_p.h
new file mode 100644
index 0000000..2bd4e16
--- /dev/null
+++ b/tools/assistant/tools/assistant/helpviewer_p.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** 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 HELPVIEWERPRIVATE_H
+#define HELPVIEWERPRIVATE_H
+
+#include "centralwidget.h"
+#include "helpviewer.h"
+#include "openpagesmanager.h"
+
+#include <QtCore/QObject>
+#include <QtGui/QComboBox>
+#ifdef QT_NO_WEBKIT
+#include <QtGui/QTextBrowser>
+#endif
+#include <QtGui/QTreeView>
+
+QT_BEGIN_NAMESPACE
+
+class HelpViewer::HelpViewerPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+#ifdef QT_NO_WEBKIT
+ HelpViewerPrivate(int zoom)
+ : zoomCount(zoom)
+ , forceFont(false)
+ , lastAnchor(QString())
+#else
+ HelpViewerPrivate()
+#endif
+ {
+ m_openPagesBox = 0;
+ }
+
+#ifdef QT_NO_WEBKIT
+ 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();
+ }
+#endif // QT_NO_WEBKIT
+
+ QComboBox *openPagesBox(QWidget *parent = 0)
+ {
+ if (!m_openPagesBox) {
+ m_openPagesBox = new QComboBox(parent);
+ m_openPagesBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
+ m_openPagesBox->setModel(OpenPagesManager::instance()
+ ->openPagesWidget()->model());
+ connect(m_openPagesBox, SIGNAL(activated(int)), this,
+ SLOT(switchToPage(int)));
+ }
+
+ return m_openPagesBox;
+ }
+
+public slots:
+
+#ifdef QT_NO_WEBKIT
+ void openLink()
+ {
+ openLink(false);
+ }
+
+ void openLinkInNewPage()
+ {
+ openLink(true);
+ }
+
+public:
+ int zoomCount;
+ bool forceFont;
+ QString lastAnchor;
+#endif // QT_NO_WEBKIT
+
+private slots:
+
+ void switchToPage(int row)
+ {
+ OpenPagesManager::instance()->setCurrentPage(row);
+ }
+
+private:
+ QComboBox *m_openPagesBox;
+};
+
+QT_END_NAMESPACE
+
+#endif // HELPVIEWERPRIVATE_H
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
index 7f82b56..98eb59f 100644
--- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
@@ -38,10 +38,13 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "helpviewer_qtb.h"
-#include "centralwidget.h"
+#include "helpviewer.h"
+
+#include "globalactions.h"
#include "helpenginewrapper.h"
+#include "helpviewer_p.h"
+#include "openpagesmanager.h"
#include "tracer.h"
#include <QtCore/QStringBuilder>
@@ -53,34 +56,34 @@
QT_BEGIN_NAMESPACE
-HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom)
+HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
: QTextBrowser(parent)
- , zoomCount(zoom)
- , controlPressed(false)
- , lastAnchor(QString())
- , parentWidget(parent)
- , helpEngine(HelpEngineWrapper::instance())
- , forceFont(false)
+ , 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);
-}
-HelpViewer::~HelpViewer()
-{
- TRACE_OBJ
+ connect(this, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(titleChanged()));
+ connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
}
QFont HelpViewer::viewerFont() const
{
TRACE_OBJ
if (HelpEngineWrapper::instance().usesBrowserFont())
- return helpEngine.browserFont();
+ return HelpEngineWrapper::instance().browserFont();
return qApp->font();
}
@@ -88,185 +91,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;
-
- parentWidget->setSourceInNewTab(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(parentWidget->globalActions());
- 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
@@ -279,11 +279,6 @@ void HelpViewer::keyPressEvent(QKeyEvent *e)
QTextBrowser::keyPressEvent(e);
}
-void HelpViewer::home()
-{
- TRACE_OBJ
- setSource(helpEngine.homePage());
-}
void HelpViewer::wheelEvent(QWheelEvent *e)
{
@@ -296,12 +291,100 @@ void HelpViewer::wheelEvent(QWheelEvent *e)
}
}
+void HelpViewer::mousePressEvent(QMouseEvent *e)
+{
+ TRACE_OBJ
+#ifdef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(e))
+ return;
+#endif
+ if (openPagesListRequested(e)) {
+ showOpenPagesList(e->pos());
+ return;
+ }
+
+ 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
+
+ if (openPagesListRequested(event))
+ return;
+
+ QMenu menu(QString(), 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 244d091..869789b 100644
--- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
@@ -39,25 +39,31 @@
**
****************************************************************************/
-#include "helpviewer_qwv.h"
+#include "helpviewer.h"
+#include "helpviewer_p.h"
#include "centralwidget.h"
#include "helpenginewrapper.h"
+#include "openpagesmanager.h"
#include "tracer.h"
#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:
@@ -109,6 +115,8 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
return len;
}
+// -- HelpNetworkAccessManager
+
class HelpNetworkAccessManager : public QNetworkAccessManager
{
public:
@@ -130,15 +138,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());
@@ -147,18 +154,20 @@ 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:
- HelpPage(CentralWidget *central, QObject *parent);
+ HelpPage(QObject *parent);
protected:
virtual QWebPage *createWindow(QWebPage::WebWindowType);
@@ -168,7 +177,6 @@ protected:
const QNetworkRequest &request, NavigationType type);
private:
- CentralWidget *centralWidget;
bool closeNewTabIfNeeded;
friend class HelpViewer;
@@ -176,9 +184,8 @@ private:
Qt::KeyboardModifiers m_keyboardModifiers;
};
-HelpPage::HelpPage(CentralWidget *central, QObject *parent)
+HelpPage::HelpPage(QObject *parent)
: QWebPage(parent)
- , centralWidget(central)
, closeNewTabIfNeeded(false)
, m_pressedButtons(Qt::NoButton)
, m_keyboardModifiers(Qt::NoModifier)
@@ -189,9 +196,9 @@ HelpPage::HelpPage(CentralWidget *central, QObject *parent)
QWebPage *HelpPage::createWindow(QWebPage::WebWindowType)
{
TRACE_OBJ
- HelpPage* newPage = static_cast<HelpPage*>(centralWidget->newEmptyTab()->page());
- if (newPage)
- newPage->closeNewTabIfNeeded = closeNewTabIfNeeded;
+ HelpPage* newPage = static_cast<HelpPage*>(OpenPagesManager::instance()
+ ->createPage()->page());
+ newPage->closeNewTabIfNeeded = closeNewTabIfNeeded;
closeNewTabIfNeeded = false;
return newPage;
}
@@ -216,19 +223,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
closeNewTabIfNeeded = false;
const QUrl &url = request.url();
- if (AbstractHelpViewer::launchWithExternalApp(url)) {
+ if (HelpViewer::launchWithExternalApp(url)) {
if (closeNewTab)
- QMetaObject::invokeMethod(centralWidget, "closeTab");
+ QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentPage");
return false;
}
if (type == QWebPage::NavigationTypeLinkClicked
- && (m_keyboardModifiers & Qt::ControlModifier
- || m_pressedButtons == Qt::MidButton)) {
- if (centralWidget->newEmptyTab())
- centralWidget->setSource(url);
+ && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)) {
m_pressedButtons = Qt::NoButton;
m_keyboardModifiers = Qt::NoModifier;
+ OpenPagesManager::instance()->createPage(url);
return false;
}
@@ -237,23 +242,19 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
// -- HelpViewer
-HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom)
- : QWebView(parent)
- , parentWidget(parent)
- , loadFinished(false)
- , helpEngine(HelpEngineWrapper::instance())
+HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
+ : QWebView(parent), d(new HelpViewerPrivate)
{
TRACE_OBJ
setAcceptDrops(false);
+ settings()->setAttribute(QWebSettings::JavaEnabled, false);
+ settings()->setAttribute(QWebSettings::PluginsEnabled, false);
- setPage(new HelpPage(parent, this));
-
+ setPage(new HelpPage(this));
page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
- action->setText(tr("Open Link in New Tab"));
- if (!parent)
- action->setVisible(false);
+ action->setText(tr("Open Link in New Page"));
pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
@@ -265,26 +266,22 @@ HelpViewer::HelpViewer(CentralWidget *parent, 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)));
+ connect(this, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged()));
connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SIGNAL(printRequested()));
setFont(viewerFont());
setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
}
-HelpViewer::~HelpViewer()
-{
- TRACE_OBJ
-}
-
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),
@@ -317,57 +314,150 @@ 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();
+}
- return false;
+void HelpViewer::setTitle(const QString &title)
+{
+ TRACE_OBJ
+ Q_UNUSED(title)
+}
+
+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
- setSource(helpEngine.homePage());
+ return pageAction(QWebPage::Forward)->isEnabled();
}
-void HelpViewer::wheelEvent(QWheelEvent *e)
+bool HelpViewer::isBackwardAvailable() const
{
TRACE_OBJ
- if (e->modifiers()& Qt::ControlModifier) {
- e->accept();
- e->delta() > 0 ? scaleUp() : scaleDown();
+ 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
+ // 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 *event)
+{
+ TRACE_OBJ
+ if (event->modifiers()& Qt::ControlModifier) {
+ event->accept();
+ event->delta() > 0 ? scaleUp() : scaleDown();
} else {
- QWebView::wheelEvent(e);
+ QWebView::wheelEvent(event);
+ }
+}
+
+void HelpViewer::mousePressEvent(QMouseEvent *event)
+{
+ TRACE_OBJ
+#ifdef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(event))
+ return;
+#endif
+
+ if (openPagesListRequested(event)) {
+ showOpenPagesList(event->pos());
+ return;
+ }
+
+ if (HelpPage *currentPage = static_cast<HelpPage*> (page())) {
+ currentPage->m_pressedButtons = event->buttons();
+ currentPage->m_keyboardModifiers = event->modifiers();
}
+
+ QWebView::mousePressEvent(event);
}
-void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
+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
@@ -380,27 +470,19 @@ 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());
+ if (!openPagesListRequested(event))
+ 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 2577828..0000000
--- a/tools/assistant/tools/assistant/helpviewer_qwv.h
+++ /dev/null
@@ -1,122 +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 CentralWidget;
-class HelpEngineWrapper;
-class QMouseEvent;
-
-class HelpViewer : public QWebView, public AbstractHelpViewer
-{
- Q_OBJECT
-
-public:
- HelpViewer(CentralWidget *parent, 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 printRequested();
-
-protected:
- virtual void wheelEvent(QWheelEvent *);
- void mouseReleaseEvent(QMouseEvent *e);
- void mousePressEvent(QMouseEvent *event);
-
-private Q_SLOTS:
- void actionChanged();
- void setLoadFinished(bool ok);
-
-private:
- CentralWidget* parentWidget;
- bool loadFinished;
- HelpEngineWrapper &helpEngine;
-};
-
-QT_END_NAMESPACE
-
-#endif // HELPVIEWERQWV_H
diff --git a/tools/assistant/tools/assistant/images/closebutton.png b/tools/assistant/tools/assistant/images/closebutton.png
new file mode 100644
index 0000000..c978cf5
--- /dev/null
+++ b/tools/assistant/tools/assistant/images/closebutton.png
Binary files differ
diff --git a/tools/assistant/tools/assistant/images/darkclosebutton.png b/tools/assistant/tools/assistant/images/darkclosebutton.png
new file mode 100644
index 0000000..1077663
--- /dev/null
+++ b/tools/assistant/tools/assistant/images/darkclosebutton.png
Binary files differ
diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp
index 63ddbe4..00f61f2 100644
--- a/tools/assistant/tools/assistant/indexwindow.cpp
+++ b/tools/assistant/tools/assistant/indexwindow.cpp
@@ -38,13 +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>
@@ -219,10 +221,10 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
return;
}
- if (!AbstractHelpViewer::canOpenPage(url.path()))
+ if (!HelpViewer::canOpenPage(url.path()))
CentralWidget::instance()->setSource(url);
else
- CentralWidget::instance()->setSourceInNewTab(url);
+ OpenPagesManager::instance()->createPage(url);
}
}
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 913e342..ca10d38 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -38,57 +38,57 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
#include "mainwindow.h"
+#include "aboutdialog.h"
#include "bookmarkmanager.h"
#include "centralwidget.h"
-#include "indexwindow.h"
-#include "topicchooser.h"
+#include "cmdlineparser.h"
#include "contentwindow.h"
-#include "preferencesdialog.h"
+#include "globalactions.h"
#include "helpenginewrapper.h"
+#include "indexwindow.h"
+#include "openpagesmanager.h"
+#include "preferencesdialog.h"
+#include "qtdocinstaller.h"
#include "remotecontrol.h"
-#include "cmdlineparser.h"
-#include "aboutdialog.h"
#include "searchwidget.h"
-#include "qtdocinstaller.h"
-
-// #define TRACING_REQUESTED
+#include "topicchooser.h"
+#include "tracer.h"
-#include <QtCore/QDir>
-#include <QtCore/QTimer>
+#include <QtCore/QByteArray>
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
-#include <QtCore/QFileSystemWatcher>
+#include <QtCore/QDir>
#include <QtCore/QPair>
#include <QtCore/QResource>
-#include <QtCore/QByteArray>
#include <QtCore/QTextStream>
-#include <QtCore/QCoreApplication>
+#include <QtCore/QTimer>
-#include <QtGui/QMenuBar>
#include <QtGui/QAction>
-#include <QtGui/QToolBar>
-#include <QtGui/QStatusBar>
+#include <QtGui/QComboBox>
+#include <QtGui/QDesktopServices>
+#include <QtGui/QDesktopWidget>
+#include <QtGui/QDockWidget>
+#include <QtGui/QFontDatabase>
+#include <QtGui/QFileDialog>
#include <QtGui/QLabel>
-#include <QtGui/QLineEdit>
#include <QtGui/QLayout>
-#include <QtGui/QDockWidget>
-#include <QtGui/QTreeView>
+#include <QtGui/QLineEdit>
+#include <QtGui/QMenuBar>
#include <QtGui/QMessageBox>
-#include <QtGui/QFontDatabase>
-#include <QtGui/QComboBox>
#include <QtGui/QProgressBar>
-#include <QtGui/QDesktopServices>
+#include <QtGui/QStatusBar>
+#include <QtGui/QToolBar>
#include <QtGui/QToolButton>
-#include <QtGui/QFileDialog>
-#include <QtHelp/QHelpEngineCore>
-#include <QtHelp/QHelpSearchEngine>
#include <QtHelp/QHelpContentModel>
+#include <QtHelp/QHelpEngineCore>
#include <QtHelp/QHelpIndexModel>
+#include <QtHelp/QHelpSearchEngine>
+
+#include <cstdlib>
QT_BEGIN_NAMESPACE
@@ -105,6 +105,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
TRACE_OBJ
setToolButtonStyle(Qt::ToolButtonFollowStyle);
+ setDockOptions(ForceTabbedDocks); // Has no effect; Qt bug?
QString collectionFile;
if (usesDefaultCollection()) {
@@ -131,29 +132,42 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
contentDock->setWidget(m_contentWindow);
addDockWidget(Qt::LeftDockWidgetArea, contentDock);
- QDockWidget *bookmarkDock = 0;
- if (BookmarkManager *manager = BookmarkManager::instance()) {
- bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
- bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
- bookmarkDock->setWidget(m_bookmarkWidget = manager->bookmarkDockWidget());
- addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);
-
- connect(manager, SIGNAL(escapePressed()), this,
+ m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine());
+ m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font()
+ : helpEngineWrapper.browserFont());
+ QDockWidget *searchDock = new QDockWidget(tr("Search"), this);
+ searchDock->setObjectName(QLatin1String("SearchWindow"));
+ searchDock->setWidget(m_searchWindow);
+ addDockWidget(Qt::LeftDockWidgetArea, searchDock);
+
+ BookmarkManager *bookMarkManager = BookmarkManager::instance();
+ QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
+ bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
+ bookmarkDock->setWidget(m_bookmarkWidget
+ = bookMarkManager->bookmarkDockWidget());
+ addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);
+
+ QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this);
+ openPagesDock->setObjectName(QLatin1String("Open Pages"));
+ OpenPagesManager *openPagesManager
+ = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url());
+ openPagesDock->setWidget(openPagesManager->openPagesWidget());
+ addDockWidget(Qt::LeftDockWidgetArea, openPagesDock);
+
+#if 0
+ connect(bookMarkManager, SIGNAL(escapePressed()), this,
SLOT(activateCurrentCentralWidgetTab()));
- connect(manager, SIGNAL(setSource(QUrl)), m_centralWidget,
+ connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
- connect(manager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget,
- SLOT(setSourceInNewTab(QUrl)));
- connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), manager,
- SLOT(addBookmark(QString, QString)));
- }
+ connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)),
+ openPagesManager, SLOT(createPage(QUrl)));
+ connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
+ bookMarkManager, SLOT(addBookmark(QString, QString)));
QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine();
connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted()));
connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));
-
- m_centralWidget->createSearchWidget(searchEngine);
- m_centralWidget->activateSearchWidget();
+#endif
QString defWindowTitle = tr("Qt Assistant");
setWindowTitle(defWindowTitle);
@@ -161,102 +175,113 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
setupActions();
statusBar()->show();
- if (initHelpDB()) {
- setupFilterToolbar();
- setupAddressToolbar();
-
- const QString windowTitle = helpEngineWrapper.windowTitle();
- setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle);
- QByteArray iconArray = helpEngineWrapper.applicationIcon();
- if (iconArray.size() > 0) {
- QPixmap pix;
- pix.loadFromData(iconArray);
- QIcon appIcon(pix);
- qApp->setWindowIcon(appIcon);
- } else {
- QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png"));
- qApp->setWindowIcon(appIcon);
- }
+ if (!initHelpDB()) {
+ qDebug("Fatal error: Help engine initialization failed. "
+ "Error message was: %s\nAssistant will now exit.",
+ qPrintable(HelpEngineWrapper::instance().error()));
+ std::exit(1);
+ }
- // Show the widget here, otherwise the restore geometry and state won't work
- // on x11.
- show();
- QByteArray ba(helpEngineWrapper.mainWindow());
- if (!ba.isEmpty())
- restoreState(ba);
-
- ba = helpEngineWrapper.mainWindowGeometry();
- if (!ba.isEmpty()) {
- restoreGeometry(ba);
- } else {
- tabifyDockWidget(contentDock, indexDock);
- if (bookmarkDock)
- tabifyDockWidget(indexDock, bookmarkDock);
- contentDock->raise();
- resize(QSize(800, 600));
- }
+ setupFilterToolbar();
+ setupAddressToolbar();
- if (!helpEngineWrapper.hasFontSettings()) {
- helpEngineWrapper.setUseAppFont(false);
- helpEngineWrapper.setUseBrowserFont(false);
- helpEngineWrapper.setAppFont(qApp->font());
- helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin);
- helpEngineWrapper.setBrowserFont(qApp->font());
- helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin);
- } else {
- updateApplicationFont();
- }
+ const QString windowTitle = helpEngineWrapper.windowTitle();
+ setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle);
+ QByteArray iconArray = helpEngineWrapper.applicationIcon();
+ if (iconArray.size() > 0) {
+ QPixmap pix;
+ pix.loadFromData(iconArray);
+ QIcon appIcon(pix);
+ qApp->setWindowIcon(appIcon);
+ } else {
+ QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png"));
+ qApp->setWindowIcon(appIcon);
+ }
- updateAboutMenuText();
-
- QTimer::singleShot(0, this, SLOT(insertLastPages()));
- if (m_cmdLine->enableRemoteControl())
- (void)new RemoteControl(this);
-
- if (m_cmdLine->contents() == CmdLineParser::Show)
- showContents();
- else if (m_cmdLine->contents() == CmdLineParser::Hide)
- hideContents();
-
- if (m_cmdLine->index() == CmdLineParser::Show)
- showIndex();
- else if (m_cmdLine->index() == CmdLineParser::Hide)
- hideIndex();
-
- if (m_cmdLine->bookmarks() == CmdLineParser::Show)
- showBookmarksDockWidget();
- else if (m_cmdLine->bookmarks() == CmdLineParser::Hide)
- hideBookmarksDockWidget();
-
- if (m_cmdLine->search() == CmdLineParser::Show)
- showSearch();
- else if (m_cmdLine->search() == CmdLineParser::Hide)
- hideSearch();
-
- if (m_cmdLine->contents() == CmdLineParser::Activate)
- showContents();
- else if (m_cmdLine->index() == CmdLineParser::Activate)
- showIndex();
- else if (m_cmdLine->bookmarks() == CmdLineParser::Activate)
- showBookmarksDockWidget();
-
- if (!m_cmdLine->currentFilter().isEmpty()) {
- const QString &curFilter = m_cmdLine->currentFilter();
- if (helpEngineWrapper.customFilters().contains(curFilter))
- helpEngineWrapper.setCurrentFilter(curFilter);
- }
+ // Show the widget here, otherwise the restore geometry and state won't work
+ // on x11.
+ show();
+ QByteArray ba(helpEngineWrapper.mainWindow());
+ if (!ba.isEmpty())
+ restoreState(ba);
- if (usesDefaultCollection())
- QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation()));
- else
- checkInitState();
+ ba = helpEngineWrapper.mainWindowGeometry();
+ if (!ba.isEmpty()) {
+ restoreGeometry(ba);
+ } else {
+ tabifyDockWidget(contentDock, indexDock);
+ tabifyDockWidget(indexDock, bookmarkDock);
+ tabifyDockWidget(bookmarkDock, openPagesDock);
+ tabifyDockWidget(openPagesDock, searchDock);
+ contentDock->raise();
+ const QRect screen = QApplication::desktop()->screenGeometry();
+ resize(4*screen.width()/5, 4*screen.height()/5);
+ }
+
+ if (!helpEngineWrapper.hasFontSettings()) {
+ helpEngineWrapper.setUseAppFont(false);
+ helpEngineWrapper.setUseBrowserFont(false);
+ helpEngineWrapper.setAppFont(qApp->font());
+ helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin);
+ helpEngineWrapper.setBrowserFont(qApp->font());
+ helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin);
+ } else {
+ updateApplicationFont();
+ }
+
+ updateAboutMenuText();
+
+ QTimer::singleShot(0, this, SLOT(insertLastPages()));
+ if (m_cmdLine->enableRemoteControl())
+ (void)new RemoteControl(this);
+
+ if (m_cmdLine->contents() == CmdLineParser::Show)
+ showContents();
+ else if (m_cmdLine->contents() == CmdLineParser::Hide)
+ hideContents();
+
+ if (m_cmdLine->index() == CmdLineParser::Show)
+ showIndex();
+ else if (m_cmdLine->index() == CmdLineParser::Hide)
+ hideIndex();
+
+ if (m_cmdLine->bookmarks() == CmdLineParser::Show)
+ showBookmarksDockWidget();
+ else if (m_cmdLine->bookmarks() == CmdLineParser::Hide)
+ hideBookmarksDockWidget();
- connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)),
- this, SLOT(documentationRemoved(QString)));
- connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)),
- this, SLOT(documentationUpdated(QString)));
+ if (m_cmdLine->search() == CmdLineParser::Show)
+ showSearch();
+ else if (m_cmdLine->search() == CmdLineParser::Hide)
+ hideSearch();
+
+ if (m_cmdLine->contents() == CmdLineParser::Activate)
+ showContents();
+ else if (m_cmdLine->index() == CmdLineParser::Activate)
+ showIndex();
+ else if (m_cmdLine->bookmarks() == CmdLineParser::Activate)
+ showBookmarksDockWidget();
+
+ if (!m_cmdLine->currentFilter().isEmpty()) {
+ const QString &curFilter = m_cmdLine->currentFilter();
+ if (helpEngineWrapper.customFilters().contains(curFilter))
+ helpEngineWrapper.setCurrentFilter(curFilter);
}
+
+ if (usesDefaultCollection())
+ QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation()));
+ else
+ checkInitState();
+
+ connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)),
+ this, SLOT(documentationRemoved(QString)));
+ connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)),
+ this, SLOT(documentationUpdated(QString)));
+
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
+ GlobalActions::instance()->updateActions();
+ if (helpEngineWrapper.addressBarEnabled())
+ showNewAddress();
}
MainWindow::~MainWindow()
@@ -387,11 +412,6 @@ void MainWindow::checkInitState()
void MainWindow::insertLastPages()
{
TRACE_OBJ
- if (m_cmdLine->url().isValid())
- m_centralWidget->setSource(m_cmdLine->url());
- else
- m_centralWidget->setupWidget();
-
if (m_cmdLine->search() == CmdLineParser::Activate)
showSearch();
}
@@ -409,8 +429,13 @@ void MainWindow::setupActions()
QMenu *menu = menuBar()->addMenu(tr("&File"));
- m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab()));
+ OpenPagesManager * const openPages = OpenPagesManager::instance();
+ m_newTabAction
+ = menu->addAction(tr("New &Tab"), openPages, SLOT(createPage()));
m_newTabAction->setShortcut(QKeySequence::AddTab);
+ m_closeTabAction = menu->addAction(tr("&Close Tab"),
+ openPages, SLOT(closeCurrentPage()));
+ m_closeTabAction->setShortcuts(QKeySequence::Close);
menu->addSeparator();
@@ -419,17 +444,10 @@ void MainWindow::setupActions()
m_printPreviewAction = menu->addAction(tr("Print Preview..."), m_centralWidget,
SLOT(printPreview()));
- m_printAction = menu->addAction(tr("&Print..."), m_centralWidget, SLOT(print()));
- m_printAction->setPriority(QAction::LowPriority);
- m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png")));
- m_printAction->setShortcut(QKeySequence::Print);
-
+ GlobalActions *globalActions = GlobalActions::instance(this);
+ menu->addAction(globalActions->printAction());
menu->addSeparator();
- m_closeTabAction = menu->addAction(tr("&Close Tab"), m_centralWidget,
- SLOT(closeTab()));
- m_closeTabAction->setShortcuts(QKeySequence::Close);
-
QAction *tmp = menu->addAction(QIcon::fromTheme("application-exit"),
tr("&Quit"), this, SLOT(close()));
tmp->setMenuRole(QAction::QuitRole);
@@ -440,19 +458,8 @@ void MainWindow::setupActions()
#endif
menu = menuBar()->addMenu(tr("&Edit"));
- m_copyAction = menu->addAction(tr("&Copy selected Text"), m_centralWidget,
- SLOT(copySelection()));
- m_copyAction->setPriority(QAction::LowPriority);
- m_copyAction->setIconText("&Copy");
- m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png")));
- m_copyAction->setShortcuts(QKeySequence::Copy);
- m_copyAction->setEnabled(false);
-
- m_findAction = menu->addAction(tr("&Find in Text..."), m_centralWidget,
- SLOT(showTextSearch()));
- m_findAction->setIconText(tr("&Find"));
- m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png")));
- m_findAction->setShortcuts(QKeySequence::Find);
+ menu->addAction(globalActions->copyAction());
+ menu->addAction(globalActions->findAction());
QAction *findNextAction = menu->addAction(tr("Find &Next"), m_centralWidget,
SLOT(findNext()));
@@ -467,17 +474,8 @@ void MainWindow::setupActions()
tmp->setMenuRole(QAction::PreferencesRole);
m_viewMenu = menuBar()->addMenu(tr("&View"));
- m_zoomInAction = m_viewMenu->addAction(tr("Zoom &in"), m_centralWidget,
- SLOT(zoomIn()));
- m_zoomInAction->setPriority(QAction::LowPriority);
- m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png")));
- m_zoomInAction->setShortcut(QKeySequence::ZoomIn);
-
- m_zoomOutAction = m_viewMenu->addAction(tr("Zoom &out"), m_centralWidget,
- SLOT(zoomOut()));
- m_zoomOutAction->setPriority(QAction::LowPriority);
- m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png")));
- m_zoomOutAction->setShortcut(QKeySequence::ZoomOut);
+ m_viewMenu->addAction(globalActions->zoomInAction());
+ m_viewMenu->addAction(globalActions->zoomOutAction());
m_resetZoomAction = m_viewMenu->addAction(tr("Normal &Size"), m_centralWidget,
SLOT(resetZoom()));
@@ -493,24 +491,15 @@ void MainWindow::setupActions()
QKeySequence(tr("ALT+I")));
m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarksDockWidget()),
QKeySequence(tr("ALT+O")));
- m_viewMenu->addAction(tr("Search"), this, SLOT(showSearchWidget()),
+ m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()),
QKeySequence(tr("ALT+S")));
+ m_viewMenu->addAction(tr("Open Pages"), this, SLOT(showOpenPages()),
+ QKeySequence(tr("ALT+P")));
menu = menuBar()->addMenu(tr("&Go"));
- m_homeAction = menu->addAction(tr("&Home"), m_centralWidget, SLOT(home()));
- m_homeAction->setShortcut(tr("ALT+Home"));
- m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png")));
-
- m_backAction = menu->addAction(tr("&Back"), m_centralWidget, SLOT(backward()));
- m_backAction->setEnabled(false);
- m_backAction->setShortcuts(QKeySequence::Back);
- m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png")));
-
- m_nextAction = menu->addAction(tr("&Forward"), m_centralWidget, SLOT(forward()));
- m_nextAction->setPriority(QAction::LowPriority);
- m_nextAction->setEnabled(false);
- m_nextAction->setShortcuts(QKeySequence::Forward);
- m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png")));
+ menu->addAction(globalActions->homeAction());
+ menu->addAction(globalActions->backAction());
+ menu->addAction(globalActions->nextAction());
m_syncAction = menu->addAction(tr("Sync with Table of Contents"), this,
SLOT(syncContents()));
@@ -519,60 +508,40 @@ void MainWindow::setupActions()
menu->addSeparator();
- tmp = menu->addAction(tr("Next Page"), m_centralWidget, SLOT(nextPage()));
+ tmp = menu->addAction(tr("Next Page"), openPages, SLOT(nextPage()));
tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Right"))
<< QKeySequence(Qt::CTRL + Qt::Key_PageDown));
- tmp = menu->addAction(tr("Previous Page"), m_centralWidget, SLOT(previousPage()));
+ tmp = menu->addAction(tr("Previous Page"), openPages, SLOT(previousPage()));
tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Left"))
<< QKeySequence(Qt::CTRL + Qt::Key_PageUp));
- if (BookmarkManager *manager = BookmarkManager::instance())
- manager->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
+ BookmarkManager::instance()->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
menu = menuBar()->addMenu(tr("&Help"));
m_aboutAction = menu->addAction(tr("About..."), this, SLOT(showAboutDialog()));
m_aboutAction->setMenuRole(QAction::AboutRole);
#ifdef Q_WS_X11
- m_newTabAction->setIcon(QIcon::fromTheme("tab-new", m_newTabAction->icon()));
- m_closeTabAction->setIcon(QIcon::fromTheme("window-close", m_closeTabAction->icon()));
- m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon()));
- m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon()));
- m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon()));
- m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon()));
m_resetZoomAction->setIcon(QIcon::fromTheme("zoom-original" , m_resetZoomAction->icon()));
m_syncAction->setIcon(QIcon::fromTheme("view-refresh" , m_syncAction->icon()));
- m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon()));
- m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon()));
- m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon()));
- m_pageSetupAction->setIcon(QIcon::fromTheme("document-page-setup", m_pageSetupAction->icon()));
- m_printPreviewAction->setIcon(QIcon::fromTheme("document-print-preview", m_printPreviewAction->icon()));
- m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon()));
- m_aboutAction->setIcon(QIcon::fromTheme("help-about", m_aboutAction->icon()));
#endif
QToolBar *navigationBar = addToolBar(tr("Navigation Toolbar"));
navigationBar->setObjectName(QLatin1String("NavigationToolBar"));
- navigationBar->addAction(m_backAction);
- navigationBar->addAction(m_nextAction);
- navigationBar->addAction(m_homeAction);
+ navigationBar->addAction(globalActions->backAction());
+ navigationBar->addAction(globalActions->nextAction());
+ navigationBar->addAction(globalActions->homeAction());
navigationBar->addAction(m_syncAction);
- QAction *sep = navigationBar->addSeparator();
- navigationBar->addAction(m_copyAction);
- navigationBar->addAction(m_printAction);
- navigationBar->addAction(m_findAction);
- QAction *sep2 = navigationBar->addSeparator();
- navigationBar->addAction(m_zoomInAction);
- navigationBar->addAction(m_zoomOutAction);
+ navigationBar->addSeparator();
+ navigationBar->addAction(globalActions->copyAction());
+ navigationBar->addAction(globalActions->printAction());
+ navigationBar->addAction(globalActions->findAction());
+ navigationBar->addSeparator();
+ navigationBar->addAction(globalActions->zoomInAction());
+ navigationBar->addAction(globalActions->zoomOutAction());
navigationBar->addAction(m_resetZoomAction);
- QList<QAction*> actionList;
- actionList << m_backAction << m_nextAction << m_homeAction << sep
- << m_zoomInAction << m_zoomOutAction << sep2 << m_copyAction
- << m_printAction << m_findAction;
- m_centralWidget->setGlobalActions(actionList);
-
#if defined(Q_WS_MAC)
QMenu *windowMenu = new QMenu(tr("&Window"), this);
menuBar()->insertMenu(menu->menuAction(), windowMenu);
@@ -582,16 +551,14 @@ void MainWindow::setupActions()
#endif
// content viewer connections
- connect(m_centralWidget, SIGNAL(copyAvailable(bool)), this,
- SLOT(copyAvailable(bool)));
- connect(m_centralWidget, SIGNAL(currentViewerChanged()), this,
- SLOT(updateNavigationItems()));
- connect(m_centralWidget, SIGNAL(currentViewerChanged()), this,
- SLOT(updateTabCloseAction()));
- connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), this,
- SLOT(updateNavigationItems()));
- connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), this,
- SLOT(updateNavigationItems()));
+ connect(m_centralWidget, SIGNAL(copyAvailable(bool)), globalActions,
+ SLOT(setCopyAvailable(bool)));
+ connect(m_centralWidget, SIGNAL(currentViewerChanged()), globalActions,
+ SLOT(updateActions()));
+ connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), globalActions,
+ SLOT(updateActions()));
+ connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), globalActions,
+ SLOT(updateActions()));
connect(m_centralWidget, SIGNAL(highlighted(QString)), statusBar(),
SLOT(showMessage(QString)));
@@ -609,6 +576,12 @@ void MainWindow::setupActions()
connect(m_contentWindow, SIGNAL(escapePressed()), this,
SLOT(activateCurrentCentralWidgetTab()));
+ // search window
+ connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)),
+ CentralWidget::instance(), SLOT(setSourceFromSearch(QUrl)));
+ connect(m_searchWindow, SIGNAL(requestShowLinkInNewTab(QUrl)),
+ OpenPagesManager::instance(), SLOT(createNewPageFromSearch(QUrl)));
+
#if defined(QT_NO_PRINTER)
m_pageSetupAction->setVisible(false);
m_printPreviewAction->setVisible(false);
@@ -732,26 +705,6 @@ void MainWindow::gotoAddress()
m_centralWidget->setSource(m_addressLineEdit->text());
}
-void MainWindow::updateNavigationItems()
-{
- TRACE_OBJ
- bool hasCurrentViewer = m_centralWidget->isHomeAvailable();
- m_copyAction->setEnabled(m_centralWidget->hasSelection());
- m_homeAction->setEnabled(hasCurrentViewer);
- m_syncAction->setEnabled(hasCurrentViewer);
- m_printPreviewAction->setEnabled(hasCurrentViewer);
- m_printAction->setEnabled(hasCurrentViewer);
- m_nextAction->setEnabled(m_centralWidget->isForwardAvailable());
- m_backAction->setEnabled(m_centralWidget->isBackwardAvailable());
- m_newTabAction->setEnabled(hasCurrentViewer);
-}
-
-void MainWindow::updateTabCloseAction()
-{
- TRACE_OBJ
- m_closeTabAction->setEnabled(m_centralWidget->enableTabCloseAction());
-}
-
void MainWindow::showTopicChooser(const QMap<QString, QUrl> &links,
const QString &keyword)
{
@@ -785,12 +738,6 @@ void MainWindow::syncContents()
qApp->restoreOverrideCursor();
}
-void MainWindow::copyAvailable(bool yes)
-{
- TRACE_OBJ
- m_copyAction->setEnabled(yes);
-}
-
void MainWindow::showAboutDialog()
{
TRACE_OBJ
@@ -899,15 +846,13 @@ void MainWindow::setBookmarksVisible(bool visible)
void MainWindow::showBookmarksDockWidget()
{
TRACE_OBJ
- if (m_bookmarkWidget)
- activateDockWidget(m_bookmarkWidget);
+ activateDockWidget(m_bookmarkWidget);
}
void MainWindow::hideBookmarksDockWidget()
{
TRACE_OBJ
- if (m_bookmarkWidget)
- m_bookmarkWidget->parentWidget()->hide();
+ m_bookmarkWidget->parentWidget()->hide();
}
void MainWindow::setSearchVisible(bool visible)
@@ -922,13 +867,19 @@ void MainWindow::setSearchVisible(bool visible)
void MainWindow::showSearch()
{
TRACE_OBJ
- m_centralWidget->activateSearchWidget();
+ activateDockWidget(m_searchWindow);
+}
+
+void MainWindow::showOpenPages()
+{
+ TRACE_OBJ
+ activateDockWidget(OpenPagesManager::instance()->openPagesWidget());
}
void MainWindow::hideSearch()
{
TRACE_OBJ
- m_centralWidget->removeSearchWidget();
+ m_searchWindow->parentWidget()->hide();
}
void MainWindow::activateDockWidget(QWidget *w)
@@ -948,10 +899,7 @@ void MainWindow::setIndexString(const QString &str)
void MainWindow::activateCurrentBrowser()
{
TRACE_OBJ
- CentralWidget *cw = CentralWidget::instance();
- if (cw) {
- cw->activateTab(true);
- }
+ CentralWidget::instance()->activateTab();
}
void MainWindow::activateCurrentCentralWidgetTab()
@@ -960,12 +908,6 @@ void MainWindow::activateCurrentCentralWidgetTab()
m_centralWidget->activateTab();
}
-void MainWindow::showSearchWidget()
-{
- TRACE_OBJ
- m_centralWidget->activateSearchWidget(true);
-}
-
void MainWindow::updateApplicationFont()
{
TRACE_OBJ
@@ -1087,17 +1029,13 @@ void MainWindow::currentFilterChanged(const QString &filter)
void MainWindow::documentationRemoved(const QString &namespaceName)
{
TRACE_OBJ
- CentralWidget* widget = CentralWidget::instance();
- widget->closeOrReloadTabs(widget->currentSourceFileList().
- keys(namespaceName), false);
+ OpenPagesManager::instance()->closePages(namespaceName);
}
void MainWindow::documentationUpdated(const QString &namespaceName)
{
TRACE_OBJ
- CentralWidget* widget = CentralWidget::instance();
- widget->closeOrReloadTabs(widget->currentSourceFileList().
- keys(namespaceName), true);
+ OpenPagesManager::instance()->reloadPages(namespaceName);
}
void MainWindow::resetQtDocInfo(const QString &component)
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index 8e4276d..7eb44e9 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -42,24 +42,27 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
+#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtGui/QMainWindow>
QT_BEGIN_NAMESPACE
class QAction;
+class QComboBox;
class QFileSystemWatcher;
class QLineEdit;
-class QComboBox;
class QMenu;
-class IndexWindow;
-class QHelpEngineCore;
-class QHelpEngine;
class CentralWidget;
-class ContentWindow;
class CmdLineParser;
+class ContentWindow;
+class IndexWindow;
+class OpenPagesWindow;
class QtDocInstaller;
+class QHelpEngineCore;
+class QHelpEngine;
+class SearchWidget;
class MainWindow : public QMainWindow
{
@@ -87,7 +90,6 @@ public slots:
void setIndexVisible(bool visible);
void setBookmarksVisible(bool visible);
void setSearchVisible(bool visible);
- void showSearchWidget();
void syncContents();
void activateCurrentCentralWidgetTab();
void currentFilterChanged(const QString &filter);
@@ -96,14 +98,12 @@ private slots:
void showContents();
void showIndex();
void showSearch();
+ void showOpenPages();
void insertLastPages();
void gotoAddress();
void showPreferences();
void showNewAddress();
void showAboutDialog();
- void copyAvailable(bool yes);
- void updateNavigationItems();
- void updateTabCloseAction();
void showNewAddress(const QUrl &url);
void showTopicChooser(const QMap<QString, QUrl> &links, const QString &keyword);
void updateApplicationFont();
@@ -144,20 +144,13 @@ private:
CentralWidget *m_centralWidget;
IndexWindow *m_indexWindow;
ContentWindow *m_contentWindow;
+ SearchWidget *m_searchWindow;
QLineEdit *m_addressLineEdit;
QComboBox *m_filterCombo;
- QAction *m_backAction;
- QAction *m_nextAction;
- QAction *m_homeAction;
QAction *m_syncAction;
- QAction *m_copyAction;
- QAction *m_findAction;
- QAction *m_printAction;
QAction *m_printPreviewAction;
QAction *m_pageSetupAction;
- QAction *m_zoomInAction;
- QAction *m_zoomOutAction;
QAction *m_resetZoomAction;
QAction *m_aboutAction;
QAction *m_closeTabAction;
diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp
new file mode 100644
index 0000000..b6005e8
--- /dev/null
+++ b/tools/assistant/tools/assistant/openpagesmanager.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** 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 Assistant module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "openpagesmanager.h"
+
+#include "centralwidget.h"
+#include "helpenginewrapper.h"
+#include "helpviewer.h"
+#include "openpagesmodel.h"
+#include "openpageswidget.h"
+#include "tracer.h"
+#include "../shared/collectionconfiguration.h"
+
+#include <QtGui/QTreeView>
+
+QT_BEGIN_NAMESPACE
+
+OpenPagesManager *OpenPagesManager::createInstance(QObject *parent,
+ bool defaultCollection, const QUrl &cmdLineUrl)
+{
+ TRACE_OBJ
+ Q_ASSERT(!m_instance);
+ m_instance = new OpenPagesManager(parent, defaultCollection, cmdLineUrl);
+ return m_instance;
+}
+
+OpenPagesManager *OpenPagesManager::instance()
+{
+ TRACE_OBJ
+ Q_ASSERT(m_instance);
+ return m_instance;
+}
+
+OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection,
+ const QUrl &cmdLineUrl)
+ : QObject(parent), m_model(new OpenPagesModel(this)),
+ m_openPagesWidget(new OpenPagesWidget(m_model))
+{
+ TRACE_OBJ
+ connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this,
+ SLOT(setCurrentPage(QModelIndex)));
+ connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this,
+ SLOT(closePage(QModelIndex)));
+ connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this,
+ SLOT(closePagesExcept(QModelIndex)));
+ setupInitialPages(defaultCollection, cmdLineUrl);
+}
+
+int OpenPagesManager::pageCount() const
+{
+ TRACE_OBJ
+ return m_model->rowCount();
+}
+
+void OpenPagesManager::setupInitialPages(bool defaultCollection,
+ const QUrl &cmdLineUrl)
+{
+ TRACE_OBJ
+ if (cmdLineUrl.isValid()) {
+ createPage(cmdLineUrl);
+ return;
+ }
+
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ int initialPage = 0;
+ switch (helpEngine.startOption()) {
+ case ShowHomePage:
+ m_model->addPage(helpEngine.homePage());
+ break;
+ case ShowBlankPage:
+ m_model->addPage(QUrl(QLatin1String("about:blank")));
+ break;
+ case ShowLastPages: {
+ const QStringList &lastShownPageList = helpEngine.lastShownPages();
+ const int pageCount = lastShownPageList.count();
+ if (pageCount == 0) {
+ if (defaultCollection)
+ m_model->addPage(QUrl(QLatin1String("help")));
+ else
+ m_model->addPage(QUrl(QLatin1String("about:blank")));
+ } else {
+ QStringList zoomFactors = helpEngine.lastZoomFactors();
+ while (zoomFactors.count() < pageCount)
+ zoomFactors.append(CollectionConfiguration::DefaultZoomFactor);
+ initialPage = helpEngine.lastTabPage();
+ if (initialPage >= pageCount) {
+ qWarning("Initial page set to %d, maximum possible value is %d",
+ initialPage, pageCount - 1);
+ initialPage = 0;
+ }
+ for (int curPage = 0; curPage < pageCount; ++curPage) {
+ const QString &curFile = lastShownPageList.at(curPage);
+ if (helpEngine.findFile(curFile).isValid()
+ || curFile == QLatin1String("about:blank")) {
+ m_model->addPage(curFile, zoomFactors.at(curPage).toFloat());
+ } else if (curPage <= initialPage && initialPage > 0)
+ --initialPage;
+ }
+ }
+ break;
+ }
+ default:
+ Q_ASSERT(!"Unhandled option");
+ }
+
+ if (m_model->rowCount() == 0)
+ m_model->addPage(helpEngine.homePage());
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ CentralWidget::instance()->addPage(m_model->pageAt(i));
+ setCurrentPage(initialPage);
+}
+
+HelpViewer *OpenPagesManager::createPage()
+{
+ TRACE_OBJ
+ return createPage(QUrl(QLatin1String("about:blank")));
+}
+
+void OpenPagesManager::closeCurrentPage()
+{
+ TRACE_OBJ
+ Q_ASSERT(m_model->rowCount() > 1);
+ const QModelIndexList selectedIndexes
+ = m_openPagesWidget->selectionModel()->selectedRows();
+ if (selectedIndexes.isEmpty())
+ return;
+ Q_ASSERT(selectedIndexes.count() == 1);
+ removePage(selectedIndexes.first().row());
+}
+
+HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch)
+{
+ TRACE_OBJ
+ if (HelpViewer::launchWithExternalApp(url))
+ return 0;
+
+ m_model->addPage(url);
+ const int index = m_model->rowCount() - 1;
+ HelpViewer * const page = m_model->pageAt(index);
+ CentralWidget::instance()->addPage(page, fromSearch);
+ setCurrentPage(index);
+ return page;
+}
+
+HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url)
+{
+ return createPage(url, true);
+}
+
+void OpenPagesManager::closePage(const QModelIndex &index)
+{
+ if (index.isValid())
+ removePage(index.row());
+}
+
+void OpenPagesManager::closePages(const QString &nameSpace)
+{
+ TRACE_OBJ
+ closeOrReloadPages(nameSpace, false);
+}
+
+void OpenPagesManager::reloadPages(const QString &nameSpace)
+{
+ TRACE_OBJ
+ closeOrReloadPages(nameSpace, true);
+ selectCurrentPage();
+}
+
+void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload)
+{
+ TRACE_OBJ
+
+ for (int i = m_model->rowCount() - 1; i >= 0; --i) {
+ HelpViewer *page = m_model->pageAt(i);
+ if (page->source().host() != nameSpace)
+ continue;
+ if (tryReload && HelpEngineWrapper::instance().findFile(page->source()).isValid())
+ page->reload();
+ else if (m_model->rowCount() == 1)
+ page->setSource(QUrl(QLatin1String("about:blank")));
+ else
+ removePage(i);
+ }
+}
+
+bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const
+{
+ TRACE_OBJ
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ if (m_model->pageAt(i)->source().host() == nameSpace)
+ return true;
+ return false;
+}
+
+void OpenPagesManager::setCurrentPage(const QModelIndex &index)
+{
+ TRACE_OBJ
+ if (!index.isValid())
+ return;
+ HelpViewer * const page = m_model->pageAt(index.row());
+ CentralWidget::instance()->setCurrentPage(page);
+}
+
+void OpenPagesManager::setCurrentPage(int index)
+{
+ TRACE_OBJ
+ CentralWidget::instance()->setCurrentPage(m_model->pageAt(index));
+ selectCurrentPage();
+}
+
+void OpenPagesManager::selectCurrentPage()
+{
+ TRACE_OBJ
+ QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel();
+ selModel->clearSelection();
+ selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0),
+ QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex());
+}
+
+void OpenPagesManager::removePage(int index)
+{
+ TRACE_OBJ
+ CentralWidget::instance()->removePage(index);
+ m_model->removePage(index);
+ selectCurrentPage();
+}
+
+
+void OpenPagesManager::closePagesExcept(const QModelIndex &index)
+{
+ TRACE_OBJ
+ if (!index.isValid())
+ return;
+
+ int i = 0;
+ HelpViewer *viewer = m_model->pageAt(index.row());
+ while (m_model->rowCount() > 1) {
+ if (m_model->pageAt(i) != viewer)
+ removePage(i);
+ else
+ ++i;
+ }
+}
+
+QAbstractItemView *OpenPagesManager::openPagesWidget() const
+{
+ return m_openPagesWidget;
+}
+
+void OpenPagesManager::nextPage()
+{
+ nextOrPreviousPage(1);
+}
+
+void OpenPagesManager::previousPage()
+{
+ nextOrPreviousPage(-1);
+}
+
+void OpenPagesManager::nextOrPreviousPage(int offset)
+{
+ setCurrentPage((CentralWidget::instance()->currentIndex() + offset
+ + m_model->rowCount()) % m_model->rowCount());
+}
+
+OpenPagesManager *OpenPagesManager::m_instance = 0;
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h
new file mode 100644
index 0000000..5e7a9af
--- /dev/null
+++ b/tools/assistant/tools/assistant/openpagesmanager.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** 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 Assistant module 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 OPENPAGESMANAGER_H
+#define OPENPAGESMANAGER_H
+
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractItemView;
+class QModelIndex;
+class QUrl;
+
+class HelpViewer;
+class OpenPagesModel;
+class OpenPagesWidget;
+
+class OpenPagesManager : public QObject
+ {
+ Q_OBJECT
+ public:
+ static OpenPagesManager *createInstance(QObject *parent,
+ bool defaultCollection, const QUrl &cmdLineUrl);
+ static OpenPagesManager *instance();
+
+ bool pagesOpenForNamespace(const QString &nameSpace) const;
+ void closePages(const QString &nameSpace);
+ void reloadPages(const QString &nameSpace);
+
+ QAbstractItemView* openPagesWidget() const;
+
+ int pageCount() const;
+ void setCurrentPage(int index);
+
+ public slots:
+ HelpViewer *createPage(const QUrl &url, bool fromSearch = false);
+ HelpViewer *createNewPageFromSearch(const QUrl &url);
+ HelpViewer *createPage();
+ void closeCurrentPage();
+ void nextPage();
+ void previousPage();
+
+private slots:
+ void setCurrentPage(const QModelIndex &index);
+ void closePage(const QModelIndex &index);
+ void closePagesExcept(const QModelIndex &index);
+
+private:
+ OpenPagesManager(QObject *parent, bool defaultCollection,
+ const QUrl &cmdLineUrl);
+ void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl);
+ void closeOrReloadPages(const QString &nameSpace, bool tryReload);
+ void selectCurrentPage();
+ void removePage(int index);
+ void nextOrPreviousPage(int offset);
+
+ OpenPagesModel *m_model;
+ OpenPagesWidget *m_openPagesWidget;
+
+ static OpenPagesManager *m_instance;
+ };
+
+QT_END_NAMESPACE
+
+#endif // OPENPAGESMANAGER_H
diff --git a/tools/assistant/tools/assistant/openpagesmodel.cpp b/tools/assistant/tools/assistant/openpagesmodel.cpp
new file mode 100644
index 0000000..2663b85
--- /dev/null
+++ b/tools/assistant/tools/assistant/openpagesmodel.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** 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 Assistant module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "openpagesmodel.h"
+
+#include "helpenginewrapper.h"
+#include "helpviewer.h"
+#include "tracer.h"
+
+#include <QtCore/QStringList>
+#include <QtCore/QUrl>
+
+QT_BEGIN_NAMESPACE
+
+OpenPagesModel::OpenPagesModel(QObject *parent) : QAbstractTableModel(parent)
+{
+ TRACE_OBJ
+}
+
+int OpenPagesModel::rowCount(const QModelIndex &parent) const
+{
+ TRACE_OBJ
+ return parent.isValid() ? 0 : m_pages.count();
+}
+
+int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ TRACE_OBJ
+ return 2;
+}
+
+QVariant OpenPagesModel::data(const QModelIndex &index, int role) const
+{
+ TRACE_OBJ
+ if (!index.isValid() || index.row() >= rowCount() || index.column() > 0
+ || role != Qt::DisplayRole)
+ return QVariant();
+ QString title = m_pages.at(index.row())->title();
+ title.replace(QLatin1Char('&'), QLatin1String("&&"));
+ return title.isEmpty() ? QLatin1String("(Untitled)") : title;
+}
+
+void OpenPagesModel::addPage(const QUrl &url, qreal zoom)
+{
+ TRACE_OBJ
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ HelpViewer *page = new HelpViewer(zoom);
+ connect(page, SIGNAL(titleChanged()), this, SLOT(handleTitleChanged()));
+ m_pages << page;
+ endInsertRows();
+ page->setSource(url);
+}
+
+void OpenPagesModel::removePage(int index)
+{
+ TRACE_OBJ
+ Q_ASSERT(index >= 0 && index < rowCount());
+ beginRemoveRows(QModelIndex(), index, index);
+ HelpViewer *page = m_pages.at(index);
+ m_pages.removeAt(index);
+ endRemoveRows();
+ page->deleteLater();
+}
+
+HelpViewer *OpenPagesModel::pageAt(int index) const
+{
+ TRACE_OBJ
+ Q_ASSERT(index >= 0 && index < rowCount());
+ return m_pages.at(index);
+}
+
+void OpenPagesModel::handleTitleChanged()
+{
+ TRACE_OBJ
+ HelpViewer *page = static_cast<HelpViewer *>(sender());
+ const int row = m_pages.indexOf(page);
+ Q_ASSERT(row != -1 );
+ const QModelIndex &item = index(row, 0);
+ emit dataChanged(item, item);
+}
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/openpagesmodel.h b/tools/assistant/tools/assistant/openpagesmodel.h
new file mode 100644
index 0000000..64013a6
--- /dev/null
+++ b/tools/assistant/tools/assistant/openpagesmodel.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 Assistant module 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 OPENPAGESMODEL_H
+#define OPENPAGESMODEL_H
+
+#include <QtCore/QAbstractTableModel>
+#include <QtCore/QList>
+
+QT_BEGIN_NAMESPACE
+
+class HelpViewer;
+class QUrl;
+
+class OpenPagesModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ OpenPagesModel(QObject *parent);
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+ void addPage(const QUrl &url, qreal zoom = 0);
+ void removePage(int index);
+ HelpViewer *pageAt(int index) const;
+
+private slots:
+ void handleTitleChanged();
+
+private:
+ QList<HelpViewer *> m_pages;
+};
+
+QT_END_NAMESPACE
+
+#endif // OPENPAGESMODEL_H
diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp
new file mode 100644
index 0000000..d702c28
--- /dev/null
+++ b/tools/assistant/tools/assistant/openpageswidget.cpp
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** 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 Assistant module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "openpageswidget.h"
+
+#include "openpagesmodel.h"
+
+#include <QtGui/QApplication>
+#include <QtGui/QHeaderView>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QMenu>
+#include <QtGui/QPainter>
+
+#ifdef Q_WS_MAC
+#include <qmacstyle_mac.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+OpenPagesDelegate::OpenPagesDelegate(QObject *parent)
+ : QStyledItemDelegate(parent)
+{
+}
+
+void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ if (option.state & QStyle::State_MouseOver) {
+ if ((QApplication::mouseButtons() & Qt::LeftButton) == 0)
+ pressedIndex = QModelIndex();
+ QBrush brush = option.palette.alternateBase();
+ if (index == pressedIndex)
+ brush = option.palette.dark();
+ painter->fillRect(option.rect, brush);
+ }
+
+ QStyledItemDelegate::paint(painter, option, index);
+
+ if (index.column() == 1 && index.model()->rowCount() > 1
+ && option.state & QStyle::State_MouseOver) {
+ QIcon icon((option.state & QStyle::State_Selected)
+ ? ":/trolltech/assistant/images/closebutton.png"
+ : ":/trolltech/assistant/images/darkclosebutton.png");
+
+ const QRect iconRect(option.rect.right() - option.rect.height(),
+ option.rect.top(), option.rect.height(), option.rect.height());
+ icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter);
+ }
+}
+
+
+OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model)
+{
+ setModel(model);
+ setIndentation(0);
+ setItemDelegate((m_delegate = new OpenPagesDelegate(this)));
+
+ setFrameStyle(QFrame::NoFrame);
+ setTextElideMode(Qt::ElideMiddle);
+ setAttribute(Qt::WA_MacShowFocusRect, false);
+
+ viewport()->setAttribute(Qt::WA_Hover);
+ setSelectionBehavior(QAbstractItemView::SelectRows);
+ setSelectionMode(QAbstractItemView::SingleSelection);
+
+ header()->hide();
+ header()->setStretchLastSection(false);
+ header()->setResizeMode(0, QHeaderView::Stretch);
+ header()->setResizeMode(1, QHeaderView::Fixed);
+ header()->resizeSection(1, 18);
+
+ installEventFilter(this);
+ setUniformRowHeights(true);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+
+ connect(this, SIGNAL(clicked(QModelIndex)), this,
+ SLOT(handleClicked(QModelIndex)));
+ connect(this, SIGNAL(pressed(QModelIndex)), this,
+ SLOT(handlePressed(QModelIndex)));
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), this,
+ SLOT(contextMenuRequested(QPoint)));
+}
+
+OpenPagesWidget::~OpenPagesWidget()
+{
+}
+
+void OpenPagesWidget::contextMenuRequested(QPoint pos)
+{
+ QModelIndex index = indexAt(pos);
+ if (!index.isValid())
+ return;
+
+ if (index.column() == 1)
+ index = index.sibling(index.row(), 0);
+ QMenu contextMenu;
+ QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data()
+ .toString()));
+ QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1")
+ .arg(index.data().toString()));
+
+ if (model()->rowCount() == 1) {
+ closeEditor->setEnabled(false);
+ closeOtherEditors->setEnabled(false);
+ }
+
+ QAction *action = contextMenu.exec(mapToGlobal(pos));
+ if (action == closeEditor)
+ emit closePage(index);
+ else if (action == closeOtherEditors)
+ emit closePagesExcept(index);
+}
+
+void OpenPagesWidget::handlePressed(const QModelIndex &index)
+{
+ if (index.column() == 0)
+ emit setCurrentPage(index);
+
+ if (index.column() == 1)
+ m_delegate->pressedIndex = index;
+}
+
+void OpenPagesWidget::handleClicked(const QModelIndex &index)
+{
+ // implemented here to handle the funky close button and to work around a
+ // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver
+ if (index.column() == 1) {
+ if (model()->rowCount() > 1)
+ emit closePage(index);
+
+ QWidget *vp = viewport();
+ const QPoint &cursorPos = QCursor::pos();
+ QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos,
+ Qt::NoButton, 0, 0);
+ QCoreApplication::sendEvent(vp, &e);
+ }
+}
+
+bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj == this && event->type() == QEvent::KeyPress) {
+ if (currentIndex().isValid()) {
+ QKeyEvent *ke = static_cast<QKeyEvent*>(event);
+ const int key = ke->key();
+ if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space)
+ && ke->modifiers() == 0) {
+ emit setCurrentPage(currentIndex());
+ } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace)
+ && ke->modifiers() == 0 && model()->rowCount() > 1) {
+ emit closePage(currentIndex());
+ }
+ }
+ }
+ return QWidget::eventFilter(obj, event);
+}
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/openpageswidget.h
index acb734b..46c0022 100644
--- a/tools/assistant/tools/assistant/helpviewer_qtb.h
+++ b/tools/assistant/tools/assistant/openpageswidget.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Assistant of the Qt Toolkit.
+** This file is part of the Assistant module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -38,76 +38,51 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef HELPVIEWERQTB_H
-#define HELPVIEWERQTB_H
-#include "helpviewer.h"
+#ifndef OPENPAGESWIDGET_H
+#define OPENPAGESWIDGET_H
-#include <QtCore/QUrl>
-#include <QtCore/QVariant>
-
-#include <QtGui/QTextBrowser>
+#include <QtGui/QStyledItemDelegate>
+#include <QtGui/QTreeView>
QT_BEGIN_NAMESPACE
-class CentralWidget;
-class HelpEngineWrapper;
-class QContextMenuEvent;
-class QKeyEvent;
-class QMouseEvent;
+class OpenPagesModel;
-class HelpViewer : public QTextBrowser, public AbstractHelpViewer
+class OpenPagesDelegate : public QStyledItemDelegate
{
Q_OBJECT
-
public:
- HelpViewer(CentralWidget *parent, 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(); }
+ explicit OpenPagesDelegate(QObject *parent = 0);
+ void paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
-public Q_SLOTS:
- void home();
+ mutable QModelIndex pressedIndex;
+};
-protected:
- void wheelEvent(QWheelEvent *e);
- bool eventFilter(QObject *obj, QEvent *event);
+class OpenPagesWidget : public QTreeView
+{
+ Q_OBJECT
+public:
+ OpenPagesWidget(OpenPagesModel *model);
+ ~OpenPagesWidget();
-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);
+signals:
+ void setCurrentPage(const QModelIndex &index);
+ void closePage(const QModelIndex &index);
+ void closePagesExcept(const QModelIndex &index);
private slots:
- void openLinkInNewTab();
+ void contextMenuRequested(QPoint pos);
+ void handlePressed(const QModelIndex &index);
+ void handleClicked(const QModelIndex &index);
private:
- int zoomCount;
- bool controlPressed;
- QString lastAnchor;
- CentralWidget* parentWidget;
- HelpEngineWrapper &helpEngine;
+ bool eventFilter(QObject *obj, QEvent *event);
- bool forceFont;
+ OpenPagesDelegate *m_delegate;
};
QT_END_NAMESPACE
-#endif // HELPVIEWERQTB_H
+#endif // OPENPAGESWIDGET_H
diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp
index 0e1d719..3535e5a 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.cpp
+++ b/tools/assistant/tools/assistant/preferencesdialog.cpp
@@ -45,6 +45,7 @@
#include "fontpanel.h"
#include "helpenginewrapper.h"
#include "installdialog.h"
+#include "openpagesmanager.h"
#include "tracer.h"
#include <QtCore/QtAlgorithms>
@@ -302,15 +303,12 @@ void PreferencesDialog::addDocumentationLocal()
void PreferencesDialog::removeDocumentation()
{
TRACE_OBJ
- bool foundBefore = false;
- CentralWidget* widget = CentralWidget::instance();
- QMap<int, QString> openedDocList = widget->currentSourceFileList();
- QStringList values(openedDocList.values());
+ bool foundBefore = false;
QList<QListWidgetItem*> l = m_ui.registeredDocsListWidget->selectedItems();
foreach (QListWidgetItem* item, l) {
const QString& ns = item->text();
- if (!foundBefore && values.contains(ns)) {
+ if (!foundBefore && OpenPagesManager::instance()->pagesOpenForNamespace(ns)) {
if (0 == QMessageBox::information(this, tr("Remove Documentation"),
tr("Some documents currently opened in Assistant reference the "
"documentation you are attempting to remove. Removing the "
@@ -320,7 +318,6 @@ void PreferencesDialog::removeDocumentation()
}
m_unregDocs.append(ns);
- m_TabsToClose += openedDocList.keys(ns);
delete m_ui.registeredDocsListWidget->takeItem(
m_ui.registeredDocsListWidget->row(item));
}
@@ -374,10 +371,10 @@ void PreferencesDialog::applyChanges()
}
}
- CentralWidget::instance()->closeOrReloadTabs(m_TabsToClose, false);
-
- foreach (const QString &doc, m_unregDocs)
+ foreach (const QString &doc, m_unregDocs) {
+ OpenPagesManager::instance()->closePages(doc);
helpEngine.unregisterDocumentation(doc);
+ }
if (filtersWereChanged || !m_regDocs.isEmpty() || !m_unregDocs.isEmpty())
helpEngine.setupData();
diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h
index 2894494..7a17275 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.h
+++ b/tools/assistant/tools/assistant/preferencesdialog.h
@@ -96,7 +96,6 @@ private:
QStringList m_docsBackup;
QStringList m_regDocs;
QStringList m_unregDocs;
- QList<int> m_TabsToClose;
FontPanel *m_appFontPanel;
FontPanel *m_browserFontPanel;
bool m_appFontChanged;
diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp
index 5ecdd69..06e5602 100644
--- a/tools/assistant/tools/assistant/remotecontrol.cpp
+++ b/tools/assistant/tools/assistant/remotecontrol.cpp
@@ -38,12 +38,13 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
-
#include "remotecontrol.h"
-#include "mainwindow.h"
+
#include "centralwidget.h"
#include "helpenginewrapper.h"
+#include "mainwindow.h"
+#include "openpagesmanager.h"
+#include "tracer.h"
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
@@ -323,8 +324,7 @@ void RemoteControl::handleUnregisterCommand(const QString &arg)
const QString &absFileName = QFileInfo(arg).absoluteFilePath();
const QString &ns = QHelpEngineCore::namespaceName(absFileName);
if (helpEngine.registeredDocumentations().contains(ns)) {
- CentralWidget* widget = CentralWidget::instance();
- widget->closeOrReloadTabs(widget->currentSourceFileList().keys(ns), false);
+ OpenPagesManager::instance()->closePages(ns);
if (helpEngine.unregisterDocumentation(ns))
helpEngine.setupData();
}
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index ee49bbf..2ec5b98 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1900,6 +1900,22 @@ QString Configure::findFileInPaths(const QString &fileName, const QString &paths
return QString();
}
+static QString mingwPaths(const QString &mingwPath, const QString &pathName)
+{
+ QString ret;
+ QDir mingwDir = QFileInfo(mingwPath).dir();
+ const QFileInfoList subdirs = mingwDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (int i = 0 ;i < subdirs.length(); ++i) {
+ const QFileInfo &fi = subdirs.at(i);
+ const QString name = fi.fileName();
+ if (name == pathName)
+ ret += fi.absoluteFilePath() + ';';
+ else if (name.contains("mingw"))
+ ret += fi.absoluteFilePath() + QDir::separator() + pathName + ';';
+ }
+ return ret;
+}
+
bool Configure::findFile( const QString &fileName )
{
const QString file = fileName.toLower();
@@ -1910,18 +1926,22 @@ bool Configure::findFile( const QString &fileName )
QString paths;
if (file.endsWith(".h")) {
if (!mingwPath.isNull()) {
- if (!findFileInPaths(file, mingwPath + QLatin1String("/../include")).isNull())
+ if (!findFileInPaths(file, mingwPaths(mingwPath, "include")).isNull())
return true;
//now let's try the additional compiler path
- QDir mingwLibDir = mingwPath + QLatin1String("/../lib/gcc/mingw32");
- foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
- if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull())
- return true;
+
+ const QFileInfoList mingwConfigs = QDir(mingwPath + QLatin1String("/../lib/gcc")).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (int i = 0; i < mingwConfigs.length(); ++i) {
+ const QDir mingwLibDir = mingwConfigs.at(i).absoluteFilePath();
+ foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
+ if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull())
+ return true;
+ }
}
}
paths = QString::fromLocal8Bit(getenv("INCLUDE"));
} else if ( file.endsWith( ".lib" ) || file.endsWith( ".a" ) ) {
- if (!mingwPath.isNull() && !findFileInPaths(file, mingwPath + QLatin1String("/../lib")).isNull())
+ if (!mingwPath.isNull() && !findFileInPaths(file, mingwPaths(mingwPath, "lib")).isNull())
return true;
paths = QString::fromLocal8Bit(getenv("LIB"));
} else {
diff --git a/tools/designer/data/ui4.xsd b/tools/designer/data/ui4.xsd
index de4253c..f44fa71 100644
--- a/tools/designer/data/ui4.xsd
+++ b/tools/designer/data/ui4.xsd
@@ -414,7 +414,7 @@
<xs:complexType name="StringList">
<xs:sequence>
- <xs:element name="string" type="xs:string" maxOccurs="unbounded" />
+ <xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
diff --git a/tools/qdoc3/doc/qdoc-manual.qdocconf b/tools/qdoc3/doc/qdoc-manual.qdocconf
index 26fd09c..5a725b9 100644
--- a/tools/qdoc3/doc/qdoc-manual.qdocconf
+++ b/tools/qdoc3/doc/qdoc-manual.qdocconf
@@ -32,7 +32,7 @@ HTML.postheader = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"5\" widt
"<td class=\"postheader\" valign=\"center\">" \
"<a href=\"01-qdoc-manual.html\">" \
"<font color=\"#004faf\">Home: QDoc Manual</font></a>&nbsp;&middot;" \
- "<a href=\"http://qt.nokia.com/doc/4.7\">" \
+ "<a href=\"http://qt.nokia.com/doc/4.8\">" \
"<font color=\"#004faf\"> Qt Reference Documentation</font></a>" \
"</td>\n" \
"</tr></table>"
diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf
index 3711ec4..9f32e52 100644
--- a/tools/qdoc3/test/assistant.qdocconf
+++ b/tools/qdoc3/test/assistant.qdocconf
@@ -6,14 +6,14 @@ include(qt-defines.qdocconf)
project = Qt Assistant
description = Qt Assistant Manual
-url = http://qt.nokia.com/doc/4.7
+url = http://qt.nokia.com/doc/4.8
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
qhp.projects = Assistant
qhp.Assistant.file = assistant.qhp
-qhp.Assistant.namespace = com.trolltech.assistant.470
+qhp.Assistant.namespace = com.trolltech.assistant.480
qhp.Assistant.virtualFolder = qdoc
qhp.Assistant.indexTitle = Qt Assistant Manual
qhp.Assistant.extraFiles = images/bg_l.png \
@@ -41,7 +41,7 @@ qhp.Assistant.extraFiles = images/bg_l.png \
style/style_ie8.css \
style/style.css
-qhp.Assistant.filterAttributes = qt 4.7.0 tools assistant
+qhp.Assistant.filterAttributes = qt 4.8.0 tools assistant
qhp.Assistant.customFilters.Assistant.name = Qt Assistant Manual
qhp.Assistant.customFilters.Assistant.filterAttributes = qt tools assistant
qhp.Assistant.subprojects = manual examples
diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf
index 39da68b..9c80f74 100644
--- a/tools/qdoc3/test/designer.qdocconf
+++ b/tools/qdoc3/test/designer.qdocconf
@@ -6,7 +6,7 @@ include(qt-defines.qdocconf)
project = Qt Designer
description = Qt Designer Manual
-url = http://qt.nokia.com/doc/4.7
+url = http://qt.nokia.com/doc/4.8
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
@@ -41,7 +41,7 @@ qhp.Designer.extraFiles = images/bg_l.png \
style/style_ie8.css \
style/style.css
-qhp.Designer.filterAttributes = qt 4.7.0 tools designer
+qhp.Designer.filterAttributes = qt 4.8.0 tools designer
qhp.Designer.customFilters.Designer.name = Qt Designer Manual
qhp.Designer.customFilters.Designer.filterAttributes = qt tools designer
qhp.Designer.subprojects = manual examples
diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf
index dba4fb5..05eeb88 100644
--- a/tools/qdoc3/test/linguist.qdocconf
+++ b/tools/qdoc3/test/linguist.qdocconf
@@ -6,14 +6,14 @@ include(qt-defines.qdocconf)
project = Qt Linguist
description = Qt Linguist Manual
-url = http://qt.nokia.com/doc/4.7
+url = http://qt.nokia.com/doc/4.8
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
qhp.projects = Linguist
qhp.Linguist.file = linguist.qhp
-qhp.Linguist.namespace = com.trolltech.linguist.470
+qhp.Linguist.namespace = com.trolltech.linguist.480
qhp.Linguist.virtualFolder = qdoc
qhp.Linguist.indexTitle = Qt Linguist Manual
qhp.Linguist.extraFiles = images/bg_l.png \
@@ -41,7 +41,7 @@ qhp.Linguist.extraFiles = images/bg_l.png \
style/style_ie8.css \
style/style.css
-qhp.Linguist.filterAttributes = qt 4.7.0 tools linguist
+qhp.Linguist.filterAttributes = qt 4.8.0 tools linguist
qhp.Linguist.customFilters.Linguist.name = Qt Linguist Manual
qhp.Linguist.customFilters.Linguist.filterAttributes = qt tools linguist
qhp.Linguist.subprojects = manual examples
diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf
index b7f4115..490faf57 100644
--- a/tools/qdoc3/test/qmake.qdocconf
+++ b/tools/qdoc3/test/qmake.qdocconf
@@ -6,14 +6,14 @@ include(qt-defines.qdocconf)
project = QMake
description = QMake Manual
-url = http://qt.nokia.com/doc/4.7
+url = http://qt.nokia.com/doc/4.8
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
qhp.projects = qmake
qhp.qmake.file = qmake.qhp
-qhp.qmake.namespace = com.trolltech.qmake.470
+qhp.qmake.namespace = com.trolltech.qmake.480
qhp.qmake.virtualFolder = qdoc
qhp.qmake.indexTitle = QMake Manual
qhp.qmake.extraFiles = images/bg_l.png \
@@ -41,7 +41,7 @@ qhp.qmake.extraFiles = images/bg_l.png \
style/style_ie8.css \
style/style.css
-qhp.qmake.filterAttributes = qt 4.7.0 tools qmake
+qhp.qmake.filterAttributes = qt 4.8.0 tools qmake
qhp.qmake.customFilters.qmake.name = qmake Manual
qhp.qmake.customFilters.qmake.filterAttributes = qt tools qmake
qhp.qmake.subprojects = manual
diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf
index d3c855f..1401fd3 100644
--- a/tools/qdoc3/test/qt-build-docs.qdocconf
+++ b/tools/qdoc3/test/qt-build-docs.qdocconf
@@ -6,7 +6,7 @@ include(qt-defines.qdocconf)
project = Qt
description = Qt Reference Documentation
-url = http://qt.nokia.com/doc/4.7
+url = http://qt.nokia.com/doc/4.8
sourceencoding = UTF-8
outputencoding = UTF-8
@@ -15,7 +15,7 @@ naturallanguage = en_US
qhp.projects = Qt
qhp.Qt.file = qt.qhp
-qhp.Qt.namespace = com.trolltech.qt.470
+qhp.Qt.namespace = com.trolltech.qt.480
qhp.Qt.virtualFolder = qdoc
qhp.Qt.indexTitle = Qt Reference Documentation
@@ -49,9 +49,9 @@ qhp.Qt.extraFiles = index.html \
-qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc
-qhp.Qt.customFilters.Qt.name = Qt 4.7.0
-qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0
+qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc
+qhp.Qt.customFilters.Qt.name = Qt 4.8.0
+qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0
qhp.Qt.subprojects = classes overviews examples
qhp.Qt.subprojects.classes.title = Classes
qhp.Qt.subprojects.classes.indexTitle = Qt's Classes
diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
index e9bc00c..13afcd9 100644
--- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
+++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
@@ -6,7 +6,7 @@ include(qt-defines.qdocconf)
project = Qt
description = Qt Reference Documentation
-url = http://qt.nokia.com/doc/zh_CN/4.7
+url = http://qt.nokia.com/doc/zh_CN/4.8
sourceencoding = UTF-8
outputencoding = UTF-8
@@ -17,15 +17,15 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
qhp.projects = Qt
qhp.Qt.file = qt.qhp
-qhp.Qt.namespace = com.trolltech.qt.470
+qhp.Qt.namespace = com.trolltech.qt.480
qhp.Qt.virtualFolder = qdoc
qhp.Qt.title = 教程
qhp.Qt.indexTitle = 教程
qhp.Qt.selectors = fake:example
-qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc zh_CN
-qhp.Qt.customFilters.Qt.name = Qt 4.7.0
-qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0
+qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc zh_CN
+qhp.Qt.customFilters.Qt.name = Qt 4.8.0
+qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0
# Files not referenced in any qdoc file (last four are needed by qtdemo)
# See also extraimages.HTML
diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf
index e83e666..f34b262 100644
--- a/tools/qdoc3/test/qt-html-templates.qdocconf
+++ b/tools/qdoc3/test/qt-html-templates.qdocconf
@@ -20,7 +20,7 @@ HTML.postheader = " <div class=\"header\" id=\"qtdocheader\">\n" \
" </div>\n" \
" <div id=\"shortCut\">\n" \
" <ul>\n" \
- " <li class=\"shortCut-topleft-inactive\"><span><a href=\"index.html\">Qt 4.7</a></span></li>\n" \
+ " <li class=\"shortCut-topleft-inactive\"><span><a href=\"index.html\">Qt 4.8</a></span></li>\n" \
" <li class=\"shortCut-topleft-active\"><a href=\"http://qt.nokia.com/doc/\">ALL Qt VERSIONS" \
" </a></li>\n" \
" </ul>\n" \
diff --git a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf
index 5fb68cf..94ac431 100644
--- a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf
+++ b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf
@@ -6,13 +6,13 @@ HTML.postheader = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0
"</td>\n" \
"<td width=\"1\">&nbsp;&nbsp;</td>" \
"<td class=\"postheader\" valign=\"center\">" \
- "<a href=\"http://qt.nokia.com/doc/4.7/index.html\">" \
+ "<a href=\"http://qt.nokia.com/doc/4.8/index.html\">" \
"<font color=\"#004faf\">主页</font></a>&nbsp;&middot;" \
- " <a href=\"http://qt.nokia.com/doc/4.7/classes.html\">" \
+ " <a href=\"http://qt.nokia.com/doc/4.8/classes.html\">" \
"<font color=\"#004faf\">所有类</font></a>&nbsp;&middot;" \
- " <a href=\"http://qt.nokia.com/doc/4.7/functions.html\">" \
+ " <a href=\"http://qt.nokia.com/doc/4.8/functions.html\">" \
"<font color=\"#004faf\">所有函数</font></a>&nbsp;&middot;" \
- " <a href=\"http://qt.nokia.com/doc/4.7/overviews.html\">" \
+ " <a href=\"http://qt.nokia.com/doc/4.8/overviews.html\">" \
"<font color=\"#004faf\">简介</font></a>" \
"</td>" \
"</tr></table>"
diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf
index 83a35a9..0c2e2f3 100644
--- a/tools/qdoc3/test/qt.qdocconf
+++ b/tools/qdoc3/test/qt.qdocconf
@@ -8,7 +8,7 @@ project = Qt
versionsym =
version = %VERSION%
description = Qt Reference Documentation
-url = http://qt.nokia.com/doc/4.7
+url = http://qt.nokia.com/doc/4.8
online = true
sourceencoding = UTF-8
@@ -18,7 +18,7 @@ naturallanguage = en_US
qhp.projects = Qt
qhp.Qt.file = qt.qhp
-qhp.Qt.namespace = com.trolltech.qt.470
+qhp.Qt.namespace = com.trolltech.qt.480
qhp.Qt.virtualFolder = qdoc
qhp.Qt.indexTitle = Qt Reference Documentation
qhp.Qt.indexRoot =
@@ -51,9 +51,9 @@ qhp.Qt.extraFiles = index.html \
style/style_ie8.css \
style/style.css
-qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc
-qhp.Qt.customFilters.Qt.name = Qt 4.7.0
-qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0
+qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc
+qhp.Qt.customFilters.Qt.name = Qt 4.8.0
+qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0
qhp.Qt.subprojects = classes overviews examples
qhp.Qt.subprojects.classes.title = Classes
qhp.Qt.subprojects.classes.indexTitle = Qt's Classes
diff --git a/tools/qdoc3/test/qt_zh_CN.qdocconf b/tools/qdoc3/test/qt_zh_CN.qdocconf
index 9275b5c..0a8d936 100644
--- a/tools/qdoc3/test/qt_zh_CN.qdocconf
+++ b/tools/qdoc3/test/qt_zh_CN.qdocconf
@@ -8,7 +8,7 @@ project = Qt
versionsym =
version = %VERSION%
description = Qt Reference Documentation
-url = http://qt.nokia.com/doc/zh_CN/4.7
+url = http://qt.nokia.com/doc/zh_CN/4.8
sourceencoding = UTF-8
outputencoding = UTF-8
@@ -19,15 +19,15 @@ indexes = $QTDIR/doc/html/qt.index
qhp.projects = Qt
qhp.Qt.file = qt.qhp
-qhp.Qt.namespace = com.trolltech.qt.470
+qhp.Qt.namespace = com.trolltech.qt.480
qhp.Qt.virtualFolder = qdoc
qhp.Qt.title = 教程
qhp.Qt.indexTitle = 教程
qhp.Qt.selectors = fake:example
-qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc zh_CN
-qhp.Qt.customFilters.Qt.name = Qt 4.7.0
-qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0
+qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc zh_CN
+qhp.Qt.customFilters.Qt.name = Qt 4.8.0
+qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0
# Files not referenced in any qdoc file (last four are needed by qtdemo)
# See also extraimages.HTML
diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp
index 9675f99..0d6b4da 100644
--- a/tools/qtconfig/mainwindow.cpp
+++ b/tools/qtconfig/mainwindow.cpp
@@ -63,6 +63,7 @@
#include <QInputContext>
#include <QInputContextFactory>
#include <QtDebug>
+#include <QPixmap>
#include <stdlib.h>
@@ -202,6 +203,7 @@ MainWindow::MainWindow()
{
modified = true;
desktopThemeName = tr("Desktop Settings (Default)");
+ setIcon(QPixmap(":/trolltech/qtconfig/images/appicon.png"));
QStringList gstyles = QStyleFactory::keys();
gstyles.sort();
gstylecombo->addItem(desktopThemeName);