|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #ifndef ScrollableWebContentView_h |
|
23 #define ScrollableWebContentView_h |
|
24 |
|
25 #include "Gestures/GestureEvent.h" |
|
26 #include "Gestures/GestureListener.h" |
|
27 #include "Gestures/GestureRecognizer.h" |
|
28 #include "ScrollableViewBase.h" |
|
29 #include "ZoomMetaData.h" |
|
30 |
|
31 #include <QPropertyAnimation> |
|
32 #include <QTimer> |
|
33 |
|
34 class QWebHitTestResult; |
|
35 |
|
36 namespace GVA { |
|
37 |
|
38 class ViewportMetaData; |
|
39 class WebContentAnimationItem; |
|
40 |
|
41 class ScrollableWebContentView : public ScrollableViewBase, protected GestureListener { |
|
42 Q_OBJECT |
|
43 public: |
|
44 ScrollableWebContentView(WebContentAnimationItem* viewportProxyWidget, QGraphicsItem* parent = 0); |
|
45 ~ScrollableWebContentView(); |
|
46 |
|
47 WebContentAnimationItem* viewportWidget() const; |
|
48 void zoomToScreenCenter(bool zoomIn); |
|
49 |
|
50 ZoomMetaData currentPageInfo(); |
|
51 void setCurrentPageInfo(ZoomMetaData data); |
|
52 ZoomMetaData defaultZoomData(); |
|
53 void updatePreferredContentSize(); |
|
54 void setSuperPage(); |
|
55 |
|
56 Q_SIGNALS: |
|
57 void contextEventObject(QWebHitTestResult* eventTarget); |
|
58 void viewScrolled(QPoint& scrollPos, QPoint& delta); |
|
59 |
|
60 public Q_SLOTS: |
|
61 void reset(); |
|
62 void contentsSizeChanged(const QSize&); |
|
63 void pageLoadFinished(bool); |
|
64 |
|
65 protected: |
|
66 bool sceneEventFilter(QGraphicsItem*, QEvent*); |
|
67 |
|
68 //From GestureListener |
|
69 void handleGesture(GestureEvent*); |
|
70 |
|
71 //Helpers |
|
72 void handlePress(GestureEvent*); |
|
73 void handleRelease(GestureEvent*); |
|
74 void handleFlick(GestureEvent*); |
|
75 void handleDoubleTap(GestureEvent*); |
|
76 void handlePan(GestureEvent*); |
|
77 void handleLongTap(GestureEvent*); |
|
78 |
|
79 void setViewportWidgetGeometry(const QRectF& r); |
|
80 void startZoomAnimToItemHotspot(const QPointF& hotspot, const QPointF& viewTargetHotspot, qreal scale, QRectF target = QRectF()); |
|
81 bool isZoomedIn() const; |
|
82 |
|
83 //To handle kinetic scroller state changes |
|
84 void stateChanged(KineticScrollable::State oldState, KineticScrollable::State newState); |
|
85 |
|
86 void startZoomAnimation(const QRectF& zoomedRect); |
|
87 void stopZoomAnimation(); |
|
88 void updateZoomEndRect(); |
|
89 void resizeEvent(QGraphicsSceneResizeEvent* event); |
|
90 void adjustViewportSize(QSizeF oldSize, QSizeF newSize); |
|
91 void sendEventToWebKit(QEvent::Type type, QPointF& scenPos); |
|
92 |
|
93 protected Q_SLOTS: |
|
94 void zoomAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State); |
|
95 |
|
96 private: |
|
97 GestureRecognizer m_gestureRecognizer; |
|
98 QRectF m_animationEndRect; |
|
99 QPropertyAnimation* m_zoomAnimator; //Animates zooming transitions |
|
100 ViewportMetaData* m_viewportMetaData; |
|
101 QTimer m_tileUpdateEnableTimer; |
|
102 }; //ScrollableWebContentView |
|
103 |
|
104 } //namespace GVA |
|
105 |
|
106 #endif //ScrollableWebContentView_h |