77 |
77 |
78 virtual void itemDataChanged(const int &firstIndex, const int &lastIndex); |
78 virtual void itemDataChanged(const int &firstIndex, const int &lastIndex); |
79 |
79 |
80 void init(Qt::Orientation scrollDirection); |
80 void init(Qt::Orientation scrollDirection); |
81 |
81 |
|
82 void setDefaultImage(QImage defaultImage); |
|
83 |
|
84 void setItemSizePolicy(HgWidget::ItemSizePolicy policy); |
|
85 HgWidget::ItemSizePolicy itemSizePolicy() const; |
|
86 |
|
87 void setItemSize(const QSizeF& size); |
|
88 QSizeF itemSize() const; |
|
89 |
|
90 void setItemSpacing(const QSizeF& size); |
|
91 QSizeF itemSpacing() const; |
|
92 |
|
93 Qt::Orientation scrollDirection() const; |
|
94 qreal scrollPosition() const; |
|
95 |
82 signals: |
96 signals: |
83 |
97 |
84 // emit this signal when scrolling. for example scrollbar can be connected to this signal. |
98 // emit this signal when scrolling. for example scrollbar can be connected to this signal. |
85 void scrollPositionChanged(qreal value, bool scrollBarAnimation); |
99 void scrollPositionChanged(qreal value, bool scrollBarAnimation); |
86 void centerItemChanged(const QModelIndex &index); |
100 void centerItemChanged(const QModelIndex &index); |
93 |
107 |
94 void updateBySpringPosition(); |
108 void updateBySpringPosition(); |
95 void redraw(); |
109 void redraw(); |
96 void updateLongPressVisualizer(); |
110 void updateLongPressVisualizer(); |
97 void updateByCurrentIndex(const QModelIndex ¤t); |
111 void updateByCurrentIndex(const QModelIndex ¤t); |
98 void onScrollingEnded(); |
|
99 |
112 |
100 protected: // from HgMediaWallDataProvider |
113 protected: // from HgMediaWallDataProvider |
101 |
114 |
102 int imageCount() const; |
115 int imageCount() const; |
103 const HgImage *image(int index) const; |
116 const HgImage *image(int index) const; |
114 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); |
127 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); |
115 // From HbWidget for gestures. |
128 // From HbWidget for gestures. |
116 virtual void gestureEvent(QGestureEvent *event); |
129 virtual void gestureEvent(QGestureEvent *event); |
117 protected: |
130 protected: |
118 |
131 |
119 virtual HgMediaWallRenderer* createRenderer()=0; |
132 virtual HgMediaWallRenderer* createRenderer(Qt::Orientation scrollDirection)=0; |
120 virtual qreal getCameraDistance(qreal springVelocity); |
133 virtual qreal getCameraDistance(qreal springVelocity); |
121 virtual qreal getCameraRotationY(qreal springVelocity); |
134 virtual qreal getCameraRotationY(qreal springVelocity); |
122 virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
135 virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
123 virtual void handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
136 virtual void handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
124 virtual void onScrollPositionChanged(qreal pos); |
137 virtual void onScrollPositionChanged(qreal pos); |
125 virtual void handleCurrentChanged(const QModelIndex ¤t); |
138 virtual void handleCurrentChanged(const QModelIndex ¤t); |
|
139 virtual QRectF drawableRect() const; |
126 |
140 |
127 protected: |
141 protected: |
128 |
142 |
129 enum ItemActionType |
143 enum ItemActionType |
130 { |
144 { |
137 |
151 |
138 qreal worldWidth() const; |
152 qreal worldWidth() const; |
139 void initSpringForScrollBar(); |
153 void initSpringForScrollBar(); |
140 void initSpringForScrolling(); |
154 void initSpringForScrolling(); |
141 void boundSpring(); |
155 void boundSpring(); |
142 void handlePanning(QPanGesture *gesture); |
156 bool handlePanning(QPanGesture *gesture); |
143 void handleTap(Qt::GestureState state, const QPointF &pos); |
157 bool handleTap(Qt::GestureState state, const QPointF &pos); |
144 void handleLongTap(Qt::GestureState state, const QPointF &pos); |
158 bool handleLongTap(Qt::GestureState state, const QPointF &pos); |
145 void handleItemAction(const QPointF &pos, ItemActionType action); |
159 bool handleItemAction(const QPointF &pos, ItemActionType action); |
146 |
160 |
147 void selectItem(); |
161 void selectItem(); |
148 void updateSelectedItem(); |
162 void updateSelectedItem(); |
149 void unselectItem(); |
163 void unselectItem(); |
150 |
164 |
|
165 bool hasItemAt(const QPointF& pos); |
151 HgWidgetItem* getItemAt(const QPointF& pos, int& index); |
166 HgWidgetItem* getItemAt(const QPointF& pos, int& index); |
152 void startLongPressWatcher(const QPointF& pos); |
167 void startLongPressWatcher(const QPointF& pos); |
153 void stopLongPressWatcher(); |
168 void stopLongPressWatcher(); |
154 bool updateSelectionModel(HgWidgetItem* item); |
169 bool updateSelectionModel(HgWidgetItem* item); |
155 |
170 |
156 QTransform qtToVgTransform() const; |
171 QTransform qtToVgTransform() const; |
157 QPointF mapQtToVg(const QPointF& p) const; |
172 QPointF mapQtToVg(const QPointF& p) const; |
|
173 |
|
174 virtual void updateItemSizeAndSpacing(); |
|
175 virtual QSizeF getAutoItemSize() const; |
|
176 virtual QSizeF getAutoItemSpacing() const; |
158 |
177 |
159 protected: // data |
178 protected: // data |
160 |
179 |
161 QList<HgWidgetItem *> mItems; |
180 QList<HgWidgetItem *> mItems; |
162 //int mRowCount; |
181 //int mRowCount; |