--- a/src/hbwidgets/itemviews/hbabstractitemview.cpp Thu Sep 02 20:44:51 2010 +0300
+++ b/src/hbwidgets/itemviews/hbabstractitemview.cpp Fri Sep 17 08:32:10 2010 +0300
@@ -536,6 +536,12 @@
d->mContainer->resizeContainer();
if (d->mPostponedScrollIndex.isValid()) {
d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint);
+ if (scrollDirections() | Qt::Vertical) {
+ d->updateScrollBar(Qt::Vertical);
+ }
+ if (scrollDirections() | Qt::Horizontal) {
+ d->updateScrollBar(Qt::Horizontal);
+ }
}
result = true;
}
@@ -1133,15 +1139,16 @@
d->mContSelectionAction = QItemSelectionModel::NoUpdate;
HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender());
- QModelIndex index = item->modelIndex();
+ if (item) {
+ QModelIndex index = item->modelIndex();
- if (d->mSelectionMode != HbAbstractItemView::NoSelection) {
- QGraphicsSceneMouseEvent mousePressEvent(QEvent::GraphicsSceneMousePress);
- mousePressEvent.setPos(pos);
- d->mSelectionModel->select(index, selectionCommand(item, &mousePressEvent));
+ if (d->mSelectionMode != HbAbstractItemView::NoSelection) {
+ QGraphicsSceneMouseEvent mousePressEvent(QEvent::GraphicsSceneMousePress);
+ mousePressEvent.setPos(pos);
+ d->mSelectionModel->select(index, selectionCommand(item, &mousePressEvent));
+ }
+ emitPressed(item->modelIndex());
}
-
- emitPressed(item->modelIndex());
}
/*!
@@ -1305,15 +1312,27 @@
/*!
Slot handles QAbstractItemModel::layoutChanged() signal.
- Default implementation sets first model item visible as first view item.
+ Default implementation sets first model item visible as first view item if the
+ buffer items needed to be modified. QSortFilterProxyModel sends layoutChanged
+ signal whenever there is a dataChange in the model but in that case the container should
+ not be scrolled.
*/
void HbAbstractItemView::modelLayoutChanged()
{
Q_D(HbAbstractItemView);
+ HbAbstractViewItem *topItem = 0;
+ if (!d->mContainer->items().isEmpty()) {
+ topItem = d->mContainer->items().first();
+ }
d->mContainer->d_func()->updateItemBuffer();
- d->mContainer->setModelIndexes(d->mModelIterator->nextIndex(QModelIndex()));
- if (d->mContainer->items().count() > 0) {
- scrollTo(d->mContainer->items().at(0)->modelIndex(), PositionAtTop);
+
+ if (!d->mContainer->items().isEmpty()) {
+ if (d->mContainer->items().first() != topItem) {
+ d->mContainer->setModelIndexes(d->mModelIterator->nextIndex(QModelIndex()));
+ scrollTo(d->mContainer->items().first()->modelIndex(), PositionAtTop);
+ } else {
+ d->mContainer->setModelIndexes(topItem->modelIndex());
+ }
}
}