14 # include "mediakeysobserver.h"
19 class QAbstractKineticScroller;
24 /** Visual representation of a book. */
25 class BookView: public QWebView
30 explicit BookView(QWidget *parent = 0);
32 /** Set current book. */
33 void setBook(Book *book);
35 /** Get current book. */
38 /** Go to the position decribed by "bookmark". */
39 void goToBookmark(const Book::Bookmark &bookmark);
41 /** Add bookmark to book at the current position. */
42 void addBookmark(const QString ¬e);
44 /** Save current reading position into book. */
45 void setLastBookmark(bool fast = false);
47 /** Go to given part + part fragment URL. */
48 void goToPart(int part, const QString &fragment);
50 /** Go to given fragment URL in current part. */
51 void goToFragment(const QString &fragment);
53 /** If grab is true, volume keys will generate act as page up/down. */
54 void grabVolumeKeys(bool grab);
56 /** Schedule restoring last reading position after loading part. */
57 void scheduleRestoreAfterLoad();
59 /** Schedule restoring last reading position. */
60 void scheduleRestoreLastBookmark();
63 /** Part loading started. */
64 void partLoadStart(int index);
66 /** Part loading finished. */
67 void partLoadEnd(int index);
69 /** Signal progress in reading the book. */
70 void progress(qreal p);
73 /** Go to next part. */
76 /** Go to previous part. */
79 /** Actions to perform after URL loading finished. */
80 void onLoadFinished(bool ok);
82 /** Handle settings changes. */
83 void onSettingsChanged(const QString &key);
85 /** Add QObjects to the main frame. */
86 void addJavaScriptObjects();
88 /** Go to previous page. */
89 void goPreviousPage();
91 /** Go to next page. */
95 /** Restore last reading position after part loading finished. */
96 void restoreAfterLoad();
98 /** Restore book's last reading position, load new part if needed. */
99 void restoreLastBookmark();
102 /** Observe media keys. */
103 void onMediaKeysPressed(MediaKeysObserver::MediaKeys key);
107 void paintEvent(QPaintEvent *e);
108 void mousePressEvent(QMouseEvent *e);
109 void wheelEvent(QWheelEvent *);
110 bool eventFilter(QObject *o, QEvent *e);
111 void timerEvent(QTimerEvent *e);
112 void hideEvent(QHideEvent *e);
114 /** Load given part. */
115 void loadContent(int index);
117 /** Get temporary directory for extracting book contents. */
120 /** Go to a given (relative) position in current part. */
121 void goToPosition(qreal position);
123 /** Show reading progress. */
127 int contentIndex; /**< Current part in book. */
128 Book *mBook; /**< Book to show. */
129 bool restorePositionAfterLoad;
130 /**< If true, restore reading position after load. */
131 qreal positionAfterLoad;
132 /**< Position to be restored after load. */
133 bool restoreFragmentAfterLoad;
134 /**< If true, restore fragment location after load. */
135 QString fragmentAfterLoad;
136 /**< Fragment location to be restored after load. */
137 QImage bookmarkImage;
138 /**< Bookmark icon pre-loaded. */
139 bool loaded; /**< True, if content has been loaded. */
140 bool mousePressed; /**< Event filter's mouse button state. */
141 bool grabbingVolumeKeys;
142 /**< True, if volume keys should be grabbed. */
143 QTimer *restoreTimer;
144 /**< Single timer for scheduling all restore ops. */
146 #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
147 int scrollerMonitor;/**< ID of timer monitoring kinetic scroll. */
150 #if defined(Q_WS_MAEMO_5)
151 QAbstractKineticScroller *scroller;
154 #if defined(Q_OS_SYMBIAN)
155 FlickCharm *charm; /**< Kinetic scroller. */