60
|
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 |
CleanupClosePushL(aSelectedIds);
|
|
39 |
TUint32 collectionId = 0;
|
|
40 |
CMPXFilter* filter = NULL;
|
|
41 |
|
|
42 |
if (aCollectionType == KGlxCollectionTypeIdAlbum)
|
|
43 |
{
|
|
44 |
aAllowMultipleSelection = EFalse;
|
|
45 |
collectionId = KGlxCollectionPluginAlbumsImplementationUid;
|
|
46 |
filter = TGlxFilterFactory::CreateCameraAlbumExclusionFilterL();
|
|
47 |
CleanupStack::PushL(filter);
|
|
48 |
}
|
|
49 |
else if (aCollectionType == KGlxCollectionTypeIdTag)
|
|
50 |
{
|
|
51 |
collectionId = KGlxTagCollectionPluginImplementationUid;
|
|
52 |
filter = TGlxFilterFactory::CreateIncludeEmptyContainersFilterL();
|
|
53 |
CleanupStack::PushL(filter);
|
|
54 |
}
|
|
55 |
|
|
56 |
__ASSERT_DEBUG(collectionId, Panic(EGlxPanicIllegalState));
|
|
57 |
// build the path.
|
|
58 |
|
|
59 |
CMPXCollectionPath* path = CMPXCollectionPath::NewL();
|
|
60 |
CleanupStack::PushL(path);
|
|
61 |
|
|
62 |
path->AppendL(collectionId);
|
|
63 |
|
|
64 |
CGlxMediaSelectionPopup* popup = new (ELeave) CGlxMediaSelectionPopup;
|
|
65 |
|
|
66 |
TBool accepted = EFalse;
|
|
67 |
CMPXCollectionPath* selection = popup->ExecuteLD(*path, accepted, aAllowMultipleSelection, aEnableContainerCreation, filter);
|
|
68 |
|
|
69 |
if (accepted)
|
|
70 |
{
|
|
71 |
CleanupStack::PushL(selection);
|
|
72 |
aSelectedIds.Reset();
|
|
73 |
|
|
74 |
TArray<TInt> selectionArray = selection->Selection();
|
|
75 |
|
|
76 |
TInt count = selectionArray.Count();
|
|
77 |
if (count)
|
|
78 |
{
|
|
79 |
for (TInt i = 0; i < count; i++)
|
|
80 |
{
|
|
81 |
aSelectedIds.AppendL(selection->IdOfIndex(selectionArray[i]));
|
|
82 |
}
|
|
83 |
}
|
|
84 |
else
|
|
85 |
{
|
|
86 |
aSelectedIds.AppendL(selection->Id());
|
|
87 |
}
|
|
88 |
|
|
89 |
CleanupStack::PopAndDestroy(selection);
|
|
90 |
}
|
|
91 |
|
|
92 |
CleanupStack::PopAndDestroy(path);
|
|
93 |
|
|
94 |
if (filter)
|
|
95 |
{
|
|
96 |
CleanupStack::PopAndDestroy(filter);
|
|
97 |
}
|
|
98 |
|
|
99 |
CleanupStack::Pop(&aSelectedIds);
|
|
100 |
|
|
101 |
if (accepted)
|
|
102 |
{
|
|
103 |
return KErrNone;
|
|
104 |
}
|
|
105 |
else
|
|
106 |
{
|
|
107 |
return KErrCancel;
|
|
108 |
}
|
|
109 |
}
|