videocollection/videocollectionview/src/videocollectionviewutils.cpp
changeset 41 229f037ce963
parent 40 13331705e488
child 44 518105d52e45
equal deleted inserted replaced
40:13331705e488 41:229f037ce963
    13 *
    13 *
    14 * Description: video collection view plugin's ui utils class
    14 * Description: video collection view plugin's ui utils class
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 41 %
    18 // Version : %version: 43 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <hbglobal.h>
    21 #include <hbglobal.h>
    22 #include <hblistview.h>
    22 #include <hblistview.h>
    23 #include <hbscrollbar.h>
    23 #include <hbscrollbar.h>
    24 #include <hblistviewitem.h>
    24 #include <hblistviewitem.h>
    25 #include <hbdialog.h>
    25 #include <hbdialog.h>
    26 #include <hbmessagebox.h>
    26 #include <hbmessagebox.h>
    27 #include <hbnotificationdialog.h>
    27 #include <hbnotificationdialog.h>
    28 #include <centralrepository.h>
    28 #include <centralrepository.h>
       
    29 #include <vcxmyvideosdefs.h>
    29 
    30 
    30 #include "videocollectioncommon.h"
    31 #include "videocollectioncommon.h"
    31 #include "videocollectionviewutils.h"
    32 #include "videocollectionviewutils.h"
    32 #include "videosortfilterproxymodel.h"
    33 #include "videosortfilterproxymodel.h"
    33 #include "videoactivitystate.h"
    34 #include "videoactivitystate.h"
       
    35 #include "videocollectioncenrepdefs.h"
    34 #include "videocollectiontrace.h"
    36 #include "videocollectiontrace.h"
    35 
    37 
    36 // Object names.
    38 // Object names.
    37 const char* const VIEW_UTILS_OBJECT_NAME_STATUS_MSG          = "vc:ViewUtilsStatusMessage";
    39 const char* const VIEW_UTILS_OBJECT_NAME_STATUS_MSG          = "vc:ViewUtilsStatusMessage";
    38 const char* const VIEW_UTILS_OBJECT_NAME_MESSAGE_BOX_WARNING = "vc:ViewUtilsMessageBoxWarning";
    40 const char* const VIEW_UTILS_OBJECT_NAME_MESSAGE_BOX_WARNING = "vc:ViewUtilsMessageBoxWarning";
    39 
    41 
    40 // Cenrep constants.
       
    41 const int KVideoCollectionViewCenrepUid(0x2002BC63);
       
    42 const int KVideoCollectionViewCenrepServiceIconKey(0x2);
       
    43 const int KVideoCollectionViewCenrepServiceIconPressedKey(0x3);
       
    44 const int KVideoCollectionViewCenrepVideoSortingRoleKey(0x5);
       
    45 const int KVideoCollectionViewCenrepVideoSortingOrderKey(0x6);
       
    46 const int KVideoCollectionViewCenrepCollectionsSortingRoleKey(0x7);
       
    47 const int KVideoCollectionViewCenrepCollectionsSortingOrderKey(0x8);
       
    48 
       
    49 const int KAddToCollectionDataCount(2);
    42 const int KAddToCollectionDataCount(2);
    50 const int KAddToCollectionCountIndex(0);
    43 const int KAddToCollectionCountIndex(0);
    51 const int KAddToCollectionNameIndex(1);
    44 const int KAddToCollectionNameIndex(1);
       
    45 
       
    46 // type of collectionview plugin's widget level(int): 
       
    47 // all videos, collections or collection video list
       
    48 static const QString KEY_WIDGET_LEVEL    = "_VideoActivity_widget_level_";
       
    49 
       
    50 // id of the collection whose videolist is to be shown (int).
       
    51 static const QString KEY_COLLECTION_ID   = "_VideoActivity_collection_id_";
       
    52 
       
    53 // name of the collection whose videolist is to be shown (QString)
       
    54 static const QString KEY_COLLECTION_NAME = "_VideoActivity_collection_name_";
    52 
    55 
    53 
    56 
    54 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    55 // instance
    58 // instance
    56 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
   205     TRAP_IGNORE(cenRep = CRepository::NewL(TUid::Uid(KVideoCollectionViewCenrepUid)));
   208     TRAP_IGNORE(cenRep = CRepository::NewL(TUid::Uid(KVideoCollectionViewCenrepUid)));
   206     if(cenRep)
   209     if(cenRep)
   207     {
   210     {
   208         TBuf<255> iconValue;
   211         TBuf<255> iconValue;
   209         TBuf<255> pressedValue;
   212         TBuf<255> pressedValue;
   210         status = cenRep->Get(KVideoCollectionViewCenrepServiceIconKey, iconValue);
   213         status = cenRep->Get(KVideoCollectionViewCenrepServiceItem1IconPath, iconValue);
   211         if(status == KErrNone)
   214         if(status == KErrNone)
   212         {
   215         {
   213             status = cenRep->Get(KVideoCollectionViewCenrepServiceIconPressedKey, pressedValue);
   216             status = cenRep->Get(KVideoCollectionViewCenrepServiceItem1PressedIconPath, pressedValue);
   214             if(status == KErrNone)
   217             if(status == KErrNone)
   215             {
   218             {
   216                 QString iconTemp((QChar*)iconValue.Ptr(),iconValue.Length());
   219                 QString iconTemp((QChar*)iconValue.Ptr(),iconValue.Length());
   217                 QString pressedTemp((QChar*)pressedValue.Ptr(),pressedValue.Length());
   220                 QString pressedTemp((QChar*)pressedValue.Ptr(),pressedValue.Length());
   218 
   221 
   236     CRepository *cenRep = 0;
   239     CRepository *cenRep = 0;
   237     TRAP_IGNORE(cenRep = CRepository::NewL(TUid::Uid(KVideoCollectionViewCenrepUid)));
   240     TRAP_IGNORE(cenRep = CRepository::NewL(TUid::Uid(KVideoCollectionViewCenrepUid)));
   238     if(cenRep)
   241     if(cenRep)
   239     {
   242     {
   240         TBuf<255> uriValue;
   243         TBuf<255> uriValue;
   241         if(cenRep->Get(KVideoCollectionViewCenrepServiceIconKey, uriValue) == KErrNone)
   244         if(cenRep->Get(KVideoCollectionViewCenrepServiceItem1Url, uriValue) == KErrNone)
   242         {
   245         {
   243             QString uriTemp((QChar*)uriValue.Ptr(),uriValue.Length());
   246             QString uriTemp((QChar*)uriValue.Ptr(),uriValue.Length());
   244             uri = uriTemp;
   247             uri = uriTemp;
   245         }
   248         }
   246         delete cenRep;
   249         delete cenRep;
   311         model->doSorting(sortRole, sortOrder, async);
   314         model->doSorting(sortRole, sortOrder, async);
   312     }
   315     }
   313 }
   316 }
   314 
   317 
   315 // ---------------------------------------------------------------------------
   318 // ---------------------------------------------------------------------------
   316 // saveWidgetLevel
   319 // setWidgetActivityLevel
   317 // ---------------------------------------------------------------------------
   320 // ---------------------------------------------------------------------------
   318 //
   321 //
   319 void VideoCollectionViewUtils::saveWidgetLevel(VideoCollectionCommon::TCollectionLevels &level)
   322 void VideoCollectionViewUtils::setWidgetActivityLevel(
       
   323         const VideoCollectionCommon::TCollectionLevels &level)
   320 {
   324 {
   321     FUNC_LOG; 
   325     FUNC_LOG; 
   322     QVariant data = int(level);
   326     QVariant data = int(level);
   323     VideoActivityState::instance().setActivityData(data, VideoActivityData::KEY_WIDGET_LEVEL);
   327     VideoActivityState::instance().setActivityData(data, KEY_WIDGET_LEVEL);
   324 }
   328 
   325   
   329     if(level != VideoCollectionCommon::ELevelDefaultColl && 
   326 // ---------------------------------------------------------------------------
   330        level != VideoCollectionCommon::ELevelAlbum)
   327 // loadWidgetLevel
   331     {
   328 // ---------------------------------------------------------------------------
   332         // no need to save collection related data, clear them
   329 //
   333         data.clear();
   330 VideoCollectionCommon::TCollectionLevels VideoCollectionViewUtils::loadWidgetLevel()
   334         VideoActivityState::instance().setActivityData(data, KEY_COLLECTION_ID);    
       
   335         VideoActivityState::instance().setActivityData(data, KEY_COLLECTION_NAME);   
       
   336     }
       
   337 }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // getActivityWidgetLevel
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 void VideoCollectionViewUtils::getActivityWidgetLevel(VideoCollectionCommon::TCollectionLevels &level)
   331 {
   344 {
   332     FUNC_LOG;
   345     FUNC_LOG;
   333     // all videos view is the default value to be returned in case nothing can be read
   346     // default value is all videos list level
   334     // from the activity manager
   347     level = VideoCollectionCommon::ELevelVideos;
   335     VideoCollectionCommon::TCollectionLevels level(VideoCollectionCommon::ELevelVideos);
   348     QVariant data = VideoActivityState::instance().getActivityData(KEY_WIDGET_LEVEL);
   336     QVariant data = VideoActivityState::instance().getActivityData(VideoActivityData::KEY_WIDGET_LEVEL);
   349     
   337     if(data.toInt() == VideoCollectionCommon::ELevelCategory)
   350     int value = data.toInt();
       
   351     if(value == VideoCollectionCommon::ELevelCategory)
   338     {
   352     {
   339         level = VideoCollectionCommon::ELevelCategory;
   353         level = VideoCollectionCommon::ELevelCategory;
   340     }
   354     }
   341     return level;
   355     else if(value == VideoCollectionCommon::ELevelDefaultColl)
   342 
   356     {
       
   357         level = VideoCollectionCommon::ELevelDefaultColl;
       
   358     }
       
   359     else if(value == VideoCollectionCommon::ELevelAlbum)
       
   360     {
       
   361         level = VideoCollectionCommon::ELevelAlbum;
       
   362     }
       
   363 }
       
   364  
       
   365 // ---------------------------------------------------------------------------
       
   366 // setCollectionActivityData
       
   367 // ---------------------------------------------------------------------------
       
   368 //
       
   369 void VideoCollectionViewUtils::setCollectionActivityData(const TMPXItemId &id, const QString &name)
       
   370 {
       
   371     FUNC_LOG;
       
   372     QVariant data = int(id.iId1);
       
   373     VideoActivityState::instance().setActivityData(data, KEY_COLLECTION_ID);
       
   374     data.clear();
       
   375     data = name;
       
   376     VideoActivityState::instance().setActivityData(data, KEY_COLLECTION_NAME);
       
   377 }
       
   378 
       
   379 // ---------------------------------------------------------------------------
       
   380 // getCollectionActivityData
       
   381 // ---------------------------------------------------------------------------
       
   382 //
       
   383 void VideoCollectionViewUtils::getCollectionActivityData(TMPXItemId &id, QString &name)
       
   384 {
       
   385     FUNC_LOG;
       
   386     id = TMPXItemId::InvalidId();
       
   387     name = "";
       
   388     VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
       
   389     getActivityWidgetLevel(level); 
       
   390     
       
   391     if(level == VideoCollectionCommon::ELevelDefaultColl)
       
   392     {
       
   393         id.iId2 = KVcxMvcMediaTypeCategory; 
       
   394     }
       
   395     else if(level == VideoCollectionCommon::ELevelAlbum)
       
   396     {
       
   397         id.iId2 = KVcxMvcMediaTypeAlbum;
       
   398     }
       
   399     if(id.iId2 != KMaxTUint32)
       
   400     {
       
   401         QVariant data = VideoActivityState::instance().getActivityData(KEY_COLLECTION_ID);
       
   402         id.iId1 = data.toInt();
       
   403         data = VideoActivityState::instance().getActivityData(KEY_COLLECTION_NAME);
       
   404         name = data.toString();
       
   405     }
   343 }
   406 }
   344 
   407 
   345 // ---------------------------------------------------------------------------
   408 // ---------------------------------------------------------------------------
   346 // showStatusMsgSlot
   409 // showStatusMsgSlot
   347 // ---------------------------------------------------------------------------
   410 // ---------------------------------------------------------------------------