40 Q_DISABLE_COPY(HgContainer) |
40 Q_DISABLE_COPY(HgContainer) |
41 |
41 |
42 public: |
42 public: |
43 explicit HgContainer(QGraphicsItem* parent = 0); |
43 explicit HgContainer(QGraphicsItem* parent = 0); |
44 virtual ~HgContainer(); |
44 virtual ~HgContainer(); |
45 |
45 |
46 void setItemCount(int count); |
46 void setItemCount(int count); |
47 int itemCount() const; |
47 int itemCount() const; |
48 int rowCount() const; |
48 int rowCount() const; |
49 |
49 |
50 QList<HgWidgetItem*> items() const; |
50 QList<HgWidgetItem*> items() const; |
51 HgWidgetItem* itemByIndex(const QModelIndex &index) const; |
51 HgWidgetItem* itemByIndex(const QModelIndex &index) const; |
52 HgWidgetItem* itemByIndex(const int &index) const; |
52 HgWidgetItem* itemByIndex(const int &index) const; |
53 |
53 |
54 void setSelectionModel(QItemSelectionModel *selectionModel); |
54 void setSelectionModel(QItemSelectionModel *selectionModel, const QModelIndex &defaultItem); |
55 QItemSelectionModel *selectionModel() const; |
55 QItemSelectionModel *selectionModel() const; |
56 void setSelectionMode(HgWidget::SelectionMode mode, bool resetSelection); |
56 void setSelectionMode(HgWidget::SelectionMode mode, bool resetSelection); |
57 HgWidget::SelectionMode selectionMode() const; |
57 HgWidget::SelectionMode selectionMode() const; |
58 |
58 |
59 void dimensions(qreal &screenSize, qreal &worldSize); |
59 void dimensions(qreal &screenSize, qreal &worldSize); |
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); |
82 void setDefaultImage(QImage defaultImage); |
83 |
83 |
84 void setItemSizePolicy(HgWidget::ItemSizePolicy policy); |
84 void setItemSizePolicy(HgWidget::ItemSizePolicy policy); |
85 HgWidget::ItemSizePolicy itemSizePolicy() const; |
85 HgWidget::ItemSizePolicy itemSizePolicy() const; |
86 |
86 |
87 void setItemSize(const QSizeF& size); |
87 void setItemSize(const QSizeF& size); |
88 QSizeF itemSize() const; |
88 QSizeF itemSize() const; |
89 |
89 |
90 void setItemSpacing(const QSizeF& size); |
90 void setItemSpacing(const QSizeF& size); |
91 QSizeF itemSpacing() const; |
91 QSizeF itemSpacing() const; |
92 |
92 |
93 Qt::Orientation scrollDirection() const; |
93 Qt::Orientation scrollDirection() const; |
94 qreal scrollPosition() const; |
94 qreal scrollPosition() const; |
95 |
95 |
96 signals: |
96 signals: |
97 |
97 |
98 // 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. |
99 void scrollPositionChanged(qreal value, bool scrollBarAnimation); |
99 void scrollPositionChanged(qreal value, bool scrollBarAnimation); |
100 void centerItemChanged(const QModelIndex &index); |
100 void centerItemChanged(const QModelIndex &index); |
101 void activated(const QModelIndex &index); |
101 void activated(const QModelIndex &index); |
102 void longPressed(const QModelIndex &index, const QPointF &coords); |
102 void longPressed(const QModelIndex &index, const QPointF &coords); |
103 void scrollingStarted(); |
103 void scrollingStarted(); |
104 void scrollingEnded(); |
104 void scrollingEnded(); |
105 |
105 |
106 protected slots: |
106 protected slots: |
107 |
107 |
108 virtual void onScrollingStarted(); |
108 virtual void onScrollingStarted(); |
109 virtual void onScrollingEnded(); |
109 virtual void onScrollingEnded(); |
110 |
110 |
111 private slots: |
111 private slots: |
112 |
112 |
113 void updateBySpringPosition(); |
113 void updateBySpringPosition(); |
114 void redraw(); |
114 void redraw(); |
115 void updateLongPressVisualizer(); |
115 void updateLongPressVisualizer(); |
116 void updateByCurrentIndex(const QModelIndex ¤t); |
|
117 |
116 |
118 protected: // from HgMediaWallDataProvider |
117 protected: // from HgMediaWallDataProvider |
119 |
118 |
120 int imageCount() const; |
119 int imageCount() const; |
121 const HgImage *image(int index) const; |
120 const HgImage *image(int index) const; |
138 virtual qreal getCameraDistance(qreal springVelocity); |
137 virtual qreal getCameraDistance(qreal springVelocity); |
139 virtual qreal getCameraRotationY(qreal springVelocity); |
138 virtual qreal getCameraRotationY(qreal springVelocity); |
140 virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
139 virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
141 virtual void handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
140 virtual void handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
142 virtual void onScrollPositionChanged(qreal pos); |
141 virtual void onScrollPositionChanged(qreal pos); |
143 virtual void handleCurrentChanged(const QModelIndex ¤t); |
|
144 |
142 |
145 protected: |
143 protected: |
146 |
144 |
147 enum ItemActionType |
145 enum ItemActionType |
148 { |
146 { |
170 HgWidgetItem* getItemAt(const QPointF& pos, int& index); |
168 HgWidgetItem* getItemAt(const QPointF& pos, int& index); |
171 void startLongPressWatcher(const QPointF& pos); |
169 void startLongPressWatcher(const QPointF& pos); |
172 void stopLongPressWatcher(); |
170 void stopLongPressWatcher(); |
173 bool updateSelectionModel(HgWidgetItem* item); |
171 bool updateSelectionModel(HgWidgetItem* item); |
174 |
172 |
175 |
173 |
176 virtual void updateItemSizeAndSpacing(); |
174 virtual void updateItemSizeAndSpacing(); |
177 virtual QSizeF getAutoItemSize() const; |
175 virtual QSizeF getAutoItemSize() const; |
178 virtual QSizeF getAutoItemSpacing() const; |
176 virtual QSizeF getAutoItemSpacing() const; |
179 |
177 |
180 protected: // data |
178 protected: // data |
198 |
196 |
199 HgWidget::SelectionMode mSelectionMode; |
197 HgWidget::SelectionMode mSelectionMode; |
200 QItemSelectionModel *mSelectionModel; |
198 QItemSelectionModel *mSelectionModel; |
201 HgImage *mMarkImageOn; |
199 HgImage *mMarkImageOn; |
202 HgImage *mMarkImageOff; |
200 HgImage *mMarkImageOff; |
203 |
201 |
204 qreal mSpringVelAtDragStart; |
202 qreal mSpringVelAtDragStart; |
205 bool mDragged; |
203 bool mDragged; |
206 int mFramesDragged; |
204 int mFramesDragged; |
207 |
205 |
208 HbAbstractViewItem* mHitItemView; |
206 HbAbstractViewItem* mHitItemView; |
218 bool mScrollBarPressed; |
216 bool mScrollBarPressed; |
219 |
217 |
220 HgWidget::ItemSizePolicy mItemSizePolicy; |
218 HgWidget::ItemSizePolicy mItemSizePolicy; |
221 QSizeF mUserItemSize; |
219 QSizeF mUserItemSize; |
222 QSizeF mUserItemSpacing; |
220 QSizeF mUserItemSpacing; |
223 |
221 |
224 Qt::Orientation mOrientation; |
222 Qt::Orientation mOrientation; |
225 QModelIndex mDelayedScrollToIndex; |
223 QModelIndex mDelayedScrollToIndex; |
226 bool mIgnoreTap; |
224 bool mIgnoreGestureAction; |
227 }; |
225 }; |
228 |
226 |
229 #endif |
227 #endif |