X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=bookview.h;h=9d25d2d46311de62aaaec19636a34c31701fc171;hb=74e2fba9252926d33bd5f37ec13c557af2ceca4d;hp=bb3269816618a624b0f0681ecf9743a5eb2aeb6e;hpb=3cbc168158c28a1ae9c30bdf2dc16504c9dab16c;p=dorian diff --git a/bookview.h b/bookview.h index bb32698..9d25d2d 100644 --- a/bookview.h +++ b/bookview.h @@ -6,48 +6,140 @@ #include #include #include +#include #include "book.h" +#ifdef Q_OS_SYMBIAN +# include "mediakeysobserver.h" +#endif + +class QModelIndex; +class Progress; +class QAbstractKineticScroller; +class ProgressDialog; +class FlickCharm; + +/** Visual representation of a book. */ class BookView: public QWebView { Q_OBJECT public: explicit BookView(QWidget *parent = 0); - virtual ~BookView(); + + /** 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); - void addBookmark(); + + /** Add bookmark to book at the current position. */ + void addBookmark(const QString ¬e); + + /** Save current reading position into book. */ void setLastBookmark(); + /** 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); + signals: - void chapterLoaded(int index); + /** Part loading started. */ + void partLoadStart(int index); + + /** 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); public slots: + /** Go to next part. */ void goPrevious(); + + /** Go to previous part. */ void goNext(); + + /** Actions to perform after URL loading finished. */ void onLoadFinished(bool ok); + + /** Handle settings changes. */ void onSettingsChanged(const QString &key); + /** Add QObjects to the main frame. */ + void addJavaScriptObjects(); + + /** Go to previous page. */ + void goPreviousPage(); + + /** Go to next page. */ + void goNextPage(); + + /** Restore saved position after URL loading finished. */ + void restoreAfterLoad(); + + /** Restore book's last reading position. */ + void restoreLastBookmark(); + +protected slots: +#ifdef Q_OS_SYMBIAN + /** Observe media keys. */ + void onMediaKeysPressed(MediaKeysObserver::MediaKeys key); +#endif + protected: - virtual void paintEvent(QPaintEvent *e); - virtual void mousePressEvent(QMouseEvent *e); + void paintEvent(QPaintEvent *e); + void mousePressEvent(QMouseEvent *e); + void wheelEvent(QWheelEvent *); + bool eventFilter(QObject *o, QEvent *e); + void timerEvent(QTimerEvent *e); -private: + /** Load given part. */ void loadContent(int index); - void addNavigationBar(); - void extractIcons(); - void removeIcons(); + + /** Get temporary directory for extracting book contents. */ QString tmpPath(); - int contentIndex; - Book *mBook; - bool restore; - qreal restorePos; - QImage bookmarkImage; - bool loadFinished; + /** Go to a given (relative) position in current part. */ + void goToPosition(qreal position); + + /** Show reading progress. */ + void showProgress(); + + 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. */ + bool restoreFragmentAfterLoad; + /**< 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. */ + +#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 }; #endif // BOOKVIEW_H