1 /* |
|
2 * Copyright (c) 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: CVIMPSTUiArray-array decorator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cvimpstuisinglelistboxarray.h" |
|
21 #include "tvimpstconsts.h" |
|
22 #include "vimpstutils.h" |
|
23 #include "mvimpstprocessarray.h" |
|
24 #include <vimpstuires.rsg> |
|
25 #include "tvimpstenums.h" |
|
26 |
|
27 // platform includes |
|
28 |
|
29 #include <AknUtils.h> |
|
30 #include <StringLoader.h> |
|
31 #include <AknIconUtils.h> |
|
32 #include <AknIconArray.h> |
|
33 #include <eikclbd.h> |
|
34 #include <AknsConstants.h> |
|
35 #include "uiservicetabtracer.h" |
|
36 |
|
37 #include <vimpstui.mbg> |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 // Two-phased constructor. |
|
42 CVIMPSTUiSingleListboxArray* CVIMPSTUiSingleListboxArray::NewL(MVIMPSTProcessArray& aItemModel, |
|
43 CColumnListBoxData* aListboxData, |
|
44 CVIMPSTUiSingleStyleListBox& aListBox |
|
45 ) |
|
46 { |
|
47 TRACER_AUTO; |
|
48 CVIMPSTUiSingleListboxArray* self = new (ELeave) CVIMPSTUiSingleListboxArray( aItemModel, |
|
49 aListboxData, aListBox); |
|
50 |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // Destructor |
|
58 CVIMPSTUiSingleListboxArray::~CVIMPSTUiSingleListboxArray() |
|
59 { |
|
60 delete iData; |
|
61 } |
|
62 |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // |
|
66 CVIMPSTUiSingleListboxArray::CVIMPSTUiSingleListboxArray( MVIMPSTProcessArray& aItemModel, |
|
67 CColumnListBoxData* aListboxData, CVIMPSTUiSingleStyleListBox& aListBox /*= NULL*/) |
|
68 : |
|
69 iItemArray(aItemModel), |
|
70 iListboxData( aListboxData ), |
|
71 iListBox(aListBox) |
|
72 { |
|
73 } |
|
74 |
|
75 // Symbian OS default constructor can leave. |
|
76 void CVIMPSTUiSingleListboxArray::ConstructL() |
|
77 { |
|
78 TRACER_AUTO; |
|
79 // maximum length of icons appended to identification |
|
80 // There can be four icons (A+B and two on D-column) |
|
81 iMaxLengthOfIcons = |
|
82 KContactOnlineIconA().Length()+ // longest A-Column icon |
|
83 KEmptyIconC().Length() + // longest C-column icon |
|
84 KContactNewMsgIcon().Length(); // longest D-Column icon |
|
85 // Reserve enough memory to handle maximum size item |
|
86 iData = HBufC::NewL( KFriendsListMaxIdentificationLength + |
|
87 KStatusMsgMaxLength + |
|
88 iMaxLengthOfIcons ); |
|
89 |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CVIMPSTUiSingleListboxArray::MdcaCount |
|
95 // Returns the number of descriptor elements in a descriptor array. |
|
96 // (other items were commented in a header). |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 TInt CVIMPSTUiSingleListboxArray::MdcaCount() const |
|
100 { |
|
101 return iItemArray.Count(); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CVIMPSTUiSingleListboxArray::MdcaCount |
|
106 // Return pointer to descriptor data in given index of an array |
|
107 // (other items were commented in a header). |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 TPtrC16 CVIMPSTUiSingleListboxArray::MdcaPoint( TInt aIndex ) const |
|
111 { |
|
112 TRACER_AUTO; |
|
113 // Although this is a const method, we do change the member data. |
|
114 // This is done because of performance |
|
115 // -> no need to create new buffer every time. |
|
116 TPtr dataPtr( iData->Des() ); |
|
117 dataPtr.Zero(); |
|
118 |
|
119 // fetch the item and process correct type |
|
120 TVIMPSTEnums::TItem type = iItemArray.GetType(aIndex); |
|
121 |
|
122 switch( type ) |
|
123 { |
|
124 case TVIMPSTEnums::EOwnStatusItem: |
|
125 { |
|
126 TRAP_IGNORE( AppendOwnDataL(dataPtr,aIndex ) ); |
|
127 break; |
|
128 } |
|
129 |
|
130 case TVIMPSTEnums::EContactItem: |
|
131 { |
|
132 // contact item |
|
133 TRAP_IGNORE( AppendContactL(dataPtr,aIndex ) ); |
|
134 break; |
|
135 } |
|
136 |
|
137 } //end outer switch |
|
138 return dataPtr; |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CVIMPSTUiSingleListboxArray::AppendContact |
|
144 // Append formatted contact identification to buffer |
|
145 // (other items were commented in a header). |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 void CVIMPSTUiSingleListboxArray::AppendContactL( TPtr& aBuffer, |
|
149 TInt aIndex |
|
150 ) const |
|
151 { |
|
152 TRACER_AUTO; |
|
153 // A-column |
|
154 aBuffer.Append( KEmptyIconA ); |
|
155 // B-column |
|
156 TPtrC identification(iItemArray.GetItemNameText(aIndex) ); |
|
157 aBuffer.Append( identification.Left(KFriendsListMaxIdentificationLength) ); |
|
158 |
|
159 //C-Column |
|
160 aBuffer.Append( KEmptyIconC ); |
|
161 |
|
162 // D-Column |
|
163 if( iItemArray.IsMsgPending( aIndex ) ) |
|
164 { |
|
165 aBuffer.Append( KContactNewMsgIcon ); |
|
166 } |
|
167 else |
|
168 { |
|
169 aBuffer.Append( KEmptyIconC ); |
|
170 } |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------- |
|
174 // CVIMPSTUiSingleListboxArray::AppendContact |
|
175 // Append formatted contact identification to buffer |
|
176 // (other items were commented in a header). |
|
177 // --------------------------------------------------------- |
|
178 // |
|
179 void CVIMPSTUiSingleListboxArray::AppendOwnDataL( TPtr& aBuffer, |
|
180 TInt aIndex |
|
181 ) const |
|
182 { |
|
183 // no need to append any icon in the a coloum as there is no presence service. |
|
184 // A-column |
|
185 aBuffer.Append( KEmptyIconA ); |
|
186 |
|
187 // B-column |
|
188 TPtrC identification(iItemArray.GetItemNameText(aIndex)); |
|
189 aBuffer.Append( identification.Left( KFriendsListMaxIdentificationLength ) ); |
|
190 |
|
191 |
|
192 //C-Column |
|
193 aBuffer.Append( KEmptyIconA ); |
|
194 |
|
195 //D-Column |
|
196 aBuffer.Append( KEmptyIconA ); |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------- |
|
200 // CVIMPSTUiSingleListboxArray::AppendContactListL |
|
201 // Append formatted contact list identification to buffer |
|
202 // (other items were commented in a header). |
|
203 // --------------------------------------------------------- |
|
204 // |
|
205 void CVIMPSTUiSingleListboxArray::AppendContactListL( TPtr& /*aBuffer*/, |
|
206 TInt /*aIndex */) const |
|
207 { |
|
208 // add functionality when contactlists supported |
|
209 } |
|
210 |
|
211 |
|
212 // End of File |
|