57 #include "helpBrowser.hh" 64 helpEngine_(_helpEngine),
66 currentVirtualFolder_(
""),
69 connect(
this, SIGNAL(sourceChanged(
const QUrl&)),
this, SLOT(
rememberHistory(
const QUrl&)));
80 QString link = _url.toString();
81 QStringList linkParts = link.split(
"/");
83 if ( linkParts.size() > 3) {
89 std::cerr <<
"Unable to detect virtual folder or namespace of this link" << _url.toString().toStdString() << std::endl;
109 emit historyChanged(_url);
114 if (_url.scheme() ==
"qthelp") {
123 if ( _url.toString().startsWith(
"..") ) {
127 newUrl = tmpURL.resolved(_url);
146 const QUrl newFileUrl =
helpEngine_->findFile(newUrl);
148 if(newFileUrl.isValid())
149 return QVariant(
helpEngine_->fileData(newFileUrl));
151 std::cerr <<
"Unable to find file at url : " << _url.toString().toStdString() << std::endl;
152 return QVariant(
"Page not Found.");
157 void HelpBrowser::open(
const QString& _url) {
162 void HelpBrowser::open(
const QUrl& _url,
bool _skipSave) {
164 QVariant data = this->
loadResource(QTextDocument::HtmlResource, _url);
168 txt = data.toString();
174 QStringList Anchor = _url.toString().split(
"#");
175 if (Anchor.size() > 1)
176 this->scrollToAnchor(Anchor[Anchor.size()-1]);
181 emit sourceChanged( _url );
182 connect(
this, SIGNAL(sourceChanged(
const QUrl&)),
this, SLOT(
rememberHistory(
const QUrl&)));
185 emit sourceChanged( _url );
191 QStringList str_list = _url.toString().split(
"/");
193 if ( str_list.size() > 0 )
194 str_list[str_list.size() - 1] =
"";
196 std::cerr <<
"Warning, getCurrentDir got invalid input: " << _url.toString().toStdString() << std::endl;
198 QString nstr = str_list.join(
"/");
void rememberHistory(const QUrl &_url)
Adds a new page to the history.
bool isForwardAvailable()
Checks if the back button was pressed and we can go forward to the next page.
void backward()
Show last page stored in the history.
QUrl getCurrentDir(const QUrl &_url)
Extract path from URL.
QHelpEngine * helpEngine_
The help engine the widget is working on.
QUrl resolveUrl(const QUrl &_url)
resolves relative urls to absolute
virtual ~HelpBrowser()
Destructor.
QString currentNameSpace_
The currently active namespace.
void updateNameSpaceAndFolder(const QUrl &_url)
updateNameSpaceAndFolder
QList< QUrl > visitedPages_
History of the visited pages.
QVariant loadResource(int _type, const QUrl &_name)
re implementation of the load resource function of the text browser
bool isBackwardAvailable()
Checks if we visited other pages before.
HelpBrowser(QHelpEngine *_helpEngine, QWidget *parent=0)
Constructor.
int currentPage_
Current position in the history.
QString currentVirtualFolder_
The currently active virtual folder.
void forward()
Show next page stored in the history.