47 */ |
47 */ |
48 MpCollectionListContainer::MpCollectionListContainer( HbDocumentLoader *loader, QGraphicsItem *parent ) |
48 MpCollectionListContainer::MpCollectionListContainer( HbDocumentLoader *loader, QGraphicsItem *parent ) |
49 : MpCollectionContainer(loader, parent), |
49 : MpCollectionContainer(loader, parent), |
50 mList(0), |
50 mList(0), |
51 mNoMusic(0), |
51 mNoMusic(0), |
52 mIndexFeedback( new HbIndexFeedback()) |
52 mIndexFeedback(0), |
|
53 mLongPressedIndex(0) |
53 { |
54 { |
54 TX_ENTRY |
55 TX_ENTRY |
|
56 mIndexFeedback = new HbIndexFeedback(); |
55 mIndexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); |
57 mIndexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); |
56 TX_EXIT |
58 TX_EXIT |
57 } |
59 } |
58 |
60 |
59 /*! |
61 /*! |
89 TX_EXIT |
91 TX_EXIT |
90 } |
92 } |
91 |
93 |
92 /*! |
94 /*! |
93 Slot to be called when an item is selected by the user. |
95 Slot to be called when an item is selected by the user. |
94 Start animation. |
|
95 */ |
96 */ |
96 void MpCollectionListContainer::itemActivated( const QModelIndex &index ) |
97 void MpCollectionListContainer::itemActivated( const QModelIndex &index ) |
97 { |
98 { |
98 TX_ENTRY_ARGS("index=" << index.row()); |
99 TX_ENTRY_ARGS("index=" << index.row()); |
99 emit MpCollectionContainer::itemActivated( index.row() ); |
100 emit MpCollectionContainer::itemActivated( index.row() ); |
100 TX_EXIT |
101 TX_EXIT |
101 } |
102 } |
102 |
103 |
103 /*! |
104 /*! |
104 Slot to be called when an item is long pressed by the user. |
105 Slot to be called when an item is long pressed by the user. |
|
106 Remember the index so that we can scroll to this vicinity if the data is reloaded, for example, |
|
107 after a delete operation is selected from the context menu. |
105 */ |
108 */ |
106 void MpCollectionListContainer::onLongPressed( HbAbstractViewItem *listViewItem, const QPointF &coords ) |
109 void MpCollectionListContainer::onLongPressed( HbAbstractViewItem *listViewItem, const QPointF &coords ) |
107 { |
110 { |
108 TX_ENTRY |
111 TX_ENTRY |
109 emit MpCollectionContainer::itemLongPressed(listViewItem->modelIndex().row(), coords); |
112 mLongPressedIndex = listViewItem->modelIndex().row(); |
|
113 emit MpCollectionContainer::itemLongPressed(mLongPressedIndex, coords); |
|
114 TX_EXIT |
|
115 } |
|
116 |
|
117 /*! |
|
118 Slot to be called data model has new data. |
|
119 If the data is reloaded as a result of operation like delete, we want to scroll to the |
|
120 nearby area where user has performed the action. |
|
121 |
|
122 \sa onLongPressed |
|
123 */ |
|
124 void MpCollectionListContainer::dataReloaded() |
|
125 { |
|
126 TX_ENTRY |
|
127 if ( mLongPressedIndex > 0 ) { |
|
128 --mLongPressedIndex; |
|
129 } |
|
130 if ( mList ) { |
|
131 mList->scrollTo( mDataModel->index(mLongPressedIndex, 0) ); |
|
132 } |
110 TX_EXIT |
133 TX_EXIT |
111 } |
134 } |
112 |
135 |
113 /*! |
136 /*! |
114 \internal |
137 \internal |
115 */ |
138 */ |
116 void MpCollectionListContainer::initializeList() |
139 void MpCollectionListContainer::initializeList() |
117 { |
140 { |
118 TX_ENTRY |
141 TX_ENTRY |
119 mList->setItemRecycling(true); |
142 mList->setItemRecycling(true); |
120 mList->setScrollingStyle( HbListView::PanOrFlick ); |
|
121 mList->setClampingStyle( HbListView::BounceBackClamping ); |
|
122 mList->setLongPressEnabled(true); |
143 mList->setLongPressEnabled(true); |
123 |
144 |
124 connect(mList, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); |
145 connect(mList, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); |
125 connect(mList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); |
146 connect(mList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); |
126 |
147 |