videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp
changeset 24 7d93ee07fb27
parent 20 b9e04db066d4
child 47 45e72b57a2fd
equal deleted inserted replaced
20:b9e04db066d4 24:7d93ee07fb27
    13 *
    13 *
    14 * Description:   VideoCollectionViewPlugin class implementation
    14 * Description:   VideoCollectionViewPlugin class implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 73 %
    18 // Version : %version: 76 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <qcoreapplication.h>
    21 #include <qcoreapplication.h>
    22 #include <xqserviceutil.h>
    22 #include <xqserviceutil.h>
    23 #include <xqplugin.h>
    23 #include <xqplugin.h>
    44 #include "videosortfilterproxymodel.h"
    44 #include "videosortfilterproxymodel.h"
    45 #include "videoservices.h"
    45 #include "videoservices.h"
    46 #include "videodetailslabel.h"
    46 #include "videodetailslabel.h"
    47 #include "videocollectiontrace.h"
    47 #include "videocollectiontrace.h"
    48 
    48 
       
    49 // Object names.
       
    50 const char* const VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL          = "vc:FileDetailsThumbnailLabel";
       
    51 const char* const VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO        = "vc:FileDetailsMessageBoxDeleteVideo";
       
    52 const char* const VIDEO_DETAILS_OBJECT_NAME_MESSAGE_BOX_WARNING = "vc:FileDetailsMessageBoxWarning";
       
    53 const char* const VIDEO_DETAILS_OBJECT_NAME_DELETE_ACTION       = "vc:FileDetailsDelete";
       
    54 const char* const VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK         = "vc:FileDetailsNavKeyBack";
       
    55 const char* const VIDEO_DETAILS_OBJECT_NAME_TITLE_ANIM          = "vc:FileDetailsTitleAnim";
       
    56 
       
    57 // Docml constants.
    49 const char* const VIDEO_DETAILS_DOCML             = ":/xml/videofiledetails.docml";
    58 const char* const VIDEO_DETAILS_DOCML             = ":/xml/videofiledetails.docml";
    50 const char* const VIDEO_DETAILS_PORTRAIT          = "portrait";
    59 const char* const VIDEO_DETAILS_PORTRAIT          = "portrait";
    51 const char* const VIDEO_DETAILS_LANDSCAPE         = "landscape";
    60 const char* const VIDEO_DETAILS_LANDSCAPE         = "landscape";
    52 const char* const VIDEO_DETAILS_GFX_DEFAULT       = ":/gfx/pri_large_video.svg";
       
    53 const char* const VIDEO_DETAILS_VIEW              = "videofiledetailsview";
    61 const char* const VIDEO_DETAILS_VIEW              = "videofiledetailsview";
    54 const char* const VIDEO_DETAILS_TITLE             = "mLblTitle";
    62 const char* const VIDEO_DETAILS_TITLE             = "mLblTitle";
    55 const char* const VIDEO_DETAILS_THUMBNAIL         = "mDetailsLabel";
    63 const char* const VIDEO_DETAILS_THUMBNAIL         = "mDetailsLabel";
    56 const char* const VIDEO_DETAILS_BUTTON            = "mButton";
    64 const char* const VIDEO_DETAILS_BUTTON            = "mButton";
    57 const char* const VIDEO_DETAILS_MENUACTION_DELETE = "mOptionsDelete";
    65 const char* const VIDEO_DETAILS_MENUACTION_DELETE = "mOptionsDelete";
    58 const char* const VIDEO_DETAILS_LISTWIDGET        = "mDetailsList";
    66 const char* const VIDEO_DETAILS_LISTWIDGET        = "mDetailsList";
       
    67 
       
    68 // Default thumbnail.
       
    69 const char* const VIDEO_DETAILS_GFX_DEFAULT       = "qtg_large_video";
       
    70 
       
    71 const int VIDEO_DETAILS_SECONDARY_TEXT_ROW_COUNT  = 255;
    59 
    72 
    60 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    61 // Constructor
    74 // Constructor
    62 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    63 //
    76 //
   134 	mTitleAnim = new HbMarqueeItem;
   147 	mTitleAnim = new HbMarqueeItem;
   135 	HbFontSpec spec = mTitleAnim->fontSpec();
   148 	HbFontSpec spec = mTitleAnim->fontSpec();
   136     spec.setRole( HbFontSpec::Primary );
   149     spec.setRole( HbFontSpec::Primary );
   137     mTitleAnim->setFontSpec( spec );
   150     mTitleAnim->setFontSpec( spec );
   138     mTitleAnim->setLoopCount(-1);
   151     mTitleAnim->setLoopCount(-1);
       
   152     mTitleAnim->setObjectName(VIDEO_DETAILS_OBJECT_NAME_TITLE_ANIM);
   139 
   153 
   140 	connect(mModel->sourceModel(),
   154 	connect(mModel->sourceModel(),
   141 			SIGNAL(shortDetailsReady(TMPXItemId)),
   155 			SIGNAL(shortDetailsReady(TMPXItemId)),
   142 			this, SLOT(shortDetailsReadySlot(TMPXItemId)));
   156 			this, SLOT(shortDetailsReadySlot(TMPXItemId)));
   143 
   157 
   158 	}
   172 	}
   159 
   173 
   160 	// no deallocation needed for this since
   174 	// no deallocation needed for this since
   161 	// stackedwidget takes ownership
   175 	// stackedwidget takes ownership
   162 	mThumbLabel = new VideoDetailsLabel;
   176 	mThumbLabel = new VideoDetailsLabel;
   163 
       
   164 	mThumbLabel->setAlignment(Qt::AlignCenter);
   177 	mThumbLabel->setAlignment(Qt::AlignCenter);
   165 
   178 	mThumbLabel->setObjectName(VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL);
       
   179 	
   166 	connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot()));
   180 	connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot()));
   167 
   181 
   168 	thumbWidget->addWidget(mThumbLabel);
   182 	thumbWidget->addWidget(mThumbLabel);
   169 
   183 
   170 	// Load details title.
   184 	// Load details title.
   181     if(!deleteAction)
   195     if(!deleteAction)
   182     {
   196     {
   183         ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to delete action.");
   197         ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to delete action.");
   184         return;
   198         return;
   185     }
   199     }
       
   200     deleteAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_ACTION);
   186 
   201 
   187 	if (mIsService)
   202 	if (mIsService)
   188 	{
   203 	{
   189 		deleteAction->setVisible(false);
   204 		deleteAction->setVisible(false);
   190 	}
   205 	}
   193 		connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteVideoSlot()));
   208 		connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteVideoSlot()));
   194 	}
   209 	}
   195 
   210 
   196 	// Create navigation keys.
   211 	// Create navigation keys.
   197 	mNavKeyBackAction = new HbAction(Hb::BackNaviAction);
   212 	mNavKeyBackAction = new HbAction(Hb::BackNaviAction);
   198 
   213 	mNavKeyBackAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK);
       
   214 	
   199 	if (!mThumbnailManager)
   215 	if (!mThumbnailManager)
   200 	{
   216 	{
   201 		mThumbnailManager = new ThumbnailManager();
   217 		mThumbnailManager = new ThumbnailManager();
   202 	}
   218 	}
   203 
   219 
   210         ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
   226         ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
   211         return;
   227         return;
   212     }
   228     }
   213     
   229     
   214     list->setEnabledAnimations(HbAbstractItemView::None);
   230     list->setEnabledAnimations(HbAbstractItemView::None);
   215 
       
   216 }
   231 }
   217 
   232 
   218 // ---------------------------------------------------------------------------
   233 // ---------------------------------------------------------------------------
   219 // Destroy view
   234 // Destroy view
   220 // ---------------------------------------------------------------------------
   235 // ---------------------------------------------------------------------------
   482     if(list->count())
   497     if(list->count())
   483     {
   498     {
   484         list->clear();
   499         list->clear();
   485     }
   500     }
   486 
   501 
   487     //TODO: define maximum line count once >3 supported
       
   488     HbListViewItem *prototype = list->listItemPrototype();
   502     HbListViewItem *prototype = list->listItemPrototype();
   489     prototype->setSecondaryTextRowCount(1, 3);
   503     prototype->setSecondaryTextRowCount(1, VIDEO_DETAILS_SECONDARY_TEXT_ROW_COUNT);
   490 
   504 
   491     for(int i = 0; i< detailCount; i++) {
   505     for(int i = 0; i< detailCount; i++) {
   492         if (metadata.contains(VideoDetailLabelKeys[i]))
   506         if (metadata.contains(VideoDetailLabelKeys[i]))
   493         {
   507         {
   494             HbListWidgetItem* listWidgetItem = new HbListWidgetItem();
   508             HbListWidgetItem* listWidgetItem = new HbListWidgetItem();
   495             listWidgetItem->setEnabled(false);
   509             listWidgetItem->setEnabled(false);
   496 
   510             listWidgetItem->setText( hbTrId(VideoDetailLabels[i]));
   497             listWidgetItem->setText( hbTrId(VideoDetailLabels[i]) );
   511             listWidgetItem->setSecondaryText(metadata[VideoDetailLabelKeys[i]].toString());
   498             listWidgetItem->setSecondaryText( metadata[VideoDetailLabelKeys[i]].toString() );
   512             list->addItem(listWidgetItem);
   499             list->addItem( listWidgetItem );
       
   500         }
   513         }
   501     }
   514     }
   502 
   515 
   503     // start title animation
   516     // start title animation
   504     mTitleAnim->startAnimation();
   517     mTitleAnim->startAnimation();
   576             QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg(
   589             QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg(
   577 			   variant.toString());
   590 			   variant.toString());
   578 
   591 
   579             HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
   592             HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
   580             messageBox->setAttribute(Qt::WA_DeleteOnClose);
   593             messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
   594             messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO);
   581             messageBox->open(this, SLOT(deleteVideoDialogFinished(HbAction *)));
   595             messageBox->open(this, SLOT(deleteVideoDialogFinished(HbAction *)));
   582             
       
   583         }
   596         }
   584     }
   597     }
   585 }
   598 }
   586 
   599 
   587 // ---------------------------------------------------------------------------
   600 // ---------------------------------------------------------------------------
   611     QModelIndexList list;
   624     QModelIndexList list;
   612     list.append(index);
   625     list.append(index);
   613     mModel->deleteItems(list);
   626     mModel->deleteItems(list);
   614 }
   627 }
   615 
   628 
   616 
       
   617 // ---------------------------------------------------------------------------
   629 // ---------------------------------------------------------------------------
   618 // Slot: rowsRemovedSlot
   630 // Slot: rowsRemovedSlot
   619 // ---------------------------------------------------------------------------
   631 // ---------------------------------------------------------------------------
   620 //
   632 //
   621 void VideoFileDetailsViewPlugin::rowsRemovedSlot(const QModelIndex& parent,
   633 void VideoFileDetailsViewPlugin::rowsRemovedSlot(const QModelIndex& parent,
   641 {
   653 {
   642 	FUNC_LOG;
   654 	FUNC_LOG;
   643     QString msg("");
   655     QString msg("");
   644     if(errorCode == VideoCollectionCommon::statusSingleDeleteFail)
   656     if(errorCode == VideoCollectionCommon::statusSingleDeleteFail)
   645     {
   657     {
   646         QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current"); 
   658         QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current");
   647         if(additional.isValid())
   659         if(additional.isValid())
   648         {
   660         {
   649            msg = format.arg(additional.toString());
   661            msg = format.arg(additional.toString());
   650         }
   662         }
   651     }
   663     }
   652     if(msg.count() > 0)
   664     if(msg.count() > 0)
   653     {
   665     {
   654         // show msg box if there's something to show
   666         // show msg box if there's something to show
   655         HbMessageBox::warning(msg);
   667         HbMessageBox *messageBox = new HbMessageBox(msg, HbMessageBox::MessageTypeWarning);
       
   668         messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
   669         messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_MESSAGE_BOX_WARNING);
       
   670         messageBox->show();
   656     }
   671     }
   657 }
   672 }
   658 
   673 
   659 // ---------------------------------------------------------------------------
   674 // ---------------------------------------------------------------------------
   660 // Slot: thumbnailReadySlot
   675 // Slot: thumbnailReadySlot
   852     return qobject_cast<T *>(mLoader.findObject(name));
   867     return qobject_cast<T *>(mLoader.findObject(name));
   853 }
   868 }
   854 
   869 
   855 XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin );
   870 XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin );
   856 
   871 
   857 // end of file
   872 // End of file