videocollection/videocollectionview/src/videolistselectiondialog.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 37 4eb2df7f7cbe
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    13 *
    13 *
    14 * Description:   videolist selection dialog implementation
    14 * Description:   videolist selection dialog implementation
    15 * 
    15 * 
    16 */
    16 */
    17 
    17 
    18 #include <QGraphicsItem>
    18 // Version : %version: 22 %
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <qgraphicsitem.h>
    19 #include <hblabel.h>
    22 #include <hblabel.h>
    20 #include <hbcheckbox.h>
    23 #include <hbcheckbox.h>
    21 #include <hbaction.h>
    24 #include <hbaction.h>
    22 #include <hbstackedwidget.h>
    25 #include <hbstackedwidget.h>
    23 #include <hbabstractitemview.h>
    26 #include <hbabstractitemview.h>
    29 #include "videosortfilterproxymodel.h"
    32 #include "videosortfilterproxymodel.h"
    30 #include "videolistselectiondialog.h"
    33 #include "videolistselectiondialog.h"
    31 #include "videocollectionwrapper.h"
    34 #include "videocollectionwrapper.h"
    32 #include "videocollectionviewutils.h"
    35 #include "videocollectionviewutils.h"
    33 #include "videocollectionclient.h"
    36 #include "videocollectionclient.h"
       
    37 #include "videocollectiontrace.h"
    34 
    38 
    35 /**
    39 /**
    36  * global qHash function required fo creating hash values for TMPXItemId -keys
    40  * global qHash function required fo creating hash values for TMPXItemId -keys
    37  */
    41  */
    38 inline uint qHash(TMPXItemId key) 
    42 inline uint qHash(TMPXItemId key) 
    44 
    48 
    45 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    46 // VideoListSelectionDialog
    50 // VideoListSelectionDialog
    47 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    48 //
    52 //
    49 VideoListSelectionDialog::VideoListSelectionDialog(VideoCollectionUiLoader *uiLoader,
    53 VideoListSelectionDialog::VideoListSelectionDialog( VideoCollectionUiLoader *uiLoader,
    50                                                    QGraphicsItem *parent) : 
    54                                                     QGraphicsItem *parent)  
    51 HbDialog(parent),
    55     : HbDialog( parent )
    52 mUiLoader(uiLoader),
    56     , mUiLoader( uiLoader )
    53 mTypeOfSelection(-1),
    57     , mTypeOfSelection( -1 )
    54 mHeading(0),
    58     , mHeading( 0 )
    55 mCheckboxContainer(0),
    59     , mCheckboxContainer( 0 )
    56 mItemCount(0),
    60     , mItemCount( 0 )
    57 mCheckBox(0),
    61     , mCheckBox( 0 )
    58 mListContainer(0),
    62     , mListContainer( 0 )
    59 mForcedCheck(false),
    63     , mForcedCheck( false )
    60 mModel(0),
    64     , mModel( 0 )
    61 mListWidget(0)
    65     , mListWidget( 0 )
    62 {
    66     , mPrimaryAction( 0 )
       
    67     , mSecondaryAction( 0 )
       
    68 {
       
    69 	FUNC_LOG;
    63     setDismissPolicy(HbDialog::NoDismiss);
    70     setDismissPolicy(HbDialog::NoDismiss);
    64     setTimeout(HbDialog::NoTimeout);    
    71     setTimeout(HbDialog::NoTimeout);    
    65 
    72 
    66     // create model for list widget
    73     // create model for list widget
    67     mModel =
    74     mModel =
    68         VideoCollectionWrapper::instance().getModel(
    75         VideoCollectionWrapper::instance().getModel(
    69             VideoCollectionWrapper::EGeneric);
    76         		VideoCollectionCommon::EModelTypeGeneric);
    70     if (mModel)
    77     if (mModel)
    71     {
    78     {
    72         // create list widget
    79         // create list widget
    73         mListWidget = new VideoListWidget(mUiLoader);
    80         mListWidget = new VideoListWidget(mUiLoader);
    74         if (mListWidget)
    81         if(mListWidget->initialize(*mModel) < 0)
    75         {
    82         {
    76             if(mListWidget->initialize(*mModel) < 0)
    83             ERROR(-1, "VideoListSelectionDialog::VideoListSelectionDialog() failed to init list widget");
    77             {
    84             delete mListWidget;
    78                 delete mListWidget;
    85             mListWidget = 0;
    79                 mListWidget = 0;
       
    80             }
       
    81         }
    86         }
    82     }
    87     }
    83 }
    88 }
    84 
    89 
    85 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    86 // ~VideoListSelectionDialog
    91 // ~VideoListSelectionDialog
    87 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    88 //
    93 //
    89 VideoListSelectionDialog::~VideoListSelectionDialog() 
    94 VideoListSelectionDialog::~VideoListSelectionDialog() 
    90 {
    95 {
       
    96 	FUNC_LOG;
    91     delete mListWidget;
    97     delete mListWidget;
    92 }
    98 }
    93 
    99 
    94 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
    95 // setupContent
   101 // setupContent
    96 // ---------------------------------------------------------------------------
   102 // ---------------------------------------------------------------------------
    97 //
   103 //
    98 void VideoListSelectionDialog::setupContent(int type, TMPXItemId activeItem)
   104 void VideoListSelectionDialog::setupContent(int type, TMPXItemId activeItem)
    99 {
   105 {
       
   106 	FUNC_LOG;
       
   107 	INFO_1("VideoListSelectionDialog::setupContent() type: %d", type);
   100     if(type < EDeleteVideos || type > ESelectCollection)
   108     if(type < EDeleteVideos || type > ESelectCollection)
   101     {
   109     {
   102         return;
   110         return;
   103     }
   111     }
   104    
   112    
   105     mTypeOfSelection = type; 
   113     mTypeOfSelection = type; 
   106     if(!initDialog())
   114     if(!initDialog())
   107     {
   115     {
       
   116         ERROR(-1, "VideoListSelectionDialog::setupContent() dialog init failed.");
   108         return;
   117         return;
   109     }
   118     }
   110     mSelection.clear();
   119     mSelection.clear();
   111     mSelectedVideos.clear();
   120     mSelectedVideos.clear();
   112     mSelectedAlbumId = TMPXItemId::InvalidId();
   121     mSelectedAlbumId = TMPXItemId::InvalidId();
   138 // initDialog
   147 // initDialog
   139 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------
   140 //
   149 //
   141 bool VideoListSelectionDialog::initDialog()
   150 bool VideoListSelectionDialog::initDialog()
   142 {
   151 {
       
   152 	FUNC_LOG;
   143     if(!mModel)
   153     if(!mModel)
   144     {
   154     {
   145         mModel = VideoCollectionWrapper::instance().getModel(VideoCollectionWrapper::EGeneric);
   155         mModel = VideoCollectionWrapper::instance().getModel(VideoCollectionCommon::EModelTypeGeneric);
   146         if (!mModel)
   156         if (!mModel)
   147         {
   157         {
   148            return false;
   158            return false;
   149         }
   159         }
   150     }  
   160     }  
   156         if(!mListWidget)
   166         if(!mListWidget)
   157         {
   167         {
   158             mListWidget = new VideoListWidget(mUiLoader);
   168             mListWidget = new VideoListWidget(mUiLoader);
   159             if(mListWidget->initialize(*mModel) < 0)
   169             if(mListWidget->initialize(*mModel) < 0)
   160             {
   170             {
       
   171                 ERROR(-1, "VideoListSelectionDialog::initDialog() failed to setup VideoListWidget.");
   161                 delete mListWidget;
   172                 delete mListWidget;
   162                 mListWidget = 0;
   173                 mListWidget = 0;
   163                 mListContainer = 0;
   174                 mListContainer = 0;
   164                 return false;
   175                 return false;
   165             }
   176             }
   176     }
   187     }
   177     if(!mCheckboxContainer)
   188     if(!mCheckboxContainer)
   178     {
   189     {
   179         mCheckboxContainer = mUiLoader->findWidget<HbWidget>(DOCML_NAME_CHECK_CONTAINER);
   190         mCheckboxContainer = mUiLoader->findWidget<HbWidget>(DOCML_NAME_CHECK_CONTAINER);
   180     }
   191     }
   181 
       
   182     if(!mItemCount)
   192     if(!mItemCount)
   183     {
   193     {
   184         mItemCount = mUiLoader->findWidget<HbLabel>(DOCML_NAME_LBL_SELECTION);
   194         mItemCount = mUiLoader->findWidget<HbLabel>(DOCML_NAME_LBL_SELECTION);
   185         mItemCount->setAlignment(Qt::AlignRight);
   195         mItemCount->setAlignment(Qt::AlignRight);
   186     }        
   196     }        
   187     if(!mCheckBox)
   197     if(!mCheckBox)
   188     {
   198     {
   189         mCheckBox = mUiLoader->findWidget<HbCheckBox >(DOCML_NAME_MARKALL);
   199         mCheckBox = mUiLoader->findWidget<HbCheckBox >(DOCML_NAME_MARKALL);
   190     }
   200     }
   191     if(!primaryAction())
   201     // HbDialog connects actions to finished signal by default. 
   192     {
   202     if(!mPrimaryAction)
   193         setPrimaryAction(new HbAction(hbTrId("txt_common_button_ok"), this));
   203     {
   194     }
   204         mPrimaryAction = new HbAction(hbTrId("txt_common_button_ok"));
   195     if(!secondaryAction())
   205         addAction(mPrimaryAction);
   196     {
   206     }
   197         setSecondaryAction(new HbAction(hbTrId("txt_common_button_cancel"), this));
   207     if(!mSecondaryAction)
   198     }
   208     {
   199     if(!mListWidget || !mListContainer || !mHeading || !mCheckBox || !primaryAction() || !secondaryAction())
   209         mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
   200     {
   210         addAction(mSecondaryAction);
       
   211     }
       
   212     if(!mListContainer || !mHeading || !mCheckBox)
       
   213     {
       
   214         ERROR(-1, "VideoListSelectionDialog::initDialog() !mListContainer || !mHeading || !mCheckBox");
   201         return false;
   215         return false;
   202     }
   216     }
   203     return true;  
   217     return true;  
   204 }
   218 }
   205 
   219 
   207 // activateSelection
   221 // activateSelection
   208 // ---------------------------------------------------------------------------
   222 // ---------------------------------------------------------------------------
   209 //
   223 //
   210 void VideoListSelectionDialog::activateSelection()
   224 void VideoListSelectionDialog::activateSelection()
   211 {
   225 {
       
   226 	FUNC_LOG;
   212     // "add to collection" and "remove from collection -selections needs 
   227     // "add to collection" and "remove from collection -selections needs 
   213     // additional functionality for primary key
   228     // additional functionality for primary key
   214     if(mTypeOfSelection == EAddToCollection ||
   229     if(mTypeOfSelection == EAddToCollection ||
   215        mTypeOfSelection == ERemoveFromCollection)
   230        mTypeOfSelection == ERemoveFromCollection)
   216     {
   231     {
   217         primaryAction()->disconnect(SIGNAL(triggered()));
   232         mPrimaryAction->disconnect(SIGNAL(triggered()));
   218         connect(primaryAction(), SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot()));
   233         connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot()));
   219     }
   234     }
   220     QString headingTxt("");
   235     QString headingTxt("");
   221     QString primaryTxt("");
   236     QString primaryTxt("");
   222     // create texts
   237     // create texts
   223     switch(mTypeOfSelection)
   238     switch(mTypeOfSelection)
   224     {
   239     {
   225     case EDeleteVideos:
   240         case EDeleteVideos:
   226         primaryTxt = hbTrId("txt_common_button_delete");
   241             primaryTxt = hbTrId("txt_common_button_delete");
   227     break;
   242         break;
   228     case EAddToCollection:
   243         case EAddToCollection:
   229         primaryTxt = hbTrId("txt_common_button_add");
   244             primaryTxt = hbTrId("txt_common_button_add");
   230     break;
   245         break;
   231     case ERemoveFromCollection:
   246         case ERemoveFromCollection:
   232         primaryTxt = hbTrId("txt_common_button_remove");
   247             primaryTxt = hbTrId("txt_common_button_remove");
   233     break;
   248         break;
   234     case ESelectCollection:
   249         case ESelectCollection:
   235         primaryTxt = hbTrId("txt_videos_button_new");
   250             primaryTxt = hbTrId("txt_videos_button_new");
   236     break;
   251         break;
   237     default:
   252         default:
   238     break;
   253         break;
   239     }
   254     }
   240 
   255 
   241     HbAction *primary = primaryAction();
   256     mPrimaryAction->setText(primaryTxt);
   242     primary->setText(primaryTxt);
       
   243 
   257 
   244     if(mTypeOfSelection == ESelectCollection)
   258     if(mTypeOfSelection == ESelectCollection)
   245     {
   259     {
   246         headingTxt = hbTrId("txt_videos_title_select_collection");
   260         headingTxt = hbTrId("txt_videos_title_select_collection");
   247         mCheckboxContainer->setVisible(false);
   261         mCheckboxContainer->setVisible(false);
   248         mListWidget->setSelectionMode(-1);   
   262         mListWidget->setSelectionMode(-1);   
   249         mListWidget->activate(VideoCollectionCommon::ELevelCategory);
   263         mListWidget->activate(VideoCollectionCommon::ELevelCategory);
   250         // need to set primaryaction disabled here in order for it 
   264         // need to set primaryaction disabled here in order for it 
   251         // get correctly updated at modelReady(), where it will be enabled
   265         // get correctly updated at modelReady(), where it will be enabled
   252         // if state would be same, no update will happen
   266         // if state would be same, no update will happen
   253         primary->setDisabled(true);
   267         mPrimaryAction->setDisabled(true);
   254     }
   268     }
   255     else
   269     else
   256     {
   270     {
   257         headingTxt = hbTrId("txt_videos_title_select_videos");
   271         headingTxt = hbTrId("txt_videos_title_select_videos");
   258         mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
   272         mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
   261         mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount())); 
   275         mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount())); 
   262         mCheckBox->setChecked(false);
   276         mCheckBox->setChecked(false);
   263         // need to set primaryaction enabled here in order for it 
   277         // need to set primaryaction enabled here in order for it 
   264         // get correctly updated at modelReady(), where it will be disabled  
   278         // get correctly updated at modelReady(), where it will be disabled  
   265         // if state would be same, no update will happen
   279         // if state would be same, no update will happen
   266         primary->setDisabled(false);
   280         mPrimaryAction->setDisabled(false);
   267     }
   281     }
   268     mHeading->setPlainText(headingTxt);         
   282     mHeading->setPlainText(headingTxt);         
   269     // sort to make sure dialog has correctly filtered content
   283     // sort to make sure dialog has correctly filtered content
   270     // at the same order as in view
   284     // at the same order as in view
   271     VideoCollectionViewUtils::sortModel(mModel, false);        
   285     VideoCollectionViewUtils::sortModel(mModel, false, mListWidget->getLevel());        
   272 }
   286 }
   273 
   287 
   274 // ---------------------------------------------------------------------------
   288 // ---------------------------------------------------------------------------
   275 // exec
   289 // exec
   276 // ---------------------------------------------------------------------------
   290 // ---------------------------------------------------------------------------
   277 //
   291 //
   278 void VideoListSelectionDialog::exec()
   292 void VideoListSelectionDialog::exec()
   279 {
   293 {
       
   294 	FUNC_LOG;
   280     // clear checkbox
   295     // clear checkbox
   281     mCheckBox->setChecked(false);
   296     mCheckBox->setChecked(false);
   282     
   297     
   283     mListWidget->clearSelection(); 
   298     mListWidget->clearSelection(); 
   284     
   299     
   292         // show dialog
   307         // show dialog
   293         HbDialog::open();
   308         HbDialog::open();
   294     }
   309     }
   295     else
   310     else
   296     {
   311     {
       
   312         INFO("VideoListSelectionDialog::exec(): nothing to show, finishing.")
   297         // no items, finish right away
   313         // no items, finish right away
   298         finishedSlot(primaryAction());
   314         finishedSlot(mPrimaryAction);
   299     }
   315     }
   300 }
   316 }
   301 
   317 
   302 // ---------------------------------------------------------------------------
   318 // ---------------------------------------------------------------------------
   303 // finishedSlot
   319 // finishedSlot
   304 // ---------------------------------------------------------------------------
   320 // ---------------------------------------------------------------------------
   305 //
   321 //
   306 void VideoListSelectionDialog::finishedSlot(HbAction *action)
   322 void VideoListSelectionDialog::finishedSlot(HbAction *action)
   307 {
   323 {
       
   324 	FUNC_LOG;
   308     disconnectSignals();
   325     disconnectSignals();
   309     if(action == secondaryAction())
   326     if(action == mSecondaryAction)
   310     {
   327     {
       
   328         INFO("VideoListSelectionDialog::exec(): secondary action triggered.")
   311         return;
   329         return;
   312     }
   330     }
   313     QString albumName("");
   331     QString albumName("");
   314     if( mTypeOfSelection == ESelectCollection )
   332     if( mTypeOfSelection == ESelectCollection )
   315     {
   333     {
   316         if( mSelectedAlbumId == TMPXItemId::InvalidId())
   334         if( mSelectedAlbumId == TMPXItemId::InvalidId())
   317         {
   335         {
   318             albumName = queryNewAlbumSelected();
   336             albumName = queryNewAlbumSelected();
   319             if(mSelectedAlbumId == TMPXItemId::InvalidId())
   337             if(mSelectedAlbumId == TMPXItemId::InvalidId())
   320             {
   338             {
   321                 // user cancelled new album creation
   339                 // user canceled new album creation
   322                 return;
   340                 return;
   323             }           
   341             }           
   324        }
   342        }
   325        mTypeOfSelection = EAddToCollection;
   343        mTypeOfSelection = EAddToCollection;
   326 
   344     }
   327     }
   345     
   328 
   346     // Must be checked again if type was ESelectCollection
   329     if(mTypeOfSelection == EAddToCollection)
   347     if(mTypeOfSelection == EAddToCollection)
   330     {  
   348     {  
   331         if(mSelectedAlbumId != TMPXItemId::InvalidId() && mSelectedVideos.count())
   349         if(mSelectedAlbumId != TMPXItemId::InvalidId() && mSelectedVideos.count())
   332         {
   350         {
   333             if(mModel->addItemsInAlbum(mSelectedAlbumId, mSelectedVideos.toList()) == 0)
   351             if(mModel->addItemsInAlbum(mSelectedAlbumId, mSelectedVideos.toList()) == 0)
   372 // markAllStateChanged
   390 // markAllStateChanged
   373 // ---------------------------------------------------------------------------
   391 // ---------------------------------------------------------------------------
   374 //
   392 //
   375 void VideoListSelectionDialog::markAllStateChangedSlot(int state)
   393 void VideoListSelectionDialog::markAllStateChangedSlot(int state)
   376 { 
   394 { 
       
   395 	FUNC_LOG;
   377     if(mForcedCheck)
   396     if(mForcedCheck)
   378     {
   397     {
   379         return;
   398         return;
   380     }
   399     }
   381     if( state == Qt::Checked)
   400     if(state == Qt::Checked)
   382     {
   401     {
   383         mListWidget->selectAll();
   402         mListWidget->selectAll();
   384     }
   403     }
   385     else
   404     else
   386     {
   405     {
   392 // selectionChangedSlot
   411 // selectionChangedSlot
   393 // ---------------------------------------------------------------------------
   412 // ---------------------------------------------------------------------------
   394 //
   413 //
   395 void VideoListSelectionDialog::selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
   414 void VideoListSelectionDialog::selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
   396 {  
   415 {  
   397     if(!primaryAction() || mTypeOfSelection == ESelectCollection)
   416 	FUNC_LOG;
   398     {
   417     if(!mPrimaryAction || mTypeOfSelection == ESelectCollection)
       
   418     {
       
   419         INFO("VideoListSelectionDialog::selectionChangedSlot(): no primary action or we are selecting collection.")
   399         return;
   420         return;
   400     }
   421     }
   401    
   422    
   402     if(selected.indexes().count() > 0)
   423     if(selected.indexes().count() > 0)
   403     {
   424     {
   409         mSelection.merge(deselected, QItemSelectionModel::Deselect);
   430         mSelection.merge(deselected, QItemSelectionModel::Deselect);
   410     }
   431     }
   411     
   432     
   412     if(mSelection.indexes().count() > 0)
   433     if(mSelection.indexes().count() > 0)
   413     {
   434     {
   414         primaryAction()->setDisabled(false);
   435         mPrimaryAction->setDisabled(false);
   415     }
   436     }
   416     else
   437     else
   417     {
   438     {
   418         primaryAction()->setDisabled(true);
   439         mPrimaryAction->setDisabled(true);
   419     }    
   440     }    
   420 
   441 
   421     updateCounterSlot();
   442     updateCounterSlot();
   422 }
   443 }
   423 
   444 
   425 // singleItemSelectedSlot
   446 // singleItemSelectedSlot
   426 // ---------------------------------------------------------------------------
   447 // ---------------------------------------------------------------------------
   427 //
   448 //
   428 void VideoListSelectionDialog::singleItemSelectedSlot(const QModelIndex &index)
   449 void VideoListSelectionDialog::singleItemSelectedSlot(const QModelIndex &index)
   429 {
   450 {
       
   451 	FUNC_LOG;
   430     if(mTypeOfSelection == ESelectCollection)
   452     if(mTypeOfSelection == ESelectCollection)
   431     {
   453     {
   432        if(index.isValid())
   454        if(index.isValid())
   433        {           
   455        {
   434            mSelectedAlbumId = mModel->getMediaIdAtIndex(index);            
   456            mSelectedAlbumId = mModel->getMediaIdAtIndex(index);            
   435            primaryAction()->trigger();
   457            mPrimaryAction->trigger();
   436        }
   458        }
   437     }
   459     }
   438 }
   460 }
   439 
   461 
   440 // ---------------------------------------------------------------------------
   462 // ---------------------------------------------------------------------------
   441 // modelReadySlot
   463 // modelReadySlot
   442 // ---------------------------------------------------------------------------
   464 // ---------------------------------------------------------------------------
   443 //
   465 //
   444 void VideoListSelectionDialog::modelReadySlot()
   466 void VideoListSelectionDialog::modelReadySlot()
   445 {
   467 {
   446    
   468 	FUNC_LOG;
   447     if(mTypeOfSelection == ESelectCollection)
   469     if(mTypeOfSelection == ESelectCollection)
   448     {
   470     {
   449         primaryAction()->setDisabled(false);
   471         mPrimaryAction->setDisabled(false);
   450         if(!mModel->rowCount())
   472         if(!mModel->rowCount())
   451         {
   473         {
   452             // in case there are no user defined albums, 
   474             // in case there are no user defined albums, 
   453             // start input dialog right away by accepting dialog
   475             // start input dialog right away by accepting dialog
   454             primaryAction()->trigger();
   476             INFO("VideoListSelectionDialog::selectionChangedSlot(): no albums, starting album creation.")
       
   477             mPrimaryAction->trigger();
   455             return;
   478             return;
   456         }
   479         }
   457     }
   480     }
   458     if(mTypeOfSelection != ESelectCollection)
   481     if(mTypeOfSelection != ESelectCollection)
   459     {
   482     {
   460         primaryAction()->setDisabled(true);
   483         mPrimaryAction->setDisabled(true);
   461     }
   484     }
   462     updateCounterSlot();
   485     updateCounterSlot();
   463 }
   486 }
   464 
   487 
   465 // ---------------------------------------------------------------------------
   488 // ---------------------------------------------------------------------------
   466 // updateCounterSlot
   489 // updateCounterSlot
   467 // ---------------------------------------------------------------------------
   490 // ---------------------------------------------------------------------------
   468 //
   491 //
   469 void VideoListSelectionDialog::updateCounterSlot()
   492 void VideoListSelectionDialog::updateCounterSlot()
   470 {
   493 {
       
   494 	FUNC_LOG;
   471     if(!mItemCount)
   495     if(!mItemCount)
   472     {
   496     {
   473         return;
   497         return;
   474     }
   498     }
   475 
   499 
   484     else
   508     else
   485     {
   509     {
   486         mCheckBox->setChecked(false);
   510         mCheckBox->setChecked(false);
   487     }
   511     }
   488     mForcedCheck = false;
   512     mForcedCheck = false;
   489        
       
   490 }
   513 }
   491 
   514 
   492 // ---------------------------------------------------------------------------
   515 // ---------------------------------------------------------------------------
   493 // primaryActionTriggeredSlot
   516 // primaryActionTriggeredSlot
   494 // ---------------------------------------------------------------------------
   517 // ---------------------------------------------------------------------------
   495 //
   518 //
   496 void VideoListSelectionDialog::primaryActionTriggeredSlot()
   519 void VideoListSelectionDialog::primaryActionTriggeredSlot()
   497 {
   520 {
       
   521 	FUNC_LOG;
   498     // reconnect primary action
   522     // reconnect primary action
   499     primaryAction()->disconnect(SIGNAL(triggered()));
   523     mPrimaryAction->disconnect(SIGNAL(triggered()));
   500     connect(primaryAction(), SIGNAL(triggered()), this, SLOT(close()));
   524     connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(close()));
   501         
   525 
   502     // update video items selection here before content changes.
   526     // update video items selection here before content changes.
   503     int count = mSelection.indexes().count();
   527     int count = mSelection.indexes().count();
   504     TMPXItemId id = TMPXItemId::InvalidId();
   528     TMPXItemId id = TMPXItemId::InvalidId();
   505     for(int i = 0; i < count; ++i)
   529     for(int i = 0; i < count; ++i)
   506     {
   530     {
   511         }
   535         }
   512     }
   536     }
   513     
   537     
   514     if(mSelectedAlbumId != TMPXItemId::InvalidId())
   538     if(mSelectedAlbumId != TMPXItemId::InvalidId())
   515     {
   539     {
   516         primaryAction()->trigger();
   540         INFO("VideoListSelectionDialog::primaryActionTriggeredSlot(): closing dialog.")
       
   541         mPrimaryAction->trigger();
   517         return;
   542         return;
   518     }
   543     }
   519     else if(mTypeOfSelection == EAddToCollection)
   544     else if(mTypeOfSelection == EAddToCollection)
   520     {
   545     {
       
   546         INFO("VideoListSelectionDialog::primaryActionTriggeredSlot(): activating collection selection.")
   521         // videos for collection selected, but collection 
   547         // videos for collection selected, but collection 
   522         // not yet selected, activate selection for it
   548         // not yet selected, activate selection for it
   523         mTypeOfSelection = ESelectCollection;
   549         mTypeOfSelection = ESelectCollection;
   524         activateSelection();
   550         activateSelection();
   525    }   
   551    }   
   529 // connectSignals
   555 // connectSignals
   530 // ---------------------------------------------------------------------------
   556 // ---------------------------------------------------------------------------
   531 //
   557 //
   532 void VideoListSelectionDialog::connectSignals()
   558 void VideoListSelectionDialog::connectSignals()
   533 {   
   559 {   
       
   560 	FUNC_LOG;
   534     // dialog finished
   561     // dialog finished
   535     connect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
   562     connect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
   536     
   563     
   537     // selection changes
   564     // selection changes
   538     connect(mListWidget, SIGNAL(activated(const QModelIndex&)),
   565     connect(mListWidget, SIGNAL(activated(const QModelIndex&)),
   539             this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
   566             this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
   540     
   567     
   541     connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
   568     connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
   542             this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
   569             this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
   543         
   570 
   544     // model changes signals
   571     // model changes signals
   545     connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));    
   572     connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));    
   546     connect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));    
   573     connect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));    
   547     
   574     
   548     // mark all state changes
   575     // mark all state changes
   553 // disconnectSignals
   580 // disconnectSignals
   554 // ---------------------------------------------------------------------------
   581 // ---------------------------------------------------------------------------
   555 //
   582 //
   556 void VideoListSelectionDialog::disconnectSignals()
   583 void VideoListSelectionDialog::disconnectSignals()
   557 {   
   584 {   
       
   585 	FUNC_LOG;
   558     disconnect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
   586     disconnect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
   559     
   587     
   560     disconnect(mListWidget, SIGNAL(activated(const QModelIndex&)),
   588     disconnect(mListWidget, SIGNAL(activated(const QModelIndex&)),
   561                 this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
   589                 this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
   562     
   590     
   563     disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
   591     disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
   564                             this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
   592                             this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
   565             
   593 
   566     // model changes signals
   594     // model changes signals
   567     disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));    
   595     disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));    
   568     disconnect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));   
   596     disconnect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));   
   569     
   597     
   570     // mark all state changes
   598     // mark all state changes
   571     disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));   
   599     disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));
   572 }
   600 }
   573 
   601 
   574 // ---------------------------------------------------------------------------
   602 // ---------------------------------------------------------------------------
   575 // getSelectedName
   603 // getSelectedName
   576 // ---------------------------------------------------------------------------
   604 // ---------------------------------------------------------------------------
   577 //
   605 //
   578 QString VideoListSelectionDialog::getSelectedName()
   606 QString VideoListSelectionDialog::getSelectedName()
   579 {
   607 {
       
   608 	FUNC_LOG;
   580     QString name;
   609     QString name;
   581     if(mSelectedAlbumId.iId2 > KVcxMvcMediaTypeVideo)
   610     if(mSelectedAlbumId.iId2 > KVcxMvcMediaTypeVideo)
   582     {
   611     {
   583         VideoSortFilterProxyModel *model = 
   612         VideoSortFilterProxyModel *model = 
   584                 VideoCollectionWrapper::instance().getModel(
   613                 VideoCollectionWrapper::instance().getModel(
   585                             VideoCollectionWrapper::ECollections);
   614                 		VideoCollectionCommon::EModelTypeCollections);
   586         if(!model)
   615         if(!model)
   587         {
   616         {
   588             return name;
   617             return name;
   589         }
   618         }
   590         QModelIndex index = model->indexOfId(mSelectedAlbumId);
   619         QModelIndex index = model->indexOfId(mSelectedAlbumId);
   591         if(index.isValid())
   620         if(index.isValid())
   592         {
   621         {
   593             name = model->data(index, Qt::DisplayRole).toStringList().first();
   622             name = model->data(index, VideoCollectionCommon::KeyTitle).toString();
   594         }
   623         }
   595     }
   624     }
   596     
   625     
   597     return name;
   626     return name;
   598 }
   627 }
   601 // queryNewAlbumSelected
   630 // queryNewAlbumSelected
   602 // ---------------------------------------------------------------------------
   631 // ---------------------------------------------------------------------------
   603 //
   632 //
   604 QString VideoListSelectionDialog::queryNewAlbumSelected()
   633 QString VideoListSelectionDialog::queryNewAlbumSelected()
   605 {
   634 {
       
   635 	FUNC_LOG;
   606     mSelectedAlbumId = TMPXItemId::InvalidId();
   636     mSelectedAlbumId = TMPXItemId::InvalidId();
   607     bool ok = false;
   637     bool ok = false;
   608     QString label(hbTrId("txt_videos_title_enter_name"));
   638     QString label(hbTrId("txt_videos_title_enter_name"));
   609     QString text("");
   639     QString text("");
   610     text = HbInputDialog::getText(label, hbTrId("txt_videos_dialog_entry_new_collection"), &ok);
   640     text = HbInputDialog::getText(label, hbTrId("txt_videos_dialog_entry_new_collection"), &ok);