22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include "hbabstractitemview_p.h" |
26 #include "hbabstractitemview_p.h" |
27 #include "hbabstractitemcontainer_p.h" |
27 #include "hbabstractitemcontainer_p_p.h" |
28 |
28 |
29 #include <hbabstractitemview.h> |
29 #include <hbabstractitemview.h> |
30 #include <hbabstractviewitem.h> |
30 #include <hbabstractviewitem.h> |
31 #include <hbevent.h> |
31 #include <hbevent.h> |
32 #include <hbabstractitemcontainer.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 |
37 |
38 #include <QGraphicsSceneMouseEvent> |
38 #include <QGraphicsSceneMouseEvent> |
39 #include <QGraphicsScene> |
39 #include <QGraphicsScene> |
40 #include <QDebug> |
40 #include <QDebug> |
41 // For QMAP_INT__ITEM_STATE_DEPRECATED's sake. Removed when QMap<int,QVariant> based state item system is removed |
|
42 #include <hbabstractviewitem_p.h> |
|
43 |
41 |
44 #include <QGesture> |
42 #include <QGesture> |
45 #include <QGestureEvent> |
43 #include <QGestureEvent> |
46 #include <QPanGesture> |
44 #include <QPanGesture> |
47 |
45 |
137 When the user selects an item in the usual way, the selection state of that item |
135 When the user selects an item in the usual way, the selection state of that item |
138 is toggled and the other items are left alone. |
136 is toggled and the other items are left alone. |
139 */ |
137 */ |
140 |
138 |
141 /*! |
139 /*! |
142 \var HbAbstractItemView::ContiguousSelection |
|
143 \deprecated HbAbstractItemView::ContiguousSelection |
|
144 is deprecated. |
|
145 |
|
146 When the user selects an item in the usual way, the selection is cleared and the new item selected. |
|
147 However, if the user presses an item, moves the selection and releases it, all the items between |
|
148 are selected or unselected, depending on the state of the first item. |
|
149 */ |
|
150 |
|
151 /*! |
|
152 \enum HbAbstractItemView::ItemAnimation |
140 \enum HbAbstractItemView::ItemAnimation |
153 |
141 |
154 animations in HbAbstractItemView that can be disabled. By default all animations are enabled. |
142 animations in HbAbstractItemView that can be disabled. By default all animations are enabled. |
155 */ |
143 */ |
156 |
144 |
201 /*! |
189 /*! |
202 \fn void HbAbstractItemView::scrollTo(const QModelIndex &index, |
190 \fn void HbAbstractItemView::scrollTo(const QModelIndex &index, |
203 HbAbstractItemView::ScrollHint hint = EnsureVisible) |
191 HbAbstractItemView::ScrollHint hint = EnsureVisible) |
204 |
192 |
205 Scrolls the view if necessary to ensure that the item at \a index is visible |
193 Scrolls the view if necessary to ensure that the item at \a index is visible |
206 according to hint. Default value just guarantees, that item will be fully visible. |
194 in a position according to \a hint. Default value just guarantees, that item will be fully visible. |
207 */ |
195 */ |
208 |
196 |
209 |
197 |
210 /*! |
198 /*! |
211 See also HbAbstractItemManager, HbAbstractViewItem, HbAbstractItemContainer. |
199 See also HbAbstractItemManager, HbAbstractViewItem, HbAbstractItemContainer. |
212 |
200 |
213 */ |
201 */ |
214 |
|
215 /*! |
|
216 \deprecated HbAbstractItemView::HbAbstractItemView(HbAbstractItemViewPrivate &, HbAbstractItemContainer *, QGraphicsItem *) |
|
217 is deprecated. Use \a HbAbstractItemView::HbAbstractItemView(HbAbstractItemViewPrivate &, HbAbstractItemContainer *, HbModelIterator *, QGraphicsItem *). |
|
218 |
|
219 Constructs a new HbAbstractItemView with \a parent. |
|
220 */ |
|
221 HbAbstractItemView::HbAbstractItemView(HbAbstractItemViewPrivate &dd, |
|
222 HbAbstractItemContainer *container, |
|
223 QGraphicsItem *parent) |
|
224 : HbScrollArea(dd, parent) |
|
225 { |
|
226 qWarning("HbAbstractItemView::HbAbstractItemView(HbAbstractItemViewPrivate &, HbAbstractItemContainer *, QGraphicsItem *) is deprecated! Use HbAbstractItemView::HbAbstractItemView(HbAbstractItemViewPrivate &, HbAbstractItemContainer *, HbModelIterator *, QGraphicsItem *)."); |
|
227 Q_D(HbAbstractItemView); |
|
228 Q_ASSERT_X(container, "HbAbstractItemView constructor", "Container is null"); |
|
229 |
|
230 d->q_ptr = this; |
|
231 d->init(container, new HbModelIterator()); |
|
232 } |
|
233 |
202 |
234 /*! |
203 /*! |
235 Constructs a new HbAbstractItemView with \a parent. |
204 Constructs a new HbAbstractItemView with \a parent. |
236 */ |
205 */ |
237 HbAbstractItemView::HbAbstractItemView(HbAbstractItemViewPrivate &dd, |
206 HbAbstractItemView::HbAbstractItemView(HbAbstractItemViewPrivate &dd, |
358 d->setSelectionModel(selectionModel); |
327 d->setSelectionModel(selectionModel); |
359 } |
328 } |
360 } |
329 } |
361 |
330 |
362 /*! |
331 /*! |
363 \deprecated HbAbstractItemView::setSelectionMode(HbAbstractItemView::SelectionMode, bool) |
|
364 is deprecated. Use \a HbAbstractItemView::setSelectionMode(HbAbstractItemView::SelectionMode newMode) |
|
365 |
|
366 If \a newMode is not same as current selection mode of view, |
332 If \a newMode is not same as current selection mode of view, |
367 updates selection mode and all viewitems. |
333 updates selection mode, all viewitems and clears all existing selections. |
368 If \a resetSelection is true, it clears all existing selections. By default this value is true. |
334 */ |
369 */ |
335 void HbAbstractItemView::setSelectionMode(SelectionMode newMode) |
370 void HbAbstractItemView::setSelectionMode(SelectionMode newMode, bool resetSelection) |
336 { |
371 { |
|
372 qWarning("HbAbstractItemView::setSelectionMode(HbAbstractItemView::SelectionMode, bool) is deprecated! Use HbAbstractItemView::setSelectionMode(HbAbstractItemView::SelectionMode)."); |
|
373 |
|
374 Q_D(HbAbstractItemView); |
337 Q_D(HbAbstractItemView); |
375 if (d->mSelectionMode != newMode) { |
338 if (d->mSelectionMode != newMode) { |
376 d->mSelectionMode = newMode; |
339 d->mSelectionMode = newMode; |
377 |
340 |
378 if (resetSelection) { |
|
379 clearSelection(); |
|
380 } |
|
381 |
|
382 d->updateItems(); |
|
383 } |
|
384 } |
|
385 |
|
386 /*! |
|
387 If \a newMode is not same as current selection mode of view, |
|
388 updates selection mode, all viewitems and clears all existing selections. |
|
389 */ |
|
390 void HbAbstractItemView::setSelectionMode(SelectionMode newMode) |
|
391 { |
|
392 Q_D(HbAbstractItemView); |
|
393 if (d->mSelectionMode != newMode) { |
|
394 d->mSelectionMode = newMode; |
|
395 |
|
396 clearSelection(); |
341 clearSelection(); |
397 |
342 |
398 d->updateItems(); |
343 d->updateItems(); |
399 } |
344 } |
400 } |
345 } |
405 void HbAbstractItemView::selectAll() |
350 void HbAbstractItemView::selectAll() |
406 { |
351 { |
407 Q_D(HbAbstractItemView); |
352 Q_D(HbAbstractItemView); |
408 if (d->mModelIterator->model() |
353 if (d->mModelIterator->model() |
409 && d->mSelectionModel |
354 && d->mSelectionModel |
410 && (d->mSelectionMode == MultiSelection |
355 && d->mSelectionMode == MultiSelection) { |
411 || d->mSelectionMode == ContiguousSelection)) { |
|
412 QModelIndex firstIndex = d->mModelIterator->nextIndex(QModelIndex()); |
356 QModelIndex firstIndex = d->mModelIterator->nextIndex(QModelIndex()); |
413 QModelIndex lastIndex = d->mModelIterator->previousIndex(QModelIndex()); |
357 QModelIndex lastIndex = d->mModelIterator->previousIndex(QModelIndex()); |
414 d->mSelectionModel->select(QItemSelection(firstIndex, lastIndex), QItemSelectionModel::Select); |
358 d->mSelectionModel->select(QItemSelection(firstIndex, lastIndex), QItemSelectionModel::Select); |
415 } |
359 } |
416 } |
360 } |
445 Q_D(const HbAbstractItemView); |
389 Q_D(const HbAbstractItemView); |
446 return d->mCurrentIndex; |
390 return d->mCurrentIndex; |
447 } |
391 } |
448 |
392 |
449 /*! |
393 /*! |
450 Sets Currentindex to \a index. The item is selected depending on the \a selectionFlag. |
394 Sets current index to \a index. The item is selected depending on the \a selectionFlag. |
451 By default item is not selected. If current selection mode is NoSelection, |
395 By default item is not selected. If current selection mode is NoSelection, |
452 item is not selected irrespective of the selection flag. |
396 item is not selected irrespective of the selection flag. |
453 */ |
397 */ |
454 void HbAbstractItemView::setCurrentIndex(const QModelIndex &index, |
398 void HbAbstractItemView::setCurrentIndex(const QModelIndex &index, |
455 QItemSelectionModel::SelectionFlags selectionFlag) |
399 QItemSelectionModel::SelectionFlags selectionFlag) |
537 if (item && item->modelIndex() != d->mCurrentIndex) { |
481 if (item && item->modelIndex() != d->mCurrentIndex) { |
538 setCurrentIndex(item->modelIndex()); |
482 setCurrentIndex(item->modelIndex()); |
539 } |
483 } |
540 result = true; |
484 result = true; |
541 } else if (e->type() == QEvent::LayoutRequest) { |
485 } else if (e->type() == QEvent::LayoutRequest) { |
542 d->refreshContainerGeometry(); |
486 d->mContainer->resizeContainer(); |
543 if (d->mPostponedScrollIndex.isValid()) { |
487 if (d->mPostponedScrollIndex.isValid()) { |
544 d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint); |
488 d->scrollTo(d->mPostponedScrollIndex, d->mPostponedScrollHint); |
545 } |
489 } |
546 result = true; |
490 result = true; |
547 } |
491 } |
564 |
508 |
565 |
509 |
566 //Setting the uniform ites sizes to container again resets size caches. |
510 //Setting the uniform ites sizes to container again resets size caches. |
567 d->mContainer->setUniformItemSizes(d->mContainer->uniformItemSizes()); |
511 d->mContainer->setUniformItemSizes(d->mContainer->uniformItemSizes()); |
568 d->mContainer->setPos(0,0); |
512 d->mContainer->setPos(0,0); |
569 d->refreshContainerGeometry(); |
513 d->mContainer->resizeContainer(); |
570 |
514 |
571 d->updateScrollMetrics(); |
515 d->updateScrollMetrics(); |
572 |
516 |
573 d->stopAnimating(); |
517 d->stopAnimating(); |
574 scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtTop); |
518 scrollTo(d->mVisibleIndex, HbAbstractItemView::PositionAtTop); |
631 */ |
575 */ |
632 bool HbAbstractItemView::isVisible(const QModelIndex & index) const |
576 bool HbAbstractItemView::isVisible(const QModelIndex & index) const |
633 { |
577 { |
634 Q_D( const HbAbstractItemView ); |
578 Q_D( const HbAbstractItemView ); |
635 return d->visible(d->mContainer->itemByIndex(index), false); |
579 return d->visible(d->mContainer->itemByIndex(index), false); |
636 } |
|
637 |
|
638 /*! |
|
639 \deprecated HbAbstractItemView::isVisible(HbAbstractViewItem*) const |
|
640 is deprecated. Use isVisible \a HbAbstractItemView::isVisible(const QModelIndex&) const. |
|
641 |
|
642 This is an overloaded member function, provided for convenience. |
|
643 Returns true if item is fully or partially visible in view. |
|
644 */ |
|
645 bool HbAbstractItemView::isVisible(HbAbstractViewItem *item) const |
|
646 { |
|
647 qWarning("HbAbstractItemView::isVisible(HbAbstractViewItem*) const is deprecated! Use isVisible \a HbAbstractItemView::isVisible(const QModelIndex&) const"); |
|
648 |
|
649 Q_D(const HbAbstractItemView); |
|
650 return d->visible(item, false); |
|
651 } |
580 } |
652 |
581 |
653 /*! |
582 /*! |
654 Base class implemmentation. Take care about scrollTo when it was |
583 Base class implemmentation. Take care about scrollTo when it was |
655 called before view was visible (first scrollTo can be done after |
584 called before view was visible (first scrollTo can be done after |
692 for (int i = 0; i < count; ++i) { |
621 for (int i = 0; i < count; ++i) { |
693 if(d->visible(d->mContainer->items().at(i), false)) |
622 if(d->visible(d->mContainer->items().at(i), false)) |
694 visibleItems.append(d->mContainer->items().at(i)); |
623 visibleItems.append(d->mContainer->items().at(i)); |
695 } |
624 } |
696 return visibleItems; |
625 return visibleItems; |
697 } |
|
698 |
|
699 /*! |
|
700 \deprecated HbAbstractItemView::itemAtPosition(const QPointF&) const |
|
701 is deprecated. |
|
702 |
|
703 Returns a pointer to item at the coordinates. |
|
704 */ |
|
705 HbAbstractViewItem *HbAbstractItemView::itemAtPosition(const QPointF& position) const |
|
706 { |
|
707 qWarning("HbAbstractItemView::itemAtPosition(const QPointF&) const is deprecated!"); |
|
708 |
|
709 Q_D(const HbAbstractItemView); |
|
710 return d->itemAt(position); |
|
711 } |
626 } |
712 |
627 |
713 /*! |
628 /*! |
714 Returns SelectionFlags to be used when updating selection of a item. |
629 Returns SelectionFlags to be used when updating selection of a item. |
715 The event is a user input event, such as a mouse or keyboard event. |
630 The event is a user input event, such as a mouse or keyboard event. |
794 { |
709 { |
795 Q_D(HbAbstractItemView); |
710 Q_D(HbAbstractItemView); |
796 |
711 |
797 if (current != d->mCurrentIndex) { |
712 if (current != d->mCurrentIndex) { |
798 d->mCurrentIndex = current; |
713 d->mCurrentIndex = current; |
799 |
714 |
800 HbAbstractViewItem* oldItem = d->mContainer->itemByIndex(previous); |
|
801 HbAbstractViewItem* newItem = d->mContainer->itemByIndex(current); |
|
802 |
|
803 if (oldItem) { |
|
804 oldItem->lostFocus(); |
|
805 } |
|
806 |
|
807 if (previous.isValid()) { |
715 if (previous.isValid()) { |
808 #ifndef QMAP_INT__ITEM_STATE_DEPRECATED |
|
809 d->mContainer->setItemStateValue(previous, HbAbstractViewItem::FocusKey, false); |
|
810 #endif |
|
811 d->mContainer->setItemTransientStateValue(previous, "focused", false); |
716 d->mContainer->setItemTransientStateValue(previous, "focused", false); |
812 } |
717 } |
813 |
|
814 if (newItem) { |
|
815 newItem->receivedFocus(); |
|
816 } |
|
817 |
718 |
818 if (d->mCurrentIndex.isValid()) { |
719 if (d->mCurrentIndex.isValid()) { |
819 #ifndef QMAP_INT__ITEM_STATE_DEPRECATED |
|
820 d->mContainer->setItemStateValue(d->mCurrentIndex, HbAbstractViewItem::FocusKey, true); |
|
821 #endif |
|
822 d->mContainer->setItemTransientStateValue(d->mCurrentIndex, "focused", true); |
720 d->mContainer->setItemTransientStateValue(d->mCurrentIndex, "focused", true); |
823 } |
721 } |
824 |
722 |
825 } |
723 } |
826 } |
724 } |
846 modifiers |= Hb::ModifierScrolling; |
744 modifiers |= Hb::ModifierScrolling; |
847 } |
745 } |
848 HbWidgetFeedback::triggered(item, Hb::InstantSelectionChanged, modifiers); |
746 HbWidgetFeedback::triggered(item, Hb::InstantSelectionChanged, modifiers); |
849 } |
747 } |
850 } |
748 } |
851 #ifndef QMAP_INT__ITEM_STATE_DEPRECATED |
|
852 d->mContainer->setItemStateValue(selectedIndexes.at(i), |
|
853 HbAbstractViewItem::CheckStateKey, |
|
854 Qt::Checked); |
|
855 #endif |
|
856 d->mContainer->setItemTransientStateValue(selectedIndexes.at(i), |
749 d->mContainer->setItemTransientStateValue(selectedIndexes.at(i), |
857 "checkState", |
750 "checkState", |
858 Qt::Checked); |
751 Qt::Checked); |
859 } |
752 } |
860 |
753 |
866 item->setCheckState(Qt::Unchecked); |
759 item->setCheckState(Qt::Unchecked); |
867 if (!d->mClearingSelection) { |
760 if (!d->mClearingSelection) { |
868 HbWidgetFeedback::triggered(item, Hb::InstantSelectionChanged); |
761 HbWidgetFeedback::triggered(item, Hb::InstantSelectionChanged); |
869 } |
762 } |
870 } |
763 } |
871 #ifndef QMAP_INT__ITEM_STATE_DEPRECATED |
|
872 d->mContainer->setItemStateValue(deselectedIndexes.at(i), |
|
873 HbAbstractViewItem::CheckStateKey, |
|
874 Qt::Unchecked); |
|
875 #endif |
|
876 d->mContainer->setItemTransientStateValue(deselectedIndexes.at(i), |
764 d->mContainer->setItemTransientStateValue(deselectedIndexes.at(i), |
877 "checkState", |
765 "checkState", |
878 Qt::Unchecked); |
766 Qt::Unchecked); |
879 } |
767 } |
880 } |
768 } |
1022 { |
910 { |
1023 emit released(modelIndex); |
911 emit released(modelIndex); |
1024 } |
912 } |
1025 |
913 |
1026 /*! |
914 /*! |
1027 \deprecated HbAbstractItemView::indexCount() const |
|
1028 is deprecated. Use \a HbModelIterator::indexCount() |
|
1029 |
|
1030 Returns the total model index count that can be traversed with nextIndex and previousIndex functions. |
|
1031 */ |
|
1032 int HbAbstractItemView::indexCount() const |
|
1033 { |
|
1034 qWarning("HbAbstractItemView::indexCount() is deprecated! Use HbModelIterator::indexCount()."); |
|
1035 |
|
1036 Q_D(const HbAbstractItemView); |
|
1037 return d->mModelIterator->indexCount(); |
|
1038 } |
|
1039 |
|
1040 /*! |
|
1041 \deprecated HbAbstractItemView::indexPosition(const QModelIndex &) const |
|
1042 is deprecated. Use \a HbModelIterator::indexPosition(const QModelIndex &) const |
|
1043 |
|
1044 Returns the position of \a index from the first index. |
|
1045 */ |
|
1046 int HbAbstractItemView::indexPosition(const QModelIndex &index) const |
|
1047 { |
|
1048 qWarning("HbAbstractItemView::indexPosition(const QModelIndex &) is deprecated! Use HbModelIterator::indexPosition(const QModelIndex &)."); |
|
1049 |
|
1050 Q_D(const HbAbstractItemView); |
|
1051 return d->mModelIterator->indexPosition(index); |
|
1052 } |
|
1053 |
|
1054 /*! |
|
1055 \deprecated HbAbstractItemView::nextIndex(const QModelIndex&) const |
|
1056 is deprecated. Use \a HbModelIterator::nextIndex(const QModelIndex&) const |
|
1057 |
|
1058 Returns the next model index from \a index. If QModelIndex() is given as a parameter |
|
1059 this should return the first model index. |
|
1060 |
|
1061 \note Returned QModelIndex() is interpret so that there is no next index from given one. |
|
1062 */ |
|
1063 QModelIndex HbAbstractItemView::nextIndex(const QModelIndex &index) const |
|
1064 { |
|
1065 qWarning("HbAbstractItemView::nextIndex(const QModelIndex&) is deprecated! Use HbModelIterator::nextIndex(const QModelIndex&)."); |
|
1066 |
|
1067 Q_D(const HbAbstractItemView); |
|
1068 return d->mModelIterator->nextIndex(index); |
|
1069 } |
|
1070 |
|
1071 /*! |
|
1072 \deprecated HbAbstractItemView::previousIndex(const QModelIndex&) const |
|
1073 is deprecated. Use \a HbModelIterator::previousIndex(const QModelIndex&) const |
|
1074 |
|
1075 Returns the previous model index from \a index. If QModelIndex() is given as a parameter |
|
1076 this should return the last model index. |
|
1077 |
|
1078 \note Returned QModelIndex() is interpret so that there is no previous index from given one. |
|
1079 */ |
|
1080 QModelIndex HbAbstractItemView::previousIndex(const QModelIndex &index) const |
|
1081 { |
|
1082 qWarning("HbAbstractItemView::previousIndex(const QModelIndex&) is deprecated! Use HbModelIterator::previousIndex(const QModelIndex&)."); |
|
1083 |
|
1084 Q_D(const HbAbstractItemView); |
|
1085 return d->mModelIterator->previousIndex(index); |
|
1086 } |
|
1087 |
|
1088 /*! |
|
1089 \reimp |
915 \reimp |
1090 */ |
916 */ |
1091 bool HbAbstractItemView::scrollByAmount(const QPointF &delta) |
917 bool HbAbstractItemView::scrollByAmount(const QPointF &delta) |
1092 { |
918 { |
1093 Q_D(HbAbstractItemView); |
919 Q_D(HbAbstractItemView); |
1096 |
922 |
1097 if (d->mContainer->itemRecycling() |
923 if (d->mContainer->itemRecycling() |
1098 && !d->mContainer->items().isEmpty()) { |
924 && !d->mContainer->items().isEmpty()) { |
1099 newDelta = d->mContainer->recycleItems(delta); |
925 newDelta = d->mContainer->recycleItems(delta); |
1100 d->mAnimationInitialPosition = d->mAnimationInitialPosition + newDelta - delta; |
926 d->mAnimationInitialPosition = d->mAnimationInitialPosition + newDelta - delta; |
1101 d->refreshContainerGeometry(); |
927 d->mContainer->resizeContainer(); |
1102 } |
928 } |
1103 |
929 |
1104 return HbScrollArea::scrollByAmount(newDelta); |
930 return HbScrollArea::scrollByAmount(newDelta); |
1105 } |
|
1106 |
|
1107 /*! |
|
1108 \deprecated HbAbstractItemView::container() const |
|
1109 is deprecated, because class HbAbstractItemContainer will be made private. |
|
1110 |
|
1111 Returns the container widget. |
|
1112 */ |
|
1113 HbAbstractItemContainer *HbAbstractItemView::container() const |
|
1114 { |
|
1115 qWarning("HbAbstractItemView::container() const is deprecated, because class HbAbstractItemContainer will be made private."); |
|
1116 Q_D(const HbAbstractItemView); |
|
1117 return d->mContainer; |
|
1118 } |
931 } |
1119 |
932 |
1120 /*! |
933 /*! |
1121 \reimp |
934 \reimp |
1122 */ |
935 */ |
1153 } |
966 } |
1154 return HbScrollArea::itemChange(change, value); |
967 return HbScrollArea::itemChange(change, value); |
1155 } |
968 } |
1156 |
969 |
1157 /*! |
970 /*! |
1158 \deprecated HbAbstractItemView::type() const |
|
1159 is deprecated. |
|
1160 |
|
1161 \reimp |
|
1162 */ |
|
1163 int HbAbstractItemView::type() const |
|
1164 { |
|
1165 qWarning("HbAbstractItemView::type() const is deprecated!"); |
|
1166 |
|
1167 return Type; |
|
1168 } |
|
1169 |
|
1170 /*! |
|
1171 Returns the current name of layout definition of view items of this view |
971 Returns the current name of layout definition of view items of this view |
1172 |
972 |
1173 \sa setLayoutName() |
973 \sa setLayoutName() |
1174 */ |
974 */ |
1175 QString HbAbstractItemView::layoutName() const |
975 QString HbAbstractItemView::layoutName() const |
1269 } else { |
1069 } else { |
1270 HbScrollArea::gestureEvent(event); |
1070 HbScrollArea::gestureEvent(event); |
1271 } |
1071 } |
1272 } |
1072 } |
1273 |
1073 |
|
1074 /*! |
|
1075 This slot is called when touch down event occurs. Default implementation handles selection |
|
1076 and calls emitPressed(). |
|
1077 |
|
1078 \sa HbAbstractViewItem::pressed(const QPointF &position) |
|
1079 \sa emitPressed() |
|
1080 */ |
1274 void HbAbstractItemView::itemPressed(const QPointF &pos) |
1081 void HbAbstractItemView::itemPressed(const QPointF &pos) |
1275 { |
1082 { |
1276 Q_D(HbAbstractItemView); |
1083 Q_D(HbAbstractItemView); |
1277 |
1084 |
1278 d->mPostponedScrollIndex = QPersistentModelIndex(); |
1085 d->mPostponedScrollIndex = QPersistentModelIndex(); |
1291 } |
1098 } |
1292 |
1099 |
1293 emitPressed(item->modelIndex()); |
1100 emitPressed(item->modelIndex()); |
1294 } |
1101 } |
1295 |
1102 |
|
1103 /*! |
|
1104 This slot is called when touch release event occurs for view item. |
|
1105 Default implementation calls emitReleased(). |
|
1106 |
|
1107 \sa HbAbstractViewItem::released(const QPointF &position) |
|
1108 \sa emitReleased() |
|
1109 */ |
1296 void HbAbstractItemView::itemReleased(const QPointF &pos) |
1110 void HbAbstractItemView::itemReleased(const QPointF &pos) |
1297 { |
1111 { |
1298 Q_UNUSED(pos); |
1112 Q_UNUSED(pos); |
1299 |
1113 |
1300 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
1114 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
1301 emitReleased(item->modelIndex()); |
1115 emitReleased(item->modelIndex()); |
1302 } |
1116 } |
1303 |
1117 |
|
1118 /*! |
|
1119 This slot is called when view item is activated. |
|
1120 Default implementation handles selection and calls emitActivated(). |
|
1121 |
|
1122 \sa HbAbstractViewItem::itemActivated(const QPointF &position) |
|
1123 \sa emitActivated() |
|
1124 */ |
1304 void HbAbstractItemView::itemActivated(const QPointF &pos) |
1125 void HbAbstractItemView::itemActivated(const QPointF &pos) |
1305 { |
1126 { |
1306 Q_D(HbAbstractItemView); |
1127 Q_D(HbAbstractItemView); |
1307 |
1128 |
1308 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
1129 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
1317 } |
1138 } |
1318 |
1139 |
1319 emitActivated(index); |
1140 emitActivated(index); |
1320 } |
1141 } |
1321 |
1142 |
|
1143 /*! |
|
1144 This slot is called when view item is long pressed and long press is enabled in itemview. |
|
1145 Default implementation calls longPressed(). |
|
1146 |
|
1147 \sa HbAbstractViewItem::longPressed(const QPointF &position) |
|
1148 \sa longPressEnabled() |
|
1149 \sa longPressed() |
|
1150 */ |
1322 void HbAbstractItemView::itemLongPressed(const QPointF &pos) |
1151 void HbAbstractItemView::itemLongPressed(const QPointF &pos) |
1323 { |
1152 { |
|
1153 Q_D(HbAbstractItemView); |
|
1154 |
1324 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
1155 HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender()); |
|
1156 QModelIndex index = item->modelIndex(); |
|
1157 |
|
1158 d->mSelectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); |
|
1159 |
1325 emit longPressed(item, item->mapToScene(pos)); |
1160 emit longPressed(item, item->mapToScene(pos)); |
1326 } |
1161 } |
1327 |
1162 |
|
1163 /*! |
|
1164 This slot is called when concrete view item has been created. Default implementation connects |
|
1165 touch event releated signals of HbAbstractViewItem to respective slots in this class. |
|
1166 |
|
1167 \sa HbAbstractViewItem::pressed(const QPointF &position) |
|
1168 \sa HbAbstractViewItem::released(const QPointF &position) |
|
1169 \sa HbAbstractViewItem::itemActivated(const QPointF &position) |
|
1170 \sa HbAbstractViewItem::longPressed(const QPointF &position) |
|
1171 \sa itemPressed() |
|
1172 \sa itemReleased() |
|
1173 \sa itemActivated() |
|
1174 \sa itemLongPressed() |
|
1175 */ |
1328 void HbAbstractItemView::itemCreated(HbAbstractViewItem *item) |
1176 void HbAbstractItemView::itemCreated(HbAbstractViewItem *item) |
1329 { |
1177 { |
1330 QObject::connect(item, SIGNAL(pressed(QPointF)), this, SLOT(itemPressed(QPointF))); |
1178 QObject::connect(item, SIGNAL(pressed(QPointF)), this, SLOT(itemPressed(QPointF))); |
1331 QObject::connect(item, SIGNAL(released(QPointF)), this, SLOT(itemReleased(QPointF))); |
1179 QObject::connect(item, SIGNAL(released(QPointF)), this, SLOT(itemReleased(QPointF))); |
1332 QObject::connect(item, SIGNAL(activated(QPointF)), this, SLOT(itemActivated(QPointF))); |
1180 QObject::connect(item, SIGNAL(activated(QPointF)), this, SLOT(itemActivated(QPointF))); |