42 #include "helpBrowser.hh" 49 helpEngine_(_helpEngine),
51 currentVirtualFolder_(
""),
54 connect(
this, SIGNAL(sourceChanged(
const QUrl&)),
this, SLOT(
rememberHistory(
const QUrl&)));
65 QString link = _url.toString();
66 QStringList linkParts = link.split(
"/");
68 if ( linkParts.size() > 3) {
74 std::cerr <<
"Unable to detect virtual folder or namespace of this link" << _url.toString().toStdString() << std::endl;
94 emit historyChanged(_url);
99 if (_url.scheme() ==
"qthelp") {
108 if ( _url.toString().startsWith(
"..") ) {
112 newUrl = tmpURL.resolved(_url);
131 const QUrl newFileUrl =
helpEngine_->findFile(newUrl);
133 if(newFileUrl.isValid())
134 return QVariant(
helpEngine_->fileData(newFileUrl));
136 std::cerr <<
"Unable to find file at url : " << _url.toString().toStdString() << std::endl;
137 return QVariant(
"Page not Found.");
142 void HelpBrowser::open(
const QString& _url) {
147 void HelpBrowser::open(
const QUrl& _url,
bool _skipSave) {
149 QVariant data = this->
loadResource(QTextDocument::HtmlResource, _url);
153 txt = data.toString();
159 QStringList Anchor = _url.toString().split(
"#");
160 if (Anchor.size() > 1)
161 this->scrollToAnchor(Anchor[Anchor.size()-1]);
166 emit sourceChanged( _url );
167 connect(
this, SIGNAL(sourceChanged(
const QUrl&)),
this, SLOT(
rememberHistory(
const QUrl&)));
170 emit sourceChanged( _url );
176 QStringList str_list = _url.toString().split(
"/");
178 if ( str_list.size() > 0 )
179 str_list[str_list.size() - 1] =
"";
181 std::cerr <<
"Warning, getCurrentDir got invalid input: " << _url.toString().toStdString() << std::endl;
183 QString nstr = str_list.join(
"/");
bool isBackwardAvailable()
Checks if we visited other pages before.
HelpBrowser(QHelpEngine *_helpEngine, QWidget *parent=0)
Constructor.
QList< QUrl > visitedPages_
History of the visited pages.
void updateNameSpaceAndFolder(const QUrl &_url)
updateNameSpaceAndFolder
QVariant loadResource(int _type, const QUrl &_name)
re implementation of the load resource function of the text browser
void rememberHistory(const QUrl &_url)
Adds a new page to the history.
QUrl resolveUrl(const QUrl &_url)
resolves relative urls to absolute
virtual ~HelpBrowser()
Destructor.
int currentPage_
Current position in the history.
QString currentVirtualFolder_
The currently active virtual folder.
bool isForwardAvailable()
Checks if the back button was pressed and we can go forward to the next page.
QUrl getCurrentDir(const QUrl &_url)
Extract path from URL.
void backward()
Show last page stored in the history.
QString currentNameSpace_
The currently active namespace.
QHelpEngine * helpEngine_
The help engine the widget is working on.
void forward()
Show next page stored in the history.