3
|
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();
|
9
|
55 |
void setGesturesEnabled(bool value) { m_gesturesEnabled = value; }
|
|
56 |
bool gesturesEnabled() { return m_gesturesEnabled; }
|
3
|
57 |
|
|
58 |
Q_SIGNALS:
|
|
59 |
void contextEventObject(QWebHitTestResult* eventTarget);
|
|
60 |
void viewScrolled(QPoint& scrollPos, QPoint& delta);
|
9
|
61 |
void mouseEvent(QEvent::Type type);
|
3
|
62 |
|
|
63 |
public Q_SLOTS:
|
|
64 |
void reset();
|
|
65 |
void contentsSizeChanged(const QSize&);
|
|
66 |
void pageLoadFinished(bool);
|
|
67 |
|
|
68 |
protected:
|
|
69 |
bool sceneEventFilter(QGraphicsItem*, QEvent*);
|
|
70 |
|
|
71 |
//From GestureListener
|
|
72 |
void handleGesture(GestureEvent*);
|
|
73 |
|
|
74 |
//Helpers
|
|
75 |
void handlePress(GestureEvent*);
|
|
76 |
void handleRelease(GestureEvent*);
|
|
77 |
void handleFlick(GestureEvent*);
|
|
78 |
void handleDoubleTap(GestureEvent*);
|
|
79 |
void handlePan(GestureEvent*);
|
|
80 |
void handleLongTap(GestureEvent*);
|
|
81 |
|
|
82 |
void setViewportWidgetGeometry(const QRectF& r);
|
|
83 |
void startZoomAnimToItemHotspot(const QPointF& hotspot, const QPointF& viewTargetHotspot, qreal scale, QRectF target = QRectF());
|
|
84 |
bool isZoomedIn() const;
|
|
85 |
|
|
86 |
//To handle kinetic scroller state changes
|
|
87 |
void stateChanged(KineticScrollable::State oldState, KineticScrollable::State newState);
|
|
88 |
|
|
89 |
void startZoomAnimation(const QRectF& zoomedRect);
|
|
90 |
void stopZoomAnimation();
|
|
91 |
void updateZoomEndRect();
|
|
92 |
void resizeEvent(QGraphicsSceneResizeEvent* event);
|
|
93 |
void adjustViewportSize(QSizeF oldSize, QSizeF newSize);
|
|
94 |
void sendEventToWebKit(QEvent::Type type, QPointF& scenPos);
|
|
95 |
|
|
96 |
protected Q_SLOTS:
|
|
97 |
void zoomAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State);
|
|
98 |
|
|
99 |
private:
|
|
100 |
GestureRecognizer m_gestureRecognizer;
|
|
101 |
QRectF m_animationEndRect;
|
|
102 |
QPropertyAnimation* m_zoomAnimator; //Animates zooming transitions
|
|
103 |
ViewportMetaData* m_viewportMetaData;
|
|
104 |
QTimer m_tileUpdateEnableTimer;
|
9
|
105 |
bool m_gesturesEnabled;
|
3
|
106 |
}; //ScrollableWebContentView
|
|
107 |
|
|
108 |
} //namespace GVA
|
|
109 |
|
|
110 |
#endif //ScrollableWebContentView_h
|