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 currentRowCount() 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, const QModelIndex &defaultItem); |
54 void setSelectionModel(QItemSelectionModel *selectionModel, const QModelIndex &defaultItem); |
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); |
60 Qt::Orientation orientation() const; |
60 Qt::Orientation orientation() const; |
61 void setOrientation(Qt::Orientation orientation, bool animate=true); |
61 virtual void setOrientation(Qt::Orientation orientation, bool animate=true); |
62 |
62 |
63 // new size for the widget. calls resize. |
63 // new size for the widget. calls resize. |
64 void scrollToPosition(qreal value, bool animate = false); |
64 void scrollToPosition(qreal value, bool animate = false); |
65 virtual void scrollToPosition(const QPointF& pos, bool animate); |
65 virtual void scrollToPosition(const QPointF& pos, bool animate); |
66 void scrollTo(const QModelIndex &index); |
66 void scrollTo(const QModelIndex &index); |
136 protected: |
136 protected: |
137 |
137 |
138 virtual HgMediaWallRenderer* createRenderer(Qt::Orientation scrollDirection)=0; |
138 virtual HgMediaWallRenderer* createRenderer(Qt::Orientation scrollDirection)=0; |
139 virtual qreal getCameraDistance(qreal springVelocity); |
139 virtual qreal getCameraDistance(qreal springVelocity); |
140 virtual qreal getCameraRotationY(qreal springVelocity); |
140 virtual qreal getCameraRotationY(qreal springVelocity); |
141 virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
141 virtual bool handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
142 virtual void handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
142 virtual bool handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex); |
143 virtual void onScrollPositionChanged(qreal pos); |
143 virtual void onScrollPositionChanged(qreal pos); |
144 virtual void loadIndicatorGraphics(bool loadIfExists = false); |
144 virtual void loadIndicatorGraphics(bool loadIfExists = false); |
|
145 virtual bool handleTap(Qt::GestureState state, const QPointF &pos) = 0; |
|
146 virtual bool handleLongTap(Qt::GestureState state, const QPointF &pos); |
145 |
147 |
146 protected: |
148 protected: |
147 |
149 |
148 enum ItemActionType |
150 enum ItemActionType |
149 { |
151 { |
157 qreal worldWidth() const; |
159 qreal worldWidth() const; |
158 void initSpringForScrollBar(); |
160 void initSpringForScrollBar(); |
159 void initSpringForScrolling(); |
161 void initSpringForScrolling(); |
160 void boundSpring(); |
162 void boundSpring(); |
161 bool handlePanning(QPanGesture *gesture); |
163 bool handlePanning(QPanGesture *gesture); |
162 bool handleTap(Qt::GestureState state, const QPointF &pos); |
|
163 bool handleLongTap(Qt::GestureState state, const QPointF &pos); |
|
164 bool handleItemAction(const QPointF &pos, ItemActionType action); |
|
165 |
164 |
166 void selectItem(int index); |
165 void selectItem(int index); |
167 void updateSelectedItem(); |
166 void updateSelectedItem(); |
168 void unselectItem(); |
167 void unselectItem(); |
169 |
168 |
170 bool hasItemAt(const QPointF& pos); |
169 bool hasItemAt(const QPointF& pos); |
171 HgWidgetItem* getItemAt(const QPointF& pos, int& index); |
170 HgWidgetItem* getItemAt(const QPointF& pos, int& index); |
172 void startLongPressWatcher(const QPointF& pos); |
171 void startLongPressWatcher(const QPointF& pos); |
173 void stopLongPressWatcher(); |
172 void stopLongPressWatcher(); |
174 bool updateSelectionModel(HgWidgetItem* item); |
173 bool handleItemSelection(HgWidgetItem* item); |
175 |
|
176 |
174 |
177 virtual void updateItemSizeAndSpacing(); |
175 virtual void updateItemSizeAndSpacing(); |
178 virtual QSizeF getAutoItemSize() const; |
176 virtual QSizeF getAutoItemSize() const; |
179 virtual QSizeF getAutoItemSpacing() const; |
177 virtual QSizeF getAutoItemSpacing() const; |
180 |
178 |