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