13 * |
13 * |
14 * Description: videolist selection dialog implementation |
14 * Description: videolist selection dialog implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // Version : %version: 30.1.5 % |
18 // Version : %version: 30.1.7 % |
19 |
19 |
20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include <qgraphicsitem.h> |
21 #include <qgraphicsitem.h> |
22 #include <hblabel.h> |
22 #include <qtimer.h> |
23 #include <hbcheckbox.h> |
23 |
|
24 #include <vcxmyvideosdefs.h> |
|
25 |
24 #include <hbaction.h> |
26 #include <hbaction.h> |
25 #include <hbstackedwidget.h> |
|
26 #include <hbabstractitemview.h> |
27 #include <hbabstractitemview.h> |
27 #include <hbinputdialog.h> |
28 #include <hbinputdialog.h> |
28 #include <vcxmyvideosdefs.h> |
29 #include <hbwidget.h> |
29 #include <hbstyleloader.h> |
30 #include <hblistview.h> |
30 |
31 #include <hblistviewitem.h> |
31 #include "videocollectionuiloader.h" |
32 |
32 #include "videolistwidget.h" |
|
33 #include "videoproxymodelgeneric.h" |
33 #include "videoproxymodelgeneric.h" |
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 #include "videothumbnaildata.h" |
39 |
40 |
40 // Object names. |
41 // 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"; |
42 const char* const SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION = "vc:SelectionDialogNewCollection"; |
43 const char* const LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION = "vc::ListViewInputDialogCreateCollection"; |
43 const char* const LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION = "vc::ListViewInputDialogCreateCollection"; |
44 const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK = "vc:SelectionDialogButtonOk"; |
44 const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK = "vc:SelectionDialogButtonOk"; |
45 const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL = "vc:SelectionDialogButtonCancel"; |
45 const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL = "vc:SelectionDialogButtonCancel"; |
|
46 |
|
47 // Interval in ms to report the scroll position. |
|
48 const int SCROLL_POSITION_TIMER_TIMEOUT = 100; |
46 |
49 |
47 /** |
50 /** |
48 * global qHash function required fo creating hash values for TMPXItemId -keys |
51 * global qHash function required fo creating hash values for TMPXItemId -keys |
49 */ |
52 */ |
50 inline uint qHash(TMPXItemId key) |
53 inline uint qHash(TMPXItemId key) |
71 |
74 |
72 // --------------------------------------------------------------------------- |
75 // --------------------------------------------------------------------------- |
73 // VideoListSelectionDialog |
76 // VideoListSelectionDialog |
74 // --------------------------------------------------------------------------- |
77 // --------------------------------------------------------------------------- |
75 // |
78 // |
76 VideoListSelectionDialog::VideoListSelectionDialog( VideoCollectionUiLoader *uiLoader, |
79 VideoListSelectionDialog::VideoListSelectionDialog( QGraphicsItem *parent) |
77 QGraphicsItem *parent) |
80 : HbSelectionDialog( parent ) |
78 : HbDialog( parent ) |
81 , mTypeOfSelection( ENoFunction ) |
79 , mUiLoader( uiLoader ) |
|
80 , mTypeOfSelection( -1 ) |
|
81 , mHeading( 0 ) |
|
82 , mCheckboxContainer( 0 ) |
|
83 , mItemCount( 0 ) |
|
84 , mCheckBoxText( 0 ) |
|
85 , mCheckBox( 0 ) |
|
86 , mListContainer( 0 ) |
|
87 , mForcedCheck( false ) |
|
88 , mModel( 0 ) |
82 , mModel( 0 ) |
89 , mModelReady( false ) |
83 , mModelReady( false ) |
90 , mAlbumListReady( false ) |
84 , mAlbumListReady( false ) |
91 , mListWidget( 0 ) |
85 , mListInitialised( false ) |
92 , mPrimaryAction( 0 ) |
86 , mPrimaryAction( 0 ) |
93 , mSecondaryAction( 0 ) |
87 , mSecondaryAction( 0 ) |
94 { |
88 , mScrollPositionTimer( 0 ) |
95 FUNC_LOG; |
89 { |
96 |
90 FUNC_LOG; |
97 HbStyleLoader::registerFilePath( ":/style/hbdialog.css" ); |
91 |
98 |
92 // create model and init list, this will create listview in HbSelectionDialog |
99 setDismissPolicy(HbDialog::NoDismiss); |
93 mModel = VideoCollectionWrapper::instance().getGenericModel(); |
100 setTimeout(HbDialog::NoTimeout); |
94 initList(0); |
101 |
|
102 // create model for list widget |
|
103 mModel = |
|
104 VideoCollectionWrapper::instance().getGenericModel(); |
|
105 if (mModel) |
|
106 { |
|
107 // create list widget |
|
108 mListWidget = new VideoListWidget(mUiLoader); |
|
109 if(mListWidget->initialize(*mModel) < 0) |
|
110 { |
|
111 ERROR(-1, "VideoListSelectionDialog::VideoListSelectionDialog() failed to init list widget"); |
|
112 delete mListWidget; |
|
113 mListWidget = 0; |
|
114 } |
|
115 // disable list related animations to make dialog faster |
|
116 mListWidget->setEnabledAnimations(HbAbstractItemView::None); |
|
117 mListWidget->setObjectName(SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET); |
|
118 } |
|
119 } |
95 } |
120 |
96 |
121 // --------------------------------------------------------------------------- |
97 // --------------------------------------------------------------------------- |
122 // ~VideoListSelectionDialog |
98 // ~VideoListSelectionDialog |
123 // --------------------------------------------------------------------------- |
99 // --------------------------------------------------------------------------- |
124 // |
100 // |
125 VideoListSelectionDialog::~VideoListSelectionDialog() |
101 VideoListSelectionDialog::~VideoListSelectionDialog() |
126 { |
102 { |
127 FUNC_LOG; |
103 FUNC_LOG; |
128 HbStyleLoader::unregisterFilePath( ":/style/hbdialog.css" ); |
104 |
129 delete mListWidget; |
105 delete mScrollPositionTimer; |
130 mListWidget = 0; |
106 delete mPrimaryAction; |
|
107 delete mSecondaryAction; |
131 } |
108 } |
132 |
109 |
133 // --------------------------------------------------------------------------- |
110 // --------------------------------------------------------------------------- |
134 // setupContent |
111 // setupContent |
135 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
136 // |
113 // |
137 void VideoListSelectionDialog::setupContent(int type, TMPXItemId activeItem) |
114 void VideoListSelectionDialog::setupContent(VideoListSelectionDialog::TSelectionFunction type, TMPXItemId activeItem) |
138 { |
115 { |
139 FUNC_LOG; |
116 FUNC_LOG; |
140 INFO_1("VideoListSelectionDialog::setupContent() type: %d", type); |
117 INFO_1("VideoListSelectionDialog::setupContent() type: %d", type); |
141 if(type < EDeleteVideos || type > ESelectCollection) |
118 if(type == ENoFunction) |
142 { |
119 { |
143 return; |
120 return; |
144 } |
121 } |
145 |
122 |
146 mTypeOfSelection = type; |
123 mTypeOfSelection = type; |
147 if(!initDialog()) |
124 if(!initDialog()) |
148 { |
125 { |
149 ERROR(-1, "VideoListSelectionDialog::setupContent() dialog init failed."); |
126 ERROR(-1, "VideoListSelectionDialog::setupContent() dialog init failed."); |
150 return; |
127 return; |
151 } |
128 } |
152 mSelection.clear(); |
|
153 mSelectedVideos.clear(); |
129 mSelectedVideos.clear(); |
154 mSelectedAlbumId = TMPXItemId::InvalidId(); |
130 mSelectedAlbumId = TMPXItemId::InvalidId(); |
155 mNewAlbumText = QString(); |
131 mNewAlbumText = QString(); |
156 |
132 |
157 // if provided "owner" is album or category |
133 // if provided "owner" is album or category |
192 if (!mModel) |
168 if (!mModel) |
193 { |
169 { |
194 return false; |
170 return false; |
195 } |
171 } |
196 } |
172 } |
197 if (!mListContainer) |
173 |
198 { |
174 if(!mScrollPositionTimer) |
199 mListContainer = |
175 { |
200 mUiLoader->findWidget<HbStackedWidget>(DOCML_NAME_LIST_CONTAINER); |
176 mScrollPositionTimer = new QTimer(); |
201 |
177 mScrollPositionTimer->setSingleShot(true); |
202 if(!mListWidget) |
178 } |
203 { |
179 return true; |
204 mListWidget = new VideoListWidget(mUiLoader); |
180 } |
205 mListWidget->setObjectName(SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET); |
181 |
206 if(mListWidget->initialize(*mModel) < 0) |
182 // --------------------------------------------------------------------------- |
207 { |
183 // initList |
208 ERROR(-1, "VideoListSelectionDialog::initDialog() failed to setup VideoListWidget."); |
184 // --------------------------------------------------------------------------- |
209 delete mListWidget; |
185 // |
210 mListWidget = 0; |
186 bool VideoListSelectionDialog::initList(VideoProxyModelGeneric *model) |
211 mListContainer = 0; |
187 { |
212 return false; |
188 FUNC_LOG; |
213 } |
189 |
214 } |
190 setModel(model); |
215 if(mListContainer) |
191 |
216 { |
192 if(!mListInitialised) |
217 mListContainer->addWidget(mListWidget); |
193 { |
218 } |
194 HbWidget* content = static_cast<HbWidget*>(this->primitive("content")); |
219 } |
195 if(content) |
220 |
196 { |
221 if(!mHeading) |
197 HbListView* view = static_cast<HbListView*>(content->primitive("list")); |
222 { |
198 if (view) |
223 mHeading = mUiLoader->findWidget<HbLabel>(DOCML_NAME_DLG_HEADINGLBL); |
199 { |
224 } |
200 HbListViewItem *prototype = view->listItemPrototype(); |
225 if(!mCheckboxContainer) |
201 if(prototype) |
226 { |
202 { |
227 mCheckboxContainer = mUiLoader->findWidget<HbWidget>(DOCML_NAME_CHECK_CONTAINER); |
203 prototype->setGraphicsSize(HbListViewItem::WideThumbnail); |
228 } |
204 } |
229 if(!mItemCount) |
205 view->setItemRecycling(true); |
230 { |
206 view->setClampingStyle(HbScrollArea::BounceBackClamping); |
231 mItemCount = mUiLoader->findWidget<HbLabel>(DOCML_NAME_LBL_SELECTION); |
207 view->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
232 mItemCount->setAlignment(Qt::AlignRight); |
208 view->setFrictionEnabled(true); |
233 } |
209 view->setUniformItemSizes(true); |
234 if(!mCheckBox) |
210 view->setSelectionMode(HbAbstractItemView::NoSelection); |
235 { |
211 view->setItemPixmapCacheEnabled(true); |
236 mCheckBox = mUiLoader->findWidget<HbCheckBox >(DOCML_NAME_MARKALL); |
212 view->setEnabledAnimations(HbAbstractItemView::None); |
237 } |
213 |
238 |
214 mListInitialised = true; |
239 if(!mCheckBoxText) |
215 } |
240 { |
216 } |
241 mCheckBoxText = mUiLoader->findWidget<HbLabel >(DOCML_NAME_LBL_MARKALL); |
217 } |
242 } |
218 return mListInitialised; |
243 |
|
244 // HbDialog connects actions to finished signal by default. |
|
245 if(!mPrimaryAction) |
|
246 { |
|
247 mPrimaryAction = new HbAction(hbTrId("txt_common_button_ok")); |
|
248 mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK); |
|
249 addAction(mPrimaryAction); |
|
250 } |
|
251 if(!mSecondaryAction) |
|
252 { |
|
253 mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); |
|
254 mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL); |
|
255 addAction(mSecondaryAction); |
|
256 } |
|
257 |
|
258 if(!mListContainer || !mHeading || !mCheckBox || !mCheckBoxText) |
|
259 { |
|
260 ERROR(-1, "VideoListSelectionDialog::initDialog() !mListContainer || !mHeading || !mCheckBox || !mCheckBoxText"); |
|
261 return false; |
|
262 } |
|
263 return true; |
|
264 } |
219 } |
265 |
220 |
266 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
267 // activateSelection |
222 // activateSelection |
268 // --------------------------------------------------------------------------- |
223 // --------------------------------------------------------------------------- |
269 // |
224 // |
270 void VideoListSelectionDialog::activateSelection() |
225 void VideoListSelectionDialog::activateSelection(bool changeMode) |
271 { |
226 { |
272 FUNC_LOG; |
227 FUNC_LOG; |
273 // "add to collection", "remove from collection" and "create collection" -selections |
|
274 // needs additional functionality for primary key |
|
275 if(mTypeOfSelection == EAddToCollection || |
|
276 mTypeOfSelection == ERemoveFromCollection || |
|
277 mTypeOfSelection == ECreateCollection) |
|
278 { |
|
279 mPrimaryAction->disconnect(SIGNAL(triggered())); |
|
280 connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot())); |
|
281 } |
|
282 QString headingTxt(""); |
228 QString headingTxt(""); |
283 QString primaryTxt(""); |
229 QString primaryTxt(""); |
284 // create texts |
230 // create texts |
285 switch(mTypeOfSelection) |
231 switch(mTypeOfSelection) |
286 { |
232 { |
287 case EDeleteVideos: |
233 case EDeleteVideos: |
288 primaryTxt = hbTrId("txt_common_button_delete"); |
234 primaryTxt = hbTrId("txt_common_button_delete"); |
|
235 headingTxt = hbTrId("txt_videos_title_delete_videos"); |
289 break; |
236 break; |
290 case EAddToCollection: |
237 case EAddToCollection: |
291 primaryTxt = hbTrId("txt_common_button_add"); |
238 primaryTxt = hbTrId("txt_common_button_add"); |
|
239 headingTxt = hbTrId("txt_videos_title_add_videos"); |
292 break; |
240 break; |
293 case ECreateCollection: |
241 case ECreateCollection: |
294 primaryTxt = hbTrId("txt_common_button_ok"); |
242 primaryTxt = hbTrId("txt_common_button_ok"); |
|
243 headingTxt = hbTrId("txt_videos_title_add_videos"); |
295 break; |
244 break; |
296 case ERemoveFromCollection: |
245 case ERemoveFromCollection: |
297 primaryTxt = hbTrId("txt_common_button_remove"); |
246 primaryTxt = hbTrId("txt_common_button_remove"); |
|
247 headingTxt = hbTrId("txt_videos_title_remove_videos"); |
298 break; |
248 break; |
299 case ESelectCollection: |
249 case ESelectCollection: |
300 primaryTxt = hbTrId("txt_videos_button_new"); |
250 primaryTxt = hbTrId("txt_videos_button_new"); |
|
251 headingTxt = hbTrId("txt_videos_title_select_collection"); |
301 break; |
252 break; |
302 default: |
253 default: |
303 break; |
254 break; |
304 } |
255 } |
305 |
256 |
306 mPrimaryAction->setText(primaryTxt); |
|
307 |
|
308 mModelReady = false; |
257 mModelReady = false; |
309 mAlbumListReady = false; |
258 mAlbumListReady = false; |
|
259 setModel(0); |
310 |
260 |
311 if(mTypeOfSelection == ESelectCollection) |
261 if(mTypeOfSelection == ESelectCollection) |
312 { |
262 { |
313 headingTxt = hbTrId("txt_videos_title_select_collection"); |
263 mModel->open(VideoCollectionCommon::ELevelCategory); |
314 mCheckboxContainer->setVisible(false); |
264 VideoCollectionViewUtils::sortModel(mModel, false, VideoCollectionCommon::ELevelCategory); |
315 mListWidget->setSelectionMode(-1); |
265 |
316 mListWidget->activate(VideoCollectionCommon::ELevelCategory); |
266 setModel(mModel); |
317 // New collection button is always enabled for collection selection. |
267 setSelectionMode(HbAbstractItemView::NoSelection); |
318 mPrimaryAction->setDisabled(false); |
268 |
|
269 if(changeMode) |
|
270 { |
|
271 removeAction(mSecondaryAction); |
|
272 if(!mPrimaryAction) |
|
273 { |
|
274 mPrimaryAction = new HbAction(); |
|
275 mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK); |
|
276 addAction(mPrimaryAction); |
|
277 } |
|
278 // New collection button is always enabled for collection selection. |
|
279 mPrimaryAction->setDisabled(false); |
|
280 } |
|
281 else |
|
282 { |
|
283 clearActions(); |
|
284 |
|
285 if(!mPrimaryAction) |
|
286 { |
|
287 mPrimaryAction = new HbAction(primaryTxt); |
|
288 mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK); |
|
289 } |
|
290 else |
|
291 { |
|
292 mPrimaryAction->setText(primaryTxt); |
|
293 } |
|
294 addAction(mPrimaryAction); |
|
295 |
|
296 if(!mSecondaryAction) |
|
297 { |
|
298 mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); |
|
299 mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL); |
|
300 } |
|
301 addAction(mSecondaryAction); |
|
302 |
|
303 // New collection button is always enabled for collection selection. |
|
304 mPrimaryAction->setDisabled(false); |
|
305 } |
319 } |
306 } |
320 else |
307 else |
321 { |
308 { |
322 headingTxt = hbTrId("txt_videos_title_select_videos"); |
309 mModel->open(VideoCollectionCommon::ELevelVideos); |
323 mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection); |
310 VideoCollectionViewUtils::sortModel(mModel, false, VideoCollectionCommon::ELevelVideos); |
324 mListWidget->activate(VideoCollectionCommon::ELevelVideos); |
311 |
325 mCheckboxContainer->setVisible(true); |
312 setModel(mModel); |
326 mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount())); |
313 setSelectionMode(HbAbstractItemView::MultiSelection); |
327 mCheckBox->setChecked(false); |
314 clearActions(); |
328 |
315 |
|
316 if(!mPrimaryAction) |
|
317 { |
|
318 mPrimaryAction = new HbAction(primaryTxt); |
|
319 mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK); |
|
320 } |
|
321 else |
|
322 { |
|
323 mPrimaryAction->setText(primaryTxt); |
|
324 } |
|
325 addAction(mPrimaryAction); |
|
326 |
329 // Add button will be enabled when videos are selected from the list. |
327 // Add button will be enabled when videos are selected from the list. |
330 mPrimaryAction->setDisabled(mTypeOfSelection != ECreateCollection); |
328 mPrimaryAction->setDisabled(mTypeOfSelection != ECreateCollection); |
331 } |
329 |
332 mHeading->setPlainText(headingTxt); |
330 if(!mSecondaryAction) |
333 // sort to make sure dialog has correctly filtered content |
331 { |
334 // at the same order as in view |
332 mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); |
335 VideoCollectionViewUtils::sortModel(mModel, false, mListWidget->getLevel()); |
333 mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL); |
|
334 } |
|
335 addAction(mSecondaryAction); |
|
336 } |
|
337 setHeadingText(headingTxt); |
|
338 |
|
339 // "add to collection", "remove from collection" and "create collection" -selections |
|
340 // needs additional functionality for primary key |
|
341 if(mTypeOfSelection == EAddToCollection || |
|
342 mTypeOfSelection == ERemoveFromCollection || |
|
343 mTypeOfSelection == ECreateCollection) |
|
344 { |
|
345 mPrimaryAction->disconnect(SIGNAL(triggered())); |
|
346 connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot())); |
|
347 } |
336 } |
348 } |
337 |
349 |
338 // --------------------------------------------------------------------------- |
350 // --------------------------------------------------------------------------- |
339 // exec |
351 // exec |
340 // --------------------------------------------------------------------------- |
352 // --------------------------------------------------------------------------- |
341 // |
353 // |
342 void VideoListSelectionDialog::exec() |
354 void VideoListSelectionDialog::exec() |
343 { |
355 { |
344 FUNC_LOG; |
356 FUNC_LOG; |
345 // clear checkbox |
357 |
346 mCheckBox->setChecked(false); |
358 connectSignals(); |
347 |
|
348 mListWidget->clearSelection(); |
|
349 |
|
350 // scroll list back to top |
|
351 mListWidget->scrollTo(mModel->index(0, 0)); |
|
352 |
|
353 connectSignals(); |
|
354 |
359 |
355 if(mTypeOfSelection == ECreateCollection) |
360 if(mTypeOfSelection == ECreateCollection) |
356 { |
361 { |
357 // note this does not leak memory as the dialog will destroy itself upon close. |
362 // note this does not leak memory as the dialog will destroy itself upon close. |
358 HbInputDialog *dialog = gCreateNewAlbumNameDialog(LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION); |
363 HbInputDialog *dialog = gCreateNewAlbumNameDialog(LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION); |
359 dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *))); |
364 dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *))); |
360 } |
365 } |
361 else if(mModel->rowCount()) |
366 else if(mModel->rowCount()) |
362 { |
367 { |
363 // show dialog |
368 // show dialog |
364 HbDialog::open(); |
369 VideoThumbnailData::instance().enableBackgroundFetching(true); |
|
370 fetchThumbnailsForVisibleItems(); |
|
371 HbSelectionDialog::open(); |
365 } |
372 } |
366 else if((mModelReady && mTypeOfSelection != ESelectCollection) || |
373 else if((mModelReady && mTypeOfSelection != ESelectCollection) || |
367 (mAlbumListReady && mTypeOfSelection == ESelectCollection)) |
374 (mAlbumListReady && mTypeOfSelection == ESelectCollection)) |
368 { |
375 { |
369 INFO("VideoListSelectionDialog::exec(): nothing to show, finishing.") |
376 INFO("VideoListSelectionDialog::exec(): nothing to show, finishing.") |
499 } |
537 } |
500 } |
538 } |
501 // user is deleting videos |
539 // user is deleting videos |
502 else if(mTypeOfSelection == EDeleteVideos) |
540 else if(mTypeOfSelection == EDeleteVideos) |
503 { |
541 { |
504 QVariant data = mSelection.indexes().count(); |
542 QModelIndexList selection = selectedModelIndexes(); |
|
543 QVariant data = selection.count(); |
|
544 |
505 VideoCollectionViewUtils::instance().showStatusMsgSlot( |
545 VideoCollectionViewUtils::instance().showStatusMsgSlot( |
506 VideoCollectionCommon::statusDeleteInProgress, |
546 VideoCollectionCommon::statusDeleteInProgress, |
507 data); |
547 data); |
508 // delete items |
548 // delete items |
509 mModel->deleteItems(mSelection.indexes()); |
549 mModel->deleteItems(selection); |
510 } |
550 } |
511 } |
|
512 |
|
513 // --------------------------------------------------------------------------- |
|
514 // markAllStateChanged |
|
515 // --------------------------------------------------------------------------- |
|
516 // |
|
517 void VideoListSelectionDialog::markAllStateChangedSlot(int state) |
|
518 { |
|
519 FUNC_LOG; |
|
520 if(mForcedCheck) |
|
521 { |
|
522 return; |
|
523 } |
|
524 if(state == Qt::Checked) |
|
525 { |
|
526 mListWidget->selectAll(); |
|
527 } |
|
528 else |
|
529 { |
|
530 mListWidget->clearSelection(); |
|
531 } |
|
532 } |
551 } |
533 |
552 |
534 // --------------------------------------------------------------------------- |
553 // --------------------------------------------------------------------------- |
535 // selectionChangedSlot |
554 // selectionChangedSlot |
536 // --------------------------------------------------------------------------- |
555 // --------------------------------------------------------------------------- |
537 // |
556 // |
538 void VideoListSelectionDialog::selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected) |
557 void VideoListSelectionDialog::selectionChangedSlot() |
539 { |
558 { |
540 FUNC_LOG; |
559 FUNC_LOG; |
541 if(!mPrimaryAction || mTypeOfSelection == ESelectCollection) |
560 if(!mPrimaryAction || mTypeOfSelection == ESelectCollection) |
542 { |
561 { |
543 INFO("VideoListSelectionDialog::selectionChangedSlot(): no primary action or we are selecting collection.") |
562 INFO("VideoListSelectionDialog::selectionChangedSlot(): no primary action or we are selecting collection.") |
544 return; |
563 return; |
545 } |
564 } |
546 |
565 |
547 if(selected.indexes().count() > 0) |
566 QModelIndexList selected(selectedModelIndexes()); |
548 { |
567 |
549 mSelection.merge(selected, QItemSelectionModel::Select); |
568 if(selected.count() > 0) |
550 } |
|
551 |
|
552 if(deselected.indexes().count() > 0) |
|
553 { |
|
554 mSelection.merge(deselected, QItemSelectionModel::Deselect); |
|
555 } |
|
556 |
|
557 if(mSelection.indexes().count() > 0) |
|
558 { |
569 { |
559 mPrimaryAction->setDisabled(false); |
570 mPrimaryAction->setDisabled(false); |
560 |
|
561 if(mTypeOfSelection == ECreateCollection) |
571 if(mTypeOfSelection == ECreateCollection) |
|
572 |
562 { |
573 { |
563 mPrimaryAction->setText(hbTrId("txt_common_button_add")); |
574 mPrimaryAction->setText(hbTrId("txt_common_button_add")); |
564 } |
575 } |
565 } |
576 } |
566 else |
577 else |
739 void VideoListSelectionDialog::connectSignals() |
696 void VideoListSelectionDialog::connectSignals() |
740 { |
697 { |
741 FUNC_LOG; |
698 FUNC_LOG; |
742 // dialog finished |
699 // dialog finished |
743 connect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*))); |
700 connect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*))); |
744 |
701 |
745 // selection changes |
702 //selection changes |
746 connect(mListWidget, SIGNAL(activated(const QModelIndex&)), |
703 connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot())); |
747 this, SLOT(singleItemSelectedSlot(const QModelIndex&))); |
|
748 |
|
749 connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)), |
|
750 this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &))); |
|
751 |
704 |
752 // model changes signals |
705 // model changes signals |
753 connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
706 connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
754 connect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot())); |
707 connect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot())); |
755 connect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot())); |
708 |
756 |
709 connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot())); |
757 // mark all state changes |
710 |
758 connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int))); |
711 HbWidget* content = static_cast<HbWidget*>(this->primitive("content")); |
759 } |
712 HbListView* view(0); |
760 |
713 if(content) |
|
714 { |
|
715 view = static_cast<HbListView*>(content->primitive("list")); |
|
716 if (view) |
|
717 { |
|
718 connect(view, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot())); |
|
719 connect(view, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot())); |
|
720 connect(view, SIGNAL(scrollPositionChanged(const QPointF &)), |
|
721 this, SLOT(scrollPositionChangedSlot(const QPointF &))); |
|
722 } |
|
723 } |
|
724 } |
|
725 |
761 // --------------------------------------------------------------------------- |
726 // --------------------------------------------------------------------------- |
762 // disconnectSignals |
727 // disconnectSignals |
763 // --------------------------------------------------------------------------- |
728 // --------------------------------------------------------------------------- |
764 // |
729 // |
765 void VideoListSelectionDialog::disconnectSignals() |
730 void VideoListSelectionDialog::disconnectSignals() |
766 { |
731 { |
767 FUNC_LOG; |
732 FUNC_LOG; |
768 disconnect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*))); |
733 disconnect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*))); |
769 |
734 |
770 disconnect(mListWidget, SIGNAL(activated(const QModelIndex&)), |
735 //selection changes |
771 this, SLOT(singleItemSelectedSlot(const QModelIndex&))); |
736 disconnect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot())); |
772 |
|
773 disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)), |
|
774 this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &))); |
|
775 |
737 |
776 // model changes signals |
738 // model changes signals |
777 disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
739 disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
778 disconnect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot())); |
740 disconnect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot())); |
779 disconnect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot())); |
741 |
780 |
742 // check that scroll position timer is created |
781 // mark all state changes |
743 if (mScrollPositionTimer) |
782 disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int))); |
744 { |
|
745 disconnect( |
|
746 mScrollPositionTimer, SIGNAL(timeout()), |
|
747 this, SLOT(scrollPositionTimerSlot())); |
|
748 } |
|
749 |
|
750 HbWidget* content = static_cast<HbWidget*>(this->primitive("content")); |
|
751 HbListView* view(0); |
|
752 if(content) |
|
753 { |
|
754 view = static_cast<HbListView*>(content->primitive("list")); |
|
755 if (view) |
|
756 { |
|
757 disconnect(view, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot())); |
|
758 disconnect(view, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot())); |
|
759 disconnect(view, SIGNAL(scrollPositionChanged(const QPointF &)), |
|
760 this, SLOT(scrollPositionChangedSlot(const QPointF &))); |
|
761 } |
|
762 } |
783 } |
763 } |
784 |
764 |
785 // --------------------------------------------------------------------------- |
765 // --------------------------------------------------------------------------- |
786 // getSelectedName |
766 // getSelectedName |
787 // --------------------------------------------------------------------------- |
767 // --------------------------------------------------------------------------- |
805 } |
785 } |
806 } |
786 } |
807 return name; |
787 return name; |
808 } |
788 } |
809 |
789 |
|
790 // --------------------------------------------------------------------------- |
|
791 // scrollingStartedSlot |
|
792 // --------------------------------------------------------------------------- |
|
793 // |
|
794 void VideoListSelectionDialog::scrollingStartedSlot() |
|
795 { |
|
796 FUNC_LOG_ADDR(this); |
|
797 VideoThumbnailData::instance().enableThumbnailCreation(false); |
|
798 } |
|
799 |
|
800 // --------------------------------------------------------------------------- |
|
801 // scrollingEndedSlot |
|
802 // --------------------------------------------------------------------------- |
|
803 // |
|
804 void VideoListSelectionDialog::scrollingEndedSlot() |
|
805 { |
|
806 FUNC_LOG_ADDR(this); |
|
807 |
|
808 if(mScrollPositionTimer) |
|
809 { |
|
810 mScrollPositionTimer->stop(); |
|
811 } |
|
812 |
|
813 VideoThumbnailData::instance().enableBackgroundFetching(true); |
|
814 VideoThumbnailData::instance().enableThumbnailCreation(true); |
|
815 fetchThumbnailsForVisibleItems(); |
|
816 } |
|
817 |
|
818 // --------------------------------------------------------------------------- |
|
819 // scrollPositionChangedSlot |
|
820 // --------------------------------------------------------------------------- |
|
821 // |
|
822 void VideoListSelectionDialog::scrollPositionChangedSlot(const QPointF &newPosition) |
|
823 { |
|
824 Q_UNUSED(newPosition); |
|
825 |
|
826 if(mScrollPositionTimer && !mScrollPositionTimer->isActive()) |
|
827 mScrollPositionTimer->start(SCROLL_POSITION_TIMER_TIMEOUT); |
|
828 } |
|
829 |
|
830 // --------------------------------------------------------------------------- |
|
831 // scrollPositionTimerSlot |
|
832 // --------------------------------------------------------------------------- |
|
833 // |
|
834 void VideoListSelectionDialog::scrollPositionTimerSlot() |
|
835 { |
|
836 FUNC_LOG_ADDR(this); |
|
837 |
|
838 fetchThumbnailsForVisibleItems(); |
|
839 } |
|
840 |
|
841 // --------------------------------------------------------------------------- |
|
842 // fetchThumbnailsForVisibleItems |
|
843 // --------------------------------------------------------------------------- |
|
844 // |
|
845 void VideoListSelectionDialog::fetchThumbnailsForVisibleItems() |
|
846 { |
|
847 FUNC_LOG_ADDR(this); |
|
848 |
|
849 // No need to do anything if thumbnail fetching is not enabled. |
|
850 if(!VideoThumbnailData::instance().backgroundFetchingEnabled()) |
|
851 { |
|
852 return; |
|
853 } |
|
854 HbWidget* content = static_cast<HbWidget*>(this->primitive("content")); |
|
855 HbListView* view(0); |
|
856 if(content) |
|
857 { |
|
858 view = static_cast<HbListView*>(content->primitive("list")); |
|
859 if (!view) |
|
860 { |
|
861 return; |
|
862 } |
|
863 } |
|
864 |
|
865 const QList<HbAbstractViewItem *> itemsVisible = view->visibleItems(); |
|
866 |
|
867 if(itemsVisible.count() > 0) |
|
868 { |
|
869 int row = itemsVisible.value(0)->modelIndex().row(); |
|
870 VideoThumbnailData::instance().startBackgroundFetching(mModel, row); |
|
871 } |
|
872 else |
|
873 { |
|
874 // Nothing visible yet, start from first index. |
|
875 VideoThumbnailData::instance().startBackgroundFetching(mModel, 0); |
|
876 } |
|
877 } |
|
878 |
810 // End of file |
879 // End of file |