summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-05-12 13:07:52 (GMT)
committerck <qt-info@nokia.com>2010-05-14 07:40:19 (GMT)
commit2e649d8dc0c1ce0b54ac10e8c95ce6d047bdb0db (patch)
tree0efea950fc74554c6a3e40ea60e5950517190fc3 /tools/assistant
parent0c6973b15cc3884f35d7d414ab7d23d365c768e8 (diff)
downloadQt-2e649d8dc0c1ce0b54ac10e8c95ce6d047bdb0db.zip
Qt-2e649d8dc0c1ce0b54ac10e8c95ce6d047bdb0db.tar.gz
Qt-2e649d8dc0c1ce0b54ac10e8c95ce6d047bdb0db.tar.bz2
Assistant: Enable switching between pages via an in-page combo box.
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp29
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h3
-rw-r--r--tools/assistant/tools/assistant/helpviewer_p.h42
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qtb.cpp16
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.cpp16
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.cpp2
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.h8
7 files changed, 95 insertions, 21 deletions
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index dfcacd1..81870a9 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include "helpviewer.h"
+#include "helpviewer_p.h"
+
#include "helpenginewrapper.h"
#include "tracer.h"
@@ -49,6 +51,7 @@
#include <QtCore/QTemporaryFile>
#include <QtCore/QUrl>
+#include <QtGui/QComboBox>
#include <QtGui/QDesktopServices>
#include <QtGui/QMouseEvent>
@@ -205,4 +208,30 @@ bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *event)
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 fc3d753..d881545 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -144,6 +144,9 @@ private:
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;
diff --git a/tools/assistant/tools/assistant/helpviewer_p.h b/tools/assistant/tools/assistant/helpviewer_p.h
index 631d65f..2bd4e16 100644
--- a/tools/assistant/tools/assistant/helpviewer_p.h
+++ b/tools/assistant/tools/assistant/helpviewer_p.h
@@ -47,7 +47,11 @@
#include "openpagesmanager.h"
#include <QtCore/QObject>
+#include <QtGui/QComboBox>
+#ifdef QT_NO_WEBKIT
#include <QtGui/QTextBrowser>
+#endif
+#include <QtGui/QTreeView>
QT_BEGIN_NAMESPACE
@@ -56,13 +60,19 @@ 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);
@@ -88,8 +98,25 @@ public:
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);
@@ -104,6 +131,17 @@ 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
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
index a73e1e1..98eb59f 100644
--- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
@@ -79,12 +79,6 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
}
-HelpViewer::~HelpViewer()
-{
- TRACE_OBJ
- delete d;
-}
-
QFont HelpViewer::viewerFont() const
{
TRACE_OBJ
@@ -304,6 +298,11 @@ void HelpViewer::mousePressEvent(QMouseEvent *e)
if (handleForwardBackwardMouseButtons(e))
return;
#endif
+ if (openPagesListRequested(e)) {
+ showOpenPagesList(e->pos());
+ return;
+ }
+
QTextBrowser::mousePressEvent(e);
}
@@ -346,8 +345,11 @@ bool HelpViewer::eventFilter(QObject *obj, QEvent *event)
void HelpViewer::contextMenuEvent(QContextMenuEvent *event)
{
TRACE_OBJ
- QMenu menu(QLatin1String(""), 0);
+ if (openPagesListRequested(event))
+ return;
+
+ QMenu menu(QString(), 0);
QUrl link;
QAction *copyAnchorAction = 0;
if (d->hasAnchorAt(this, event->pos())) {
diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
index 4fde20f..f9c8161 100644
--- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp
+++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "helpviewer.h"
+#include "helpviewer_p.h"
#include "centralwidget.h"
#include "helpenginewrapper.h"
@@ -242,7 +243,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
// -- HelpViewer
HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
- : QWebView(parent)
+ : QWebView(parent), d(new HelpViewerPrivate)
{
TRACE_OBJ
setAcceptDrops(false);
@@ -275,11 +276,6 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
}
-HelpViewer::~HelpViewer()
-{
- TRACE_OBJ
-}
-
QFont HelpViewer::viewerFont() const
{
TRACE_OBJ
@@ -435,6 +431,11 @@ void HelpViewer::mousePressEvent(QMouseEvent *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();
@@ -479,7 +480,8 @@ bool HelpViewer::eventFilter(QObject *obj, QEvent *event)
void HelpViewer::contextMenuEvent(QContextMenuEvent *event)
{
TRACE_OBJ
- QWebView::contextMenuEvent(event);
+ if (!openPagesListRequested(event))
+ QWebView::contextMenuEvent(event);
}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp
index 6db1879..b6005e8 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.cpp
+++ b/tools/assistant/tools/assistant/openpagesmanager.cpp
@@ -280,7 +280,7 @@ void OpenPagesManager::closePagesExcept(const QModelIndex &index)
}
}
-QWidget *OpenPagesManager::openPagesWidget() const
+QAbstractItemView *OpenPagesManager::openPagesWidget() const
{
return m_openPagesWidget;
}
diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h
index 407ee79..5e7a9af 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.h
+++ b/tools/assistant/tools/assistant/openpagesmanager.h
@@ -46,9 +46,9 @@
QT_BEGIN_NAMESPACE
+class QAbstractItemView;
class QModelIndex;
class QUrl;
-class QWidget;
class HelpViewer;
class OpenPagesModel;
@@ -66,10 +66,11 @@ class OpenPagesManager : public QObject
void closePages(const QString &nameSpace);
void reloadPages(const QString &nameSpace);
- QWidget* openPagesWidget() const;
+ 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);
@@ -88,7 +89,6 @@ private:
const QUrl &cmdLineUrl);
void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl);
void closeOrReloadPages(const QString &nameSpace, bool tryReload);
- void setCurrentPage(int index);
void selectCurrentPage();
void removePage(int index);
void nextOrPreviousPage(int offset);