|
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 LINEARFLOWSNIPPET_H |
|
20 #define LINEARFLOWSNIPPET_H |
|
21 |
|
22 #include <QTime> |
|
23 #include <QImage> |
|
24 #include <QWidget> |
|
25 #include <QGraphicsWidget> |
|
26 #include <QGraphicsItem> |
|
27 |
|
28 class DragPoint |
|
29 { |
|
30 public: |
|
31 QPoint iPoint; |
|
32 QTime iTime; |
|
33 }; |
|
34 |
|
35 namespace GVA { |
|
36 |
|
37 class Filmstrip; |
|
38 class FilmstripFlowPrivate; |
|
39 class FilmstripMovieFactory; |
|
40 |
|
41 /*! |
|
42 Class GraphicsFilmstripFlow |
|
43 */ |
|
44 class LinearFlowSnippet: public QGraphicsWidget |
|
45 { |
|
46 Q_OBJECT |
|
47 friend class Filmstrip; |
|
48 friend class FilmstripMovieFactory; |
|
49 |
|
50 public: |
|
51 /*! |
|
52 Creates a new FilmstripFlow widget. |
|
53 */ |
|
54 LinearFlowSnippet(QGraphicsWidget* parent = 0); |
|
55 |
|
56 /*! |
|
57 Destroys the widget. |
|
58 */ |
|
59 ~LinearFlowSnippet(); |
|
60 |
|
61 /*! |
|
62 init the FilmstripFlow |
|
63 */ |
|
64 void init(QString displayMode, QString titleName); |
|
65 |
|
66 //! Clear all slides |
|
67 void clear(); |
|
68 |
|
69 //! Add a slide to the flow |
|
70 void addSlide(const QImage& image); |
|
71 |
|
72 //! Add a slide to the flow with title |
|
73 void addSlide(const QImage& image, const QString& title); |
|
74 |
|
75 //! Set the center of the flow |
|
76 void setCenterIndex(int i); |
|
77 |
|
78 //! Show the previous item |
|
79 void showPrevious(); |
|
80 |
|
81 //! Show the next item |
|
82 void showNext(); |
|
83 |
|
84 //! Returns the total number of slides. |
|
85 int slideCount() const; |
|
86 |
|
87 //! Returns QImage of specified slide. |
|
88 QImage slide(int) const; |
|
89 |
|
90 //! Return the index of the current center slide |
|
91 int centerIndex() const; |
|
92 |
|
93 //! return true if slide animation is ongoing |
|
94 bool slideAnimationOngoing() const; |
|
95 |
|
96 //! return center slide's rect |
|
97 QRect centralRect() const; |
|
98 |
|
99 //! show the ith slide |
|
100 void showSlide(int) {} |
|
101 |
|
102 //! inserts filmstrip at index position i. |
|
103 void insert(int i, const QImage& image, const QString& title); |
|
104 |
|
105 //! removes filmstrip at index position i. |
|
106 void removeAt (int i); |
|
107 |
|
108 //! set background color |
|
109 void backgroundColor(const QRgb& c); |
|
110 |
|
111 //! handle the display mode change |
|
112 void displayModeChanged(QString& newMode); |
|
113 |
|
114 //! prepare start-animation |
|
115 void prepareStartAnimation(); |
|
116 |
|
117 //! run start-animation |
|
118 void runStartAnimation(); |
|
119 |
|
120 //! run end-animation |
|
121 void runEndAnimation(); |
|
122 |
|
123 bool isFlick(); |
|
124 |
|
125 QPoint speed(); |
|
126 |
|
127 QPoint currentPos(); |
|
128 |
|
129 QPoint previousPos(); |
|
130 |
|
131 qreal dragTime() const; |
|
132 |
|
133 void startFlickScroll(); |
|
134 |
|
135 signals: |
|
136 void removed(int index); |
|
137 void endAnimationCplt(); |
|
138 void centerIndexChanged(int index); |
|
139 void ok(int index); |
|
140 void cancel(); |
|
141 void mouseEvent(QEvent::Type type); |
|
142 protected: |
|
143 void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); |
|
144 void resizeEvent(QGraphicsSceneResizeEvent* event); |
|
145 void moveEvent(QGraphicsSceneMoveEvent* event); |
|
146 void mouseMoveEvent(QGraphicsSceneMouseEvent* event); |
|
147 void mousePressEvent(QGraphicsSceneMouseEvent* event); |
|
148 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event); |
|
149 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); |
|
150 |
|
151 private slots: |
|
152 void stopMovie(); |
|
153 void playMovie(int frame); |
|
154 void closeAnimation(); |
|
155 |
|
156 private: |
|
157 void scroll(); |
|
158 void adjustFilmstripSize(QSize& s); |
|
159 void showInsertOnRight(); |
|
160 void showInsertOnLeft(); |
|
161 bool hitCloseIcon(); |
|
162 |
|
163 private: |
|
164 FilmstripFlowPrivate* d; |
|
165 QList<DragPoint> m_dragPoints; |
|
166 QTime m_lastMoveEventTime; |
|
167 bool m_scrolled; |
|
168 QString m_displayMode; |
|
169 int m_countFlicks; |
|
170 QTimer *m_flickTimer; |
|
171 QString m_titleName; |
|
172 }; |
|
173 |
|
174 } |
|
175 #endif // LINEARFLOWSNIPPET_H |
|
176 |