30
|
1 |
/*
|
34
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
30
|
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
|
34
|
15 |
*
|
30
|
16 |
*/
|
|
17 |
|
58
|
18 |
// Version : %version: 76.1.9 %
|
36
|
19 |
|
30
|
20 |
// INCLUDE FILES
|
34
|
21 |
#include <qcoreapplication.h>
|
30
|
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>
|
34
|
32 |
#include <hblistwidget.h>
|
|
33 |
#include <hblistwidgetitem.h>
|
|
34 |
#include <hblistviewitem.h>
|
44
|
35 |
#include <hbparameterlengthlimiter.h>
|
50
|
36 |
#include <hbtextitem.h>
|
55
|
37 |
#include <hbscrollbar.h>
|
30
|
38 |
#include <cmath>
|
|
39 |
#include <thumbnailmanager_qt.h>
|
36
|
40 |
#include <shareui.h>
|
|
41 |
|
30
|
42 |
#include "videocollectionclient.h"
|
|
43 |
#include "videofiledetailsviewplugin.h"
|
|
44 |
#include "videocollectioncommon.h"
|
|
45 |
#include "mpxhbvideocommondefs.h"
|
|
46 |
#include "videocollectionwrapper.h"
|
58
|
47 |
#include "videoproxymodelgeneric.h"
|
30
|
48 |
#include "videoservices.h"
|
34
|
49 |
#include "videodetailslabel.h"
|
36
|
50 |
#include "videocollectiontrace.h"
|
30
|
51 |
|
38
|
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.
|
36
|
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";
|
30
|
68 |
const char* const VIDEO_DETAILS_MENUACTION_DELETE = "mOptionsDelete";
|
36
|
69 |
const char* const VIDEO_DETAILS_LISTWIDGET = "mDetailsList";
|
30
|
70 |
|
38
|
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 |
|
30
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// Constructor
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
VideoFileDetailsViewPlugin::VideoFileDetailsViewPlugin()
|
36
|
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() )
|
50
|
93 |
, mShareUi(0)
|
30
|
94 |
{
|
36
|
95 |
FUNC_LOG;
|
30
|
96 |
}
|
|
97 |
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
// Destructor
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
VideoFileDetailsViewPlugin::~VideoFileDetailsViewPlugin()
|
|
103 |
{
|
36
|
104 |
FUNC_LOG;
|
34
|
105 |
destroyView();
|
30
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
// Create view
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
void VideoFileDetailsViewPlugin::createView()
|
|
113 |
{
|
36
|
114 |
FUNC_LOG;
|
35
|
115 |
mLoader.reset();
|
30
|
116 |
|
|
117 |
mActivated = false;
|
34
|
118 |
|
35
|
119 |
bool ok = false;
|
44
|
120 |
|
35
|
121 |
//Load the details view docml first
|
|
122 |
mLoader.load(VIDEO_DETAILS_DOCML, &ok);
|
44
|
123 |
|
35
|
124 |
if(!ok)
|
30
|
125 |
{
|
36
|
126 |
ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load docml.");
|
35
|
127 |
return;
|
30
|
128 |
}
|
35
|
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);
|
44
|
132 |
|
35
|
133 |
if(!ok)
|
|
134 |
{
|
36
|
135 |
ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load portrait view.");
|
35
|
136 |
return;
|
|
137 |
}
|
30
|
138 |
|
58
|
139 |
mModel = mCollectionWrapper.getAllVideosModel();
|
30
|
140 |
|
|
141 |
if (!mModel)
|
|
142 |
{
|
36
|
143 |
ERROR(-1, "VideoFileDetailsViewPlugin::createView() get model failed.");
|
30
|
144 |
return;
|
|
145 |
}
|
|
146 |
|
|
147 |
mIsService = XQServiceUtil::isService();
|
|
148 |
|
|
149 |
// no deallocation needed for this since
|
|
150 |
// stackedwidget takes ownership
|
|
151 |
mTitleAnim = new HbMarqueeItem;
|
34
|
152 |
HbFontSpec spec = mTitleAnim->fontSpec();
|
|
153 |
spec.setRole( HbFontSpec::Primary );
|
|
154 |
mTitleAnim->setFontSpec( spec );
|
|
155 |
mTitleAnim->setLoopCount(-1);
|
38
|
156 |
mTitleAnim->setObjectName(VIDEO_DETAILS_OBJECT_NAME_TITLE_ANIM);
|
34
|
157 |
|
|
158 |
connect(mModel->sourceModel(),
|
|
159 |
SIGNAL(shortDetailsReady(TMPXItemId)),
|
|
160 |
this, SLOT(shortDetailsReadySlot(TMPXItemId)));
|
30
|
161 |
|
35
|
162 |
connect(mModel->sourceModel(),
|
36
|
163 |
SIGNAL(fullVideoDetailsReady(QVariant&)),
|
|
164 |
this, SLOT(fullDetailsReadySlot(QVariant&)));
|
30
|
165 |
|
|
166 |
connect(mModel,
|
|
167 |
SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
|
|
168 |
this, SLOT(rowsRemovedSlot(const QModelIndex&, int, int)));
|
|
169 |
|
36
|
170 |
// Setup thumbnail widget.
|
34
|
171 |
HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
|
36
|
172 |
if(!thumbWidget)
|
|
173 |
{
|
|
174 |
ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load thumbnail widget.");
|
|
175 |
return;
|
|
176 |
}
|
34
|
177 |
|
|
178 |
// no deallocation needed for this since
|
|
179 |
// stackedwidget takes ownership
|
|
180 |
mThumbLabel = new VideoDetailsLabel;
|
|
181 |
mThumbLabel->setAlignment(Qt::AlignCenter);
|
38
|
182 |
mThumbLabel->setObjectName(VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL);
|
44
|
183 |
|
34
|
184 |
connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot()));
|
|
185 |
|
|
186 |
thumbWidget->addWidget(mThumbLabel);
|
|
187 |
|
36
|
188 |
// Load details title.
|
30
|
189 |
HbStackedWidget* title = findObject<HbStackedWidget>(VIDEO_DETAILS_TITLE);
|
36
|
190 |
if(!title)
|
|
191 |
{
|
|
192 |
ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load title.");
|
|
193 |
return;
|
|
194 |
}
|
30
|
195 |
title->addWidget(mTitleAnim);
|
|
196 |
|
36
|
197 |
// Load delete action.
|
30
|
198 |
HbAction* deleteAction = findObject<HbAction>(VIDEO_DETAILS_MENUACTION_DELETE);
|
36
|
199 |
if(!deleteAction)
|
|
200 |
{
|
|
201 |
ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to delete action.");
|
|
202 |
return;
|
|
203 |
}
|
38
|
204 |
deleteAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_ACTION);
|
30
|
205 |
|
|
206 |
if (mIsService)
|
|
207 |
{
|
|
208 |
deleteAction->setVisible(false);
|
|
209 |
}
|
|
210 |
else
|
|
211 |
{
|
|
212 |
connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteVideoSlot()));
|
|
213 |
}
|
35
|
214 |
|
34
|
215 |
// Create navigation keys.
|
|
216 |
mNavKeyBackAction = new HbAction(Hb::BackNaviAction);
|
38
|
217 |
mNavKeyBackAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK);
|
44
|
218 |
|
35
|
219 |
if (!mThumbnailManager)
|
|
220 |
{
|
|
221 |
mThumbnailManager = new ThumbnailManager();
|
|
222 |
}
|
|
223 |
|
34
|
224 |
connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap,void*,int,int)),
|
30
|
225 |
this, SLOT(thumbnailReadySlot(QPixmap,void*,int,int)));
|
44
|
226 |
|
37
|
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 |
}
|
44
|
233 |
|
37
|
234 |
list->setEnabledAnimations(HbAbstractItemView::None);
|
55
|
235 |
|
|
236 |
list->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
|
|
237 |
|
|
238 |
HbScrollBar* bar = list->verticalScrollBar();
|
|
239 |
|
|
240 |
if(bar)
|
|
241 |
{
|
|
242 |
bar->setInteractive(true);
|
|
243 |
}
|
30
|
244 |
}
|
|
245 |
|
|
246 |
// ---------------------------------------------------------------------------
|
|
247 |
// Destroy view
|
|
248 |
// ---------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
void VideoFileDetailsViewPlugin::destroyView()
|
|
251 |
{
|
36
|
252 |
FUNC_LOG;
|
30
|
253 |
if (mActivated)
|
|
254 |
{
|
|
255 |
deactivateView();
|
|
256 |
}
|
|
257 |
|
|
258 |
if(mVideoServices)
|
|
259 |
{
|
|
260 |
mVideoServices->decreaseReferenceCount();
|
|
261 |
mVideoServices = 0;
|
|
262 |
}
|
|
263 |
|
36
|
264 |
delete mNavKeyBackAction;
|
|
265 |
mNavKeyBackAction = 0;
|
44
|
266 |
|
36
|
267 |
delete mThumbnailManager;
|
|
268 |
mThumbnailManager = 0;
|
44
|
269 |
|
30
|
270 |
disconnect();
|
35
|
271 |
mLoader.reset();
|
30
|
272 |
}
|
|
273 |
|
|
274 |
// ---------------------------------------------------------------------------
|
|
275 |
// Activate view
|
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
//
|
|
278 |
void VideoFileDetailsViewPlugin::activateView()
|
|
279 |
{
|
36
|
280 |
FUNC_LOG;
|
35
|
281 |
if (!mActivated)
|
30
|
282 |
{
|
|
283 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
284 |
|
34
|
285 |
HbView *currentView = mainWnd->currentView();
|
|
286 |
if(currentView && mNavKeyBackAction)
|
|
287 |
{
|
50
|
288 |
if (connect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back())), Qt::UniqueConnection)
|
34
|
289 |
{
|
|
290 |
currentView->setNavigationAction(mNavKeyBackAction);
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
36
|
294 |
ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to connect navkey signal.");
|
34
|
295 |
return;
|
|
296 |
}
|
|
297 |
}
|
35
|
298 |
|
34
|
299 |
mainWnd->setOrientation(Qt::Vertical, false);
|
|
300 |
|
|
301 |
// following if is for the future implementations where we should support
|
|
302 |
// also landscape configuration.
|
30
|
303 |
Qt::Orientation orientation = mainWnd->orientation();
|
35
|
304 |
if ( (orientation == Qt::Vertical) && (orientation != mPreviousOrietation) )
|
30
|
305 |
{
|
35
|
306 |
mPreviousOrietation = orientation;
|
|
307 |
mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT);
|
30
|
308 |
}
|
35
|
309 |
else if ( (orientation == Qt::Horizontal) && (orientation != mPreviousOrietation) )
|
30
|
310 |
{
|
35
|
311 |
mPreviousOrietation = orientation;
|
|
312 |
mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE);
|
30
|
313 |
}
|
|
314 |
|
|
315 |
if (mIsService && !mVideoServices)
|
|
316 |
{
|
|
317 |
mVideoServices = VideoServices::instance();
|
|
318 |
|
|
319 |
if (!mVideoServices)
|
|
320 |
{
|
36
|
321 |
ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to get video services instance.");
|
30
|
322 |
return;
|
|
323 |
}
|
34
|
324 |
}
|
35
|
325 |
|
36
|
326 |
VideoServices::TVideoService service = VideoServices::ENoService;
|
35
|
327 |
if (mIsService && mVideoServices)
|
34
|
328 |
{
|
36
|
329 |
service = mVideoServices->currentService();
|
44
|
330 |
|
34
|
331 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
332 |
mainWnd->currentView()->setTitle(mVideoServices->contextTitle());
|
|
333 |
}
|
36
|
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 |
}
|
44
|
341 |
|
41
|
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;
|
44
|
345 |
|
41
|
346 |
HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
|
|
347 |
thumbWidget->setPreferredWidth(width);
|
|
348 |
thumbWidget->setPreferredHeight(height);
|
44
|
349 |
|
36
|
350 |
if (service == VideoServices::EUriFetcher)
|
|
351 |
{
|
44
|
352 |
HbIcon icon = HbIcon("qtg_mono_attach");
|
|
353 |
button->setIcon(icon);
|
36
|
354 |
|
50
|
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);
|
36
|
357 |
}
|
|
358 |
else
|
|
359 |
{
|
50
|
360 |
connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()), Qt::UniqueConnection);
|
44
|
361 |
|
|
362 |
HbIcon icon = HbIcon("qtg_mono_share");
|
|
363 |
button->setIcon(icon);
|
30
|
364 |
}
|
|
365 |
|
|
366 |
connect(mainWnd,
|
|
367 |
SIGNAL(orientationChanged(Qt::Orientation)),
|
50
|
368 |
this, SLOT(orientationChange(Qt::Orientation)),
|
|
369 |
Qt::UniqueConnection);
|
34
|
370 |
|
|
371 |
connect(&mCollectionWrapper,
|
|
372 |
SIGNAL(asyncStatus(int, QVariant&)),
|
50
|
373 |
this, SLOT(handleErrorSlot(int, QVariant&)),
|
|
374 |
Qt::UniqueConnection);
|
30
|
375 |
|
|
376 |
// setup title size in order for animation to be enabled if needed
|
34
|
377 |
mTitleAnim->setMinimumWidth(hbInstance->allMainWindows().value(0)->width()-50);
|
30
|
378 |
mTitleAnim->adjustSize();
|
34
|
379 |
|
30
|
380 |
mActivated = true;
|
|
381 |
}
|
|
382 |
}
|
|
383 |
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
// Deactivate view
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
void VideoFileDetailsViewPlugin::deactivateView()
|
|
389 |
{
|
36
|
390 |
FUNC_LOG;
|
30
|
391 |
if ( mActivated )
|
|
392 |
{
|
34
|
393 |
mVideoId = TMPXItemId::InvalidId();
|
|
394 |
|
|
395 |
mDeletedIndex = -1; // set index as invalid.
|
|
396 |
|
30
|
397 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
34
|
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()));
|
30
|
408 |
|
|
409 |
disconnect(mainWnd, SIGNAL( orientationChanged( Qt::Orientation ) ),
|
|
410 |
this, SLOT( orientationChange( Qt::Orientation ) ));
|
|
411 |
|
34
|
412 |
disconnect(&mCollectionWrapper,
|
|
413 |
SIGNAL(asyncStatus(int, QVariant&)),
|
30
|
414 |
this, SLOT(handleErrorSlot(int, QVariant&)));
|
|
415 |
|
|
416 |
mTitleAnim->stopAnimation();
|
|
417 |
mTitleAnim->setText("");
|
34
|
418 |
|
30
|
419 |
mActivated = false;
|
|
420 |
|
34
|
421 |
mThumbLabel->setIcon(HbIcon());
|
|
422 |
|
|
423 |
HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON);
|
30
|
424 |
|
|
425 |
if (mIsService)
|
|
426 |
{
|
34
|
427 |
disconnect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()));
|
30
|
428 |
disconnect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
|
|
429 |
}
|
34
|
430 |
else
|
|
431 |
{
|
35
|
432 |
disconnect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
|
34
|
433 |
}
|
30
|
434 |
}
|
50
|
435 |
delete mShareUi;
|
|
436 |
mShareUi = 0;
|
30
|
437 |
}
|
|
438 |
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
// Get view
|
|
441 |
// ---------------------------------------------------------------------------
|
|
442 |
//
|
|
443 |
QGraphicsWidget* VideoFileDetailsViewPlugin::getView()
|
|
444 |
{
|
36
|
445 |
FUNC_LOG;
|
35
|
446 |
return mLoader.findWidget(VIDEO_DETAILS_VIEW);
|
30
|
447 |
}
|
|
448 |
|
|
449 |
// ---------------------------------------------------------------------------
|
|
450 |
// Slot: Orientation change
|
|
451 |
// ---------------------------------------------------------------------------
|
|
452 |
//
|
|
453 |
void VideoFileDetailsViewPlugin::orientationChange( Qt::Orientation orientation )
|
34
|
454 |
{
|
36
|
455 |
FUNC_LOG;
|
|
456 |
if (orientation == Qt::Vertical)
|
30
|
457 |
{
|
35
|
458 |
mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT);
|
30
|
459 |
}
|
34
|
460 |
|
36
|
461 |
else if (orientation == Qt::Horizontal)
|
30
|
462 |
{
|
35
|
463 |
mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE);
|
30
|
464 |
}
|
|
465 |
mTitleAnim->adjustSize();
|
|
466 |
mTitleAnim->startAnimation();
|
|
467 |
}
|
|
468 |
|
|
469 |
// ---------------------------------------------------------------------------
|
|
470 |
// Slot: back
|
|
471 |
// ---------------------------------------------------------------------------
|
|
472 |
//
|
|
473 |
void VideoFileDetailsViewPlugin::back()
|
|
474 |
{
|
36
|
475 |
FUNC_LOG;
|
|
476 |
if (mActivated)
|
30
|
477 |
{
|
|
478 |
emit command( MpxHbVideoCommon::ActivateCollectionView );
|
|
479 |
}
|
|
480 |
}
|
|
481 |
|
|
482 |
// ---------------------------------------------------------------------------
|
|
483 |
// Slot: shortDetailsReadySlot
|
|
484 |
// ---------------------------------------------------------------------------
|
|
485 |
//
|
34
|
486 |
void VideoFileDetailsViewPlugin::shortDetailsReadySlot(TMPXItemId id)
|
30
|
487 |
{
|
36
|
488 |
FUNC_LOG;
|
30
|
489 |
// first clear all details, so that the view doesn't display the old data.
|
34
|
490 |
findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET)->clear();
|
30
|
491 |
|
34
|
492 |
QModelIndex modelIndex = mModel->indexOfId(id);
|
|
493 |
|
|
494 |
mVideoId = id;
|
30
|
495 |
|
36
|
496 |
QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle);
|
30
|
497 |
|
34
|
498 |
if (variant.isValid() && mTitleAnim)
|
30
|
499 |
{
|
36
|
500 |
mTitleAnim->setText(variant.toString());
|
34
|
501 |
}
|
30
|
502 |
startFetchingThumbnail();
|
|
503 |
}
|
|
504 |
|
|
505 |
// ---------------------------------------------------------------------------
|
|
506 |
// Slot: fullDetailsReadySlot
|
|
507 |
// ---------------------------------------------------------------------------
|
|
508 |
//
|
36
|
509 |
void VideoFileDetailsViewPlugin::fullDetailsReadySlot(QVariant& variant)
|
30
|
510 |
{
|
36
|
511 |
FUNC_LOG;
|
30
|
512 |
using namespace VideoCollectionCommon;
|
34
|
513 |
|
30
|
514 |
int detailCount = sizeof(VideoDetailLabelKeys) / sizeof(int);
|
|
515 |
|
|
516 |
QMap<QString, QVariant> metadata = variant.toMap();
|
44
|
517 |
|
34
|
518 |
HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET);
|
36
|
519 |
if(!list)
|
|
520 |
{
|
|
521 |
ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
|
|
522 |
return;
|
|
523 |
}
|
44
|
524 |
|
34
|
525 |
if(list->count())
|
|
526 |
{
|
|
527 |
list->clear();
|
|
528 |
}
|
|
529 |
|
|
530 |
HbListViewItem *prototype = list->listItemPrototype();
|
38
|
531 |
prototype->setSecondaryTextRowCount(1, VIDEO_DETAILS_SECONDARY_TEXT_ROW_COUNT);
|
34
|
532 |
|
30
|
533 |
for(int i = 0; i< detailCount; i++) {
|
34
|
534 |
if (metadata.contains(VideoDetailLabelKeys[i]))
|
|
535 |
{
|
|
536 |
HbListWidgetItem* listWidgetItem = new HbListWidgetItem();
|
38
|
537 |
listWidgetItem->setText( hbTrId(VideoDetailLabels[i]));
|
|
538 |
listWidgetItem->setSecondaryText(metadata[VideoDetailLabelKeys[i]].toString());
|
|
539 |
list->addItem(listWidgetItem);
|
50
|
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 |
}
|
30
|
551 |
}
|
|
552 |
}
|
|
553 |
|
|
554 |
// start title animation
|
|
555 |
mTitleAnim->startAnimation();
|
|
556 |
}
|
|
557 |
|
|
558 |
// ---------------------------------------------------------------------------
|
|
559 |
// Slot: getFileUri
|
|
560 |
// ---------------------------------------------------------------------------
|
|
561 |
//
|
|
562 |
void VideoFileDetailsViewPlugin::getFileUri()
|
|
563 |
{
|
36
|
564 |
FUNC_LOG;
|
34
|
565 |
if (mVideoId != TMPXItemId::InvalidId())
|
30
|
566 |
{
|
34
|
567 |
QModelIndex modelIndex = mModel->indexOfId(mVideoId);
|
|
568 |
QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
|
36
|
569 |
if (variant.isValid())
|
30
|
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 |
{
|
36
|
583 |
FUNC_LOG;
|
34
|
584 |
if (mVideoId != TMPXItemId::InvalidId())
|
|
585 |
{
|
|
586 |
mModel->openItem(mVideoId);
|
|
587 |
}
|
30
|
588 |
}
|
|
589 |
|
|
590 |
// ---------------------------------------------------------------------------
|
|
591 |
// Slot: sendVideo
|
|
592 |
// ---------------------------------------------------------------------------
|
|
593 |
//
|
|
594 |
void VideoFileDetailsViewPlugin::sendVideoSlot()
|
|
595 |
{
|
36
|
596 |
FUNC_LOG;
|
44
|
597 |
|
37
|
598 |
if(mVideoId != TMPXItemId::InvalidId())
|
36
|
599 |
{
|
50
|
600 |
if(!mShareUi)
|
|
601 |
{
|
|
602 |
mShareUi = new ShareUi();
|
|
603 |
}
|
36
|
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());
|
50
|
610 |
mShareUi->send(fileList, true);
|
36
|
611 |
}
|
37
|
612 |
}
|
30
|
613 |
}
|
|
614 |
|
|
615 |
// ---------------------------------------------------------------------------
|
|
616 |
// Slot: deleteVideo
|
|
617 |
// ---------------------------------------------------------------------------
|
|
618 |
//
|
|
619 |
void VideoFileDetailsViewPlugin::deleteVideoSlot()
|
|
620 |
{
|
36
|
621 |
FUNC_LOG;
|
34
|
622 |
if (mVideoId != TMPXItemId::InvalidId())
|
30
|
623 |
{
|
34
|
624 |
QModelIndex modelIndex = mModel->indexOfId(mVideoId);
|
36
|
625 |
QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle);
|
30
|
626 |
|
34
|
627 |
if (variant.isValid())
|
|
628 |
{
|
44
|
629 |
QString text = HbParameterLengthLimiter(hbTrId("txt_videos_info_do_you_want_to_delete_1")).
|
|
630 |
arg(variant.toString());
|
30
|
631 |
|
37
|
632 |
HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
|
|
633 |
messageBox->setAttribute(Qt::WA_DeleteOnClose);
|
44
|
634 |
messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
|
38
|
635 |
messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO);
|
44
|
636 |
messageBox->open(this, SLOT(deleteVideoDialogFinished(int)));
|
30
|
637 |
}
|
|
638 |
}
|
|
639 |
}
|
|
640 |
|
|
641 |
// ---------------------------------------------------------------------------
|
37
|
642 |
// deleteVideoDialogFinished
|
|
643 |
// ---------------------------------------------------------------------------
|
|
644 |
//
|
44
|
645 |
void VideoFileDetailsViewPlugin::deleteVideoDialogFinished(int action)
|
37
|
646 |
{
|
|
647 |
FUNC_LOG;
|
|
648 |
QModelIndex modelIndex = mModel->indexOfId(mVideoId);
|
44
|
649 |
if(action == HbMessageBox::Yes && modelIndex.isValid())
|
37
|
650 |
{
|
|
651 |
deleteItem(modelIndex);
|
|
652 |
}
|
|
653 |
}
|
|
654 |
|
|
655 |
// ---------------------------------------------------------------------------
|
30
|
656 |
// deleteItem
|
|
657 |
// ---------------------------------------------------------------------------
|
|
658 |
//
|
|
659 |
void VideoFileDetailsViewPlugin::deleteItem(QModelIndex index)
|
|
660 |
{
|
36
|
661 |
FUNC_LOG;
|
34
|
662 |
mDeletedIndex = index.row();
|
|
663 |
|
30
|
664 |
QModelIndexList list;
|
|
665 |
list.append(index);
|
|
666 |
mModel->deleteItems(list);
|
|
667 |
}
|
|
668 |
|
|
669 |
// ---------------------------------------------------------------------------
|
|
670 |
// Slot: rowsRemovedSlot
|
|
671 |
// ---------------------------------------------------------------------------
|
|
672 |
//
|
34
|
673 |
void VideoFileDetailsViewPlugin::rowsRemovedSlot(const QModelIndex& parent,
|
30
|
674 |
int first, int last)
|
|
675 |
{
|
36
|
676 |
FUNC_LOG;
|
34
|
677 |
Q_UNUSED(parent);
|
|
678 |
|
|
679 |
if(mActivated && mDeletedIndex > -1 &&
|
|
680 |
(mDeletedIndex >= first && mDeletedIndex <= last))
|
30
|
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 |
{
|
36
|
694 |
FUNC_LOG;
|
30
|
695 |
QString msg("");
|
|
696 |
if(errorCode == VideoCollectionCommon::statusSingleDeleteFail)
|
|
697 |
{
|
38
|
698 |
QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current");
|
30
|
699 |
if(additional.isValid())
|
|
700 |
{
|
44
|
701 |
msg = HbParameterLengthLimiter(format).arg(additional.toString());
|
30
|
702 |
}
|
|
703 |
}
|
|
704 |
if(msg.count() > 0)
|
|
705 |
{
|
|
706 |
// show msg box if there's something to show
|
38
|
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();
|
34
|
711 |
}
|
30
|
712 |
}
|
|
713 |
|
|
714 |
// ---------------------------------------------------------------------------
|
|
715 |
// Slot: thumbnailReadySlot
|
|
716 |
// ---------------------------------------------------------------------------
|
|
717 |
//
|
34
|
718 |
void VideoFileDetailsViewPlugin::thumbnailReadySlot(QPixmap pixmap,
|
30
|
719 |
void * clientData, int id, int errorCode)
|
|
720 |
{
|
36
|
721 |
FUNC_LOG;
|
30
|
722 |
Q_UNUSED(clientData);
|
|
723 |
Q_UNUSED(id);
|
|
724 |
|
44
|
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());
|
30
|
733 |
|
34
|
734 |
if (!errorCode)
|
|
735 |
{
|
30
|
736 |
QImage sourceImage = pixmap.toImage();
|
|
737 |
|
34
|
738 |
if ((sourceImage.size().height() != size.height()) || (sourceImage.size().width() != size.width()))
|
30
|
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 );
|
34
|
745 |
sourceImage = sourceImage.scaled(intermediate_size, Qt::KeepAspectRatioByExpanding, Qt::FastTransformation );
|
30
|
746 |
}
|
34
|
747 |
sourceImage = sourceImage.scaled(size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
30
|
748 |
}
|
|
749 |
|
34
|
750 |
int difference(0);
|
44
|
751 |
QRect rect = thumbWidget->rect().toRect();
|
34
|
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);
|
30
|
767 |
QImage resultImage = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied);
|
34
|
768 |
|
30
|
769 |
QPainter painter(&resultImage);
|
35
|
770 |
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
30
|
771 |
painter.fillRect(resultImage.rect(), Qt::transparent);
|
|
772 |
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
35
|
773 |
painter.drawPixmap( (int)(sourceImage.width() - playIcon().width())/2,
|
|
774 |
(int)(sourceImage.height() - playIcon().height())/2,
|
|
775 |
playIcon() );
|
30
|
776 |
painter.setCompositionMode(QPainter::CompositionMode_Screen);
|
35
|
777 |
painter.drawImage(0, 0, sourceImage);
|
30
|
778 |
painter.end();
|
|
779 |
|
|
780 |
HbIcon compsedIcon(QPixmap::fromImage(resultImage));
|
34
|
781 |
mThumbLabel->setIcon(compsedIcon);
|
30
|
782 |
}
|
34
|
783 |
else
|
|
784 |
{
|
36
|
785 |
ERROR(errorCode, "VideoFileDetailsViewPlugin::thumbnailReadySlot() tbn fetch failed.");
|
34
|
786 |
mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
|
30
|
787 |
}
|
|
788 |
}
|
|
789 |
|
|
790 |
// ---------------------------------------------------------------------------
|
|
791 |
// startFetchingThumbnail
|
|
792 |
// ---------------------------------------------------------------------------
|
|
793 |
//
|
|
794 |
void VideoFileDetailsViewPlugin::startFetchingThumbnail()
|
|
795 |
{
|
36
|
796 |
FUNC_LOG;
|
30
|
797 |
int tnId = -1;
|
34
|
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 |
{
|
30
|
805 |
mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
|
|
806 |
tnId = mThumbnailManager->getThumbnail(variant.toString(), 0, 5000);
|
|
807 |
}
|
34
|
808 |
}
|
|
809 |
|
|
810 |
if(tnId == -1)
|
|
811 |
{
|
36
|
812 |
ERROR(-1, "VideoFileDetailsViewPlugin::startFetchingThumbnail() starting the fetch failed.");
|
34
|
813 |
mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
|
30
|
814 |
}
|
|
815 |
}
|
|
816 |
|
|
817 |
// ---------------------------------------------------------------------------
|
35
|
818 |
// playIcon
|
|
819 |
// ---------------------------------------------------------------------------
|
|
820 |
//
|
|
821 |
const QPixmap &VideoFileDetailsViewPlugin::playIcon()
|
|
822 |
{
|
36
|
823 |
FUNC_LOG;
|
35
|
824 |
// Check if we have already the icon.
|
|
825 |
if(!mPlayIcon.isNull())
|
|
826 |
{
|
|
827 |
return mPlayIcon;
|
|
828 |
}
|
44
|
829 |
|
35
|
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();
|
44
|
844 |
|
35
|
845 |
mPlayIcon = QPixmap(width, height);
|
44
|
846 |
|
35
|
847 |
QPainter painter(&mPlayIcon);
|
|
848 |
painter.fillRect(mPlayIcon.rect(), Qt::white);
|
44
|
849 |
|
35
|
850 |
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
44
|
851 |
|
35
|
852 |
int x = 0;
|
|
853 |
int y = 0;
|
|
854 |
|
|
855 |
// Draw top
|
|
856 |
painter.drawPixmap(QPoint(x, y), topLeft.pixmap());
|
|
857 |
x += left.width();
|
44
|
858 |
|
35
|
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();
|
44
|
864 |
|
35
|
865 |
// Draw center
|
|
866 |
x = 0;
|
|
867 |
painter.drawPixmap(QPoint(x, y), left.pixmap());
|
|
868 |
x += left.width();
|
44
|
869 |
|
35
|
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();
|
44
|
875 |
|
35
|
876 |
// Draw bottom
|
|
877 |
x = 0;
|
|
878 |
painter.drawPixmap(QPoint(x, y), bottomLeft.pixmap());
|
|
879 |
x += left.width();
|
44
|
880 |
|
35
|
881 |
painter.drawPixmap(QPoint(x, y), bottom.pixmap());
|
|
882 |
x += top.width();
|
44
|
883 |
|
35
|
884 |
painter.drawPixmap(QPoint(x, y), bottomRight.pixmap());
|
44
|
885 |
|
35
|
886 |
// Draw play icon
|
|
887 |
play.setSize(mPlayIcon.size());
|
|
888 |
play.setColor(Qt::white);
|
|
889 |
painter.drawPixmap(mPlayIcon.rect(), play.pixmap());
|
|
890 |
painter.end();
|
44
|
891 |
|
35
|
892 |
return mPlayIcon;
|
|
893 |
}
|
|
894 |
|
|
895 |
// ---------------------------------------------------------------------------
|
30
|
896 |
// findWidget
|
|
897 |
// ---------------------------------------------------------------------------
|
|
898 |
//
|
|
899 |
template<class T>
|
|
900 |
T* VideoFileDetailsViewPlugin::findWidget(QString name)
|
|
901 |
{
|
36
|
902 |
FUNC_LOG;
|
35
|
903 |
return qobject_cast<T *>(mLoader.findWidget(name));
|
30
|
904 |
}
|
|
905 |
|
|
906 |
// ---------------------------------------------------------------------------
|
|
907 |
// findObject
|
|
908 |
// ---------------------------------------------------------------------------
|
|
909 |
//
|
|
910 |
template<class T>
|
|
911 |
T* VideoFileDetailsViewPlugin::findObject(QString name)
|
|
912 |
{
|
36
|
913 |
FUNC_LOG;
|
35
|
914 |
return qobject_cast<T *>(mLoader.findObject(name));
|
30
|
915 |
}
|
|
916 |
|
|
917 |
XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin );
|
|
918 |
|
38
|
919 |
// End of file
|