equal
deleted
inserted
replaced
118 */ |
118 */ |
119 void HbGridView::setRowCount(int rowCount) |
119 void HbGridView::setRowCount(int rowCount) |
120 { |
120 { |
121 Q_D(HbGridView); |
121 Q_D(HbGridView); |
122 |
122 |
123 d->mVisibleIndex = d->indexInTheCenter(); |
123 if (d->itemContainer()->rowCount() != rowCount) { |
124 |
124 d->mVisibleIndex = d->firstFullyVisibleIndex(); |
125 d->itemContainer()->setRowCount(rowCount); |
125 |
126 |
126 d->itemContainer()->setRowCount(rowCount); |
127 scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtCenter); |
127 |
|
128 scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtTop); |
|
129 } |
128 } |
130 } |
129 |
131 |
130 /*! |
132 /*! |
131 Returns the total number of columns in the view. |
133 Returns the total number of columns in the view. |
132 |
134 |
145 */ |
147 */ |
146 void HbGridView::setColumnCount(int columnCount) |
148 void HbGridView::setColumnCount(int columnCount) |
147 { |
149 { |
148 Q_D(HbGridView); |
150 Q_D(HbGridView); |
149 |
151 |
150 d->mVisibleIndex = d->indexInTheCenter(); |
152 if (d->itemContainer()->columnCount() != columnCount) { |
151 |
153 d->mVisibleIndex = d->firstFullyVisibleIndex(); |
152 d->itemContainer()->setColumnCount(columnCount); |
154 |
153 |
155 d->itemContainer()->setColumnCount(columnCount); |
154 scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtCenter); |
156 |
|
157 scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtTop); |
|
158 } |
155 } |
159 } |
156 |
160 |
157 |
161 |
158 /*! |
162 /*! |
159 Returns true if icons are currently displayed in GridView. |
163 Returns true if icons are currently displayed in GridView. |
250 \reimp |
254 \reimp |
251 */ |
255 */ |
252 void HbGridView::scrollTo(const QModelIndex &index, ScrollHint hint) |
256 void HbGridView::scrollTo(const QModelIndex &index, ScrollHint hint) |
253 { |
257 { |
254 Q_D(HbGridView); |
258 Q_D(HbGridView); |
255 // always use container, event if recycling is off and all items are |
259 |
256 // in container, but still additional action is needed - |
260 // always use HbGridItemContainer::scrollTo, even if recycling |
|
261 // is off - still additional action is needed - |
257 // container::scrollTo is responsible for procesing all |
262 // container::scrollTo is responsible for procesing all |
258 // posponed events (DelayedLayoutRequest) |
263 // posponed events (DelayedLayoutRequest) |
259 if ( d->mModelIterator->model() |
264 if ( d->mModelIterator->model() |
260 && index.model() == d->mModelIterator->model()) { |
265 && index.model() == d->mModelIterator->model()) { |
261 d->itemContainer()->scrollTo(index, hint); |
266 d->itemContainer()->scrollTo(index, hint); |
262 HbAbstractItemView::scrollTo(index, hint); |
267 HbAbstractItemView::scrollTo(index, hint); |
263 } |
268 } |
264 } |
269 } |
265 |
270 |
277 \reimp |
282 \reimp |
278 */ |
283 */ |
279 void HbGridView::orientationAboutToBeChanged() |
284 void HbGridView::orientationAboutToBeChanged() |
280 { |
285 { |
281 Q_D(HbGridView); |
286 Q_D(HbGridView); |
282 d->mVisibleIndex = d->indexInTheCenter(); |
287 d->mVisibleIndex = d->firstFullyVisibleIndex(); |
283 } |
288 } |
284 |
289 |
285 /*! |
290 /*! |
286 \reimp |
291 \reimp |
287 */ |
292 */ |
289 { |
294 { |
290 Q_D(HbGridView); |
295 Q_D(HbGridView); |
291 d->mContainer->setPos(0,0); |
296 d->mContainer->setPos(0,0); |
292 if (d->mSwapDimensionsOnOrientationChange) { |
297 if (d->mSwapDimensionsOnOrientationChange) { |
293 d->itemContainer()->orientationChanged(newOrientation); |
298 d->itemContainer()->orientationChanged(newOrientation); |
294 } |
299 int indexPosition = d->mModelIterator->indexPosition(d->mVisibleIndex); |
295 |
300 int columnsCount = 0; |
296 // abstract part is enough - container update buffer |
301 if (d->mScrollDirections == Qt::Vertical) { |
297 HbAbstractItemView::scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtCenter); |
302 columnsCount = columnCount(); |
|
303 } else { |
|
304 columnsCount = rowCount(); |
|
305 } |
|
306 int remainder = indexPosition % columnsCount; |
|
307 if (remainder > columnsCount / 2) { |
|
308 d->mVisibleIndex = d->mModelIterator->index(indexPosition + columnsCount - remainder); |
|
309 } |
|
310 } |
|
311 |
|
312 scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtTop); |
298 |
313 |
299 d->mVisibleIndex = QModelIndex(); |
314 d->mVisibleIndex = QModelIndex(); |
300 } |
315 } |
301 |
316 |
302 /*! |
317 /*! |
393 */ |
408 */ |
394 void HbGridView::scrollDirectionChanged(Qt::Orientations scrollDirection) |
409 void HbGridView::scrollDirectionChanged(Qt::Orientations scrollDirection) |
395 { |
410 { |
396 Q_D(HbGridView); |
411 Q_D(HbGridView); |
397 // scroll direction changed, calculations need to be done on old value |
412 // scroll direction changed, calculations need to be done on old value |
398 d->mVisibleIndex = d->indexInTheCenter((d->mScrollDirections == Qt::Vertical) |
413 d->mVisibleIndex = d->firstFullyVisibleIndex(); |
399 ? Qt::Horizontal : Qt::Vertical); |
|
400 d->mContainer->setPos(0,0); |
414 d->mContainer->setPos(0,0); |
401 d->itemContainer()->scrollDirectionChanged(scrollDirection); |
415 d->itemContainer()->scrollDirectionChanged(scrollDirection); |
402 |
416 |
403 // abstract part is enough - container update buffer |
417 // abstract part is enough - container update buffer |
404 HbAbstractItemView::scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtCenter); |
418 HbAbstractItemView::scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtTop); |
405 |
419 |
406 d->mVisibleIndex = QModelIndex(); |
420 d->mVisibleIndex = QModelIndex(); |
407 } |
421 } |
408 |
422 |
409 #include "moc_hbgridview.cpp" |
423 #include "moc_hbgridview.cpp" |