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(
"/");
virtual ~HelpBrowser()
Destructor.
bool isBackwardAvailable()
Checks if we visited other pages before.
int currentPage_
Current position in the history.
void backward()
Show last page stored in the history.
void updateNameSpaceAndFolder(const QUrl &_url)
updateNameSpaceAndFolder
QHelpEngine * helpEngine_
The help engine the widget is working on.
QUrl resolveUrl(const QUrl &_url)
resolves relative urls to absolute
void rememberHistory(const QUrl &_url)
Adds a new page to the history.
QUrl getCurrentDir(const QUrl &_url)
Extract path from URL.
void forward()
Show next page stored in the history.
QVariant loadResource(int _type, const QUrl &_name)
re implementation of the load resource function of the text browser
QString currentNameSpace_
The currently active namespace.
bool isForwardAvailable()
Checks if the back button was pressed and we can go forward to the next page.
HelpBrowser(QHelpEngine *_helpEngine, QWidget *parent=0)
Constructor.
QList< QUrl > visitedPages_
History of the visited pages.
QString currentVirtualFolder_
The currently active virtual folder.