1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef VISUALFLOWLITE_H |
|
20 #define VISUALFLOWLITE_H |
|
21 |
|
22 #include <QWidget> |
|
23 #include <QKeyEvent> |
|
24 #include "FlowInterface.h" |
|
25 |
|
26 class QPainter; |
|
27 |
|
28 namespace WRT { |
|
29 |
|
30 class VisualFlowLite : public FlowInterface |
|
31 { |
|
32 Q_OBJECT |
|
33 public: |
|
34 VisualFlowLite(QWidget* parent); |
|
35 void init(); |
|
36 void addSlide(const QImage& image); |
|
37 void clear(); |
|
38 int slideCount() const; |
|
39 QImage slide(int index) const; |
|
40 void setCenterIndex(int i); |
|
41 int centerIndex() const; |
|
42 bool slideAnimationOngoing() const; |
|
43 void setCenterThumbnail(int i); |
|
44 void setCurrentIndex(int i); |
|
45 virtual ~VisualFlowLite(); |
|
46 void keyPressEvent(QKeyEvent* event); |
|
47 void paintEvent(QPaintEvent* event); |
|
48 void calculateLayout(); |
|
49 void showPrevious(); |
|
50 void showNext(); |
|
51 void paintNormalState(QPaintEvent* event); |
|
52 void paintInTransition(QPaintEvent* event); |
|
53 void setImagesScaled(bool scaled) { m_scalingAllowed = scaled; } |
|
54 QRect centralRect() const; |
|
55 |
|
56 signals: |
|
57 void centerIndexChanged(int index); |
|
58 void ok(int index); |
|
59 void cancel(); |
|
60 |
|
61 public slots: |
|
62 bool calcRepaintRect(); |
|
63 bool animatePlaceHolderPosition(); |
|
64 void scroll(); |
|
65 |
|
66 protected: |
|
67 void mousePressEvent(QMouseEvent* event); |
|
68 void resizeEvent(QResizeEvent* event); |
|
69 void mouseMoveEvent(QMouseEvent* event); |
|
70 void mouseReleaseEvent(QMouseEvent* event); |
|
71 |
|
72 private: |
|
73 enum PaintState { |
|
74 paintStateNormal, |
|
75 paintStateInTransition |
|
76 }; |
|
77 |
|
78 void paintImage(QPainter* painter, QRect rect, QImage image); |
|
79 |
|
80 // indicates the index of the center thumbnail |
|
81 int m_centerPageIndex; |
|
82 QRect m_offscreenRect; |
|
83 // represents the entry corresponding to the selected page in view |
|
84 // timer used to do animation |
|
85 QTimer* m_repaintTimer; |
|
86 //repaint rect using during animating initial display of the view |
|
87 QRect m_repaintRect; |
|
88 //resize factor applied during initial display animation |
|
89 int m_resizeFactor; |
|
90 //left place holder rectangle |
|
91 QRect m_leftPlaceHolderRect; |
|
92 //left place holder rectangle |
|
93 QRect m_centerPlaceHolderRect; |
|
94 //left place holder rectangle |
|
95 QRect m_rightPlaceHolderRect; |
|
96 //Left Arrow position |
|
97 QPoint m_leftArrow[3]; |
|
98 //Right arrow position |
|
99 QPoint m_rightArrow[3]; |
|
100 //Factor used during animation of place holders |
|
101 int m_placeHolderResizeFactor; |
|
102 //Direction of movement |
|
103 int m_direction; |
|
104 //Flag to check if fast animation is needed or not |
|
105 bool m_fastScroll; |
|
106 PaintState m_paintState; |
|
107 // Initial position |
|
108 int m_currentIndex; |
|
109 QList<const QImage*> m_imageList; |
|
110 QPoint m_lastMoveEventPos; |
|
111 QTimer* m_scrollTimer; |
|
112 bool m_scalingAllowed; |
|
113 }; |
|
114 |
|
115 } |
|
116 #endif // VISUALFLOWLITE_H |
|
117 |
|