X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=bookview.h;h=9a177e60932328b1e5e0813d60d2fa5c044e2397;hb=HEAD;hp=e2e1d17270ddc44e54f63a5be83ef17ed0b6ab56;hpb=156e40ef8337b8c0d668fb33a9c8bf2b6b34ba79;p=dorian diff --git a/bookview.h b/bookview.h index e2e1d17..9a177e6 100644 --- a/bookview.h +++ b/bookview.h @@ -19,6 +19,7 @@ class Progress; class QAbstractKineticScroller; class ProgressDialog; class FlickCharm; +class QTimer; /** Visual representation of a book. */ class BookView: public QWebView @@ -27,18 +28,37 @@ class BookView: public QWebView public: explicit BookView(QWidget *parent = 0); + + /** Set current book. */ void setBook(Book *book); + + /** Get current book. */ Book *book(); + + /** Go to the position decribed by "bookmark". */ void goToBookmark(const Book::Bookmark &bookmark); + + /** Add bookmark to book at the current position. */ void addBookmark(const QString ¬e); - void setLastBookmark(); - void restoreLastBookmark(); + + /** Save current reading position into book. */ + void setLastBookmark(bool fast = false); + + /** Go to given part + part fragment URL. */ void goToPart(int part, const QString &fragment); + + /** Go to given fragment URL in current part. */ void goToFragment(const QString &fragment); /** If grab is true, volume keys will generate act as page up/down. */ void grabVolumeKeys(bool grab); + /** Schedule restoring last reading position after loading part. */ + void scheduleRestoreAfterLoad(); + + /** Schedule restoring last reading position. */ + void scheduleRestoreLastBookmark(); + signals: /** Part loading started. */ void partLoadStart(int index); @@ -46,9 +66,6 @@ signals: /** 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); @@ -74,10 +91,13 @@ public slots: /** Go to next page. */ void goNextPage(); - /** Restore saved position after URL loading finished. */ +protected slots: + /** Restore last reading position after part loading finished. */ void restoreAfterLoad(); -protected slots: + /** Restore book's last reading position, load new part if needed. */ + void restoreLastBookmark(); + #ifdef Q_OS_SYMBIAN /** Observe media keys. */ void onMediaKeysPressed(MediaKeysObserver::MediaKeys key); @@ -89,10 +109,7 @@ protected: void wheelEvent(QWheelEvent *); bool eventFilter(QObject *o, QEvent *e); void timerEvent(QTimerEvent *e); -#ifdef Q_WS_MAEMO_5 - void leaveEvent(QEvent *e); - void resizeEvent(QEvent *e); -#endif // Q_WS_MAEMO_5 + void hideEvent(QHideEvent *e); /** Load given part. */ void loadContent(int index); @@ -106,27 +123,36 @@ protected: /** Show reading progress. */ void showProgress(); - int contentIndex; /**< Current part in book. */ - Book *mBook; /**< Book to show. */ +private: + int contentIndex; /**< Current part in book. */ + Book *mBook; /**< Book to show. */ bool restorePositionAfterLoad; - /**< If true, restore current position after load. */ - qreal positionAfterLoad;/**< Position to be restored after load. */ + /**< If true, restore reading position after load. */ + qreal positionAfterLoad; + /**< Position to be restored after load. */ bool restoreFragmentAfterLoad; - /**< If true, restore fragment location after load. */ + /**< If true, restore fragment location after load. */ QString fragmentAfterLoad; - /**< Fragment location to be restored after load. */ - QImage bookmarkImage; /**< Bookmark icon pre-loaded. */ - bool loaded; /**< True, if content has been loaded. */ - bool mousePressed; /**< Event filter's mouse button state. */ - bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */ + /**< Fragment location to be restored after load. */ + QImage bookmarkImage; + /**< Bookmark icon pre-loaded. */ + bool loaded; /**< True, if content has been loaded. */ + bool mousePressed; /**< Event filter's mouse button state. */ + bool grabbingVolumeKeys; + /**< True, if volume keys should be grabbed. */ + QTimer *restoreTimer; + /**< Single timer for scheduling all restore ops. */ #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) - int scrollerMonitor; /**< ID of timer monitoring kinetic scroll. */ + 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 };