Commit c0b99d53 authored by Matthias Möller's avatar Matthias Möller
Browse files

fix: back/forward button works when link in textbrowser was clicked

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14398 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5b171208
...@@ -59,7 +59,7 @@ HelpBrowser::HelpBrowser(QHelpEngine* _helpEngine, QWidget* parent) : ...@@ -59,7 +59,7 @@ HelpBrowser::HelpBrowser(QHelpEngine* _helpEngine, QWidget* parent) :
currentVirtualFolder_(""), currentVirtualFolder_(""),
currentNameSpace_("") currentNameSpace_("")
{ {
connect(this, SIGNAL(sourceChanged(const QUrl&)), this, SLOT(rememberHistory(const QUrl&)));
} }
HelpBrowser::~HelpBrowser() { HelpBrowser::~HelpBrowser() {
...@@ -85,11 +85,12 @@ void HelpBrowser::updateNameSpaceAndFolder (const QUrl& _url) { ...@@ -85,11 +85,12 @@ void HelpBrowser::updateNameSpaceAndFolder (const QUrl& _url) {
void HelpBrowser::rememberHistory (const QUrl& _url) { void HelpBrowser::rememberHistory (const QUrl& _url) {
QUrl newUrl = resolveUrl(_url);
// Delete the visited pages after the current position if they exist // Delete the visited pages after the current position if they exist
if ( currentPage_ < visitedPages_.size()-1 ) if ( currentPage_ < visitedPages_.size()-1 )
visitedPages_.erase((visitedPages_.begin()+currentPage_),visitedPages_.end()); visitedPages_.erase((visitedPages_.begin()+currentPage_),visitedPages_.end());
visitedPages_.push_back(_url); visitedPages_.push_back(newUrl);
currentPage_ = visitedPages_.size()-1; currentPage_ = visitedPages_.size()-1;
} }
...@@ -142,7 +143,7 @@ QVariant HelpBrowser::loadResource (int /*_type*/, const QUrl& _url) { ...@@ -142,7 +143,7 @@ QVariant HelpBrowser::loadResource (int /*_type*/, const QUrl& _url) {
void HelpBrowser::open(const QString& _url) { void HelpBrowser::open(const QString& _url) {
open(QUrl(_url)); open(QUrl(_url));
} }emit sourceChanged( _url );
void HelpBrowser::open(const QUrl& _url, bool _skipSave) { void HelpBrowser::open(const QUrl& _url, bool _skipSave) {
...@@ -163,16 +164,21 @@ void HelpBrowser::open(const QUrl& _url, bool _skipSave) { ...@@ -163,16 +164,21 @@ void HelpBrowser::open(const QUrl& _url, bool _skipSave) {
setHtml(txt); setHtml(txt);
if(!_skipSave)
rememberHistory(_url);
//jumps to a reference (Doxygen reference name and not section name) //jumps to a reference (Doxygen reference name and not section name)
//references are at the end of url after last '#' //references are at the end of url after last '#'
QStringList Anchor = _url.toString().split("#"); QStringList Anchor = _url.toString().split("#");
if (Anchor.size() > 1) if (Anchor.size() > 1)
this->scrollToAnchor(Anchor[Anchor.size()-1]); this->scrollToAnchor(Anchor[Anchor.size()-1]);
emit sourceChanged( _url ); if (_skipSave)
{
disconnect(this,SLOT(rememberHistory(const QUrl&)));
emit sourceChanged( _url );
connect(this, SIGNAL(sourceChanged(const QUrl&)), this, SLOT(rememberHistory(const QUrl&)));
}
else
emit sourceChanged( _url );
} }
QUrl HelpBrowser::getCurrentDir(const QUrl& _url) { QUrl HelpBrowser::getCurrentDir(const QUrl& _url) {
...@@ -203,7 +209,7 @@ void HelpBrowser::backward() { ...@@ -203,7 +209,7 @@ void HelpBrowser::backward() {
if(isBackwardAvailable()) { if(isBackwardAvailable()) {
currentPage_--; currentPage_--;
open(visitedPages_[currentPage_-1], true); open(visitedPages_[currentPage_], true);
} }
} }
......
...@@ -150,11 +150,13 @@ private: ...@@ -150,11 +150,13 @@ private:
*/ */
void updateNameSpaceAndFolder (const QUrl& _url); void updateNameSpaceAndFolder (const QUrl& _url);
private slots:
/** \brief Adds a new page to the history /** \brief Adds a new page to the history
* *
* @param _url URL of the new page * @param _url URL of the new page
*/ */
void rememberHistory (const QUrl& _url); void rememberHistory (const QUrl& _url);
private:
/// The help engine the widget is working on /// The help engine the widget is working on
QHelpEngine* helpEngine_; QHelpEngine* helpEngine_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment