equal
deleted
inserted
replaced
49 |
49 |
50 \sa HsAppLibraryState |
50 \sa HsAppLibraryState |
51 */ |
51 */ |
52 |
52 |
53 /*! |
53 /*! |
54 |
54 \fn void activated(const QModelIndex &index); |
|
55 \param index of activated item. |
|
56 Emitted on tap event on the list view. |
|
57 */ |
|
58 |
|
59 /*! |
|
60 \fn void longPressed(HbAbstractViewItem *item, const QPointF &coords); |
|
61 \param item List element that was long-pressed. |
|
62 \param coords Coordinates of the long-press. |
|
63 Emitted on long-press event on the list view |
|
64 */ |
|
65 /*! |
|
66 \fn void listViewChange(); |
|
67 Emitted on model count change for current model |
|
68 \see void setModel(QAbstractItemModel *model) |
|
69 */ |
|
70 /*! |
55 Retrieves UI objects for a requested context and sets up signals' connections. |
71 Retrieves UI objects for a requested context and sets up signals' connections. |
56 |
72 |
57 \param builder Menu View builder. |
73 \param builder Menu View builder. |
58 \param stateContext Variable representing view context the view is to be prepared for. |
74 \param stateContext Variable representing view context the view is to be prepared for. |
59 \param mainWindow Object responsible for making a given view |
75 \param mainWindow Object responsible for making a given view |
80 connect(mHsSearchView.data(), SIGNAL(activated(QModelIndex)), |
96 connect(mHsSearchView.data(), SIGNAL(activated(QModelIndex)), |
81 this, SIGNAL(activated(QModelIndex))); |
97 this, SIGNAL(activated(QModelIndex))); |
82 connect(mHsSearchView.data(), |
98 connect(mHsSearchView.data(), |
83 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
99 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
84 this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF))); |
100 this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF))); |
|
101 connect(mHsSearchView.data(), SIGNAL(searchComplete(QModelIndex)), |
|
102 this, SLOT(handleSearchComplete(QModelIndex))); |
85 } |
103 } |
86 |
104 |
87 /*! |
105 /*! |
88 Empty. |
106 Empty. |
89 */ |
107 */ |
108 SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)), |
126 SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)), |
109 this, |
127 this, |
110 SLOT(scrollToRow(int, QAbstractItemView::ScrollHint))); |
128 SLOT(scrollToRow(int, QAbstractItemView::ScrollHint))); |
111 disconnect(mListView->model(), SIGNAL(countChange()), |
129 disconnect(mListView->model(), SIGNAL(countChange()), |
112 this, |
130 this, |
113 SIGNAL(listViewChange())); |
131 SIGNAL(listViewChange())); |
114 } |
132 } |
115 |
133 |
116 mListView->setItemPixmapCacheEnabled(true); // TODO: remove when enabled from default |
134 mListView->setItemPixmapCacheEnabled(true); // TODO: remove when enabled from default |
117 mListView->setModel(model, new HsListViewItem()); |
135 mListView->setModel(model, new HsListViewItem()); |
118 |
136 |
129 |
147 |
130 HSMENUTEST_FUNC_EXIT("HsMenuView::setModel"); |
148 HSMENUTEST_FUNC_EXIT("HsMenuView::setModel"); |
131 } |
149 } |
132 |
150 |
133 /*! |
151 /*! |
134 Returns model for list item view. |
152 Returns model for list item view or null if list view is not available. |
135 */ |
153 */ |
136 QAbstractItemModel *HsMenuView::model() const |
154 QAbstractItemModel *HsMenuView::model() const |
137 { |
155 { |
138 return mListView->model(); |
156 if (mListView != NULL) { |
|
157 return mListView->model(); |
|
158 } else { |
|
159 return NULL; |
|
160 } |
139 } |
161 } |
140 |
162 |
141 /*! |
163 /*! |
142 \return View widget of the menu view. |
164 \return View widget of the menu view. |
143 */ |
165 */ |
251 Add the view to main window and connect search action with \a showSearchPanel |
273 Add the view to main window and connect search action with \a showSearchPanel |
252 slot of the window. |
274 slot of the window. |
253 */ |
275 */ |
254 void HsMenuView::activate() |
276 void HsMenuView::activate() |
255 { |
277 { |
256 mMainWindow.setCurrentView(mView); |
278 if (!mHsSearchView->isActive()) { |
257 connect(mBuilder.searchAction(), SIGNAL(triggered()), |
279 mMainWindow.setCurrentView(mView); |
258 this, SLOT(showSearchPanel()), Qt::UniqueConnection); |
280 connect(mBuilder.searchAction(), SIGNAL(triggered()), |
|
281 this, SLOT(showSearchPanel()), Qt::UniqueConnection); |
|
282 } |
259 } |
283 } |
260 |
284 |
261 /*! |
285 /*! |
262 Disconnects search action and disconnects \a showSearchPanel slot from the window. |
286 Disconnects search action and disconnects \a showSearchPanel slot from the window. |
263 */ |
287 */ |
320 mView = mBuilder.currentView(); |
344 mView = mBuilder.currentView(); |
321 mListView = mBuilder.currentListView(); |
345 mListView = mBuilder.currentListView(); |
322 mViewLabel = mBuilder.currentViewLabel(); |
346 mViewLabel = mBuilder.currentViewLabel(); |
323 mAddContentButton = mBuilder.currentAddContentButton(); |
347 mAddContentButton = mBuilder.currentAddContentButton(); |
324 } |
348 } |
|
349 |
|
350 |
|
351 /*! |
|
352 Slot. |
|
353 \param firstMatching Index of first item of search result. |
|
354 If menu view is about to show it scrolls the list to \a firstMatching. |
|
355 Makes view represented by the object main view of the application. |
|
356 */ |
|
357 void HsMenuView::handleSearchComplete(const QModelIndex& firstMatching) |
|
358 { |
|
359 if (mListView != NULL) { |
|
360 mListView->scrollTo(firstMatching, HbAbstractItemView::PositionAtTop); |
|
361 } |
|
362 |
|
363 activate(); |
|
364 } |