|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: VideoCollectionViewPlugin class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 76.1.8 % |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <qcoreapplication.h> |
|
22 #include <xqserviceutil.h> |
|
23 #include <xqplugin.h> |
|
24 #include <hbview.h> |
|
25 #include <hbinstance.h> |
|
26 #include <hbstackedwidget.h> |
|
27 #include <hbmarqueeitem.h> |
|
28 #include <hbpushbutton.h> |
|
29 #include <hbaction.h> |
|
30 #include <qabstractitemmodel.h> |
|
31 #include <hbmessagebox.h> |
|
32 #include <hblistwidget.h> |
|
33 #include <hblistwidgetitem.h> |
|
34 #include <hblistviewitem.h> |
|
35 #include <hbparameterlengthlimiter.h> |
|
36 #include <hbtextitem.h> |
|
37 #include <hbscrollbar.h> |
|
38 #include <cmath> |
|
39 #include <thumbnailmanager_qt.h> |
|
40 #include <shareui.h> |
|
41 |
|
42 #include "videocollectionclient.h" |
|
43 #include "videofiledetailsviewplugin.h" |
|
44 #include "videocollectioncommon.h" |
|
45 #include "mpxhbvideocommondefs.h" |
|
46 #include "videocollectionwrapper.h" |
|
47 #include "videosortfilterproxymodel.h" |
|
48 #include "videoservices.h" |
|
49 #include "videodetailslabel.h" |
|
50 #include "videocollectiontrace.h" |
|
51 |
|
52 // Object names. |
|
53 const char* const VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL = "vc:FileDetailsThumbnailLabel"; |
|
54 const char* const VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO = "vc:FileDetailsMessageBoxDeleteVideo"; |
|
55 const char* const VIDEO_DETAILS_OBJECT_NAME_MESSAGE_BOX_WARNING = "vc:FileDetailsMessageBoxWarning"; |
|
56 const char* const VIDEO_DETAILS_OBJECT_NAME_DELETE_ACTION = "vc:FileDetailsDelete"; |
|
57 const char* const VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK = "vc:FileDetailsNavKeyBack"; |
|
58 const char* const VIDEO_DETAILS_OBJECT_NAME_TITLE_ANIM = "vc:FileDetailsTitleAnim"; |
|
59 |
|
60 // Docml constants. |
|
61 const char* const VIDEO_DETAILS_DOCML = ":/xml/videofiledetails.docml"; |
|
62 const char* const VIDEO_DETAILS_PORTRAIT = "portrait"; |
|
63 const char* const VIDEO_DETAILS_LANDSCAPE = "landscape"; |
|
64 const char* const VIDEO_DETAILS_VIEW = "videofiledetailsview"; |
|
65 const char* const VIDEO_DETAILS_TITLE = "mLblTitle"; |
|
66 const char* const VIDEO_DETAILS_THUMBNAIL = "mDetailsLabel"; |
|
67 const char* const VIDEO_DETAILS_BUTTON = "mButton"; |
|
68 const char* const VIDEO_DETAILS_MENUACTION_DELETE = "mOptionsDelete"; |
|
69 const char* const VIDEO_DETAILS_LISTWIDGET = "mDetailsList"; |
|
70 |
|
71 // Default thumbnail. |
|
72 const char* const VIDEO_DETAILS_GFX_DEFAULT = "qtg_large_video"; |
|
73 |
|
74 const int VIDEO_DETAILS_SECONDARY_TEXT_ROW_COUNT = 255; |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Constructor |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 VideoFileDetailsViewPlugin::VideoFileDetailsViewPlugin() |
|
81 : mModel( 0 ) |
|
82 , mVideoServices( 0 ) |
|
83 , mActivated( false ) |
|
84 , mIsService( false ) |
|
85 , mVideoId( TMPXItemId::InvalidId() ) |
|
86 , mDeletedIndex( -1 ) |
|
87 , mPreviousOrietation( Qt::Vertical ) |
|
88 , mNavKeyBackAction( 0 ) |
|
89 , mTitleAnim( 0 ) |
|
90 , mThumbLabel( 0 ) |
|
91 , mThumbnailManager( 0 ) |
|
92 , mCollectionWrapper( VideoCollectionWrapper::instance() ) |
|
93 , mShareUi(0) |
|
94 { |
|
95 FUNC_LOG; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // Destructor |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 VideoFileDetailsViewPlugin::~VideoFileDetailsViewPlugin() |
|
103 { |
|
104 FUNC_LOG; |
|
105 destroyView(); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // Create view |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void VideoFileDetailsViewPlugin::createView() |
|
113 { |
|
114 FUNC_LOG; |
|
115 mLoader.reset(); |
|
116 |
|
117 mActivated = false; |
|
118 |
|
119 bool ok = false; |
|
120 |
|
121 //Load the details view docml first |
|
122 mLoader.load(VIDEO_DETAILS_DOCML, &ok); |
|
123 |
|
124 if(!ok) |
|
125 { |
|
126 ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load docml."); |
|
127 return; |
|
128 } |
|
129 |
|
130 //Load portrait section by default as only vertical orientation is currently supported by videoplayer |
|
131 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT, &ok); |
|
132 |
|
133 if(!ok) |
|
134 { |
|
135 ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load portrait view."); |
|
136 return; |
|
137 } |
|
138 |
|
139 mModel = mCollectionWrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
|
140 |
|
141 if (!mModel) |
|
142 { |
|
143 ERROR(-1, "VideoFileDetailsViewPlugin::createView() get model failed."); |
|
144 return; |
|
145 } |
|
146 |
|
147 mIsService = XQServiceUtil::isService(); |
|
148 |
|
149 // no deallocation needed for this since |
|
150 // stackedwidget takes ownership |
|
151 mTitleAnim = new HbMarqueeItem; |
|
152 HbFontSpec spec = mTitleAnim->fontSpec(); |
|
153 spec.setRole( HbFontSpec::Primary ); |
|
154 mTitleAnim->setFontSpec( spec ); |
|
155 mTitleAnim->setLoopCount(-1); |
|
156 mTitleAnim->setObjectName(VIDEO_DETAILS_OBJECT_NAME_TITLE_ANIM); |
|
157 |
|
158 connect(mModel->sourceModel(), |
|
159 SIGNAL(shortDetailsReady(TMPXItemId)), |
|
160 this, SLOT(shortDetailsReadySlot(TMPXItemId))); |
|
161 |
|
162 connect(mModel->sourceModel(), |
|
163 SIGNAL(fullVideoDetailsReady(QVariant&)), |
|
164 this, SLOT(fullDetailsReadySlot(QVariant&))); |
|
165 |
|
166 connect(mModel, |
|
167 SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
|
168 this, SLOT(rowsRemovedSlot(const QModelIndex&, int, int))); |
|
169 |
|
170 // Setup thumbnail widget. |
|
171 HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL); |
|
172 if(!thumbWidget) |
|
173 { |
|
174 ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load thumbnail widget."); |
|
175 return; |
|
176 } |
|
177 |
|
178 // no deallocation needed for this since |
|
179 // stackedwidget takes ownership |
|
180 mThumbLabel = new VideoDetailsLabel; |
|
181 mThumbLabel->setAlignment(Qt::AlignCenter); |
|
182 mThumbLabel->setObjectName(VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL); |
|
183 |
|
184 connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot())); |
|
185 |
|
186 thumbWidget->addWidget(mThumbLabel); |
|
187 |
|
188 // Load details title. |
|
189 HbStackedWidget* title = findObject<HbStackedWidget>(VIDEO_DETAILS_TITLE); |
|
190 if(!title) |
|
191 { |
|
192 ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load title."); |
|
193 return; |
|
194 } |
|
195 title->addWidget(mTitleAnim); |
|
196 |
|
197 // Load delete action. |
|
198 HbAction* deleteAction = findObject<HbAction>(VIDEO_DETAILS_MENUACTION_DELETE); |
|
199 if(!deleteAction) |
|
200 { |
|
201 ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to delete action."); |
|
202 return; |
|
203 } |
|
204 deleteAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_ACTION); |
|
205 |
|
206 if (mIsService) |
|
207 { |
|
208 deleteAction->setVisible(false); |
|
209 } |
|
210 else |
|
211 { |
|
212 connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteVideoSlot())); |
|
213 } |
|
214 |
|
215 // Create navigation keys. |
|
216 mNavKeyBackAction = new HbAction(Hb::BackNaviAction); |
|
217 mNavKeyBackAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK); |
|
218 |
|
219 if (!mThumbnailManager) |
|
220 { |
|
221 mThumbnailManager = new ThumbnailManager(); |
|
222 } |
|
223 |
|
224 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap,void*,int,int)), |
|
225 this, SLOT(thumbnailReadySlot(QPixmap,void*,int,int))); |
|
226 |
|
227 HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET); |
|
228 if(!list) |
|
229 { |
|
230 ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget."); |
|
231 return; |
|
232 } |
|
233 |
|
234 list->setEnabledAnimations(HbAbstractItemView::None); |
|
235 |
|
236 list->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
|
237 |
|
238 HbScrollBar* bar = list->verticalScrollBar(); |
|
239 |
|
240 if(bar) |
|
241 { |
|
242 bar->setInteractive(true); |
|
243 } |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // Destroy view |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 void VideoFileDetailsViewPlugin::destroyView() |
|
251 { |
|
252 FUNC_LOG; |
|
253 if (mActivated) |
|
254 { |
|
255 deactivateView(); |
|
256 } |
|
257 |
|
258 if(mVideoServices) |
|
259 { |
|
260 mVideoServices->decreaseReferenceCount(); |
|
261 mVideoServices = 0; |
|
262 } |
|
263 |
|
264 delete mNavKeyBackAction; |
|
265 mNavKeyBackAction = 0; |
|
266 |
|
267 delete mThumbnailManager; |
|
268 mThumbnailManager = 0; |
|
269 |
|
270 disconnect(); |
|
271 mLoader.reset(); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // Activate view |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void VideoFileDetailsViewPlugin::activateView() |
|
279 { |
|
280 FUNC_LOG; |
|
281 if (!mActivated) |
|
282 { |
|
283 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
|
284 |
|
285 HbView *currentView = mainWnd->currentView(); |
|
286 if(currentView && mNavKeyBackAction) |
|
287 { |
|
288 if (connect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back())), Qt::UniqueConnection) |
|
289 { |
|
290 currentView->setNavigationAction(mNavKeyBackAction); |
|
291 } |
|
292 else |
|
293 { |
|
294 ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to connect navkey signal."); |
|
295 return; |
|
296 } |
|
297 } |
|
298 |
|
299 mainWnd->setOrientation(Qt::Vertical, false); |
|
300 |
|
301 // following if is for the future implementations where we should support |
|
302 // also landscape configuration. |
|
303 Qt::Orientation orientation = mainWnd->orientation(); |
|
304 if ( (orientation == Qt::Vertical) && (orientation != mPreviousOrietation) ) |
|
305 { |
|
306 mPreviousOrietation = orientation; |
|
307 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT); |
|
308 } |
|
309 else if ( (orientation == Qt::Horizontal) && (orientation != mPreviousOrietation) ) |
|
310 { |
|
311 mPreviousOrietation = orientation; |
|
312 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE); |
|
313 } |
|
314 |
|
315 if (mIsService && !mVideoServices) |
|
316 { |
|
317 mVideoServices = VideoServices::instance(); |
|
318 |
|
319 if (!mVideoServices) |
|
320 { |
|
321 ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to get video services instance."); |
|
322 return; |
|
323 } |
|
324 } |
|
325 |
|
326 VideoServices::TVideoService service = VideoServices::ENoService; |
|
327 if (mIsService && mVideoServices) |
|
328 { |
|
329 service = mVideoServices->currentService(); |
|
330 |
|
331 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
|
332 mainWnd->currentView()->setTitle(mVideoServices->contextTitle()); |
|
333 } |
|
334 |
|
335 HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON); |
|
336 if(!button) |
|
337 { |
|
338 ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details button."); |
|
339 return; |
|
340 } |
|
341 |
|
342 // Fix the size of the thumbnail, as that needs to be in 16:9 |
|
343 qreal width = button->size().width(); |
|
344 qreal height = width * 9 / 16; |
|
345 |
|
346 HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL); |
|
347 thumbWidget->setPreferredWidth(width); |
|
348 thumbWidget->setPreferredHeight(height); |
|
349 |
|
350 if (service == VideoServices::EUriFetcher) |
|
351 { |
|
352 HbIcon icon = HbIcon("qtg_mono_attach"); |
|
353 button->setIcon(icon); |
|
354 |
|
355 connect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()), Qt::UniqueConnection); |
|
356 connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)), Qt::UniqueConnection); |
|
357 } |
|
358 else |
|
359 { |
|
360 connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()), Qt::UniqueConnection); |
|
361 |
|
362 HbIcon icon = HbIcon("qtg_mono_share"); |
|
363 button->setIcon(icon); |
|
364 } |
|
365 |
|
366 connect(mainWnd, |
|
367 SIGNAL(orientationChanged(Qt::Orientation)), |
|
368 this, SLOT(orientationChange(Qt::Orientation)), |
|
369 Qt::UniqueConnection); |
|
370 |
|
371 connect(&mCollectionWrapper, |
|
372 SIGNAL(asyncStatus(int, QVariant&)), |
|
373 this, SLOT(handleErrorSlot(int, QVariant&)), |
|
374 Qt::UniqueConnection); |
|
375 |
|
376 // setup title size in order for animation to be enabled if needed |
|
377 mTitleAnim->setMinimumWidth(hbInstance->allMainWindows().value(0)->width()-50); |
|
378 mTitleAnim->adjustSize(); |
|
379 |
|
380 mActivated = true; |
|
381 } |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // Deactivate view |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 void VideoFileDetailsViewPlugin::deactivateView() |
|
389 { |
|
390 FUNC_LOG; |
|
391 if ( mActivated ) |
|
392 { |
|
393 mVideoId = TMPXItemId::InvalidId(); |
|
394 |
|
395 mDeletedIndex = -1; // set index as invalid. |
|
396 |
|
397 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
|
398 |
|
399 mainWnd->unsetOrientation(); |
|
400 |
|
401 HbView *currentView = mainWnd->currentView(); |
|
402 if(currentView) |
|
403 { |
|
404 currentView->setNavigationAction(0); |
|
405 } |
|
406 |
|
407 disconnect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back())); |
|
408 |
|
409 disconnect(mainWnd, SIGNAL( orientationChanged( Qt::Orientation ) ), |
|
410 this, SLOT( orientationChange( Qt::Orientation ) )); |
|
411 |
|
412 disconnect(&mCollectionWrapper, |
|
413 SIGNAL(asyncStatus(int, QVariant&)), |
|
414 this, SLOT(handleErrorSlot(int, QVariant&))); |
|
415 |
|
416 mTitleAnim->stopAnimation(); |
|
417 mTitleAnim->setText(""); |
|
418 |
|
419 mActivated = false; |
|
420 |
|
421 mThumbLabel->setIcon(HbIcon()); |
|
422 |
|
423 HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON); |
|
424 |
|
425 if (mIsService) |
|
426 { |
|
427 disconnect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri())); |
|
428 disconnect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&))); |
|
429 } |
|
430 else |
|
431 { |
|
432 disconnect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot())); |
|
433 } |
|
434 } |
|
435 delete mShareUi; |
|
436 mShareUi = 0; |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------------------------- |
|
440 // Get view |
|
441 // --------------------------------------------------------------------------- |
|
442 // |
|
443 QGraphicsWidget* VideoFileDetailsViewPlugin::getView() |
|
444 { |
|
445 FUNC_LOG; |
|
446 return mLoader.findWidget(VIDEO_DETAILS_VIEW); |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // Slot: Orientation change |
|
451 // --------------------------------------------------------------------------- |
|
452 // |
|
453 void VideoFileDetailsViewPlugin::orientationChange( Qt::Orientation orientation ) |
|
454 { |
|
455 FUNC_LOG; |
|
456 if (orientation == Qt::Vertical) |
|
457 { |
|
458 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT); |
|
459 } |
|
460 |
|
461 else if (orientation == Qt::Horizontal) |
|
462 { |
|
463 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE); |
|
464 } |
|
465 mTitleAnim->adjustSize(); |
|
466 mTitleAnim->startAnimation(); |
|
467 } |
|
468 |
|
469 // --------------------------------------------------------------------------- |
|
470 // Slot: back |
|
471 // --------------------------------------------------------------------------- |
|
472 // |
|
473 void VideoFileDetailsViewPlugin::back() |
|
474 { |
|
475 FUNC_LOG; |
|
476 if (mActivated) |
|
477 { |
|
478 emit command( MpxHbVideoCommon::ActivateCollectionView ); |
|
479 } |
|
480 } |
|
481 |
|
482 // --------------------------------------------------------------------------- |
|
483 // Slot: shortDetailsReadySlot |
|
484 // --------------------------------------------------------------------------- |
|
485 // |
|
486 void VideoFileDetailsViewPlugin::shortDetailsReadySlot(TMPXItemId id) |
|
487 { |
|
488 FUNC_LOG; |
|
489 // first clear all details, so that the view doesn't display the old data. |
|
490 findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET)->clear(); |
|
491 |
|
492 QModelIndex modelIndex = mModel->indexOfId(id); |
|
493 |
|
494 mVideoId = id; |
|
495 |
|
496 QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle); |
|
497 |
|
498 if (variant.isValid() && mTitleAnim) |
|
499 { |
|
500 mTitleAnim->setText(variant.toString()); |
|
501 } |
|
502 startFetchingThumbnail(); |
|
503 } |
|
504 |
|
505 // --------------------------------------------------------------------------- |
|
506 // Slot: fullDetailsReadySlot |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 void VideoFileDetailsViewPlugin::fullDetailsReadySlot(QVariant& variant) |
|
510 { |
|
511 FUNC_LOG; |
|
512 using namespace VideoCollectionCommon; |
|
513 |
|
514 int detailCount = sizeof(VideoDetailLabelKeys) / sizeof(int); |
|
515 |
|
516 QMap<QString, QVariant> metadata = variant.toMap(); |
|
517 |
|
518 HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET); |
|
519 if(!list) |
|
520 { |
|
521 ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget."); |
|
522 return; |
|
523 } |
|
524 |
|
525 if(list->count()) |
|
526 { |
|
527 list->clear(); |
|
528 } |
|
529 |
|
530 HbListViewItem *prototype = list->listItemPrototype(); |
|
531 prototype->setSecondaryTextRowCount(1, VIDEO_DETAILS_SECONDARY_TEXT_ROW_COUNT); |
|
532 |
|
533 for(int i = 0; i< detailCount; i++) { |
|
534 if (metadata.contains(VideoDetailLabelKeys[i])) |
|
535 { |
|
536 HbListWidgetItem* listWidgetItem = new HbListWidgetItem(); |
|
537 listWidgetItem->setText( hbTrId(VideoDetailLabels[i])); |
|
538 listWidgetItem->setSecondaryText(metadata[VideoDetailLabelKeys[i]].toString()); |
|
539 list->addItem(listWidgetItem); |
|
540 |
|
541 // following is required to change wrapping-mode for the second row |
|
542 HbListViewItem *viewItem = static_cast<HbListViewItem*>(list->viewItem(list->row(listWidgetItem))); |
|
543 if(viewItem) |
|
544 { |
|
545 HbTextItem *secondLine = static_cast<HbTextItem*>(viewItem->primitive("text-2")); |
|
546 if(secondLine) |
|
547 { |
|
548 secondLine->setTextWrapping(Hb::TextWrapAnywhere); |
|
549 } |
|
550 } |
|
551 } |
|
552 } |
|
553 |
|
554 // start title animation |
|
555 mTitleAnim->startAnimation(); |
|
556 } |
|
557 |
|
558 // --------------------------------------------------------------------------- |
|
559 // Slot: getFileUri |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 void VideoFileDetailsViewPlugin::getFileUri() |
|
563 { |
|
564 FUNC_LOG; |
|
565 if (mVideoId != TMPXItemId::InvalidId()) |
|
566 { |
|
567 QModelIndex modelIndex = mModel->indexOfId(mVideoId); |
|
568 QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath); |
|
569 if (variant.isValid()) |
|
570 { |
|
571 QString itemPath = variant.value<QString>(); |
|
572 emit(fileUri(itemPath)); |
|
573 } |
|
574 } |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // Slot: startPlaybackSlot |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 void VideoFileDetailsViewPlugin::startPlaybackSlot() |
|
582 { |
|
583 FUNC_LOG; |
|
584 if (mVideoId != TMPXItemId::InvalidId()) |
|
585 { |
|
586 mModel->openItem(mVideoId); |
|
587 } |
|
588 } |
|
589 |
|
590 // --------------------------------------------------------------------------- |
|
591 // Slot: sendVideo |
|
592 // --------------------------------------------------------------------------- |
|
593 // |
|
594 void VideoFileDetailsViewPlugin::sendVideoSlot() |
|
595 { |
|
596 FUNC_LOG; |
|
597 |
|
598 if(mVideoId != TMPXItemId::InvalidId()) |
|
599 { |
|
600 if(!mShareUi) |
|
601 { |
|
602 mShareUi = new ShareUi(); |
|
603 } |
|
604 QModelIndex modelIndex = mModel->indexOfId(mVideoId); |
|
605 QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath); |
|
606 if(variant.isValid()) |
|
607 { |
|
608 QStringList fileList; |
|
609 fileList.append(variant.toString()); |
|
610 mShareUi->send(fileList, true); |
|
611 } |
|
612 } |
|
613 } |
|
614 |
|
615 // --------------------------------------------------------------------------- |
|
616 // Slot: deleteVideo |
|
617 // --------------------------------------------------------------------------- |
|
618 // |
|
619 void VideoFileDetailsViewPlugin::deleteVideoSlot() |
|
620 { |
|
621 FUNC_LOG; |
|
622 if (mVideoId != TMPXItemId::InvalidId()) |
|
623 { |
|
624 QModelIndex modelIndex = mModel->indexOfId(mVideoId); |
|
625 QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle); |
|
626 |
|
627 if (variant.isValid()) |
|
628 { |
|
629 QString text = HbParameterLengthLimiter(hbTrId("txt_videos_info_do_you_want_to_delete_1")). |
|
630 arg(variant.toString()); |
|
631 |
|
632 HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion); |
|
633 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
634 messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No); |
|
635 messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO); |
|
636 messageBox->open(this, SLOT(deleteVideoDialogFinished(int))); |
|
637 } |
|
638 } |
|
639 } |
|
640 |
|
641 // --------------------------------------------------------------------------- |
|
642 // deleteVideoDialogFinished |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 void VideoFileDetailsViewPlugin::deleteVideoDialogFinished(int action) |
|
646 { |
|
647 FUNC_LOG; |
|
648 QModelIndex modelIndex = mModel->indexOfId(mVideoId); |
|
649 if(action == HbMessageBox::Yes && modelIndex.isValid()) |
|
650 { |
|
651 deleteItem(modelIndex); |
|
652 } |
|
653 } |
|
654 |
|
655 // --------------------------------------------------------------------------- |
|
656 // deleteItem |
|
657 // --------------------------------------------------------------------------- |
|
658 // |
|
659 void VideoFileDetailsViewPlugin::deleteItem(QModelIndex index) |
|
660 { |
|
661 FUNC_LOG; |
|
662 mDeletedIndex = index.row(); |
|
663 |
|
664 QModelIndexList list; |
|
665 list.append(index); |
|
666 mModel->deleteItems(list); |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // Slot: rowsRemovedSlot |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 void VideoFileDetailsViewPlugin::rowsRemovedSlot(const QModelIndex& parent, |
|
674 int first, int last) |
|
675 { |
|
676 FUNC_LOG; |
|
677 Q_UNUSED(parent); |
|
678 |
|
679 if(mActivated && mDeletedIndex > -1 && |
|
680 (mDeletedIndex >= first && mDeletedIndex <= last)) |
|
681 { |
|
682 // item is withing the group of removed items, deactivate view |
|
683 emit command(MpxHbVideoCommon::ActivateCollectionView); |
|
684 } |
|
685 } |
|
686 |
|
687 // ------------------------------------------------------------------------------------------------- |
|
688 // Slot: handleErrorSlot() |
|
689 // error signal received from collectionwrapper |
|
690 // ------------------------------------------------------------------------------------------------- |
|
691 // |
|
692 void VideoFileDetailsViewPlugin::handleErrorSlot(int errorCode, QVariant &additional) |
|
693 { |
|
694 FUNC_LOG; |
|
695 QString msg(""); |
|
696 if(errorCode == VideoCollectionCommon::statusSingleDeleteFail) |
|
697 { |
|
698 QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current"); |
|
699 if(additional.isValid()) |
|
700 { |
|
701 msg = HbParameterLengthLimiter(format).arg(additional.toString()); |
|
702 } |
|
703 } |
|
704 if(msg.count() > 0) |
|
705 { |
|
706 // show msg box if there's something to show |
|
707 HbMessageBox *messageBox = new HbMessageBox(msg, HbMessageBox::MessageTypeWarning); |
|
708 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
709 messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_MESSAGE_BOX_WARNING); |
|
710 messageBox->show(); |
|
711 } |
|
712 } |
|
713 |
|
714 // --------------------------------------------------------------------------- |
|
715 // Slot: thumbnailReadySlot |
|
716 // --------------------------------------------------------------------------- |
|
717 // |
|
718 void VideoFileDetailsViewPlugin::thumbnailReadySlot(QPixmap pixmap, |
|
719 void * clientData, int id, int errorCode) |
|
720 { |
|
721 FUNC_LOG; |
|
722 Q_UNUSED(clientData); |
|
723 Q_UNUSED(id); |
|
724 |
|
725 HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL); |
|
726 if(!thumbWidget) |
|
727 { |
|
728 ERROR(-1, "VideoFileDetailsViewPlugin::thumbnailReadySlot() failed to load thumbnail widget."); |
|
729 return; |
|
730 } |
|
731 |
|
732 QSize size(thumbWidget->size().toSize()); |
|
733 |
|
734 if (!errorCode) |
|
735 { |
|
736 QImage sourceImage = pixmap.toImage(); |
|
737 |
|
738 if ((sourceImage.size().height() != size.height()) || (sourceImage.size().width() != size.width())) |
|
739 { |
|
740 // Smooth scaling is very expensive (size^2). Therefore we reduce the size |
|
741 // to 2x of the destination size and using fast transformation before doing final smooth scaling. |
|
742 if (sourceImage.size().width() > (4*size.width()) || sourceImage.size().height() > (4*size.height())) |
|
743 { |
|
744 QSize intermediate_size = QSize( size.width() * 2, size.height() * 2 ); |
|
745 sourceImage = sourceImage.scaled(intermediate_size, Qt::KeepAspectRatioByExpanding, Qt::FastTransformation ); |
|
746 } |
|
747 sourceImage = sourceImage.scaled(size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); |
|
748 } |
|
749 |
|
750 int difference(0); |
|
751 QRect rect = thumbWidget->rect().toRect(); |
|
752 |
|
753 if(sourceImage.width() > size.width()) |
|
754 { |
|
755 difference = sourceImage.width() - size.width(); |
|
756 difference = (difference/2)+1; |
|
757 rect.moveLeft(rect.left()+difference); |
|
758 } |
|
759 else if(sourceImage.height() > size.height()) |
|
760 { |
|
761 difference = sourceImage.height() - size.height(); |
|
762 difference = (difference/2)+1; |
|
763 rect.moveBottom(rect.bottom()+difference); |
|
764 } |
|
765 |
|
766 sourceImage = sourceImage.copy(rect); |
|
767 QImage resultImage = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied); |
|
768 |
|
769 QPainter painter(&resultImage); |
|
770 painter.setCompositionMode(QPainter::CompositionMode_Source); |
|
771 painter.fillRect(resultImage.rect(), Qt::transparent); |
|
772 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
|
773 painter.drawPixmap( (int)(sourceImage.width() - playIcon().width())/2, |
|
774 (int)(sourceImage.height() - playIcon().height())/2, |
|
775 playIcon() ); |
|
776 painter.setCompositionMode(QPainter::CompositionMode_Screen); |
|
777 painter.drawImage(0, 0, sourceImage); |
|
778 painter.end(); |
|
779 |
|
780 HbIcon compsedIcon(QPixmap::fromImage(resultImage)); |
|
781 mThumbLabel->setIcon(compsedIcon); |
|
782 } |
|
783 else |
|
784 { |
|
785 ERROR(errorCode, "VideoFileDetailsViewPlugin::thumbnailReadySlot() tbn fetch failed."); |
|
786 mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT)); |
|
787 } |
|
788 } |
|
789 |
|
790 // --------------------------------------------------------------------------- |
|
791 // startFetchingThumbnail |
|
792 // --------------------------------------------------------------------------- |
|
793 // |
|
794 void VideoFileDetailsViewPlugin::startFetchingThumbnail() |
|
795 { |
|
796 FUNC_LOG; |
|
797 int tnId = -1; |
|
798 |
|
799 if(mModel && mThumbnailManager) |
|
800 { |
|
801 QModelIndex modelIndex = mModel->indexOfId(mVideoId); |
|
802 QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath); |
|
803 if(variant.isValid()) |
|
804 { |
|
805 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
|
806 tnId = mThumbnailManager->getThumbnail(variant.toString(), 0, 5000); |
|
807 } |
|
808 } |
|
809 |
|
810 if(tnId == -1) |
|
811 { |
|
812 ERROR(-1, "VideoFileDetailsViewPlugin::startFetchingThumbnail() starting the fetch failed."); |
|
813 mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT)); |
|
814 } |
|
815 } |
|
816 |
|
817 // --------------------------------------------------------------------------- |
|
818 // playIcon |
|
819 // --------------------------------------------------------------------------- |
|
820 // |
|
821 const QPixmap &VideoFileDetailsViewPlugin::playIcon() |
|
822 { |
|
823 FUNC_LOG; |
|
824 // Check if we have already the icon. |
|
825 if(!mPlayIcon.isNull()) |
|
826 { |
|
827 return mPlayIcon; |
|
828 } |
|
829 |
|
830 // Compose the icon. |
|
831 HbIcon play = HbIcon("qtg_mono_play"); |
|
832 HbIcon topLeft = HbIcon("qtg_fr_popup_trans_tl"); |
|
833 HbIcon top = HbIcon("qtg_fr_popup_trans_t"); |
|
834 HbIcon topRight = HbIcon("qtg_fr_popup_trans_tr"); |
|
835 HbIcon left = HbIcon("qtg_fr_popup_trans_l"); |
|
836 HbIcon center = HbIcon("qtg_fr_popup_trans_c"); |
|
837 HbIcon right = HbIcon("qtg_fr_popup_trans_r"); |
|
838 HbIcon bottomLeft = HbIcon("qtg_fr_popup_trans_bl"); |
|
839 HbIcon bottom = HbIcon("qtg_fr_popup_trans_b"); |
|
840 HbIcon bottomRight = HbIcon("qtg_fr_popup_trans_br"); |
|
841 |
|
842 int width = topLeft.width() + top.width() + topRight.width(); |
|
843 int height = topLeft.height() + center.height() + bottomLeft.height(); |
|
844 |
|
845 mPlayIcon = QPixmap(width, height); |
|
846 |
|
847 QPainter painter(&mPlayIcon); |
|
848 painter.fillRect(mPlayIcon.rect(), Qt::white); |
|
849 |
|
850 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
|
851 |
|
852 int x = 0; |
|
853 int y = 0; |
|
854 |
|
855 // Draw top |
|
856 painter.drawPixmap(QPoint(x, y), topLeft.pixmap()); |
|
857 x += left.width(); |
|
858 |
|
859 painter.drawPixmap(QPoint(x, y), top.pixmap()); |
|
860 x += top.width(); |
|
861 |
|
862 painter.drawPixmap(QPoint(x, y), topRight.pixmap()); |
|
863 y += top.height(); |
|
864 |
|
865 // Draw center |
|
866 x = 0; |
|
867 painter.drawPixmap(QPoint(x, y), left.pixmap()); |
|
868 x += left.width(); |
|
869 |
|
870 painter.drawPixmap(QPoint(x, y), center.pixmap()); |
|
871 x += center.width(); |
|
872 |
|
873 painter.drawPixmap(QPoint(x, y), right.pixmap()); |
|
874 y += center.height(); |
|
875 |
|
876 // Draw bottom |
|
877 x = 0; |
|
878 painter.drawPixmap(QPoint(x, y), bottomLeft.pixmap()); |
|
879 x += left.width(); |
|
880 |
|
881 painter.drawPixmap(QPoint(x, y), bottom.pixmap()); |
|
882 x += top.width(); |
|
883 |
|
884 painter.drawPixmap(QPoint(x, y), bottomRight.pixmap()); |
|
885 |
|
886 // Draw play icon |
|
887 play.setSize(mPlayIcon.size()); |
|
888 play.setColor(Qt::white); |
|
889 painter.drawPixmap(mPlayIcon.rect(), play.pixmap()); |
|
890 painter.end(); |
|
891 |
|
892 return mPlayIcon; |
|
893 } |
|
894 |
|
895 // --------------------------------------------------------------------------- |
|
896 // findWidget |
|
897 // --------------------------------------------------------------------------- |
|
898 // |
|
899 template<class T> |
|
900 T* VideoFileDetailsViewPlugin::findWidget(QString name) |
|
901 { |
|
902 FUNC_LOG; |
|
903 return qobject_cast<T *>(mLoader.findWidget(name)); |
|
904 } |
|
905 |
|
906 // --------------------------------------------------------------------------- |
|
907 // findObject |
|
908 // --------------------------------------------------------------------------- |
|
909 // |
|
910 template<class T> |
|
911 T* VideoFileDetailsViewPlugin::findObject(QString name) |
|
912 { |
|
913 FUNC_LOG; |
|
914 return qobject_cast<T *>(mLoader.findObject(name)); |
|
915 } |
|
916 |
|
917 XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin ); |
|
918 |
|
919 // End of file |