photosgallery/controllers/collectionmanager/src/glxcollectionselectionpopup.cpp
changeset 0 4e91876724a2
child 25 191387a8b767
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Interface for displaying/using the popup to select collections
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "glxcollectionselectionpopup.h"
       
    21 
       
    22 #include <glxcollectionpluginalbums.hrh>
       
    23 #include <glxcollectionplugintags.hrh>
       
    24 #include <mpxcollectionpath.h>
       
    25 #include <glxfilterfactory.h>
       
    26 #include <mglxmedialist.h>
       
    27 #include <glxmediaselectionpopup.h>
       
    28 
       
    29  
       
    30 // -----------------------------------------------------------------------------
       
    31 // ShowPopupL
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 EXPORT_C TInt TGlxCollectionSelectionPopup::ShowPopupL(
       
    35         RArray<TUint32>& aSelectedIds, TUint32 aCollectionType, 
       
    36         TBool aAllowMultipleSelection, TBool aEnableContainerCreation)
       
    37 	{
       
    38 	TUint32 collectionId = 0;
       
    39 	CMPXFilter* filter = NULL;
       
    40 
       
    41     if (aCollectionType == KGlxCollectionTypeIdAlbum)
       
    42         {
       
    43         aAllowMultipleSelection = EFalse;
       
    44         collectionId = KGlxCollectionPluginAlbumsImplementationUid;   
       
    45         filter = TGlxFilterFactory::CreateCameraAlbumExclusionFilterL();
       
    46 	    CleanupStack::PushL(filter);
       
    47         }
       
    48     else if (aCollectionType ==  KGlxCollectionTypeIdTag)
       
    49         {
       
    50         collectionId = KGlxTagCollectionPluginImplementationUid;
       
    51         filter = TGlxFilterFactory::CreateIncludeEmptyContainersFilterL();
       
    52         CleanupStack::PushL(filter);
       
    53         }
       
    54     
       
    55     __ASSERT_DEBUG(collectionId, Panic(EGlxPanicIllegalState));
       
    56      // build the path.
       
    57     
       
    58     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
    59     CleanupStack::PushL(path);
       
    60     
       
    61     path->AppendL(collectionId);
       
    62       
       
    63     CGlxMediaSelectionPopup* popup = new (ELeave) CGlxMediaSelectionPopup;
       
    64     
       
    65     TBool accepted = EFalse;
       
    66     CMPXCollectionPath* selection = popup->ExecuteLD(*path, accepted, aAllowMultipleSelection, aEnableContainerCreation, filter);
       
    67         
       
    68     if (accepted)
       
    69         {
       
    70         CleanupStack::PushL(selection);
       
    71         aSelectedIds.Reset();
       
    72         
       
    73         TArray<TInt> selectionArray = selection->Selection();
       
    74         
       
    75         TInt count = selectionArray.Count();
       
    76         if (count)
       
    77         	{
       
    78 	        for (TInt i = 0; i < count; i++)
       
    79 	            {
       
    80 	            aSelectedIds.AppendL(selection->IdOfIndex(selectionArray[i]));
       
    81 	            }
       
    82         	}
       
    83         else
       
    84         	{
       
    85         	aSelectedIds.AppendL(selection->Id());
       
    86         	}
       
    87         
       
    88         CleanupStack::PopAndDestroy(selection);
       
    89         }
       
    90 
       
    91     CleanupStack::PopAndDestroy(path);
       
    92     
       
    93     if (filter)
       
    94     	{
       
    95     	CleanupStack::PopAndDestroy(filter);
       
    96     	}
       
    97     	
       
    98     
       
    99     if (accepted)
       
   100         {        
       
   101         return KErrNone;
       
   102         }
       
   103     else
       
   104         {
       
   105         return KErrCancel;
       
   106         }
       
   107 	}