videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 37 4eb2df7f7cbe
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    13 *
    13 *
    14 * Description:   VideoCollectionViewPlugin class implementation
    14 * Description:   VideoCollectionViewPlugin class implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 // Version : %version: 69 %
       
    19 
    18 // INCLUDE FILES
    20 // INCLUDE FILES
    19 #include <qcoreapplication.h>
    21 #include <qcoreapplication.h>
    20 #include <xqserviceutil.h>
    22 #include <xqserviceutil.h>
    21 #include <xqplugin.h>
    23 #include <xqplugin.h>
    22 #include <hbview.h>
    24 #include <hbview.h>
    24 #include <hbstackedwidget.h>
    26 #include <hbstackedwidget.h>
    25 #include <hbmarqueeitem.h>
    27 #include <hbmarqueeitem.h>
    26 #include <hbpushbutton.h>
    28 #include <hbpushbutton.h>
    27 #include <hbaction.h>
    29 #include <hbaction.h>
    28 #include <qabstractitemmodel.h>
    30 #include <qabstractitemmodel.h>
    29 #include <qdebug.h>
       
    30 #include <hbmessagebox.h>
    31 #include <hbmessagebox.h>
    31 #include <hblistwidget.h>
    32 #include <hblistwidget.h>
    32 #include <hblistwidgetitem.h>
    33 #include <hblistwidgetitem.h>
    33 #include <hblistviewitem.h>
    34 #include <hblistviewitem.h>
    34 #include <cmath>
    35 #include <cmath>
    35 #include <thumbnailmanager_qt.h>
    36 #include <thumbnailmanager_qt.h>
       
    37 #include <shareui.h>
       
    38 
    36 #include "videocollectionclient.h"
    39 #include "videocollectionclient.h"
    37 #include "videofiledetailsviewplugin.h"
    40 #include "videofiledetailsviewplugin.h"
    38 #include "videocollectioncommon.h"
    41 #include "videocollectioncommon.h"
    39 #include "mpxhbvideocommondefs.h"
    42 #include "mpxhbvideocommondefs.h"
    40 #include "videocollectionwrapper.h"
    43 #include "videocollectionwrapper.h"
    41 #include "videosortfilterproxymodel.h"
    44 #include "videosortfilterproxymodel.h"
    42 #include "videoservices.h"
    45 #include "videoservices.h"
    43 #include "videodetailslabel.h"
    46 #include "videodetailslabel.h"
    44 
    47 #include "videocollectiontrace.h"
    45 const char* const VIDEO_DETAILS_DOCML = ":/xml/videofiledetails.docml";
    48 
    46 const char* const VIDEO_DETAILS_PORTRAIT = "portrait";
    49 const char* const VIDEO_DETAILS_DOCML             = ":/xml/videofiledetails.docml";
    47 const char* const VIDEO_DETAILS_LANDSCAPE = "landscape";
    50 const char* const VIDEO_DETAILS_PORTRAIT          = "portrait";
    48 const char* const VIDEO_DETAILS_GFX_DEFAULT = ":/gfx/pri_large_video.svg";
    51 const char* const VIDEO_DETAILS_LANDSCAPE         = "landscape";
    49 const char* const VIDEO_DETAILS_VIEW = "videofiledetailsview";
    52 const char* const VIDEO_DETAILS_GFX_DEFAULT       = ":/gfx/pri_large_video.svg";
    50 const char* const VIDEO_DETAILS_TITLE = "mLblTitle";
    53 const char* const VIDEO_DETAILS_VIEW              = "videofiledetailsview";
    51 const char* const VIDEO_DETAILS_THUMBNAIL = "mDetailsLabel";
    54 const char* const VIDEO_DETAILS_TITLE             = "mLblTitle";
    52 const char* const VIDEO_DETAILS_BUTTON = "mButton";
    55 const char* const VIDEO_DETAILS_THUMBNAIL         = "mDetailsLabel";
       
    56 const char* const VIDEO_DETAILS_BUTTON            = "mButton";
    53 const char* const VIDEO_DETAILS_MENUACTION_DELETE = "mOptionsDelete";
    57 const char* const VIDEO_DETAILS_MENUACTION_DELETE = "mOptionsDelete";
    54 const char* const VIDEO_DETAILS_LISTWIDGET ="mDetailsList";
    58 const char* const VIDEO_DETAILS_LISTWIDGET        = "mDetailsList";
    55 
       
    56 // Just for testing, remove this
       
    57 void _DebugNotImplementedYet()
       
    58 {
       
    59     HbMessageBox::information(QObject::tr("Not implemented yet"));
       
    60 }
       
    61 
    59 
    62 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    63 // Constructor
    61 // Constructor
    64 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    65 //
    63 //
    66 VideoFileDetailsViewPlugin::VideoFileDetailsViewPlugin()
    64 VideoFileDetailsViewPlugin::VideoFileDetailsViewPlugin()
    67     : mModel(0),
    65     : mModel( 0 )
    68       mVideoServices(0),
    66     , mVideoServices( 0 )
    69       mActivated(false),
    67     , mActivated( false )
    70       mIsService(false),
    68     , mIsService( false )
    71       mVideoId(TMPXItemId::InvalidId()),
    69     , mVideoId( TMPXItemId::InvalidId() )
    72       mDeletedIndex(-1),
    70     , mDeletedIndex( -1 )
    73       mPreviousOrietation(Qt::Vertical),
    71     , mPreviousOrietation( Qt::Vertical )
    74       mNavKeyBackAction(0),
    72     , mNavKeyBackAction( 0 )
    75       mTitleAnim(0),
    73     , mTitleAnim( 0 )
    76       mThumbLabel(0),
    74     , mThumbLabel( 0 )
    77       mThumbnailManager(0),
    75     , mThumbnailManager( 0 )
    78       mCollectionWrapper(VideoCollectionWrapper::instance())
    76     , mCollectionWrapper( VideoCollectionWrapper::instance() )
    79 {
    77 {
    80 
    78 	FUNC_LOG;
    81 }
    79 }
    82 
    80 
    83 // ---------------------------------------------------------------------------
    81 // ---------------------------------------------------------------------------
    84 // Destructor
    82 // Destructor
    85 // ---------------------------------------------------------------------------
    83 // ---------------------------------------------------------------------------
    86 //
    84 //
    87 VideoFileDetailsViewPlugin::~VideoFileDetailsViewPlugin()
    85 VideoFileDetailsViewPlugin::~VideoFileDetailsViewPlugin()
    88 {
    86 {
       
    87 	FUNC_LOG;
    89 	destroyView();
    88 	destroyView();
    90 }
    89 }
    91 
    90 
    92 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
    93 // Create view
    92 // Create view
    94 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
    95 //
    94 //
    96 void VideoFileDetailsViewPlugin::createView()
    95 void VideoFileDetailsViewPlugin::createView()
    97 {
    96 {
       
    97 	FUNC_LOG;
    98 	mLoader.reset();
    98 	mLoader.reset();
    99 
    99 
   100 	mActivated = false;
   100 	mActivated = false;
   101 
   101 
   102 	bool ok = false;
   102 	bool ok = false;
   104 	//Load the details view docml first
   104 	//Load the details view docml first
   105 	mLoader.load(VIDEO_DETAILS_DOCML, &ok);
   105 	mLoader.load(VIDEO_DETAILS_DOCML, &ok);
   106 	
   106 	
   107 	if(!ok)
   107 	if(!ok)
   108 	{
   108 	{
       
   109 	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load docml.");
   109 		return;
   110 		return;
   110 	}
   111 	}
   111 
   112 
   112 	//Load portrait section by default as only vertical orientation is currently supported by videoplayer
   113 	//Load portrait section by default as only vertical orientation is currently supported by videoplayer
   113 	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT, &ok);
   114 	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT, &ok);
   114 	
   115 	
   115 	if(!ok)
   116 	if(!ok)
   116 	{
   117 	{
       
   118 	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load portrait view.");
   117 		return;
   119 		return;
   118 	}
   120 	}
   119 
   121 
   120 	mModel = mCollectionWrapper.getModel(VideoCollectionWrapper::EAllVideos);
   122 	mModel = mCollectionWrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos);
   121 
   123 
   122 	if (!mModel)
   124 	if (!mModel)
   123 		{
   125 		{
   124 		qDebug() << "VideoFileDetailsViewPlugin::createView(): Unable to open collection wrapper. Cannot connect slots, aborting...";
   126 	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() get model failed.");
   125 		// TODO need to throw exception instead?
   127 		// TODO need to throw exception instead?
   126 		return;
   128 		return;
   127 		}
   129 		}
   128 
   130 
   129 	mIsService = XQServiceUtil::isService();
   131 	mIsService = XQServiceUtil::isService();
   139 	connect(mModel->sourceModel(),
   141 	connect(mModel->sourceModel(),
   140 			SIGNAL(shortDetailsReady(TMPXItemId)),
   142 			SIGNAL(shortDetailsReady(TMPXItemId)),
   141 			this, SLOT(shortDetailsReadySlot(TMPXItemId)));
   143 			this, SLOT(shortDetailsReadySlot(TMPXItemId)));
   142 
   144 
   143 	connect(mModel->sourceModel(),
   145 	connect(mModel->sourceModel(),
   144 			SIGNAL(fullVideoDetailsReady(TMPXItemId)),
   146 			SIGNAL(fullVideoDetailsReady(QVariant&)),
   145 			this, SLOT(fullDetailsReadySlot(TMPXItemId)));
   147 			this, SLOT(fullDetailsReadySlot(QVariant&)));
   146 
   148 
   147 	connect(mModel,
   149 	connect(mModel,
   148 			SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
   150 			SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
   149 			this, SLOT(rowsRemovedSlot(const QModelIndex&, int, int)));
   151 			this, SLOT(rowsRemovedSlot(const QModelIndex&, int, int)));
   150 
   152 
       
   153 	// Setup thumbnail widget.
   151 	HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
   154 	HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
       
   155 	if(!thumbWidget)
       
   156 	{
       
   157 	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load thumbnail widget.");
       
   158 	    return;
       
   159 	}
   152 
   160 
   153 	// no deallocation needed for this since
   161 	// no deallocation needed for this since
   154 	// stackedwidget takes ownership
   162 	// stackedwidget takes ownership
   155 	mThumbLabel = new VideoDetailsLabel;
   163 	mThumbLabel = new VideoDetailsLabel;
   156 
   164 
   158 
   166 
   159 	connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot()));
   167 	connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot()));
   160 
   168 
   161 	thumbWidget->addWidget(mThumbLabel);
   169 	thumbWidget->addWidget(mThumbLabel);
   162 
   170 
       
   171 	// Load details title.
   163 	HbStackedWidget* title = findObject<HbStackedWidget>(VIDEO_DETAILS_TITLE);
   172 	HbStackedWidget* title = findObject<HbStackedWidget>(VIDEO_DETAILS_TITLE);
       
   173 	if(!title)
       
   174 	{
       
   175 	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load title.");
       
   176 	    return;
       
   177 	}
   164 	title->addWidget(mTitleAnim);
   178 	title->addWidget(mTitleAnim);
   165 
   179 
       
   180 	// Load delete action.
   166 	HbAction* deleteAction = findObject<HbAction>(VIDEO_DETAILS_MENUACTION_DELETE);
   181 	HbAction* deleteAction = findObject<HbAction>(VIDEO_DETAILS_MENUACTION_DELETE);
       
   182     if(!deleteAction)
       
   183     {
       
   184         ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to delete action.");
       
   185         return;
       
   186     }
   167 
   187 
   168 	if (mIsService)
   188 	if (mIsService)
   169 	{
   189 	{
   170 		deleteAction->setVisible(false);
   190 		deleteAction->setVisible(false);
   171 	}
   191 	}
   190 // Destroy view
   210 // Destroy view
   191 // ---------------------------------------------------------------------------
   211 // ---------------------------------------------------------------------------
   192 //
   212 //
   193 void VideoFileDetailsViewPlugin::destroyView()
   213 void VideoFileDetailsViewPlugin::destroyView()
   194 {
   214 {
       
   215 	FUNC_LOG;
   195     if (mActivated)
   216     if (mActivated)
   196     {
   217     {
   197         deactivateView();
   218         deactivateView();
   198     }
   219     }
   199 
   220 
   201     {
   222     {
   202     	mVideoServices->decreaseReferenceCount();
   223     	mVideoServices->decreaseReferenceCount();
   203     	mVideoServices = 0;
   224     	mVideoServices = 0;
   204     }
   225     }
   205 
   226 
   206     delete mNavKeyBackAction; mNavKeyBackAction = 0;
   227     delete mNavKeyBackAction;
   207     delete mThumbnailManager; mThumbnailManager = 0;
   228     mNavKeyBackAction = 0;
       
   229     
       
   230     delete mThumbnailManager;
       
   231     mThumbnailManager = 0;
       
   232     
   208     disconnect();
   233     disconnect();
   209     mLoader.reset();
   234     mLoader.reset();
   210 }
   235 }
   211 
   236 
   212 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   213 // Activate view
   238 // Activate view
   214 // ---------------------------------------------------------------------------
   239 // ---------------------------------------------------------------------------
   215 //
   240 //
   216 void VideoFileDetailsViewPlugin::activateView()
   241 void VideoFileDetailsViewPlugin::activateView()
   217 {
   242 {
       
   243 	FUNC_LOG;
   218 	if (!mActivated)
   244 	if (!mActivated)
   219     {
   245     {
   220         HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   246         HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   221 
   247 
   222         HbView *currentView = mainWnd->currentView();
   248         HbView *currentView = mainWnd->currentView();
   226         	{
   252         	{
   227         		currentView->setNavigationAction(mNavKeyBackAction);
   253         		currentView->setNavigationAction(mNavKeyBackAction);
   228         	}
   254         	}
   229         	else
   255         	else
   230         	{
   256         	{
       
   257         	    ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to connect navkey signal.");
   231         		return;
   258         		return;
   232         	}
   259         	}
   233         }
   260         }
   234 
   261 
   235         mainWnd->setOrientation(Qt::Vertical, false);
   262         mainWnd->setOrientation(Qt::Vertical, false);
   252     	{
   279     	{
   253     		mVideoServices = VideoServices::instance();
   280     		mVideoServices = VideoServices::instance();
   254 
   281 
   255 			if (!mVideoServices)
   282 			if (!mVideoServices)
   256 			{
   283 			{
       
   284 			    ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to get video services instance.");
   257 				return;
   285 				return;
   258 			}
   286 			}
   259     	}
   287     	}
   260 
   288 
   261 		HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON);
   289 		VideoServices::TVideoService service = VideoServices::ENoService;
   262 
       
   263 		if (mIsService && mVideoServices)
   290 		if (mIsService && mVideoServices)
   264 		{
   291 		{
   265 			button->setText(tr("Attach")); //localisation
   292 		    service = mVideoServices->currentService();
   266 
   293 		    
   267 			connect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()));
       
   268 			connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
       
   269 
       
   270             HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   294             HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   271 
       
   272             mainWnd->currentView()->setTitle(mVideoServices->contextTitle());
   295             mainWnd->currentView()->setTitle(mVideoServices->contextTitle());
   273 		}
   296 		}
   274     	else if(!mIsService)
   297 
   275     	{
   298         HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON);
       
   299 		if(!button)
       
   300 		{
       
   301 		    ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details button.");
       
   302 		    return;
       
   303 		}
       
   304 				
       
   305 		if (service == VideoServices::EUriFetcher)
       
   306 		{
       
   307             button->setText(hbTrId("txt_videos_button_attach"));
       
   308 
       
   309             connect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()));
       
   310             connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
       
   311 		}
       
   312 		else
       
   313 		{
   276 			connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
   314 			connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
   277 			button->setText(hbTrId("txt_videos_opt_share"));
   315 			button->setText(hbTrId("txt_videos_opt_share"));
   278     	}
   316     	}
   279 
   317 
   280         connect(mainWnd,
   318         connect(mainWnd,
   297 // Deactivate view
   335 // Deactivate view
   298 // ---------------------------------------------------------------------------
   336 // ---------------------------------------------------------------------------
   299 //
   337 //
   300 void VideoFileDetailsViewPlugin::deactivateView()
   338 void VideoFileDetailsViewPlugin::deactivateView()
   301 {
   339 {
       
   340 	FUNC_LOG;
   302     if ( mActivated )
   341     if ( mActivated )
   303     {
   342     {
   304         mVideoId = TMPXItemId::InvalidId();
   343         mVideoId = TMPXItemId::InvalidId();
   305 
   344 
   306         mDeletedIndex = -1;  // set index as invalid.
   345         mDeletedIndex = -1;  // set index as invalid.
   340     	}
   379     	}
   341 		else
   380 		else
   342 		{
   381 		{
   343 			disconnect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
   382 			disconnect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
   344 		}
   383 		}
   345 
       
   346     }
   384     }
   347 }
   385 }
   348 
   386 
   349 // ---------------------------------------------------------------------------
   387 // ---------------------------------------------------------------------------
   350 // Get view
   388 // Get view
   351 // ---------------------------------------------------------------------------
   389 // ---------------------------------------------------------------------------
   352 //
   390 //
   353 QGraphicsWidget* VideoFileDetailsViewPlugin::getView()
   391 QGraphicsWidget* VideoFileDetailsViewPlugin::getView()
   354 {
   392 {
       
   393 	FUNC_LOG;
   355     return mLoader.findWidget(VIDEO_DETAILS_VIEW);
   394     return mLoader.findWidget(VIDEO_DETAILS_VIEW);
   356 }
   395 }
   357 
   396 
   358 // ---------------------------------------------------------------------------
   397 // ---------------------------------------------------------------------------
   359 // Slot: Orientation change
   398 // Slot: Orientation change
   360 // ---------------------------------------------------------------------------
   399 // ---------------------------------------------------------------------------
   361 //
   400 //
   362 void VideoFileDetailsViewPlugin::orientationChange( Qt::Orientation orientation )
   401 void VideoFileDetailsViewPlugin::orientationChange( Qt::Orientation orientation )
   363 {
   402 {
   364     if ( orientation == Qt::Vertical )
   403 	FUNC_LOG;
       
   404     if (orientation == Qt::Vertical)
   365     {
   405     {
   366     	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT);
   406     	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT);
   367     }
   407     }
   368 
   408 
   369     else if ( orientation == Qt::Horizontal )
   409     else if (orientation == Qt::Horizontal)
   370     {
   410     {
   371        	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE);
   411        	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE);
   372     }
   412     }
   373     mTitleAnim->adjustSize();
   413     mTitleAnim->adjustSize();
   374     mTitleAnim->startAnimation();
   414     mTitleAnim->startAnimation();
   378 // Slot: back
   418 // Slot: back
   379 // ---------------------------------------------------------------------------
   419 // ---------------------------------------------------------------------------
   380 //
   420 //
   381 void VideoFileDetailsViewPlugin::back()
   421 void VideoFileDetailsViewPlugin::back()
   382 {
   422 {
   383     if ( mActivated )
   423 	FUNC_LOG;
       
   424     if (mActivated)
   384     {
   425     {
   385         emit command( MpxHbVideoCommon::ActivateCollectionView );
   426         emit command( MpxHbVideoCommon::ActivateCollectionView );
   386     }
   427     }
   387 }
   428 }
   388 
   429 
   390 // Slot: shortDetailsReadySlot
   431 // Slot: shortDetailsReadySlot
   391 // ---------------------------------------------------------------------------
   432 // ---------------------------------------------------------------------------
   392 //
   433 //
   393 void VideoFileDetailsViewPlugin::shortDetailsReadySlot(TMPXItemId id)
   434 void VideoFileDetailsViewPlugin::shortDetailsReadySlot(TMPXItemId id)
   394 {
   435 {
       
   436 	FUNC_LOG;
   395     // first clear all details, so that the view doesn't display the old data.
   437     // first clear all details, so that the view doesn't display the old data.
   396     findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET)->clear();
   438     findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET)->clear();
   397 
   439 
   398     QModelIndex modelIndex = mModel->indexOfId(id);
   440     QModelIndex modelIndex = mModel->indexOfId(id);
   399 
   441 
   400     mVideoId = id;
   442     mVideoId = id;
   401 
   443 
   402     QVariant variant = mModel->data(modelIndex, Qt::DisplayRole);
   444     QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle);
   403 
   445 
   404     if (variant.isValid() && mTitleAnim)
   446     if (variant.isValid() && mTitleAnim)
   405     {
   447     {
   406         mTitleAnim->setText(variant.toStringList().first());
   448         mTitleAnim->setText(variant.toString());
   407     }
   449     }
   408     startFetchingThumbnail();
   450     startFetchingThumbnail();
   409 }
   451 }
   410 
   452 
   411 // ---------------------------------------------------------------------------
   453 // ---------------------------------------------------------------------------
   412 // Slot: fullDetailsReadySlot
   454 // Slot: fullDetailsReadySlot
   413 // ---------------------------------------------------------------------------
   455 // ---------------------------------------------------------------------------
   414 //
   456 //
   415 void VideoFileDetailsViewPlugin::fullDetailsReadySlot(TMPXItemId id)
   457 void VideoFileDetailsViewPlugin::fullDetailsReadySlot(QVariant& variant)
   416 {
   458 {
       
   459 	FUNC_LOG;
   417     using namespace VideoCollectionCommon;
   460     using namespace VideoCollectionCommon;
   418 
   461 
   419     int detailCount = sizeof(VideoDetailLabelKeys) / sizeof(int);
   462     int detailCount = sizeof(VideoDetailLabelKeys) / sizeof(int);
   420 
   463 
   421     QModelIndex modelIndex = mModel->indexOfId(id);
       
   422 
       
   423     QVariant variant = mModel->data(modelIndex, KeyMetaData);
       
   424 
       
   425     QMap<QString, QVariant> metadata = variant.toMap();
   464     QMap<QString, QVariant> metadata = variant.toMap();
   426 
   465     
   427     HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET);
   466     HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET);
   428 
   467     if(!list)
       
   468     {
       
   469         ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
       
   470         return;
       
   471     }
       
   472     
   429     if(list->count())
   473     if(list->count())
   430     {
   474     {
   431         list->clear();
   475         list->clear();
   432     }
   476     }
   433 
   477 
   455 // Slot: getFileUri
   499 // Slot: getFileUri
   456 // ---------------------------------------------------------------------------
   500 // ---------------------------------------------------------------------------
   457 //
   501 //
   458 void VideoFileDetailsViewPlugin::getFileUri()
   502 void VideoFileDetailsViewPlugin::getFileUri()
   459 {
   503 {
       
   504 	FUNC_LOG;
   460 	if (mVideoId != TMPXItemId::InvalidId())
   505 	if (mVideoId != TMPXItemId::InvalidId())
   461     {
   506     {
   462         QModelIndex modelIndex = mModel->indexOfId(mVideoId);
   507         QModelIndex modelIndex = mModel->indexOfId(mVideoId);
   463 		QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
   508 		QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
   464 		if ( variant.isValid()  )
   509 		if (variant.isValid())
   465 		{
   510 		{
   466 			QString itemPath = variant.value<QString>();
   511 			QString itemPath = variant.value<QString>();
   467     		emit(fileUri(itemPath));
   512     		emit(fileUri(itemPath));
   468 		}
   513 		}
   469     }
   514     }
   473 // Slot: startPlaybackSlot
   518 // Slot: startPlaybackSlot
   474 // ---------------------------------------------------------------------------
   519 // ---------------------------------------------------------------------------
   475 //
   520 //
   476 void VideoFileDetailsViewPlugin::startPlaybackSlot()
   521 void VideoFileDetailsViewPlugin::startPlaybackSlot()
   477 {
   522 {
       
   523 	FUNC_LOG;
   478 	if (mVideoId != TMPXItemId::InvalidId())
   524 	if (mVideoId != TMPXItemId::InvalidId())
   479 	{
   525 	{
   480     	mModel->openItem(mVideoId);
   526     	mModel->openItem(mVideoId);
   481 	}
   527 	}
   482 }
   528 }
   485 // Slot: sendVideo
   531 // Slot: sendVideo
   486 // ---------------------------------------------------------------------------
   532 // ---------------------------------------------------------------------------
   487 //
   533 //
   488 void VideoFileDetailsViewPlugin::sendVideoSlot()
   534 void VideoFileDetailsViewPlugin::sendVideoSlot()
   489 {
   535 {
   490     _DebugNotImplementedYet();
   536 	FUNC_LOG;
       
   537 	HbMessageBox::information(tr("Not implemented yet"));
       
   538 	
       
   539 /*    if(mVideoId != TMPXItemId::InvalidId())
       
   540     {
       
   541         ShareUi dialog;
       
   542         QModelIndex modelIndex = mModel->indexOfId(mVideoId);
       
   543         QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
       
   544         if(variant.isValid())
       
   545         {
       
   546             QStringList fileList;
       
   547             fileList.append(variant.toString());
       
   548             dialog.send(fileList, true);
       
   549         }
       
   550     }*/
   491 }
   551 }
   492 
   552 
   493 // ---------------------------------------------------------------------------
   553 // ---------------------------------------------------------------------------
   494 // Slot: deleteVideo
   554 // Slot: deleteVideo
   495 // ---------------------------------------------------------------------------
   555 // ---------------------------------------------------------------------------
   496 //
   556 //
   497 void VideoFileDetailsViewPlugin::deleteVideoSlot()
   557 void VideoFileDetailsViewPlugin::deleteVideoSlot()
   498 {
   558 {
       
   559 	FUNC_LOG;
   499 	if (mVideoId != TMPXItemId::InvalidId())
   560 	if (mVideoId != TMPXItemId::InvalidId())
   500         {
   561         {
   501 		QModelIndex modelIndex = mModel->indexOfId(mVideoId);
   562 		QModelIndex modelIndex = mModel->indexOfId(mVideoId);
   502 		QVariant variant = mModel->data(modelIndex, Qt::DisplayRole);
   563 		QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle);
   503 
   564 
   504         if (variant.isValid())
   565         if (variant.isValid())
   505         {
   566         {
   506             QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg(
   567             QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg(
   507 			   variant.toStringList().first());
   568 			   variant.toString());
   508 
   569 
   509             if (HbMessageBox::question(text))
   570             if (HbMessageBox::question(text))
   510             {
   571             {
   511                 deleteItem(modelIndex);
   572                 deleteItem(modelIndex);
   512             }
   573             }
   518 // deleteItem
   579 // deleteItem
   519 // ---------------------------------------------------------------------------
   580 // ---------------------------------------------------------------------------
   520 //
   581 //
   521 void VideoFileDetailsViewPlugin::deleteItem(QModelIndex index)
   582 void VideoFileDetailsViewPlugin::deleteItem(QModelIndex index)
   522 {
   583 {
       
   584 	FUNC_LOG;
   523     mDeletedIndex = index.row();
   585     mDeletedIndex = index.row();
   524 
   586 
   525     QModelIndexList list;
   587     QModelIndexList list;
   526     list.append(index);
   588     list.append(index);
   527     mModel->deleteItems(list);
   589     mModel->deleteItems(list);
   533 // ---------------------------------------------------------------------------
   595 // ---------------------------------------------------------------------------
   534 //
   596 //
   535 void VideoFileDetailsViewPlugin::rowsRemovedSlot(const QModelIndex& parent,
   597 void VideoFileDetailsViewPlugin::rowsRemovedSlot(const QModelIndex& parent,
   536                                                  int first, int last)
   598                                                  int first, int last)
   537 {
   599 {
       
   600 	FUNC_LOG;
   538 	Q_UNUSED(parent);
   601 	Q_UNUSED(parent);
   539 
   602 
   540 	if(mActivated && mDeletedIndex > -1 &&
   603 	if(mActivated && mDeletedIndex > -1 &&
   541        (mDeletedIndex >= first && mDeletedIndex <= last))
   604        (mDeletedIndex >= first && mDeletedIndex <= last))
   542     {
   605     {
   550 // error signal received from collectionwrapper
   613 // error signal received from collectionwrapper
   551 // -------------------------------------------------------------------------------------------------
   614 // -------------------------------------------------------------------------------------------------
   552 //
   615 //
   553 void VideoFileDetailsViewPlugin::handleErrorSlot(int errorCode, QVariant &additional)
   616 void VideoFileDetailsViewPlugin::handleErrorSlot(int errorCode, QVariant &additional)
   554 {
   617 {
       
   618 	FUNC_LOG;
   555     QString msg("");
   619     QString msg("");
   556     if(errorCode == VideoCollectionCommon::statusSingleDeleteFail)
   620     if(errorCode == VideoCollectionCommon::statusSingleDeleteFail)
   557     {
   621     {
   558         QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current"); 
   622         QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current"); 
   559         if(additional.isValid())
   623         if(additional.isValid())
   573 // ---------------------------------------------------------------------------
   637 // ---------------------------------------------------------------------------
   574 //
   638 //
   575 void VideoFileDetailsViewPlugin::thumbnailReadySlot(QPixmap pixmap,
   639 void VideoFileDetailsViewPlugin::thumbnailReadySlot(QPixmap pixmap,
   576         void * clientData, int id, int errorCode)
   640         void * clientData, int id, int errorCode)
   577 {
   641 {
       
   642 	FUNC_LOG;
   578     Q_UNUSED(clientData);
   643     Q_UNUSED(clientData);
   579     Q_UNUSED(id);
   644     Q_UNUSED(id);
   580 
   645 
   581 	QSize size(mThumbLabel->size().toSize());
   646 	QSize size(mThumbLabel->size().toSize());
   582 
   647 
   629 		HbIcon compsedIcon(QPixmap::fromImage(resultImage));
   694 		HbIcon compsedIcon(QPixmap::fromImage(resultImage));
   630 	    mThumbLabel->setIcon(compsedIcon);
   695 	    mThumbLabel->setIcon(compsedIcon);
   631 	}
   696 	}
   632     else
   697     else
   633     {
   698     {
       
   699         ERROR(errorCode, "VideoFileDetailsViewPlugin::thumbnailReadySlot() tbn fetch failed.");
   634 		mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
   700 		mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
   635 	}
   701 	}
   636 }
   702 }
   637 
   703 
   638 // ---------------------------------------------------------------------------
   704 // ---------------------------------------------------------------------------
   639 // startFetchingThumbnail
   705 // startFetchingThumbnail
   640 // ---------------------------------------------------------------------------
   706 // ---------------------------------------------------------------------------
   641 //
   707 //
   642 void VideoFileDetailsViewPlugin::startFetchingThumbnail()
   708 void VideoFileDetailsViewPlugin::startFetchingThumbnail()
   643 {
   709 {
       
   710 	FUNC_LOG;
   644     int tnId = -1;
   711     int tnId = -1;
   645 
   712 
   646     if(mModel && mThumbnailManager)
   713     if(mModel && mThumbnailManager)
   647     {
   714     {
   648     	QModelIndex modelIndex = mModel->indexOfId(mVideoId);
   715     	QModelIndex modelIndex = mModel->indexOfId(mVideoId);
   651         {
   718         {
   652             mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
   719             mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
   653             tnId = mThumbnailManager->getThumbnail(variant.toString(), 0, 5000);
   720             tnId = mThumbnailManager->getThumbnail(variant.toString(), 0, 5000);
   654         }
   721         }
   655     }
   722     }
   656     else
       
   657     {
       
   658         qWarning() << "Tried to start fetching thumbnail when either mModel or mThumbnailManager is NULL!";
       
   659     }
       
   660 
   723 
   661     if(tnId == -1)
   724     if(tnId == -1)
   662     {
   725     {
       
   726         ERROR(-1, "VideoFileDetailsViewPlugin::startFetchingThumbnail() starting the fetch failed.");
   663     	mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
   727     	mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
   664     }
   728     }
   665 }
   729 }
   666 
   730 
   667 // ---------------------------------------------------------------------------
   731 // ---------------------------------------------------------------------------
   668 // playIcon
   732 // playIcon
   669 // ---------------------------------------------------------------------------
   733 // ---------------------------------------------------------------------------
   670 //
   734 //
   671 const QPixmap &VideoFileDetailsViewPlugin::playIcon()
   735 const QPixmap &VideoFileDetailsViewPlugin::playIcon()
   672 {
   736 {
       
   737 	FUNC_LOG;
   673     // Check if we have already the icon.
   738     // Check if we have already the icon.
   674     if(!mPlayIcon.isNull())
   739     if(!mPlayIcon.isNull())
   675     {
   740     {
   676         return mPlayIcon;
   741         return mPlayIcon;
   677     }
   742     }
   746 // ---------------------------------------------------------------------------
   811 // ---------------------------------------------------------------------------
   747 //
   812 //
   748 template<class T>
   813 template<class T>
   749 T* VideoFileDetailsViewPlugin::findWidget(QString name)
   814 T* VideoFileDetailsViewPlugin::findWidget(QString name)
   750 {
   815 {
       
   816 	FUNC_LOG;
   751     return qobject_cast<T *>(mLoader.findWidget(name));
   817     return qobject_cast<T *>(mLoader.findWidget(name));
   752 }
   818 }
   753 
   819 
   754 // ---------------------------------------------------------------------------
   820 // ---------------------------------------------------------------------------
   755 // findObject
   821 // findObject
   756 // ---------------------------------------------------------------------------
   822 // ---------------------------------------------------------------------------
   757 //
   823 //
   758 template<class T>
   824 template<class T>
   759 T* VideoFileDetailsViewPlugin::findObject(QString name)
   825 T* VideoFileDetailsViewPlugin::findObject(QString name)
   760 {
   826 {
       
   827 	FUNC_LOG;
   761     return qobject_cast<T *>(mLoader.findObject(name));
   828     return qobject_cast<T *>(mLoader.findObject(name));
   762 }
   829 }
   763 
   830 
   764 XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin );
   831 XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin );
   765 
   832