ui/commandhandlers/commoncommandhandlers/src/glxcommandhandleraddtocontainer.cpp
author hgs
Fri, 06 Aug 2010 20:44:25 +0530
changeset 54 0f0f3f26f787
parent 50 a0f57508af73
child 62 36d93b4dc635
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <mpxcollectionpath.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <mglxmedialist.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <glxcommandfactory.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <glxcommandhandleraddtocontainer.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <glxcommandhandlernewmedia.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <QStringListModel>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <hblabel.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <hbaction.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <glxalbummodel.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <glxcollectionpluginalbums.hrh>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <glxmodelparm.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include <glxfilterfactory.h>
40
hgs
parents: 26
diff changeset
    32
#include <QEventLoop>
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include <hblistwidget.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include <hbview.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include <hbpushbutton.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include <QGraphicsGridLayout>
50
hgs
parents: 45
diff changeset
    38
#include <hbselectiondialog.h>
hgs
parents: 45
diff changeset
    39
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    40
#include <hbmessagebox.h>
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    41
40
hgs
parents: 26
diff changeset
    42
#include <glxcommandhandlers.hrh>
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    43
#include "glxlocalisationstrings.h"
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    44
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    45
#include "OstTraceDefinitions.h"
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    46
#ifdef OST_TRACE_COMPILER_IN_USE
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    47
#include "glxcommandhandleraddtocontainerTraces.h"
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    48
#endif
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    49
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
const TInt KSelectionPopupListHierarchy = 5;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
40
hgs
parents: 26
diff changeset
    53
GlxAlbumSelectionPopup::GlxAlbumSelectionPopup() 
50
hgs
parents: 45
diff changeset
    54
    : mSelectionModel( 0 ),
40
hgs
parents: 26
diff changeset
    55
      mEventLoop( 0 ),
hgs
parents: 26
diff changeset
    56
      mResult( false )
hgs
parents: 26
diff changeset
    57
{
hgs
parents: 26
diff changeset
    58
}
hgs
parents: 26
diff changeset
    59
hgs
parents: 26
diff changeset
    60
GlxAlbumSelectionPopup::~GlxAlbumSelectionPopup()
hgs
parents: 26
diff changeset
    61
{
hgs
parents: 26
diff changeset
    62
}
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    63
40
hgs
parents: 26
diff changeset
    64
QModelIndexList GlxAlbumSelectionPopup::GetSelectionList(GlxAlbumModel *model, bool *ok) 
hgs
parents: 26
diff changeset
    65
{
50
hgs
parents: 45
diff changeset
    66
    HbSelectionDialog *dlg = new HbSelectionDialog;
hgs
parents: 45
diff changeset
    67
	dlg->setHeadingWidget(new HbLabel(GLX_ALBUM_SELECTION_TITLE));
hgs
parents: 45
diff changeset
    68
    dlg->setSelectionMode(HbAbstractItemView::SingleSelection);
hgs
parents: 45
diff changeset
    69
    dlg->setModel(model);
hgs
parents: 45
diff changeset
    70
    dlg->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 45
diff changeset
    71
    dlg->clearActions();
hgs
parents: 45
diff changeset
    72
    HbAction *action;
hgs
parents: 45
diff changeset
    73
    action= new HbAction(GLX_BUTTON_NEW);
hgs
parents: 45
diff changeset
    74
    action->setObjectName( "ch_new_album_button" );
hgs
parents: 45
diff changeset
    75
    dlg->addAction(action);
hgs
parents: 45
diff changeset
    76
    action= new HbAction(GLX_BUTTON_CANCEL);
hgs
parents: 45
diff changeset
    77
    action->setObjectName( "ch_cancel_album_button" );
hgs
parents: 45
diff changeset
    78
    dlg->addAction(action);
hgs
parents: 45
diff changeset
    79
    dlg->open(this, SLOT(dialogClosed(HbAction*)));
hgs
parents: 45
diff changeset
    80
    
40
hgs
parents: 26
diff changeset
    81
    QEventLoop eventLoop;
hgs
parents: 26
diff changeset
    82
    mEventLoop = &eventLoop;
50
hgs
parents: 45
diff changeset
    83
  
40
hgs
parents: 26
diff changeset
    84
    eventLoop.exec( );
hgs
parents: 26
diff changeset
    85
    mEventLoop = 0 ;
hgs
parents: 26
diff changeset
    86
    if ( ok ) {
hgs
parents: 26
diff changeset
    87
        *ok = mResult ;
hgs
parents: 26
diff changeset
    88
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    89
50
hgs
parents: 45
diff changeset
    90
    QModelIndexList selectedIndexes = dlg->selectedModelIndexes();
40
hgs
parents: 26
diff changeset
    91
    return selectedIndexes;
hgs
parents: 26
diff changeset
    92
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
40
hgs
parents: 26
diff changeset
    94
hgs
parents: 26
diff changeset
    95
void GlxAlbumSelectionPopup::dialogClosed(HbAction *action)
hgs
parents: 26
diff changeset
    96
{
50
hgs
parents: 45
diff changeset
    97
    HbSelectionDialog *dlg = (HbSelectionDialog*)(sender());
hgs
parents: 45
diff changeset
    98
hgs
parents: 45
diff changeset
    99
    if( action == dlg->actions().at(1) ) {
hgs
parents: 45
diff changeset
   100
        mResult = false ;
40
hgs
parents: 26
diff changeset
   101
    }
hgs
parents: 26
diff changeset
   102
    else {
50
hgs
parents: 45
diff changeset
   103
        mResult = true ;
40
hgs
parents: 26
diff changeset
   104
    }
hgs
parents: 26
diff changeset
   105
    if ( mEventLoop && mEventLoop->isRunning( ) ) {
hgs
parents: 26
diff changeset
   106
        mEventLoop->exit( 0 );
hgs
parents: 26
diff changeset
   107
    }
hgs
parents: 26
diff changeset
   108
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   110
GlxCommandHandlerAddToContainer::GlxCommandHandlerAddToContainer() :
50
hgs
parents: 45
diff changeset
   111
    mNewMediaAdded(false),mAlbumName(QString())
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   112
    {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   113
    OstTraceFunctionEntry0( GLXCOMMANDHANDLERADDTOCONTAINER_GLXCOMMANDHANDLERADDTOCONTAINER_ENTRY );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    mTargetContainers = NULL;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   115
    OstTraceFunctionExit0( GLXCOMMANDHANDLERADDTOCONTAINER_GLXCOMMANDHANDLERADDTOCONTAINER_EXIT );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   116
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
GlxCommandHandlerAddToContainer::~GlxCommandHandlerAddToContainer()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   119
    {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   120
    OstTraceFunctionEntry0( DUP1_GLXCOMMANDHANDLERADDTOCONTAINER_GLXCOMMANDHANDLERADDTOCONTAINER_ENTRY );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    delete mTargetContainers;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   122
    OstTraceFunctionExit0( DUP1_GLXCOMMANDHANDLERADDTOCONTAINER_GLXCOMMANDHANDLERADDTOCONTAINER_EXIT );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   123
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
40
hgs
parents: 26
diff changeset
   125
CMPXCommand* GlxCommandHandlerAddToContainer::CreateCommandL(TInt aCommandId,
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   126
        MGlxMediaList& aMediaList, TBool& /*aConsume*/) const
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   127
    {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   128
    OstTraceFunctionEntry0( GLXCOMMANDHANDLERADDTOCONTAINER_CREATECOMMANDL_ENTRY );
40
hgs
parents: 26
diff changeset
   129
    CMPXCommand* command = NULL;
50
hgs
parents: 45
diff changeset
   130
    mAlbumName.clear();
40
hgs
parents: 26
diff changeset
   131
    if(aCommandId == EGlxCmdAddToFav)
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   132
        {
54
hgs
parents: 50
diff changeset
   133
		   mAlbumName = GLX_ALBUM_FAV;
40
hgs
parents: 26
diff changeset
   134
           CMPXCollectionPath* targetCollection = CMPXCollectionPath::NewL();
hgs
parents: 26
diff changeset
   135
           CleanupStack::PushL(targetCollection);
hgs
parents: 26
diff changeset
   136
           // The target collection has to be appeneded with the albums plugin id
hgs
parents: 26
diff changeset
   137
           targetCollection->AppendL(KGlxCollectionPluginAlbumsImplementationUid);
hgs
parents: 26
diff changeset
   138
           // The target collection has also to be appeneded with the the relation id.
hgs
parents: 26
diff changeset
   139
           // appending another level into the albums to get favourites and 1 is the relation id of albums
hgs
parents: 26
diff changeset
   140
           targetCollection->AppendL( TMPXItemId(KGlxCollectionFavoritesId) );
hgs
parents: 26
diff changeset
   141
           targetCollection->Set( 0 );
hgs
parents: 26
diff changeset
   142
    
hgs
parents: 26
diff changeset
   143
           CMPXCollectionPath* sourceItems = aMediaList.PathLC( NGlxListDefs::EPathFocusOrSelection );
hgs
parents: 26
diff changeset
   144
      
hgs
parents: 26
diff changeset
   145
           command = TGlxCommandFactory::AddToContainerCommandLC(
hgs
parents: 26
diff changeset
   146
               *sourceItems, *targetCollection);
hgs
parents: 26
diff changeset
   147
           CleanupStack::Pop(command); 
hgs
parents: 26
diff changeset
   148
           
hgs
parents: 26
diff changeset
   149
           CleanupStack::PopAndDestroy(sourceItems);
hgs
parents: 26
diff changeset
   150
           CleanupStack::PopAndDestroy(targetCollection);
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
        }
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   152
    else
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   153
        {
40
hgs
parents: 26
diff changeset
   154
hgs
parents: 26
diff changeset
   155
            CMPXCollectionPath* sourceItems = aMediaList.PathLC(
hgs
parents: 26
diff changeset
   156
            NGlxListDefs::EPathFocusOrSelection);
hgs
parents: 26
diff changeset
   157
            bool ok = false;
hgs
parents: 26
diff changeset
   158
        
hgs
parents: 26
diff changeset
   159
            //create target medialist
hgs
parents: 26
diff changeset
   160
            CMPXCollectionPath* path = CMPXCollectionPath::NewL();
hgs
parents: 26
diff changeset
   161
            CleanupStack::PushL(path);
hgs
parents: 26
diff changeset
   162
            path->AppendL(KGlxCollectionPluginAlbumsImplementationUid);
hgs
parents: 26
diff changeset
   163
        
hgs
parents: 26
diff changeset
   164
            CMPXFilter* filter =
hgs
parents: 26
diff changeset
   165
            TGlxFilterFactory::CreateCameraAlbumExclusionFilterL();
hgs
parents: 26
diff changeset
   166
            CleanupStack::PushL(filter);
hgs
parents: 26
diff changeset
   167
    
hgs
parents: 26
diff changeset
   168
            // Create the media list
hgs
parents: 26
diff changeset
   169
            MGlxMediaList* targetMediaList = MGlxMediaList::InstanceL(*path,
hgs
parents: 26
diff changeset
   170
                    TGlxHierarchyId(KSelectionPopupListHierarchy), filter); //todo take actual hierarchy 
hgs
parents: 26
diff changeset
   171
            CleanupStack::PopAndDestroy(filter);
hgs
parents: 26
diff changeset
   172
            CleanupStack::PopAndDestroy(path);
hgs
parents: 26
diff changeset
   173
    
hgs
parents: 26
diff changeset
   174
            //create target model
hgs
parents: 26
diff changeset
   175
            GlxModelParm modelParm(KGlxCollectionPluginAlbumsImplementationUid,
hgs
parents: 26
diff changeset
   176
                    KSelectionPopupListHierarchy, EGlxFilterExcludeCamera);
hgs
parents: 26
diff changeset
   177
            GlxAlbumModel *albumMediaModel = new GlxAlbumModel(modelParm);
hgs
parents: 26
diff changeset
   178
            albumMediaModel->setData(QModelIndex(), (int) GlxContextSelectionList,
hgs
parents: 26
diff changeset
   179
                    GlxContextRole);
hgs
parents: 26
diff changeset
   180
    
hgs
parents: 26
diff changeset
   181
            GlxAlbumSelectionPopup popupWidget;
hgs
parents: 26
diff changeset
   182
            QModelIndexList modelList = popupWidget.GetSelectionList(albumMediaModel, &ok);
hgs
parents: 26
diff changeset
   183
            if(ok && modelList.count() == 0)
hgs
parents: 26
diff changeset
   184
            {
hgs
parents: 26
diff changeset
   185
                createNewMedia();
hgs
parents: 26
diff changeset
   186
                ok = false;        
hgs
parents: 26
diff changeset
   187
            }    
hgs
parents: 26
diff changeset
   188
            OstTraceExt2( TRACE_NORMAL, GLXCOMMANDHANDLERADDTOCONTAINER_CREATECOMMANDL, "GlxCommandHandlerAddToContainer::CreateCommandL;ok=%d;newMedia=%d", ok, mNewMediaAdded );
hgs
parents: 26
diff changeset
   189
    
hgs
parents: 26
diff changeset
   190
            if (ok || mNewMediaAdded)
hgs
parents: 26
diff changeset
   191
                {
hgs
parents: 26
diff changeset
   192
                int count = modelList.count();
hgs
parents: 26
diff changeset
   193
    
hgs
parents: 26
diff changeset
   194
                for (int i = 0; i < count; i++)
hgs
parents: 26
diff changeset
   195
                    {
hgs
parents: 26
diff changeset
   196
                    albumMediaModel->setData(modelList[i], modelList[i].row(),
hgs
parents: 26
diff changeset
   197
                            GlxSelectedIndexRole);
hgs
parents: 26
diff changeset
   198
                    }
hgs
parents: 26
diff changeset
   199
    
hgs
parents: 26
diff changeset
   200
                if (!mNewMediaAdded)
hgs
parents: 26
diff changeset
   201
                    {
hgs
parents: 26
diff changeset
   202
                    CMPXCollectionPath* targetContainers = targetMediaList->PathLC(
hgs
parents: 26
diff changeset
   203
                            NGlxListDefs::EPathFocusOrSelection);
hgs
parents: 26
diff changeset
   204
                    CleanupStack::Pop(targetContainers);
hgs
parents: 26
diff changeset
   205
                    delete mTargetContainers;
hgs
parents: 26
diff changeset
   206
                    mTargetContainers = NULL;
hgs
parents: 26
diff changeset
   207
                    mTargetContainers = targetContainers;
50
hgs
parents: 45
diff changeset
   208
hgs
parents: 45
diff changeset
   209
					const TGlxMedia& item = targetMediaList->Item(targetMediaList->SelectedItemIndex(0));
hgs
parents: 45
diff changeset
   210
					const TDesC& title = item.Title();
hgs
parents: 45
diff changeset
   211
					mAlbumName = QString::fromUtf16(title.Ptr(),title.Length());
40
hgs
parents: 26
diff changeset
   212
                    }
hgs
parents: 26
diff changeset
   213
    
hgs
parents: 26
diff changeset
   214
                command = TGlxCommandFactory::AddToContainerCommandLC(*sourceItems,
hgs
parents: 26
diff changeset
   215
                        *mTargetContainers);
hgs
parents: 26
diff changeset
   216
                CleanupStack::Pop(command);
hgs
parents: 26
diff changeset
   217
                mNewMediaAdded = false;
hgs
parents: 26
diff changeset
   218
                }
hgs
parents: 26
diff changeset
   219
            else
hgs
parents: 26
diff changeset
   220
                {
hgs
parents: 26
diff changeset
   221
                MGlxMediaList::UnmarkAllL(aMediaList);
hgs
parents: 26
diff changeset
   222
                }
hgs
parents: 26
diff changeset
   223
    
hgs
parents: 26
diff changeset
   224
            MGlxMediaList::UnmarkAllL(*targetMediaList);
hgs
parents: 26
diff changeset
   225
            targetMediaList->Close();
hgs
parents: 26
diff changeset
   226
            CleanupStack::PopAndDestroy(sourceItems);
hgs
parents: 26
diff changeset
   227
            delete albumMediaModel;
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   228
        }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   229
    OstTraceFunctionExit0( GLXCOMMANDHANDLERADDTOCONTAINER_CREATECOMMANDL_EXIT );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    return command;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   231
    }
40
hgs
parents: 26
diff changeset
   232
  
hgs
parents: 26
diff changeset
   233
void GlxCommandHandlerAddToContainer::createNewMedia() const
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   234
    {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   235
    OstTraceFunctionEntry0( GLXCOMMANDHANDLERADDTOCONTAINER_CREATENEWMEDIA_ENTRY );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   236
    GlxCommandHandlerNewMedia* commandHandlerNewMedia =
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   237
            new GlxCommandHandlerNewMedia();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
    TGlxMediaId newMediaId;
50
hgs
parents: 45
diff changeset
   239
    QString newTitle;
hgs
parents: 45
diff changeset
   240
    TInt error = commandHandlerNewMedia->ExecuteLD(newMediaId,newTitle);
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   241
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   242
    while (error == KErrAlreadyExists)
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   243
        {
54
hgs
parents: 50
diff changeset
   244
        HbMessageBox::warning(GLX_NAME_ALREADY_EXIST);
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   245
        error = KErrNone;
50
hgs
parents: 45
diff changeset
   246
        error = commandHandlerNewMedia->ExecuteLD(newMediaId,newTitle);
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   247
        }
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   248
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   249
    if (error == KErrNone)
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   250
        {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
        CMPXCollectionPath* path = CMPXCollectionPath::NewL();
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   252
        CleanupStack::PushL(path);
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
        path->AppendL(KGlxCollectionPluginAlbumsImplementationUid);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        path->AppendL(newMediaId.Value());
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
        CleanupStack::Pop(path);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
        delete mTargetContainers;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
        mTargetContainers = NULL;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
        mTargetContainers = path;
50
hgs
parents: 45
diff changeset
   259
        mAlbumName = newTitle;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
        mNewMediaAdded = true;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   261
        }
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   262
    OstTraceFunctionExit0( GLXCOMMANDHANDLERADDTOCONTAINER_CREATENEWMEDIA_EXIT );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   264
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   265
QString GlxCommandHandlerAddToContainer::CompletionTextL() const
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   266
    {
50
hgs
parents: 45
diff changeset
   267
    if(!mAlbumName.isNull()){
54
hgs
parents: 50
diff changeset
   268
        return (hbTrId(GLX_IMAGES_ADDED).arg(mAlbumName)); 
50
hgs
parents: 45
diff changeset
   269
        }
hgs
parents: 45
diff changeset
   270
	return 	QString();
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   271
    }
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   272
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   273
QString GlxCommandHandlerAddToContainer::ProgressTextL() const
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   274
    {
54
hgs
parents: 50
diff changeset
   275
    return GLX_ADDING_IMAGES;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   276
    }