32 #include <hbabstractitemcontainer_p.h> |
32 #include <hbabstractitemcontainer_p.h> |
33 #include <hbwidgetfeedback.h> |
33 #include <hbwidgetfeedback.h> |
34 #include <hbinstance.h> |
34 #include <hbinstance.h> |
35 #include <hbscrollbar.h> |
35 #include <hbscrollbar.h> |
36 #include <hbmodeliterator.h> |
36 #include <hbmodeliterator.h> |
|
37 #include <hbdataform.h> |
37 |
38 |
38 #include <QGraphicsSceneMouseEvent> |
39 #include <QGraphicsSceneMouseEvent> |
39 #include <QGraphicsScene> |
40 #include <QGraphicsScene> |
40 #include <QDebug> |
41 #include <QDebug> |
41 |
42 |
528 Q_D(HbAbstractItemView); |
530 Q_D(HbAbstractItemView); |
529 |
531 |
530 bool result = HbScrollArea::event(e); |
532 bool result = HbScrollArea::event(e); |
531 |
533 |
532 // The two above statements have to be executed before these |
534 // The two above statements have to be executed before these |
533 if (e->type() == HbEvent::ChildFocusIn) { |
535 if (e->type() == QEvent::LayoutRequest) { |
534 HbAbstractViewItem *item = 0; |
|
535 QList<HbAbstractViewItem *> items = d->mContainer->items(); |
|
536 |
|
537 for (QGraphicsItem *currentItem = scene()->focusItem(); currentItem != 0; currentItem = currentItem->parentItem()) { |
|
538 item = d->viewItem(currentItem); |
|
539 if (item) { |
|
540 if (items.indexOf(item) == -1) { |
|
541 item = 0; |
|
542 } else { |
|
543 break; |
|
544 } |
|
545 } |
|
546 } |
|
547 if (item && item->modelIndex() != d->mCurrentIndex) { |
|
548 setCurrentIndex(item->modelIndex()); |
|
549 } |
|
550 result = true; |
|
551 } else if (e->type() == QEvent::LayoutRequest) { |
|
552 d->mContainer->resizeContainer(); |
536 d->mContainer->resizeContainer(); |
553 if (d->mPostponedScrollIndex.isValid()) { |
537 if (d->mPostponedScrollIndex.isValid()) { |
554 d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint); |
538 d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint); |
555 } |
539 } |
556 result = true; |
540 result = true; |
772 current is the changed or current index and previous in the old current index. |
756 current is the changed or current index and previous in the old current index. |
773 current index may not be selected. |
757 current index may not be selected. |
774 */ |
758 */ |
775 void HbAbstractItemView::currentIndexChanged(const QModelIndex ¤t, const QModelIndex &previous) |
759 void HbAbstractItemView::currentIndexChanged(const QModelIndex ¤t, const QModelIndex &previous) |
776 { |
760 { |
777 Q_D(HbAbstractItemView); |
761 Q_UNUSED(previous); |
|
762 Q_D(HbAbstractItemView); |
|
763 |
778 |
764 |
779 if (current != d->mCurrentIndex) { |
765 if (current != d->mCurrentIndex) { |
780 d->mCurrentIndex = current; |
766 d->mCurrentIndex = current; |
781 |
|
782 if (previous.isValid()) { |
|
783 d->mContainer->setItemTransientStateValue(previous, "focused", false); |
|
784 } |
|
785 |
|
786 if (d->mCurrentIndex.isValid()) { |
|
787 d->mContainer->setItemTransientStateValue(d->mCurrentIndex, "focused", true); |
|
788 } |
|
789 |
|
790 } |
767 } |
791 } |
768 } |
792 |
769 |
793 /*! |
770 /*! |
794 This slot is called when selection of items has changed. |
771 This slot is called when selection of items has changed. |
1203 mouseReleaseEvent.setPos(pos); |
1180 mouseReleaseEvent.setPos(pos); |
1204 d->mSelectionModel->select(index, selectionCommand(item, &mouseReleaseEvent)); |
1181 d->mSelectionModel->select(index, selectionCommand(item, &mouseReleaseEvent)); |
1205 } |
1182 } |
1206 |
1183 |
1207 emitActivated(index); |
1184 emitActivated(index); |
|
1185 |
|
1186 setCurrentIndex(index); |
1208 } |
1187 } |
1209 |
1188 |
1210 /*! |
1189 /*! |
1211 This slot is called when view item is long pressed and long press is enabled in itemview. |
1190 This slot is called when view item is long pressed and long press is enabled in itemview. |
1212 Default implementation calls longPressed(). |
1191 Default implementation calls longPressed(). |
1223 QModelIndex index = item->modelIndex(); |
1202 QModelIndex index = item->modelIndex(); |
1224 |
1203 |
1225 d->mSelectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); |
1204 d->mSelectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); |
1226 |
1205 |
1227 emit longPressed(item, item->mapToScene(pos)); |
1206 emit longPressed(item, item->mapToScene(pos)); |
|
1207 |
|
1208 setCurrentIndex(index); |
1228 } |
1209 } |
1229 |
1210 |
1230 /*! |
1211 /*! |
1231 This slot is called when concrete view item has been created. Default implementation connects |
1212 This slot is called when concrete view item has been created. Default implementation connects |
1232 touch event related signals of HbAbstractViewItem to respective slots in this class. |
1213 touch event related signals of HbAbstractViewItem to respective slots in this class. |
1287 Q_D(const HbAbstractItemView); |
1268 Q_D(const HbAbstractItemView); |
1288 return d->mLongPressEnabled; |
1269 return d->mLongPressEnabled; |
1289 } |
1270 } |
1290 |
1271 |
1291 /*! |
1272 /*! |
|
1273 Enables item's pixmap cache if \a enable is true, or disables item's pixmap cache if \a enable is false. |
|
1274 |
|
1275 Enabling item's pixmap cache will significantly improve the item view scrolling speed. That is why in |
|
1276 most of the cases the pixmap cache should be enabled. It should only be disabled if there is a real need to |
|
1277 do it like; a custom view item prototype used that cannot update the pixmap properly or an effect is applied |
|
1278 to view item's child item. |
|
1279 |
|
1280 \note Item pixmap cache is not supported by HbDataForm. |
|
1281 |
|
1282 By default, the item's pixmap cache is disabled. |
|
1283 |
|
1284 \sa HbAbstractItemView::itemPixmapCacheEnabled(), HbAbstractViewItem::updatePixmapCache() |
|
1285 */ |
|
1286 void HbAbstractItemView::setItemPixmapCacheEnabled(bool enabled) |
|
1287 { |
|
1288 Q_D(HbAbstractItemView); |
|
1289 |
|
1290 if (qgraphicsitem_cast<HbDataForm*>(this) == 0) { |
|
1291 d->mItemPixmapCacheEnabled = enabled; |
|
1292 } |
|
1293 } |
|
1294 |
|
1295 /*! |
|
1296 Returns true if item's pixmap cache is enabled; otherwise returns false. |
|
1297 |
|
1298 \sa HbAbstractItemView::setItemPixmapCacheEnabled() |
|
1299 */ |
|
1300 bool HbAbstractItemView::itemPixmapCacheEnabled() const |
|
1301 { |
|
1302 Q_D(const HbAbstractItemView); |
|
1303 return d->mItemPixmapCacheEnabled; |
|
1304 } |
|
1305 |
|
1306 /*! |
1292 Slot handles QAbstractItemModel::layoutChanged() signal. |
1307 Slot handles QAbstractItemModel::layoutChanged() signal. |
1293 Default implementation sets first model item visible as first view item. |
1308 Default implementation sets first model item visible as first view item. |
1294 */ |
1309 */ |
1295 void HbAbstractItemView::modelLayoutChanged() |
1310 void HbAbstractItemView::modelLayoutChanged() |
1296 { |
1311 { |