34 #include "videolistselectiondialog.h" |
34 #include "videolistselectiondialog.h" |
35 #include "videocollectionwrapper.h" |
35 #include "videocollectionwrapper.h" |
36 #include "videocollectionviewutils.h" |
36 #include "videocollectionviewutils.h" |
37 #include "videocollectionclient.h" |
37 #include "videocollectionclient.h" |
38 #include "videocollectiontrace.h" |
38 #include "videocollectiontrace.h" |
|
39 |
|
40 // Object names. |
|
41 const char* const SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET = "vc:SelectionDialogListWidget"; |
|
42 const char* const SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION = "vc:SelectionDialogNewCollection"; |
|
43 const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK = "vc:SelectionDialogButtonOk"; |
|
44 const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL = "vc:SelectionDialogButtonCancel"; |
39 |
45 |
40 /** |
46 /** |
41 * global qHash function required fo creating hash values for TMPXItemId -keys |
47 * global qHash function required fo creating hash values for TMPXItemId -keys |
42 */ |
48 */ |
43 inline uint qHash(TMPXItemId key) |
49 inline uint qHash(TMPXItemId key) |
89 delete mListWidget; |
95 delete mListWidget; |
90 mListWidget = 0; |
96 mListWidget = 0; |
91 } |
97 } |
92 // disable list related animations to make dialog faster |
98 // disable list related animations to make dialog faster |
93 mListWidget->setEnabledAnimations(HbAbstractItemView::None); |
99 mListWidget->setEnabledAnimations(HbAbstractItemView::None); |
|
100 mListWidget->setObjectName(SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET); |
94 } |
101 } |
95 } |
102 } |
96 |
103 |
97 // --------------------------------------------------------------------------- |
104 // --------------------------------------------------------------------------- |
98 // ~VideoListSelectionDialog |
105 // ~VideoListSelectionDialog |
173 mUiLoader->findWidget<HbStackedWidget>(DOCML_NAME_LIST_CONTAINER); |
180 mUiLoader->findWidget<HbStackedWidget>(DOCML_NAME_LIST_CONTAINER); |
174 |
181 |
175 if(!mListWidget) |
182 if(!mListWidget) |
176 { |
183 { |
177 mListWidget = new VideoListWidget(mUiLoader); |
184 mListWidget = new VideoListWidget(mUiLoader); |
|
185 mListWidget->setObjectName(SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET); |
178 if(mListWidget->initialize(*mModel) < 0) |
186 if(mListWidget->initialize(*mModel) < 0) |
179 { |
187 { |
180 ERROR(-1, "VideoListSelectionDialog::initDialog() failed to setup VideoListWidget."); |
188 ERROR(-1, "VideoListSelectionDialog::initDialog() failed to setup VideoListWidget."); |
181 delete mListWidget; |
189 delete mListWidget; |
182 mListWidget = 0; |
190 mListWidget = 0; |
215 |
223 |
216 // HbDialog connects actions to finished signal by default. |
224 // HbDialog connects actions to finished signal by default. |
217 if(!mPrimaryAction) |
225 if(!mPrimaryAction) |
218 { |
226 { |
219 mPrimaryAction = new HbAction(hbTrId("txt_common_button_ok")); |
227 mPrimaryAction = new HbAction(hbTrId("txt_common_button_ok")); |
|
228 mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK); |
220 addAction(mPrimaryAction); |
229 addAction(mPrimaryAction); |
221 } |
230 } |
222 if(!mSecondaryAction) |
231 if(!mSecondaryAction) |
223 { |
232 { |
224 mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); |
233 mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); |
|
234 mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL); |
225 addAction(mSecondaryAction); |
235 addAction(mSecondaryAction); |
226 } |
236 } |
227 |
237 |
228 if(!mListContainer || !mHeading || !mCheckBox || !mCheckBoxText) |
238 if(!mListContainer || !mHeading || !mCheckBox || !mCheckBoxText) |
229 { |
239 { |
275 { |
285 { |
276 headingTxt = hbTrId("txt_videos_title_select_collection"); |
286 headingTxt = hbTrId("txt_videos_title_select_collection"); |
277 mCheckboxContainer->setVisible(false); |
287 mCheckboxContainer->setVisible(false); |
278 mListWidget->setSelectionMode(-1); |
288 mListWidget->setSelectionMode(-1); |
279 mListWidget->activate(VideoCollectionCommon::ELevelCategory); |
289 mListWidget->activate(VideoCollectionCommon::ELevelCategory); |
280 // need to set primaryaction disabled here in order for it |
290 // New collection button is always enabled for collection selection. |
281 // get correctly updated at modelReady(), where it will be enabled |
291 mPrimaryAction->setDisabled(false); |
282 // if state would be same, no update will happen |
|
283 mPrimaryAction->setDisabled(true); |
|
284 } |
292 } |
285 else |
293 else |
286 { |
294 { |
287 headingTxt = hbTrId("txt_videos_title_select_videos"); |
295 headingTxt = hbTrId("txt_videos_title_select_videos"); |
288 mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection); |
296 mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection); |
289 mListWidget->activate(VideoCollectionCommon::ELevelVideos); |
297 mListWidget->activate(VideoCollectionCommon::ELevelVideos); |
290 mCheckboxContainer->setVisible(true); |
298 mCheckboxContainer->setVisible(true); |
291 mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount())); |
299 mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount())); |
292 mCheckBox->setChecked(false); |
300 mCheckBox->setChecked(false); |
293 // need to set primaryaction enabled here in order for it |
301 // Add button will be enabled when videos are selected from the list. |
294 // get correctly updated at modelReady(), where it will be disabled |
302 mPrimaryAction->setDisabled(true); |
295 // if state would be same, no update will happen |
|
296 mPrimaryAction->setDisabled(false); |
|
297 } |
303 } |
298 mHeading->setPlainText(headingTxt); |
304 mHeading->setPlainText(headingTxt); |
299 // sort to make sure dialog has correctly filtered content |
305 // sort to make sure dialog has correctly filtered content |
300 // at the same order as in view |
306 // at the same order as in view |
301 VideoCollectionViewUtils::sortModel(mModel, false, mListWidget->getLevel()); |
307 VideoCollectionViewUtils::sortModel(mModel, false, mListWidget->getLevel()); |
343 { |
349 { |
344 INFO("VideoListSelectionDialog::exec(): secondary action triggered.") |
350 INFO("VideoListSelectionDialog::exec(): secondary action triggered.") |
345 return; |
351 return; |
346 } |
352 } |
347 QString albumName(""); |
353 QString albumName(""); |
348 if( mTypeOfSelection == ESelectCollection ) |
354 if(mTypeOfSelection == ESelectCollection) |
349 { |
355 { |
350 mTypeOfSelection = EAddToCollection; |
356 mTypeOfSelection = EAddToCollection; |
351 if( mSelectedAlbumId == TMPXItemId::InvalidId()) |
357 if(mSelectedAlbumId == TMPXItemId::InvalidId()) |
352 { |
358 { |
353 QString label(hbTrId("txt_videos_title_enter_name")); |
359 QString label(hbTrId("txt_videos_title_enter_name")); |
354 HbInputDialog *dialog = new HbInputDialog(); |
360 HbInputDialog *dialog = new HbInputDialog(); |
|
361 dialog->setObjectName(SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION); |
355 dialog->setAttribute(Qt::WA_DeleteOnClose); |
362 dialog->setAttribute(Qt::WA_DeleteOnClose); |
356 dialog->getText(label, this, SLOT(newAlbumNameDialogFinished(HbAction *)), |
363 dialog->setPromptText(label); |
357 hbTrId("txt_videos_dialog_entry_new_collection")); |
364 dialog->setValue(hbTrId("txt_videos_dialog_entry_new_collection")); |
|
365 dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *))); |
358 } |
366 } |
359 else |
367 else |
360 { |
368 { |
361 finalize(); |
369 finalize(); |
362 } |
370 } |
406 { |
414 { |
407 if(!albumName.length()) |
415 if(!albumName.length()) |
408 { |
416 { |
409 albumName = getSelectedName(); |
417 albumName = getSelectedName(); |
410 } |
418 } |
411 QVariant data = albumName; |
419 QList<QVariant> dataList; |
|
420 dataList.append(QVariant(mSelectedVideos.count())); |
|
421 dataList.append(QVariant(albumName)); |
|
422 QVariant data = dataList; |
412 VideoCollectionViewUtils::instance().showStatusMsgSlot( |
423 VideoCollectionViewUtils::instance().showStatusMsgSlot( |
413 VideoCollectionCommon::statusVideosAddedToCollection, |
424 VideoCollectionCommon::statusVideosAddedToCollection, |
414 data); |
425 data); |
415 } |
426 } |
416 } |
427 } |
520 void VideoListSelectionDialog::modelReadySlot() |
531 void VideoListSelectionDialog::modelReadySlot() |
521 { |
532 { |
522 FUNC_LOG; |
533 FUNC_LOG; |
523 if(mTypeOfSelection == ESelectCollection) |
534 if(mTypeOfSelection == ESelectCollection) |
524 { |
535 { |
525 mPrimaryAction->setDisabled(false); |
|
526 if(!mModel->rowCount()) |
536 if(!mModel->rowCount()) |
527 { |
537 { |
528 // in case there are no user defined albums, |
538 // in case there are no user defined albums, |
529 // start input dialog right away by accepting dialog |
539 // start input dialog right away by accepting dialog |
530 INFO("VideoListSelectionDialog::selectionChangedSlot(): no albums, starting album creation.") |
540 INFO("VideoListSelectionDialog::selectionChangedSlot(): no albums, starting album creation.") |
531 mPrimaryAction->trigger(); |
541 mPrimaryAction->trigger(); |
532 return; |
542 return; |
533 } |
543 } |
534 } |
|
535 if(mTypeOfSelection != ESelectCollection) |
|
536 { |
|
537 mPrimaryAction->setDisabled(true); |
|
538 } |
544 } |
539 updateCounterSlot(); |
545 updateCounterSlot(); |
540 } |
546 } |
541 |
547 |
542 // --------------------------------------------------------------------------- |
548 // --------------------------------------------------------------------------- |