125 |
119 |
126 /*! |
120 /*! |
127 Shows check box list with all application. |
121 Shows check box list with all application. |
128 \param sortAttribute order to sort applications. |
122 \param sortAttribute order to sort applications. |
129 */ |
123 */ |
130 #ifdef COVERAGE_MEASUREMENT |
|
131 #pragma CTC SKIP |
|
132 #endif //COVERAGE_MEASUREMENT |
|
133 void HsAppsCheckList::showAppsCheckboxList(HsSortAttribute sortOrder) |
124 void HsAppsCheckList::showAppsCheckboxList(HsSortAttribute sortOrder) |
134 { |
125 { |
135 HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::showAppsCheckboxList"); |
126 HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::showAppsCheckboxList"); |
136 if (!mModel) { |
127 if (!mModel) { |
137 mModel = HsMenuService::getAllApplicationsModel(sortOrder); |
128 mModel = HsMenuService::getAllApplicationsModel(sortOrder); |
138 } |
129 } |
139 // fills model with data |
130 // fills model with data |
140 // constucts controls such as checklist |
131 // constucts controls such as checklist |
141 constructControls(); |
132 constructControls(); |
142 |
133 |
143 // Add mListView to main window |
134 if (mAppsSelectDialog) { |
144 HbMainWindow *hbMainWindow = mainWindow(); |
135 mAppsSelectDialog->setTimeout(HbPopup::NoTimeout); |
145 |
136 mAppsSelectDialog->setAttribute(Qt::WA_DeleteOnClose); |
146 // add confirm action |
137 mAppsSelectDialog->open(this, |
147 mView->setNavigationAction(mActionConfirm); |
138 SLOT(appsSelectionDialogFinished(HbAction*))); |
148 |
139 } |
149 hbMainWindow->addView(mView); |
140 |
150 // record the current view in order to activate it once done |
|
151 mPreviousView = hbMainWindow->currentView(); |
|
152 hbMainWindow->setCurrentView(mView); |
|
153 hbMainWindow->show(); |
|
154 HSMENUTEST_FUNC_EXIT("HsAppsCheckList::showAppsCheckboxList"); |
141 HSMENUTEST_FUNC_EXIT("HsAppsCheckList::showAppsCheckboxList"); |
155 } |
142 } |
156 #ifdef COVERAGE_MEASUREMENT |
143 |
157 #pragma CTC ENDSKIP |
|
158 #endif //COVERAGE_MEASUREMENT |
|
159 /*! |
144 /*! |
160 Construct contrlos. |
145 Construct contrlos. |
161 */ |
146 */ |
162 void HsAppsCheckList::constructControls() |
147 void HsAppsCheckList::constructControls() |
163 { |
148 { |
164 HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::constructControls"); |
149 HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::constructControls"); |
165 if (!mActionConfirm) { |
150 |
166 mActionConfirm = new HbAction(Hb::ConfirmNaviAction, mView); |
151 bool loadStatusOk = false; |
167 connect(mActionConfirm, SIGNAL(triggered()),SLOT(selectApplicationsDone())); |
152 HbDocumentLoader loader; |
168 } |
153 loader.load(HS_APP_CHECK_LIST_LAYOUT, &loadStatusOk); |
169 |
154 |
170 if (!mView) { // it implies that mListView is NULL as well |
155 Q_ASSERT_X(loadStatusOk, |
171 bool loadStatusOk = false; |
156 HS_APP_CHECK_LIST_LAYOUT, |
172 |
157 "Error while loading docml file."); |
173 HbDocumentLoader loader; |
158 |
174 mLoadedObjects = loader.load(HS_APP_CHECK_LIST_LAYOUT, &loadStatusOk); |
159 static const QString APPS_SELECTION_DIALOG("applications_selection_dialog"); |
175 |
160 mAppsSelectDialog = |
176 Q_ASSERT_X(loadStatusOk, |
161 qobject_cast<HbDialog *>(loader.findWidget(APPS_SELECTION_DIALOG)); |
177 HS_APP_CHECK_LIST_LAYOUT, |
162 |
178 "Error while loading docml file."); |
163 if (mAppsSelectDialog) { |
179 |
164 static const QString LIST_VIEW_WIDGET("listView"); |
180 static const QString VIEW_WIDGET_NAME("view"); |
|
181 mView = qobject_cast<HbView *> (loader.findWidget(VIEW_WIDGET_NAME)); |
|
182 mView->setParent(this); |
|
183 |
|
184 static const QString LIST_VIEW_WIDGET_NAME("listView"); |
|
185 mListView = qobject_cast<HbListView *> (loader.findWidget( |
165 mListView = qobject_cast<HbListView *> (loader.findWidget( |
186 LIST_VIEW_WIDGET_NAME)); |
166 LIST_VIEW_WIDGET)); |
|
167 mModel->setParent(mAppsSelectDialog); |
187 mListView->setModel(mModel); |
168 mListView->setModel(mModel); |
|
169 |
|
170 connect(mListView,SIGNAL(activated(const QModelIndex&) ),this |
|
171 ,SLOT(selectedItemsChanged())); |
|
172 connect(mModel,SIGNAL(rowsRemoved(const QModelIndex&, int,int)), |
|
173 this, SLOT(selectedItemsChanged())); |
|
174 |
|
175 // add confirm action |
|
176 static const QString HS_APPS_SELECTION_DIALOG_CONFIRMATION_ACTION |
|
177 ("aps_dialog_softkey_2_left"); |
|
178 mActionConfirm = qobject_cast<HbAction*>(loader.findObject( |
|
179 HS_APPS_SELECTION_DIALOG_CONFIRMATION_ACTION)); |
|
180 mActionConfirm->setEnabled(false); |
|
181 mAppsSelectDialog->actions()[0]->setParent(mAppsSelectDialog); |
|
182 mAppsSelectDialog->actions()[1]->setParent(mAppsSelectDialog); |
188 } |
183 } |
189 HSMENUTEST_FUNC_EXIT("HsAppsCheckList::constructControls"); |
184 HSMENUTEST_FUNC_EXIT("HsAppsCheckList::constructControls"); |
190 } |
185 } |
191 |
186 |
192 /*! |
187 /*! |
193 Slot connected trrigger action of secondary soft key of check list box. |
188 Action after closed application selection dialog. |
194 It is called when done button is selected. |
189 \param finishedAction chosen action. |
195 */ |
190 \retval void |
196 #ifdef COVERAGE_MEASUREMENT |
191 */ |
197 #pragma CTC SKIP |
192 void HsAppsCheckList::appsSelectionDialogFinished(HbAction* finishedAction) |
198 #endif //COVERAGE_MEASUREMENT |
193 { |
199 void HsAppsCheckList::selectApplicationsDone() |
194 HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::appsSelectionDialogFinished"); |
200 { |
|
201 HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::selectApplicationsDone"); |
|
202 // Remove mListView from main window and restore previous view. |
|
203 HbMainWindow *hbMainWindow = mainWindow(); |
|
204 hbMainWindow->setCurrentView(mPreviousView); |
|
205 hbMainWindow->removeView(mView); |
|
206 |
|
207 QItemSelectionModel *itemSelectionModel = mListView->selectionModel(); |
|
208 QList<int> itemsList; |
195 QList<int> itemsList; |
209 if (itemSelectionModel) { |
196 if (finishedAction == mActionConfirm) { |
210 QModelIndexList modelIndexList = |
197 QItemSelectionModel *itemSelectionModel = mListView->selectionModel(); |
211 itemSelectionModel->selectedIndexes(); |
198 if (itemSelectionModel) { |
212 itemsList = getSortedItemsList(modelIndexList); |
199 QModelIndexList modelIndexList = |
213 } |
200 itemSelectionModel->selectedIndexes(); |
|
201 itemsList = getSortedItemsList(modelIndexList); |
|
202 } |
|
203 } |
|
204 mAppsSelectDialog = NULL; |
214 emit commit(itemsList); |
205 emit commit(itemsList); |
215 HSMENUTEST_FUNC_EXIT("HsAppsCheckList::selectApplicationsDone"); |
206 HSMENUTEST_FUNC_EXIT("HsAppsCheckList::appsSelectionDialogFinished"); |
216 } |
207 } |
217 #ifdef COVERAGE_MEASUREMENT |
|
218 #pragma CTC ENDSKIP |
|
219 #endif //COVERAGE_MEASUREMENT |
|
220 |
208 |
221 /*! |
209 /*! |
222 Returns list with selected items ids. |
210 Returns list with selected items ids. |
223 \param modelIndexList list with selected model indexes. |
211 \param modelIndexList list with selected model indexes. |
224 \return list with items ids. |
212 \return list with items ids. |