aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/help/textbrowserhelpviewer.cpp
diff options
context:
space:
mode:
authorEike Ziller <[email protected]>2014-05-06 13:37:06 +0200
committerEike Ziller <[email protected]>2014-05-13 09:00:18 +0200
commit1228ffcd6c059693d8138dabc9575b66f2d74f1c (patch)
treea7f2890e92f5aa1ae2dd7b4164a09984731ba235 /src/plugins/help/textbrowserhelpviewer.cpp
parent96e8f0bb7b4e289af45c17bf66026fca47b1e626 (diff)
Help: Implement history menus for text browser backend
Change-Id: Idbdb3f9807c8282f8c9050ba28c1e28a7e3865e7 Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/plugins/help/textbrowserhelpviewer.cpp')
-rw-r--r--src/plugins/help/textbrowserhelpviewer.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/plugins/help/textbrowserhelpviewer.cpp b/src/plugins/help/textbrowserhelpviewer.cpp
index 746f556c011..5e7f5c07a80 100644
--- a/src/plugins/help/textbrowserhelpviewer.cpp
+++ b/src/plugins/help/textbrowserhelpviewer.cpp
@@ -34,6 +34,7 @@
#include <coreplugin/find/findplugin.h>
#include <utils/hostosinfo.h>
+#include <utils/qtcassert.h>
#include <QApplication>
#include <QClipboard>
@@ -193,6 +194,28 @@ bool TextBrowserHelpViewer::isBackwardAvailable() const
return m_textBrowser->isBackwardAvailable();
}
+void TextBrowserHelpViewer::addBackHistoryItems(QMenu *backMenu)
+{
+ for (int i = 1; i <= m_textBrowser->backwardHistoryCount(); ++i) {
+ QAction *action = new QAction(backMenu);
+ action->setText(m_textBrowser->historyTitle(-i));
+ action->setData(-i);
+ connect(action, SIGNAL(triggered()), this, SLOT(goToHistoryItem()));
+ backMenu->addAction(action);
+ }
+}
+
+void TextBrowserHelpViewer::addForwardHistoryItems(QMenu *forwardMenu)
+{
+ for (int i = 1; i <= m_textBrowser->forwardHistoryCount(); ++i) {
+ QAction *action = new QAction(forwardMenu);
+ action->setText(m_textBrowser->historyTitle(i));
+ action->setData(i);
+ connect(action, SIGNAL(triggered()), this, SLOT(goToHistoryItem()));
+ forwardMenu->addAction(action);
+ }
+}
+
void TextBrowserHelpViewer::setOpenInNewWindowActionVisible(bool visible)
{
m_textBrowser->showOpenInNewWindowAction = visible;
@@ -277,6 +300,25 @@ void TextBrowserHelpViewer::print(QPrinter *printer)
m_textBrowser->print(printer);
}
+void TextBrowserHelpViewer::goToHistoryItem()
+{
+ QAction *action = qobject_cast<QAction *>(sender());
+ QTC_ASSERT(action, return);
+ bool ok = false;
+ int index = action->data().toInt(&ok);
+ QTC_ASSERT(ok, return);
+ // go back?
+ while (index < 0) {
+ m_textBrowser->backward();
+ ++index;
+ }
+ // go forward?
+ while (index > 0) {
+ m_textBrowser->forward();
+ --index;
+ }
+}
+
// -- private
TextBrowserHelpWidget::TextBrowserHelpWidget(int zoom, TextBrowserHelpViewer *parent)