1 /* |
|
2 * Copyright (c) 2006-2008 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: Memory card info popup |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <StringLoader.h> |
|
22 #include <aknPopup.h> |
|
23 #include <aknlists.h> |
|
24 #include <FileManagerView.rsg> |
|
25 #include <cmemstatepopup.h> |
|
26 #include "CFileManagerMMCInfoPopup.h" |
|
27 #include "TFileManagerDriveInfo.h" |
|
28 |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KSeparator, "\t" ); |
|
32 const TUint KDefaultItemCount = 4; |
|
33 |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CFileManagerMMCInfoPopup::CFileManagerMMCInfoPopup |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CFileManagerMMCInfoPopup::CFileManagerMMCInfoPopup() |
|
42 { |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CFileManagerMMCInfoPopup::ConstructL |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 void CFileManagerMMCInfoPopup::ConstructL( |
|
50 const TFileManagerDriveInfo& aInfo ) |
|
51 { |
|
52 // Get unit utility instance |
|
53 CMemStatePopup::GetUtilL( iUtil ); |
|
54 |
|
55 iListBox = new ( ELeave ) CAknSingleHeadingPopupMenuStyleListBox; |
|
56 iPopupList = CAknPopupList::NewL( |
|
57 iListBox, |
|
58 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
59 AknPopupLayouts::EMenuGraphicHeadingWindow ); |
|
60 |
|
61 HBufC* title = StringLoader::LoadLC( R_QTN_FMGR_MEMCARD_INFO_HEADING ); |
|
62 iPopupList->SetTitleL( *title ); |
|
63 CleanupStack::PopAndDestroy( title ); |
|
64 |
|
65 iListBox->ConstructL( iPopupList, EAknListBoxViewerFlags ); |
|
66 |
|
67 MDesCArray* array = ConstructDataArrayL( aInfo ); |
|
68 iListBox->Model()->SetItemTextArray( array ); |
|
69 |
|
70 iListBox->CreateScrollBarFrameL( ETrue ); |
|
71 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
72 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
73 iListBox->SetMopParent( this ); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CFileManagerMMCInfoPopup::~CFileManagerMMCInfoPopup |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CFileManagerMMCInfoPopup::~CFileManagerMMCInfoPopup() |
|
81 { |
|
82 if( iIsDestroyed ) |
|
83 { |
|
84 *iIsDestroyed = ETrue; |
|
85 } |
|
86 delete iListBox; |
|
87 delete iUtil; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CFileManagerMMCInfoPopup::NewL |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CFileManagerMMCInfoPopup* CFileManagerMMCInfoPopup::NewL( |
|
95 const TFileManagerDriveInfo& aInfo ) |
|
96 { |
|
97 CFileManagerMMCInfoPopup* self = |
|
98 new( ELeave ) CFileManagerMMCInfoPopup(); |
|
99 |
|
100 CleanupStack::PushL( self ); |
|
101 self->ConstructL( aInfo ); |
|
102 CleanupStack::Pop( self ); |
|
103 |
|
104 return self; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CFileManagerMMCInfoPopup::ExecuteLD |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 TBool CFileManagerMMCInfoPopup::ExecuteLD() |
|
112 { |
|
113 CFileManagerMMCInfoPopup* self = this; |
|
114 CleanupStack::PushL( self ); |
|
115 |
|
116 TBool thisDestroyed( EFalse ); |
|
117 iIsDestroyed = &thisDestroyed; |
|
118 |
|
119 TBool ret( EFalse ); |
|
120 TRAPD( err, ( ret = iPopupList->ExecuteLD() )); |
|
121 |
|
122 // just in case check is this base object still on, |
|
123 // before using member variable |
|
124 if( !thisDestroyed ) |
|
125 { |
|
126 iPopupList = NULL; |
|
127 } |
|
128 |
|
129 if( thisDestroyed ) |
|
130 { |
|
131 CleanupStack::Pop( self ); |
|
132 } |
|
133 else |
|
134 { |
|
135 CleanupStack::PopAndDestroy( self ); |
|
136 } |
|
137 |
|
138 User::LeaveIfError( err ); |
|
139 return ret; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CFileManagerMMCInfoPopup::ConstructDataArrayL |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 MDesCArray* CFileManagerMMCInfoPopup::ConstructDataArrayL( |
|
147 const TFileManagerDriveInfo& aInfo ) |
|
148 { |
|
149 CDesCArray* array = new( ELeave ) CDesCArrayFlat( KDefaultItemCount ); |
|
150 CleanupStack::PushL( array ); |
|
151 |
|
152 // Name |
|
153 HBufC* entry = NameEntryLC( aInfo ); |
|
154 array->AppendL( *entry ); |
|
155 CleanupStack::PopAndDestroy( entry ); |
|
156 |
|
157 // Capacity |
|
158 entry = SizeEntryLC( R_QTN_FMGR_CARD_INFO_SIZE, aInfo.iCapacity ); |
|
159 array->AppendL( *entry ); |
|
160 CleanupStack::PopAndDestroy( entry ); |
|
161 |
|
162 // Used |
|
163 entry = SizeEntryLC( R_QTN_FMGR_CARD_INFO_USED, |
|
164 aInfo.iCapacity - aInfo.iSpaceFree ); |
|
165 array->AppendL( *entry ); |
|
166 CleanupStack::PopAndDestroy( entry ); |
|
167 |
|
168 // Free |
|
169 entry = SizeEntryLC( R_QTN_FMGR_CARD_INFO_FREE, aInfo.iSpaceFree ); |
|
170 array->AppendL( *entry ); |
|
171 CleanupStack::PopAndDestroy( entry ); |
|
172 |
|
173 CleanupStack::Pop( array ); |
|
174 return array; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CFileManagerMMCInfoPopup::NameEntryLC |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 HBufC* CFileManagerMMCInfoPopup::NameEntryLC( |
|
182 const TFileManagerDriveInfo& aInfo ) |
|
183 { |
|
184 HBufC* title = StringLoader::LoadLC( R_QTN_FMGR_CARD_INFO_NAME ); |
|
185 HBufC* name = NULL; |
|
186 if ( aInfo.iName.Length() ) |
|
187 { |
|
188 name = aInfo.iName.AllocLC(); |
|
189 } |
|
190 else |
|
191 { |
|
192 name = StringLoader::LoadLC( R_QTN_FMGR_CARD_INFO_DEFAULT_NAME ); |
|
193 } |
|
194 HBufC* dataStr = HBufC::NewL( title->Length() + name->Length() + 1 ); |
|
195 TPtr dataPtr( dataStr->Des() ); |
|
196 |
|
197 dataPtr.Append( *title ); |
|
198 dataPtr.Append( KSeparator ); |
|
199 dataPtr.Append( *name ); |
|
200 |
|
201 CleanupStack::PopAndDestroy( name ); |
|
202 CleanupStack::PopAndDestroy( title ); |
|
203 CleanupStack::PushL( dataStr ); |
|
204 return dataStr; |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CFileManagerMMCInfoPopup::SizeEntryLC |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 HBufC* CFileManagerMMCInfoPopup::SizeEntryLC( |
|
212 TInt aTextId, TInt64 aSize ) |
|
213 { |
|
214 TPtrC unit( iUtil->SolveUnitAndSize( aSize ) ); |
|
215 HBufC* title = StringLoader::LoadLC( aTextId ); |
|
216 HBufC* sizeAndUnit = StringLoader::LoadLC( |
|
217 R_QTN_FMGR_CARD_INFO_DATA, unit, I64INT( aSize ) ); |
|
218 HBufC* dataStr = HBufC::NewL( |
|
219 title->Length() + sizeAndUnit->Length() + 1 ); |
|
220 TPtr dataPtr( dataStr->Des() ); |
|
221 |
|
222 dataPtr.Append( *title ); |
|
223 dataPtr.Append( KSeparator ); |
|
224 dataPtr.Append( *sizeAndUnit ); |
|
225 |
|
226 CleanupStack::PopAndDestroy( sizeAndUnit ); |
|
227 CleanupStack::PopAndDestroy( title ); |
|
228 CleanupStack::PushL( dataStr ); |
|
229 return dataStr; |
|
230 } |
|
231 |
|
232 // End of File |
|