void AdopterWindow::resizeEvent(QResizeEvent *event)
{
Trace t("AdopterWindow::resizeEvent");
+#if defined(Q_OS_SYMBIAN)
+ if (bookView) {
+ bookView->setLastBookmark();
+ }
+#endif
MainBase::resizeEvent(event);
placeDecorations();
+#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
if (bookView) {
QTimer::singleShot(110, bookView, SLOT(restoreLastBookmark()));
}
+#endif
}
void AdopterWindow::closeEvent(QCloseEvent *event)
}
}
-void BookView::setLastBookmark()
+void BookView::setLastBookmark(bool fast)
{
TRACE;
if (mBook) {
int pos = frame->scrollPosition().y();
qDebug() << QString("At %1 (%2%, height %3)").
arg(pos).arg((qreal)pos / (qreal)height * 100).arg(height);
- mBook->setLastBookmark(contentIndex, (qreal)pos / (qreal)height);
+ mBook->setLastBookmark(contentIndex, (qreal)pos / (qreal)height, fast);
}
}
if (scroller) {
scrollerMonitor = startTimer(500);
}
+#elif defined(Q_OS_SYMBIAN)
+ // Do nothing
#else
- // Handle mouse presses on the scroll bar
+ // Handle mouse press on the scroll bar
QWebFrame *frame = page()->mainFrame();
if (frame->scrollBarGeometry(Qt::Vertical).contains(e->pos())) {
e->accept();
return;
}
-#endif // Q_WS_MAEMO_5
+#endif
e->ignore();
}
// Work around Qt bug that sometimes selects web view contents during swipe
switch (e->type()) {
case QEvent::MouseButtonPress:
- emit suppressedMouseButtonPress();
mousePressed = true;
break;
case QEvent::MouseButtonRelease:
scrollerMonitor = -1;
}
}
-#endif
+#endif // Q_WS_MAEMO_5
+
QWebView::timerEvent(e);
}
if (pos == frame->scrollPosition().y()) {
goNext();
} else {
- // setLastBookmark();
showProgress();
}
}
}
#endif // Q_OS_SYMBIAN
+
+void BookView::adjustPosition(const QSize &size, const QSize &oldSize)
+{
+ if (mBook) {
+ QWebFrame *frame = page()->mainFrame();
+ int height = frame->contentsSize().height();
+ int pos = frame->scrollPosition().y();
+ qDebug() << QString("At %1 (%2%, height %3)").
+ arg(pos).arg((qreal)pos / (qreal)height * 100).arg(height);
+ }
+}
void addBookmark(const QString ¬e);
/** Save current reading position into book. */
- void setLastBookmark();
+ void setLastBookmark(bool fast = false);
/** Go to given part + part fragment URL. */
void goToPart(int part, const QString &fragment);
/** Part loading finished. */
void partLoadEnd(int index);
- /** Signal button press, when the real event has been suppressed. */
- void suppressedMouseButtonPress();
-
/** Signal progress in reading the book. */
void progress(qreal p);
/** Restore book's last reading position. */
void restoreLastBookmark();
+ /** Adjust web view position after orientation change. */
+ void adjustPosition(const QSize &size, const QSize &oldSize);
+
protected slots:
#ifdef Q_OS_SYMBIAN
/** Observe media keys. */
/** Show reading progress. */
void showProgress();
+private:
int contentIndex; /**< Current part in book. */
Book *mBook; /**< Book to show. */
bool restorePositionAfterLoad;
#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
int scrollerMonitor; /**< ID of timer monitoring kinetic scroll. */
#endif
+
#if defined(Q_WS_MAEMO_5)
QAbstractKineticScroller *scroller;
-#elif defined(Q_OS_SYMBIAN)
- FlickCharm *charm;
+#endif
+
+#if defined(Q_OS_SYMBIAN)
+ FlickCharm *charm; /**< Kinetic scroller. */
#endif
};
BookDb::instance()->save(path(), data);
}
-void Book::setLastBookmark(int part, qreal position)
+void Book::setLastBookmark(int part, qreal position, bool fast)
{
TRACE;
- load();
+ if (!fast) {
+ load();
+ }
mLastBookmark.part = part;
mLastBookmark.pos = position;
- save();
+ if (!fast) {
+ save();
+ }
}
Book::Bookmark Book::lastBookmark()
bool clearDir(const QString &directory);
/** Set last bookmark. */
- void setLastBookmark(int part, qreal position);
+ void setLastBookmark(int part, qreal position, bool fast = false);
/** Get last bookmark. */
Bookmark lastBookmark();