#endif
BookView::BookView(QWidget *parent):
- QWebView(parent), contentIndex(0), mBook(0), restore(true), restorePos(0),
- loadFinished(false)
+ QWebView(parent), contentIndex(-1), mBook(0),
+ restore(true), restorePos(0), loadFinished(false)
{
settings()->setAttribute(QWebSettings::AutoLoadImages, true);
settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
settings()->setAttribute(QWebSettings::PluginsEnabled, false);
settings()->setAttribute(QWebSettings::ZoomTextOnly, true);
- settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, false);
+ settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,
+ false);
page()->setContentEditable(false);
#if defined(Q_WS_MAEMO_5)
}
else {
loadFinished = false;
+ emit chapterLoadStart(index);
load(QUrl(contentFile));
}
contentIndex = index;
if (book != mBook) {
mBook = book;
if (book) {
+ contentIndex = -1;
book->open();
goToBookmark(book->lastBookmark());
}
else {
+ contentIndex = 0;
setHtml(tr("No book"));
}
}
if (mBook) {
restore = true;
restorePos = bookmark.pos;
- loadContent(bookmark.chapter);
+ if (bookmark.chapter != contentIndex) {
+ loadContent(bookmark.chapter);
+ } else {
+ onLoadFinished(true);
+ }
}
}
loadFinished = true;
addNavigationBar();
onSettingsChanged("scheme");
+ emit chapterLoadEnd(contentIndex);
if (restore) {
restore = false;
if (ok && mBook) {
void BookView::addNavigationBar()
{
- QWebFrame *frame = page()->currentFrame();
- frame->addToJavaScriptWindowObject("bv", this);
+ if (!mBook) {
+ return;
+ }
QString naviPrev =
"<a href=\"javascript:bv.goPrevious();\">"
+ tmpPath() +
"/next.png\" />"
"</a>";
-
if (contentIndex == 0) {
naviPrev = "";
}
naviNext = "";
}
+ QWebFrame *frame = page()->currentFrame();
+ frame->addToJavaScriptWindowObject("bv", this);
QString headerScript = "document.body.innerHTML = '" +
naviPrev + naviNext + "<br />" + "' + document.body.innerHTML;";
QString trailerScript = "document.body.innerHTML += '<br /><br />" +
frame->evaluateJavaScript(headerScript);
frame->evaluateJavaScript(trailerScript);
-
- // qDebug() << page()->currentFrame()->toHtml();
}
QString BookView::tmpPath()