|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // ========== INCLUDE FILES ================================ |
|
19 #include <msvapi.h> |
|
20 #include <eikspane.h> |
|
21 #include <eikmenup.h> |
|
22 #include <AknDef.h> |
|
23 #include <aknappui.h> |
|
24 #include <akntitle.h> |
|
25 #include <aknnavi.h> |
|
26 #include <aknlists.h> |
|
27 #include <gulicon.h> |
|
28 #include <coeutils.h> // for ConeUtils::FileExists |
|
29 #include <bautils.h> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <AknWaitDialog.h> // CAknWaitDialog |
|
32 #include <DocumentHandler.h> |
|
33 #include <StringLoader.h> // StringLoader |
|
34 #include <AiwCommon.h> |
|
35 #include <NpdApi.h> |
|
36 #include <avkon.hrh> |
|
37 #include <aknlayout.cdl.h> |
|
38 #include <aknlayoutscalable_avkon.cdl.h> |
|
39 #include <AknUtils.h> |
|
40 #include <AknsUtils.h> // skinned icons |
|
41 #include <AknsConstants.h> // skinned icon ids |
|
42 |
|
43 #include "calenattachmentinfo.h" |
|
44 #include "calenattachmentmodel.h" |
|
45 #include "calenviewattachmentsdialog.h" |
|
46 #include "calenattachmentutils.h" |
|
47 #include "calenattalistitemarray.h" |
|
48 #include "calendarui_debug.h" |
|
49 |
|
50 #include <calendar.mbg> |
|
51 #include "calendar.hrh" |
|
52 #include <Calendar.rsg> // resouce identifiers |
|
53 #include <calencommonui.rsg> |
|
54 |
|
55 #include <aknlistloadertfx.h> |
|
56 #include <aknlistboxtfxinternal.h> |
|
57 |
|
58 // ========== CONSTANTS ==================================== |
|
59 |
|
60 _LIT( KStripList, "\x000A\x000D\x2029\x2028\x0085" ); |
|
61 |
|
62 // ================= MEMBER FUNCTIONS ======================= |
|
63 |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CCalenAttaListItemArray::NewL |
|
67 // Two-phased constructor. |
|
68 // (other items were commented in a header). |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 CCalenAttaListItemArray* CCalenAttaListItemArray::NewL( |
|
72 CCalenAttachmentModel& aAttachmentModel, |
|
73 CArrayPtr<CGulIcon>* aIconArray ) |
|
74 { |
|
75 TRACE_ENTRY_POINT; |
|
76 |
|
77 CCalenAttaListItemArray* self = new ( ELeave ) CCalenAttaListItemArray( |
|
78 aAttachmentModel, |
|
79 aIconArray ); |
|
80 |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop(); // self |
|
84 |
|
85 TRACE_EXIT_POINT; |
|
86 return self; |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CCalenAttaListItemArray::~CCalenAttaListItemArray |
|
91 // Destructor. |
|
92 // (other items were commented in a header). |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 CCalenAttaListItemArray::~CCalenAttaListItemArray() |
|
96 { |
|
97 TRACE_ENTRY_POINT; |
|
98 |
|
99 delete iListItemText; |
|
100 TRACE_EXIT_POINT; |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CCalenAttaListItemArray::ConstructL |
|
105 // (other items were commented in a header). |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 void CCalenAttaListItemArray::ConstructL() |
|
109 { |
|
110 TRACE_ENTRY_POINT; |
|
111 |
|
112 iListItemText = new ( ELeave ) TBuf<100>; |
|
113 TRACE_EXIT_POINT; |
|
114 } |
|
115 |
|
116 // ---------------------------------------------------------------------------- |
|
117 // CCalenAttaListItemArray::MdcaCount |
|
118 // returns the count of the items in attachment model. |
|
119 // ---------------------------------------------------------------------------- |
|
120 // |
|
121 TInt CCalenAttaListItemArray::MdcaCount() const |
|
122 { |
|
123 TRACE_ENTRY_POINT; |
|
124 TRACE_EXIT_POINT; |
|
125 |
|
126 return iAttachmentModel.NumberOfItems(); |
|
127 } |
|
128 |
|
129 // ---------------------------------------------------------------------------- |
|
130 // CCalenAttaListItemArray::MdcaPoint |
|
131 // ---------------------------------------------------------------------------- |
|
132 // |
|
133 TPtrC CCalenAttaListItemArray::MdcaPoint(TInt aIndex) const |
|
134 { |
|
135 TRACE_ENTRY_POINT; |
|
136 |
|
137 CCalenAttachmentInfo& attInfo = iAttachmentModel.AttachmentInfoAt( aIndex ); |
|
138 |
|
139 // if application icon has been inserted previously, delete it from index 0 |
|
140 // and insert new app icon to index 0. |
|
141 iIconArray->Reset(); |
|
142 TRAP_IGNORE( iIconArray->AppendL( attInfo.Icon() ) ); |
|
143 |
|
144 // then get the file name from atta info full path name. |
|
145 TParsePtrC parser( attInfo.FileName() ); |
|
146 TFileName filename( parser.NameAndExt() ); |
|
147 |
|
148 HBufC* convertedFilename = NULL; |
|
149 |
|
150 if ( filename.Length() == 0 ) |
|
151 { |
|
152 CEikonEnv::Static()->ReadResource( filename, R_QTN_CALEN_NO_NAME_FOR_FILE ); |
|
153 } |
|
154 else |
|
155 { |
|
156 TRAP_IGNORE( convertedFilename = AknTextUtils::ConvertFileNameL( filename ) ); |
|
157 |
|
158 TPtr convertedFileNamePtr = convertedFilename->Des(); |
|
159 AknTextUtils::StripCharacters( convertedFileNamePtr, KStripList ); |
|
160 } |
|
161 |
|
162 // generate item text for list item by combining |
|
163 // icon index (always zero), file name and file size. |
|
164 iListItemText->Zero(); |
|
165 |
|
166 iListItemText->AppendNum( 0 ); |
|
167 iListItemText->Append( KColumnListSeparator ); |
|
168 |
|
169 if ( convertedFilename ) |
|
170 { |
|
171 iListItemText->Append( *convertedFilename ); |
|
172 delete convertedFilename; |
|
173 } |
|
174 else |
|
175 { |
|
176 iListItemText->Append( filename ); |
|
177 } |
|
178 |
|
179 iListItemText->Append( KColumnListSeparator ); |
|
180 |
|
181 // Get the size of the attachment in string format |
|
182 HBufC* sizeString = attInfo.SizeString(); |
|
183 |
|
184 // Cobvert the string to buff with proper length |
|
185 TBuf<KCalenAttaSizeStringLength> sizeStringBuf; |
|
186 sizeStringBuf.Zero(); |
|
187 sizeStringBuf.Append( *sizeString ); |
|
188 |
|
189 // Append the size string of the attachment |
|
190 iListItemText->Append(sizeStringBuf); |
|
191 |
|
192 // delete the size string |
|
193 delete sizeString; |
|
194 |
|
195 TRACE_EXIT_POINT; |
|
196 return *iListItemText; |
|
197 } |
|
198 |
|
199 // ---------------------------------------------------------------------------- |
|
200 // CCalenAttaListItemArray::CCalenAttaListItemArray |
|
201 // Constructor |
|
202 // (other items were commented in a header). |
|
203 // ---------------------------------------------------------------------------- |
|
204 // |
|
205 CCalenAttaListItemArray::CCalenAttaListItemArray(CCalenAttachmentModel& aAttachmentModel, |
|
206 CArrayPtr<CGulIcon>* aIconArray ): |
|
207 iAttachmentModel( aAttachmentModel ), |
|
208 iIconArray( aIconArray ) |
|
209 { |
|
210 TRACE_ENTRY_POINT; |
|
211 TRACE_EXIT_POINT; |
|
212 } |
|
213 |
|
214 // End of File |