330 /*! |
330 /*! |
331 Removes item from buffer shifting other items if necessary |
331 Removes item from buffer shifting other items if necessary |
332 */ |
332 */ |
333 void HbGridItemContainerPrivate::removeItem(const QModelIndex &index, bool animate) |
333 void HbGridItemContainerPrivate::removeItem(const QModelIndex &index, bool animate) |
334 { |
334 { |
|
335 Q_Q(HbGridItemContainer); |
335 HbAbstractViewItem *viewItem = item(index); |
336 HbAbstractViewItem *viewItem = item(index); |
336 |
337 |
337 bool scrollingNeeded = false; |
338 bool scrollingNeeded = false; |
338 bool layoutUpdateNeeded = false; |
339 bool layoutUpdateNeeded = false; |
339 |
340 |
373 |
374 |
374 if (scrollingNeeded) { |
375 if (scrollingNeeded) { |
375 // when shiftDownItem return false then shift up was done |
376 // when shiftDownItem return false then shift up was done |
376 // need to scroll visible area to be consist in grid view behaviour |
377 // need to scroll visible area to be consist in grid view behaviour |
377 // checking boundaries after scroll is also done |
378 // checking boundaries after scroll is also done |
378 Q_Q(HbGridItemContainer); |
|
379 QRectF viewRect(itemBoundingRect(mItemView)); |
379 QRectF viewRect(itemBoundingRect(mItemView)); |
380 QSizeF itemsCanvas(q->layout()->preferredSize()); |
380 QSizeF itemsCanvas(q->layout()->preferredSize()); |
381 QPointF pos = q->pos(); |
381 QPointF pos = q->pos(); |
382 qreal itemSize = getScrollDirectionItemSize(); |
382 qreal itemSize = getScrollDirectionItemSize(); |
383 if (Qt::Vertical == mScrollDirection) { |
383 if (Qt::Vertical == mScrollDirection) { |
384 pos.setY(q->pos().y() - itemSize); |
384 pos.setY(pos.y() - itemSize); |
385 if (pos.y() < viewRect.height() - itemsCanvas.height()) { |
385 if (pos.y() < viewRect.height() - itemsCanvas.height()) { |
386 pos.setY(viewRect.height() - itemsCanvas.height()); |
386 pos.setY(viewRect.height() - itemsCanvas.height()); |
387 } |
387 } |
|
388 if (pos.y() > 0) { |
|
389 pos.setY(0); |
|
390 } |
388 } else { |
391 } else { |
389 pos.setX(q->pos().x() - itemSize); |
392 pos.setX(pos.x() - itemSize); |
390 if (pos.x() < viewRect.width() - itemsCanvas.width()) { |
393 if (pos.x() < viewRect.width() - itemsCanvas.width()) { |
391 pos.setX(viewRect.width() - itemsCanvas.width()); |
394 pos.setX(viewRect.width() - itemsCanvas.width()); |
392 } |
395 } |
|
396 if (pos.x() > 0) { |
|
397 pos.setX(0); |
|
398 } |
393 } |
399 } |
394 q->setPos(pos); |
400 q->setPos(pos); |
395 } |
401 } |
396 if (layoutUpdateNeeded) { |
402 if (layoutUpdateNeeded) { |
397 mLayout->invalidate(); |
403 mLayout->invalidate(); |
398 } |
404 } |
|
405 emit q->itemAboutToBeDeleted(viewItem); |
399 } |
406 } |
400 |
407 |
401 |
408 |
402 void HbGridItemContainerPrivate::scrollToEnsureVisible(const QModelIndex &index) |
409 void HbGridItemContainerPrivate::scrollToEnsureVisible(const QModelIndex &index) |
403 { |
410 { |