Make orientation switch explicit on Symbian, too.
[dorian] / bookview.h
1 #ifndef BOOKVIEW_H
2 #define BOOKVIEW_H
3
4 #include <QWebView>
5 #include <QString>
6 #include <QStringList>
7 #include <QHash>
8 #include <QImage>
9 #include <QPoint>
10
11 #include "book.h"
12
13 #ifdef Q_OS_SYMBIAN
14 #   include "mediakeysobserver.h"
15 #endif
16
17 class QModelIndex;
18 class Progress;
19 class QAbstractKineticScroller;
20 class ProgressDialog;
21 class FlickCharm;
22
23 /** Visual representation of a book. */
24 class BookView: public QWebView
25 {
26     Q_OBJECT
27
28 public:
29     explicit BookView(QWidget *parent = 0);
30
31     /** Set current book. */
32     void setBook(Book *book);
33
34     /** Get current book. */
35     Book *book();
36
37     /** Go to the position decribed by "bookmark". */
38     void goToBookmark(const Book::Bookmark &bookmark);
39
40     /** Add bookmark to book at the current position. */
41     void addBookmark(const QString &note);
42
43     /** Save current reading position into book. */
44     void setLastBookmark(bool fast = false);
45
46     /** Go to given part + part fragment URL. */
47     void goToPart(int part, const QString &fragment);
48
49     /** Go to given fragment URL in current part. */
50     void goToFragment(const QString &fragment);
51
52     /** If grab is true, volume keys will generate act as page up/down. */
53     void grabVolumeKeys(bool grab);
54
55 signals:
56     /** Part loading started. */
57     void partLoadStart(int index);
58
59     /** Part loading finished. */
60     void partLoadEnd(int index);
61
62     /** Signal progress in reading the book. */
63     void progress(qreal p);
64
65 public slots:
66     /** Go to next part. */
67     void goPrevious();
68
69     /** Go to previous part. */
70     void goNext();
71
72     /** Actions to perform after URL loading finished. */
73     void onLoadFinished(bool ok);
74
75     /** Handle settings changes. */
76     void onSettingsChanged(const QString &key);
77
78     /** Add QObjects to the main frame. */
79     void addJavaScriptObjects();
80
81     /** Go to previous page. */
82     void goPreviousPage();
83
84     /** Go to next page. */
85     void goNextPage();
86
87     /** Restore saved position after URL loading finished. */
88     void restoreAfterLoad();
89
90     /** Restore book's last reading position. */
91     void restoreLastBookmark();
92
93 protected slots:
94 #ifdef Q_OS_SYMBIAN
95     /** Observe media keys. */
96     void onMediaKeysPressed(MediaKeysObserver::MediaKeys key);
97 #endif
98
99 protected:
100     void paintEvent(QPaintEvent *e);
101     void mousePressEvent(QMouseEvent *e);
102     void wheelEvent(QWheelEvent *);
103     bool eventFilter(QObject *o, QEvent *e);
104     void timerEvent(QTimerEvent *e);
105
106     /** Load given part. */
107     void loadContent(int index);
108
109     /** Get temporary directory for extracting book contents. */
110     QString tmpPath();
111
112     /** Go to a given (relative) position in current part. */
113     void goToPosition(qreal position);
114
115     /** Show reading progress. */
116     void showProgress();
117
118 private:
119     int contentIndex;       /**< Current part in book. */
120     Book *mBook;            /**< Book to show. */
121     bool restorePositionAfterLoad;
122                             /**< If true, restore current position after load. */
123     qreal positionAfterLoad;/**< Position to be restored after load. */
124     bool restoreFragmentAfterLoad;
125                             /**< If true, restore fragment location after load. */
126     QString fragmentAfterLoad;
127                             /**< Fragment location to be restored after load. */
128     QImage bookmarkImage;   /**< Bookmark icon pre-loaded. */
129     bool loaded;            /**< True, if content has been loaded. */
130     bool mousePressed;      /**< Event filter's mouse button state. */
131     bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */
132
133 #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
134     int scrollerMonitor;    /**< ID of timer monitoring kinetic scroll. */
135 #endif
136
137 #if defined(Q_WS_MAEMO_5)
138     QAbstractKineticScroller *scroller;
139 #endif
140
141 #if defined(Q_OS_SYMBIAN)
142     FlickCharm *charm;      /**< Kinetic scroller. */
143 #endif
144 };
145
146 #endif // BOOKVIEW_H