author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 68 | 9da50d567e3c |
parent 63 | f4a778e096c2 |
child 85 | 38bb213f60ba |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 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: Phonebook 2 contact view list box model. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
||
21 |
#include <CPbk2ContactIconsUtils.h> |
|
22 |
||
23 |
// Phonebook 2 |
|
24 |
#include <CPbk2IconArray.h> |
|
25 |
#include <CPbk2StoreProperty.h> |
|
26 |
#include <CPbk2StoreViewDefinition.h> |
|
27 |
#include <CPbk2StorePropertyArray.h> |
|
28 |
#include <MPbk2ContactUiControlExtension.h> |
|
29 |
#include <CPbk2UIExtensionManager.h> |
|
30 |
#include <MPbk2UIExtensionIconSupport.h> |
|
31 |
||
68
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
32 |
#include <pbk2uicontrols.rsg> |
63 | 33 |
#include <Pbk2PresentationUtils.h> |
34 |
#include "Pbk2NamesListExUID.h" |
|
35 |
||
36 |
// Virtual Phonebook |
|
37 |
#include <MVPbkContactViewBase.h> |
|
38 |
#include <MVPbkContactStore.h> |
|
39 |
#include <MVPbkContactStoreProperties.h> |
|
40 |
#include <MVPbkViewContact.h> |
|
41 |
#include <CVPbkContactViewDefinition.h> |
|
42 |
#include <CVPbkContactManager.h> |
|
43 |
#include <MVPbkFieldType.h> |
|
44 |
#include <MVPbkBaseContactField.h> |
|
45 |
#include <CVPbkFieldTypeSelector.h> |
|
46 |
#include <MVPbkBaseContactFieldCollection.h> |
|
47 |
#include <MVPbkContactFieldData.h> |
|
48 |
||
49 |
// System includes |
|
50 |
#include <eikenv.h> |
|
51 |
#include <barsread.h> |
|
52 |
||
53 |
||
54 |
EXPORT_C CPbk2ContactIconsUtils* CPbk2ContactIconsUtils::NewL( |
|
55 |
CPbk2StorePropertyArray& aStoreProperties, |
|
56 |
MPbk2ContactUiControlExtension* aUiExtension ) |
|
57 |
{ |
|
58 |
CPbk2ContactIconsUtils* self = new(ELeave) CPbk2ContactIconsUtils( |
|
59 |
aStoreProperties, |
|
60 |
aUiExtension); |
|
61 |
return self; |
|
62 |
} |
|
63 |
||
64 |
CPbk2ContactIconsUtils::~CPbk2ContactIconsUtils() |
|
65 |
{ |
|
66 |
} |
|
67 |
||
68 |
CPbk2ContactIconsUtils::CPbk2ContactIconsUtils( |
|
69 |
CPbk2StorePropertyArray& aStoreProperties, |
|
70 |
MPbk2ContactUiControlExtension* aUiExtension ): |
|
71 |
iStoreProperties(aStoreProperties), |
|
72 |
iUiExtension(aUiExtension) |
|
73 |
{ |
|
74 |
} |
|
75 |
||
76 |
EXPORT_C CPbk2IconArray* CPbk2ContactIconsUtils::CreateListboxIconArrayL( |
|
77 |
TInt aResourceId) |
|
78 |
{ |
|
79 |
TResourceReader reader; |
|
80 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, aResourceId ); |
|
81 |
CPbk2IconArray* iconArray = CPbk2IconArray::NewL( reader ); |
|
82 |
CleanupStack::PushL( iconArray ); |
|
83 |
||
84 |
// Add icons from UI extensions |
|
85 |
CPbk2UIExtensionManager* extManager = CPbk2UIExtensionManager::InstanceL(); |
|
86 |
extManager->PushL(); |
|
87 |
extManager->IconSupportL().AppendExtensionIconsL( *iconArray ); |
|
88 |
CleanupStack::PopAndDestroy(); // extManager |
|
89 |
CleanupStack::Pop( iconArray ); |
|
90 |
CleanupStack::PopAndDestroy(); // reader |
|
91 |
||
92 |
return iconArray; |
|
93 |
} |
|
94 |
||
95 |
EXPORT_C void CPbk2ContactIconsUtils::GetIconIdsForContactL( |
|
96 |
const MVPbkViewContact& aViewContact, |
|
97 |
RArray<TPbk2IconId>& aIconArray ) const |
|
98 |
{ |
|
99 |
CleanupClosePushL( aIconArray ); |
|
100 |
aIconArray.Reset(); |
|
101 |
||
102 |
// get dynamic icons from ui extension |
|
103 |
if ( iUiExtension ) |
|
104 |
{ |
|
105 |
const TArray<TPbk2IconId>& ids = |
|
106 |
iUiExtension->GetDynamicIconsL( &aViewContact ); |
|
107 |
for (TInt i = 0; i < ids.Count(); ++i) |
|
108 |
{ |
|
109 |
aIconArray.AppendL( ids[i] ); |
|
110 |
} |
|
111 |
} |
|
112 |
||
113 |
// find icon from view definition |
|
114 |
TVPbkContactViewType viewType = aViewContact.ParentView().Type(); |
|
115 |
const TInt propCount = iStoreProperties.Count(); |
|
116 |
TBool propertyFound = EFalse; |
|
117 |
TBool viewIconFound = EFalse; |
|
118 |
for (TInt i = 0; i < propCount && !propertyFound; ++i) |
|
119 |
{ |
|
120 |
// Find store property for the view contact |
|
121 |
const CPbk2StoreProperty& prop = iStoreProperties.At(i); |
|
122 |
if (aViewContact.MatchContactStore(prop.StoreUri().UriDes())) |
|
123 |
{ |
|
124 |
propertyFound = ETrue; |
|
125 |
TArray<const CPbk2StoreViewDefinition*> pbk2Defs = prop.Views(); |
|
126 |
const TInt defCount = pbk2Defs.Count(); |
|
127 |
for (TInt j = 0; j < defCount && !viewIconFound; ++j) |
|
128 |
{ |
|
129 |
// if types are same use item icon |
|
130 |
if (viewType == pbk2Defs[j]->ViewDefinition().Type()) |
|
131 |
{ |
|
132 |
aIconArray.AppendL( pbk2Defs[j]->ViewItemIconId() ); |
|
133 |
viewIconFound = ETrue; |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
CleanupStack::Pop(); |
|
139 |
} |
|
140 |
||
141 |
// End of File |