Struggle...
[dorian] / bookview.h
index b79e8bf..4a5e447 100644 (file)
 
 #include "book.h"
 
+#ifdef Q_OS_SYMBIAN
+#   include "mediakeysobserver.h"
+#endif
+
 class QModelIndex;
 class Progress;
 class QAbstractKineticScroller;
@@ -23,22 +27,37 @@ class BookView: public QWebView
 
 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);
+
+    /** Add bookmark to book at the current position. */
     void addBookmark(const QString &note);
-    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);
+
 signals:
+    /** Part loading started. */
     void partLoadStart(int index);
-    void partLoadEnd(int index);
 
-    /** Signal button press, when the real event has been suppressed. */
-    void suppressedMouseButtonPress();
+    /** Part loading finished. */
+    void partLoadEnd(int index);
 
     /** Signal progress in reading the book. */
     void progress(qreal p);
@@ -50,34 +69,43 @@ public slots:
     /** 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();
 
-    /** Handle main frame contents size changes. */
-    void onContentsSizeChanged(const QSize &size);
-
     /** 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();
+
+    /** Adjust web view position after orientation change. */
+    void adjustPosition(const QSize &size, const QSize &oldSize);
+
+protected slots:
+#ifdef Q_OS_SYMBIAN
+    /** Observe media keys. */
+    void onMediaKeysPressed(MediaKeysObserver::MediaKeys key);
+#endif
+
 protected:
     void paintEvent(QPaintEvent *e);
     void mousePressEvent(QMouseEvent *e);
     void wheelEvent(QWheelEvent *);
     bool eventFilter(QObject *o, QEvent *e);
-#ifdef Q_WS_MAEMO_5
-    void leaveEvent(QEvent *e);
-    void enterEvent(QEvent *e);
-#endif // Q_WS_MAEMO_5
     void timerEvent(QTimerEvent *e);
-    void keyPressEvent(QKeyEvent *e);
 
-private:
     /** Load given part. */
     void loadContent(int index);
 
@@ -90,29 +118,31 @@ private:
     /** 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 current 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;
-    int contentsHeight; /**< Last know height of the frame. */
+                            /**< 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;
+    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
 };