videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
--- a/videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp	Tue Jul 06 14:17:50 2010 +0300
+++ b/videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp	Wed Aug 18 09:50:14 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 76.1.1 %
+// Version : %version: 76.1.7 %
 
 // INCLUDE FILES
 #include <qcoreapplication.h>
@@ -32,6 +32,8 @@
 #include <hblistwidget.h>
 #include <hblistwidgetitem.h>
 #include <hblistviewitem.h>
+#include <hbparameterlengthlimiter.h>
+#include <hbtextitem.h>
 #include <cmath>
 #include <thumbnailmanager_qt.h>
 #include <shareui.h>
@@ -87,6 +89,7 @@
     , mThumbLabel( 0 )
     , mThumbnailManager( 0 )
     , mCollectionWrapper( VideoCollectionWrapper::instance() )
+    , mShareUi(0)
 {
 	FUNC_LOG;
 }
@@ -113,10 +116,10 @@
 	mActivated = false;
 
 	bool ok = false;
-	
+
 	//Load the details view docml first
 	mLoader.load(VIDEO_DETAILS_DOCML, &ok);
-	
+
 	if(!ok)
 	{
 	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load docml.");
@@ -125,7 +128,7 @@
 
 	//Load portrait section by default as only vertical orientation is currently supported by videoplayer
 	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT, &ok);
-	
+
 	if(!ok)
 	{
 	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load portrait view.");
@@ -176,7 +179,7 @@
 	mThumbLabel = new VideoDetailsLabel;
 	mThumbLabel->setAlignment(Qt::AlignCenter);
 	mThumbLabel->setObjectName(VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL);
-	
+
 	connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot()));
 
 	thumbWidget->addWidget(mThumbLabel);
@@ -211,7 +214,7 @@
 	// Create navigation keys.
 	mNavKeyBackAction = new HbAction(Hb::BackNaviAction);
 	mNavKeyBackAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK);
-	
+
 	if (!mThumbnailManager)
 	{
 		mThumbnailManager = new ThumbnailManager();
@@ -219,14 +222,14 @@
 
 	connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap,void*,int,int)),
 			this, SLOT(thumbnailReadySlot(QPixmap,void*,int,int)));
-	
+
     HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET);
     if(!list)
     {
         ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
         return;
     }
-    
+
     list->setEnabledAnimations(HbAbstractItemView::None);
 }
 
@@ -250,10 +253,10 @@
 
     delete mNavKeyBackAction;
     mNavKeyBackAction = 0;
-    
+
     delete mThumbnailManager;
     mThumbnailManager = 0;
-    
+
     disconnect();
     mLoader.reset();
 }
@@ -272,7 +275,7 @@
         HbView *currentView = mainWnd->currentView();
         if(currentView && mNavKeyBackAction)
         {
-        	if (connect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back())))
+        	if (connect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back())), Qt::UniqueConnection)
         	{
         		currentView->setNavigationAction(mNavKeyBackAction);
         	}
@@ -314,7 +317,7 @@
 		if (mIsService && mVideoServices)
 		{
 		    service = mVideoServices->currentService();
-		    
+
             HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
             mainWnd->currentView()->setTitle(mVideoServices->contextTitle());
 		}
@@ -325,35 +328,40 @@
 		    ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details button.");
 		    return;
 		}
-				
+
 	    // Fix the size of the thumbnail, as that needs to be in 16:9
 	    qreal width = button->size().width();
 	    qreal height = width * 9 / 16;
-	    
+
 	    HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
 	    thumbWidget->setPreferredWidth(width);
 	    thumbWidget->setPreferredHeight(height);
-	    
+
 		if (service == VideoServices::EUriFetcher)
 		{
-            button->setText(hbTrId("txt_videos_button_attach"));
+			HbIcon icon = HbIcon("qtg_mono_attach");
+			button->setIcon(icon);
 
-            connect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()));
-            connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
+            connect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()), Qt::UniqueConnection);
+            connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)), Qt::UniqueConnection);
 		}
 		else
 		{
-			connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
-			button->setText(hbTrId("txt_videos_opt_share"));
+			connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()), Qt::UniqueConnection);
+
+			HbIcon icon = HbIcon("qtg_mono_share");
+			button->setIcon(icon);
     	}
 
         connect(mainWnd,
                 SIGNAL(orientationChanged(Qt::Orientation)),
-                this, SLOT(orientationChange(Qt::Orientation)));
+                this, SLOT(orientationChange(Qt::Orientation)),
+                Qt::UniqueConnection);
 
         connect(&mCollectionWrapper,
                SIGNAL(asyncStatus(int, QVariant&)),
-               this, SLOT(handleErrorSlot(int, QVariant&)));
+               this, SLOT(handleErrorSlot(int, QVariant&)),
+               Qt::UniqueConnection);
 
         // setup title size in order for animation to be enabled if needed
         mTitleAnim->setMinimumWidth(hbInstance->allMainWindows().value(0)->width()-50);
@@ -414,6 +422,8 @@
 			disconnect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
 		}
     }
+    delete mShareUi;
+    mShareUi = 0;
 }
 
 // ---------------------------------------------------------------------------
@@ -494,14 +504,14 @@
     int detailCount = sizeof(VideoDetailLabelKeys) / sizeof(int);
 
     QMap<QString, QVariant> metadata = variant.toMap();
-    
+
     HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET);
     if(!list)
     {
         ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
         return;
     }
-    
+
     if(list->count())
     {
         list->clear();
@@ -514,10 +524,20 @@
         if (metadata.contains(VideoDetailLabelKeys[i]))
         {
             HbListWidgetItem* listWidgetItem = new HbListWidgetItem();
-            listWidgetItem->setEnabled(false);
             listWidgetItem->setText( hbTrId(VideoDetailLabels[i]));
             listWidgetItem->setSecondaryText(metadata[VideoDetailLabelKeys[i]].toString());
             list->addItem(listWidgetItem);
+            
+            // following is required to change wrapping-mode for the second row
+            HbListViewItem *viewItem = static_cast<HbListViewItem*>(list->viewItem(list->row(listWidgetItem)));
+            if(viewItem)
+            {
+                HbTextItem *secondLine = static_cast<HbTextItem*>(viewItem->primitive("text-2"));
+                if(secondLine)
+                {
+                    secondLine->setTextWrapping(Hb::TextWrapAnywhere);
+                }
+            }
         }
     }
 
@@ -564,18 +584,20 @@
 void VideoFileDetailsViewPlugin::sendVideoSlot()
 {
 	FUNC_LOG;
-//	HbMessageBox::information(tr("Not implemented yet"));
-	
+
     if(mVideoId != TMPXItemId::InvalidId())
     {
-        ShareUi dialog;
+        if(!mShareUi)
+        {
+            mShareUi = new ShareUi();
+        }
         QModelIndex modelIndex = mModel->indexOfId(mVideoId);
         QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
         if(variant.isValid())
         {
             QStringList fileList;
             fileList.append(variant.toString());
-            dialog.send(fileList, true);
+            mShareUi->send(fileList, true);
         }
     }
 }
@@ -594,13 +616,14 @@
 
         if (variant.isValid())
         {
-            QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg(
-			   variant.toString());
+        	QString text = HbParameterLengthLimiter(hbTrId("txt_videos_info_do_you_want_to_delete_1")).
+        			arg(variant.toString());
 
             HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
             messageBox->setAttribute(Qt::WA_DeleteOnClose);
+            messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
             messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO);
-            messageBox->open(this, SLOT(deleteVideoDialogFinished(HbAction *)));
+            messageBox->open(this, SLOT(deleteVideoDialogFinished(int)));
         }
     }
 }
@@ -609,12 +632,11 @@
 // deleteVideoDialogFinished
 // ---------------------------------------------------------------------------
 //
-void VideoFileDetailsViewPlugin::deleteVideoDialogFinished(HbAction *action)
+void VideoFileDetailsViewPlugin::deleteVideoDialogFinished(int action)
 {
     FUNC_LOG;
-    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
     QModelIndex modelIndex = mModel->indexOfId(mVideoId);
-    if(action == dlg->actions().at(0) && modelIndex.isValid()) 
+    if(action == HbMessageBox::Yes && modelIndex.isValid())
     {
         deleteItem(modelIndex);
     }
@@ -666,7 +688,7 @@
         QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current");
         if(additional.isValid())
         {
-           msg = format.arg(additional.toString());
+           msg = HbParameterLengthLimiter(format).arg(additional.toString());
         }
     }
     if(msg.count() > 0)
@@ -690,7 +712,14 @@
     Q_UNUSED(clientData);
     Q_UNUSED(id);
 
-	QSize size(mThumbLabel->size().toSize());
+	HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
+	if(!thumbWidget)
+	{
+	    ERROR(-1, "VideoFileDetailsViewPlugin::thumbnailReadySlot() failed to load thumbnail widget.");
+	    return;
+	}
+
+	QSize size(thumbWidget->size().toSize());
 
 	if (!errorCode)
 	{
@@ -709,7 +738,7 @@
 		}
 
 		int difference(0);
-		QRect rect = mThumbLabel->rect().toRect();
+		QRect rect = thumbWidget->rect().toRect();
 
 		if(sourceImage.width() > size.width())
 		{
@@ -787,7 +816,7 @@
     {
         return mPlayIcon;
     }
-    
+
     // Compose the icon.
     HbIcon play =        HbIcon("qtg_mono_play");
     HbIcon topLeft =     HbIcon("qtg_fr_popup_trans_tl");
@@ -802,54 +831,54 @@
 
     int width = topLeft.width() + top.width() + topRight.width();
     int height = topLeft.height() + center.height() + bottomLeft.height();
-    
+
     mPlayIcon = QPixmap(width, height);
-    
+
     QPainter painter(&mPlayIcon);
     painter.fillRect(mPlayIcon.rect(), Qt::white);
-    
+
     painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
-    
+
     int x = 0;
     int y = 0;
 
     // Draw top
     painter.drawPixmap(QPoint(x, y), topLeft.pixmap());
     x += left.width();
-    
+
     painter.drawPixmap(QPoint(x, y), top.pixmap());
     x += top.width();
 
     painter.drawPixmap(QPoint(x, y), topRight.pixmap());
     y += top.height();
-    
+
     // Draw center
     x = 0;
     painter.drawPixmap(QPoint(x, y), left.pixmap());
     x += left.width();
-    
+
     painter.drawPixmap(QPoint(x, y), center.pixmap());
     x += center.width();
 
     painter.drawPixmap(QPoint(x, y), right.pixmap());
     y += center.height();
-    
+
     // Draw bottom
     x = 0;
     painter.drawPixmap(QPoint(x, y), bottomLeft.pixmap());
     x += left.width();
-    
+
     painter.drawPixmap(QPoint(x, y), bottom.pixmap());
     x += top.width();
-    
+
     painter.drawPixmap(QPoint(x, y), bottomRight.pixmap());
-    
+
     // Draw play icon
     play.setSize(mPlayIcon.size());
     play.setColor(Qt::white);
     painter.drawPixmap(mPlayIcon.rect(), play.pixmap());
     painter.end();
-    
+
     return mPlayIcon;
 }