author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 21 | 9da50d567e3c |
parent 20 | f4a778e096c2 |
permissions | -rw-r--r-- |
20 | 1 |
/* |
2 |
* Copyright (c) 2002-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: A dialog the shows the memory status of different stores |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include "CPbk2PhonebookInfoDlg.h" |
|
21 |
||
22 |
#include "CPbk2StoreInfoItemBuilder.h" |
|
23 |
#include "MPbk2StoreInfoUiItem.h" |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
24 |
#include <pbk2uicontrols.rsg> |
20 | 25 |
#include <CPbk2StorePropertyArray.h> |
26 |
#include <CPbk2StoreProperty.h> |
|
27 |
#include <MPbk2ApplicationServices.h> |
|
28 |
#include <MPbk2AppUi.h> |
|
29 |
#include <CVPbkContactStoreUriArray.h> |
|
30 |
#include <TVPbkContactStoreUriPtr.h> |
|
31 |
#include <aknPopup.h> |
|
32 |
#include <aknlists.h> |
|
33 |
#include <StringLoader.h> |
|
34 |
||
35 |
||
36 |
/// Unnamed namespace for local definitions |
|
37 |
namespace |
|
38 |
{ |
|
39 |
// LOCAL CONSTANTS AND MACROS |
|
40 |
_LIT( KSpace, " " ); |
|
41 |
} |
|
42 |
||
43 |
||
44 |
// ================= MEMBER FUNCTIONS ======================= |
|
45 |
||
46 |
// inline because only one call site |
|
47 |
inline CPbk2PhonebookInfoDlg::CPbk2PhonebookInfoDlg() |
|
48 |
{ |
|
49 |
} |
|
50 |
||
51 |
||
52 |
CPbk2PhonebookInfoDlg::~CPbk2PhonebookInfoDlg() |
|
53 |
{ |
|
54 |
if(iDestroyed) |
|
55 |
{ |
|
56 |
*iDestroyed = ETrue; |
|
57 |
} |
|
58 |
delete iListBox; |
|
59 |
if (iInfoItems) |
|
60 |
{ |
|
61 |
iInfoItems->ResetAndDestroy(); |
|
62 |
delete iInfoItems; |
|
63 |
} |
|
64 |
} |
|
65 |
||
66 |
// inline because only one call site |
|
67 |
inline void CPbk2PhonebookInfoDlg::ConstructL() |
|
68 |
{ |
|
69 |
iListBox = new(ELeave) CAknSinglePopupMenuStyleListBox; |
|
70 |
iPopupList = CAknPopupList::NewL(iListBox, |
|
71 |
R_AVKON_SOFTKEYS_OK_EMPTY__OK, |
|
72 |
AknPopupLayouts::EMenuGraphicHeadingWindow); |
|
73 |
iListBox->ConstructL(iPopupList, EAknListBoxViewerFlags); |
|
74 |
||
75 |
iListBox->CreateScrollBarFrameL(ETrue); |
|
76 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL |
|
77 |
(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
78 |
} |
|
79 |
||
80 |
EXPORT_C CPbk2PhonebookInfoDlg* CPbk2PhonebookInfoDlg::NewL() |
|
81 |
{ |
|
82 |
CPbk2PhonebookInfoDlg* self = new(ELeave) CPbk2PhonebookInfoDlg; |
|
83 |
CleanupStack::PushL(self); |
|
84 |
self->ConstructL(); |
|
85 |
CleanupStack::Pop(); |
|
86 |
return self; |
|
87 |
} |
|
88 |
||
89 |
EXPORT_C void CPbk2PhonebookInfoDlg::ExecuteLD( |
|
90 |
CVPbkContactStoreUriArray& aStoreUris) |
|
91 |
{ |
|
92 |
CleanupStack::PushL(this); |
|
93 |
TBool thisDestroyed(EFalse); |
|
94 |
iDestroyed = &thisDestroyed; |
|
95 |
||
96 |
SetDataL(Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager(), |
|
97 |
aStoreUris); |
|
98 |
// Set title |
|
99 |
SetTitleL(aStoreUris); |
|
100 |
||
101 |
||
102 |
TRAPD(err, iPopupList->ExecuteLD()); |
|
103 |
||
104 |
// Just in case |
|
105 |
if(!thisDestroyed) |
|
106 |
{ |
|
107 |
iPopupList = NULL; |
|
108 |
} |
|
109 |
||
110 |
User::LeaveIfError(err); |
|
111 |
||
112 |
if(thisDestroyed) |
|
113 |
{ |
|
114 |
CleanupStack::Pop(); // this |
|
115 |
} |
|
116 |
else |
|
117 |
{ |
|
118 |
CleanupStack::PopAndDestroy(); // this |
|
119 |
} |
|
120 |
iDestroyed = NULL; |
|
121 |
} |
|
122 |
||
123 |
void CPbk2PhonebookInfoDlg::SetTitleL( CVPbkContactStoreUriArray& aStoreUris ) |
|
124 |
{ |
|
125 |
HBufC* title = NULL; |
|
126 |
const TInt oneStore = 1; |
|
127 |
if ( aStoreUris.Count() == oneStore ) |
|
128 |
{ |
|
129 |
title = StringLoader::LoadLC( R_QTN_PHOB_QTL_PB_INFO_SELECTED ); |
|
130 |
} |
|
131 |
else |
|
132 |
{ |
|
133 |
title = StringLoader::LoadLC( R_QTN_PHOB_QTL_PB_INFO_ALL ); |
|
134 |
} |
|
135 |
||
136 |
iPopupList->SetTitleL( *title ); |
|
137 |
CleanupStack::PopAndDestroy( title ); // title |
|
138 |
} |
|
139 |
||
140 |
void CPbk2PhonebookInfoDlg::SetDataL(CVPbkContactManager& aContactManager, |
|
141 |
CVPbkContactStoreUriArray& aStoreUris) |
|
142 |
{ |
|
143 |
CPbk2StoreInfoItemBuilder* itemBuilder = CPbk2StoreInfoItemBuilder::NewL( |
|
144 |
aContactManager, Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
145 |
StoreProperties()); |
|
146 |
CleanupStack::PushL(itemBuilder); |
|
147 |
||
148 |
const TInt oneStore = 1; |
|
149 |
if (aStoreUris.Count() == oneStore) |
|
150 |
{ |
|
151 |
iInfoItems = itemBuilder->BuildSingleStoreItemsL(aStoreUris[0]); |
|
152 |
} |
|
153 |
else |
|
154 |
{ |
|
155 |
iInfoItems = itemBuilder->BuildAllStoresItemsL(aStoreUris); |
|
156 |
} |
|
157 |
||
158 |
const TInt count = iInfoItems->Count(); |
|
159 |
CDesCArray* array = new(ELeave) CDesCArrayFlat(count); |
|
160 |
CleanupStack::PushL(array); |
|
161 |
||
162 |
for (TInt i = 0; i < count; ++i) |
|
163 |
{ |
|
164 |
MPbk2StoreInfoUiItem& uiItem = *iInfoItems->At(i); |
|
165 |
HBufC* itemBuf = HBufC::NewLC(uiItem.HeadingText().Length() + |
|
166 |
uiItem.ItemText().Length() + KSpace().Length()); |
|
167 |
TPtr ptr(itemBuf->Des()); |
|
168 |
ptr.Append(uiItem.HeadingText()); |
|
169 |
ptr.Append(KSpace); |
|
170 |
ptr.Append(uiItem.ItemText()); |
|
171 |
// Convert digits |
|
172 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr); |
|
173 |
array->AppendL(*itemBuf); |
|
174 |
CleanupStack::PopAndDestroy(itemBuf); |
|
175 |
} |
|
176 |
||
177 |
iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); |
|
178 |
iListBox->Model()->SetItemTextArray(array); |
|
179 |
iListBox->DrawNow(); |
|
180 |
CleanupStack::Pop(array); |
|
181 |
CleanupStack::PopAndDestroy(itemBuilder); |
|
182 |
} |
|
183 |
||
184 |
// End of File |