534 // The two above statements have to be executed before these |
534 // The two above statements have to be executed before these |
535 if (e->type() == QEvent::LayoutRequest) { |
535 if (e->type() == QEvent::LayoutRequest) { |
536 d->mContainer->resizeContainer(); |
536 d->mContainer->resizeContainer(); |
537 if (d->mPostponedScrollIndex.isValid()) { |
537 if (d->mPostponedScrollIndex.isValid()) { |
538 d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint); |
538 d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint); |
|
539 if (scrollDirections() | Qt::Vertical) { |
|
540 d->updateScrollBar(Qt::Vertical); |
|
541 } |
|
542 if (scrollDirections() | Qt::Horizontal) { |
|
543 d->updateScrollBar(Qt::Horizontal); |
|
544 } |
539 } |
545 } |
540 result = true; |
546 result = true; |
541 } |
547 } |
542 |
548 |
543 return result; |
549 return result; |
1131 d->mPreviousSelectedCommand = QItemSelectionModel::NoUpdate; |
1137 d->mPreviousSelectedCommand = QItemSelectionModel::NoUpdate; |
1132 d->mSelectionSettings &= ~HbAbstractItemViewPrivate::Selection; |
1138 d->mSelectionSettings &= ~HbAbstractItemViewPrivate::Selection; |
1133 d->mContSelectionAction = QItemSelectionModel::NoUpdate; |
1139 d->mContSelectionAction = QItemSelectionModel::NoUpdate; |
1134 |
1140 |
1135 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
1141 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
1136 QModelIndex index = item->modelIndex(); |
1142 if (item) { |
1137 |
1143 QModelIndex index = item->modelIndex(); |
1138 if (d->mSelectionMode != HbAbstractItemView::NoSelection) { |
1144 |
1139 QGraphicsSceneMouseEvent mousePressEvent(QEvent::GraphicsSceneMousePress); |
1145 if (d->mSelectionMode != HbAbstractItemView::NoSelection) { |
1140 mousePressEvent.setPos(pos); |
1146 QGraphicsSceneMouseEvent mousePressEvent(QEvent::GraphicsSceneMousePress); |
1141 d->mSelectionModel->select(index, selectionCommand(item, &mousePressEvent)); |
1147 mousePressEvent.setPos(pos); |
1142 } |
1148 d->mSelectionModel->select(index, selectionCommand(item, &mousePressEvent)); |
1143 |
1149 } |
1144 emitPressed(item->modelIndex()); |
1150 emitPressed(item->modelIndex()); |
|
1151 } |
1145 } |
1152 } |
1146 |
1153 |
1147 /*! |
1154 /*! |
1148 This slot is called when release event occurs for view item. |
1155 This slot is called when release event occurs for view item. |
1149 Default implementation calls emitReleased(). |
1156 Default implementation calls emitReleased(). |
1303 return d->mItemPixmapCacheEnabled; |
1310 return d->mItemPixmapCacheEnabled; |
1304 } |
1311 } |
1305 |
1312 |
1306 /*! |
1313 /*! |
1307 Slot handles QAbstractItemModel::layoutChanged() signal. |
1314 Slot handles QAbstractItemModel::layoutChanged() signal. |
1308 Default implementation sets first model item visible as first view item. |
1315 Default implementation sets first model item visible as first view item if the |
|
1316 buffer items needed to be modified. QSortFilterProxyModel sends layoutChanged |
|
1317 signal whenever there is a dataChange in the model but in that case the container should |
|
1318 not be scrolled. |
1309 */ |
1319 */ |
1310 void HbAbstractItemView::modelLayoutChanged() |
1320 void HbAbstractItemView::modelLayoutChanged() |
1311 { |
1321 { |
1312 Q_D(HbAbstractItemView); |
1322 Q_D(HbAbstractItemView); |
|
1323 HbAbstractViewItem *topItem = 0; |
|
1324 if (!d->mContainer->items().isEmpty()) { |
|
1325 topItem = d->mContainer->items().first(); |
|
1326 } |
1313 d->mContainer->d_func()->updateItemBuffer(); |
1327 d->mContainer->d_func()->updateItemBuffer(); |
1314 d->mContainer->setModelIndexes(d->mModelIterator->nextIndex(QModelIndex())); |
1328 |
1315 if (d->mContainer->items().count() > 0) { |
1329 if (!d->mContainer->items().isEmpty()) { |
1316 scrollTo(d->mContainer->items().at(0)->modelIndex(), PositionAtTop); |
1330 if (d->mContainer->items().first() != topItem) { |
|
1331 d->mContainer->setModelIndexes(d->mModelIterator->nextIndex(QModelIndex())); |
|
1332 scrollTo(d->mContainer->items().first()->modelIndex(), PositionAtTop); |
|
1333 } else { |
|
1334 d->mContainer->setModelIndexes(topItem->modelIndex()); |
|
1335 } |
1317 } |
1336 } |
1318 } |
1337 } |
1319 |
1338 |
1320 #include "moc_hbabstractitemview.cpp" |
1339 #include "moc_hbabstractitemview.cpp" |
1321 |
1340 |