|
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: Implementation of detailsview plugin control container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cvimpstdetailsviewcontainer.h" |
|
21 |
|
22 #include "cvimpstdetailsheadercontrol.h" |
|
23 #include "cvimpstdetailsviewlistboxmodel.h" |
|
24 #include "cvimpstdetailsviewbrandhandler.h" |
|
25 #include "mvimpstdetailspresencehandler.h" |
|
26 #include "cvimpstfieldpropertyarray.h" |
|
27 #include "cvimpstfieldproperty.h" |
|
28 #include "vimpstdetailsview.hrh" |
|
29 #include <vimpstdetailsviewpluginrsc.rsg> |
|
30 |
|
31 // System includes |
|
32 #include <aknlists.h> |
|
33 #include <bautils.h> |
|
34 #include <layoutmetadata.cdl.h> |
|
35 #include <aknlayoutscalable_apps.cdl.h> |
|
36 #include <AknsBasicBackgroundControlContext.h> |
|
37 // virtual phonebook |
|
38 #include <MVPbkStoreContact.h> |
|
39 |
|
40 #include "vimpstextentionuiuid.h" |
|
41 #include "meco.hlp.hrh" |
|
42 |
|
43 _LIT(KVIMPSTDetailsViewDllResFileName, "\\resource\\vimpstdetailsviewpluginrsc.rsc" ); |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CVIMPSTDetailsViewContainer::ConstructL() |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CVIMPSTDetailsViewContainer::ConstructL() |
|
53 { |
|
54 // Create the listbox |
|
55 RFs& fsSession( CCoeEnv::Static()->FsSession() ); |
|
56 TFileName fileName( KVIMPSTDetailsViewDllResFileName ); |
|
57 BaflUtils::NearestLanguageFile( fsSession , fileName); |
|
58 |
|
59 iResourceFile.OpenL(fsSession, fileName); |
|
60 iResourceFile.ConfirmSignatureL(); |
|
61 |
|
62 // Create the header |
|
63 iHeaderCtrl = CVIMPSTDetailsHeaderControl::NewL( iBrandHandler, iPresenceHandler ); |
|
64 iHeaderCtrl->SetContainerWindowL( *this ); |
|
65 |
|
66 // Get the skin background for the view |
|
67 iBackground = CAknsBasicBackgroundControlContext::NewL( |
|
68 KAknsIIDQsnBgAreaMain, TRect( 0, 0, 0, 0 ), EFalse ); |
|
69 |
|
70 |
|
71 iListBox = new(ELeave) CAknFormDoubleGraphicStyleListBox; |
|
72 |
|
73 iListBox->ConstructL(this, EAknListBoxLoopScrolling); |
|
74 iListBox->View()->SetListEmptyTextL(KNullDesC); |
|
75 iListBox->SetContainerWindowL(*this); |
|
76 iListBox->CreateScrollBarFrameL(ETrue); |
|
77 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
|
78 CEikScrollBarFrame::EAuto); |
|
79 iListBox->SetMopParent(this); |
|
80 |
|
81 iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
82 |
|
83 CAknIconArray* iconArray = iBrandHandler.LoadIconsLC(); |
|
84 // Set icon array |
|
85 iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray); |
|
86 CleanupStack::Pop(); // iconArray |
|
87 |
|
88 // Read field property resource strucutre array |
|
89 HBufC8* fieldBuffer = iResourceFile.AllocReadLC( R_VIMPST_FIELD_PROPERTIES ) ; |
|
90 // reader ownership to model |
|
91 iListBoxModel = CVIMPSTDetailsViewListBoxModel::NewL(*iListBox, iPresenceHandler, fieldBuffer); |
|
92 CleanupStack::Pop(); // fieldBuffer |
|
93 iListBox->Model()->SetItemTextArray(iListBoxModel); |
|
94 iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
95 |
|
96 //Set listbox observer |
|
97 iListBox->SetListBoxObserver( this ); |
|
98 iListBox->ActivateL(); |
|
99 |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CVIMPSTDetailsViewContainer::CVIMPSTDetailsViewContainer() |
|
104 // C++ default constructor can NOT contain any code, that might leave. |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 CVIMPSTDetailsViewContainer::CVIMPSTDetailsViewContainer(const TUid& aPluginUid, |
|
108 CVIMPSTDetailsViewBrandHandler& aBrandHandler, |
|
109 MVIMPSTDetailsPresenceHandler& aPresenceHandler, |
|
110 TInt aFocusedListIndex ) |
|
111 : |
|
112 iPluginUid(aPluginUid), |
|
113 iBrandHandler( aBrandHandler ), |
|
114 iPresenceHandler( aPresenceHandler ), |
|
115 iFocusedListIndex( aFocusedListIndex ) |
|
116 { |
|
117 //No implementation needed. |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CVIMPSTDetailsViewContainer::~CVIMPSTDetailsViewContainer() |
|
123 // Destructor. |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 CVIMPSTDetailsViewContainer::~CVIMPSTDetailsViewContainer() |
|
127 { |
|
128 delete iBackground; |
|
129 delete iListBoxModel; |
|
130 delete iListBox; |
|
131 delete iHeaderCtrl; |
|
132 iResourceFile.Close(); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CVIMPSTDetailsViewContainer::Draw() |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CVIMPSTDetailsViewContainer::Draw(const TRect& /*aRect*/) const |
|
140 { |
|
141 // Draw the background using skin |
|
142 if ( iBackground ) |
|
143 { |
|
144 AknsDrawUtils::Background( |
|
145 AknsUtils::SkinInstance(), iBackground, this, SystemGc(), Rect() ); |
|
146 } |
|
147 } |
|
148 |
|
149 // -------------------------------------------------------------------------- |
|
150 // CVIMPSTDetailsViewContainer::CountComponentControls |
|
151 // -------------------------------------------------------------------------- |
|
152 // |
|
153 TInt CVIMPSTDetailsViewContainer::CountComponentControls() const |
|
154 { |
|
155 // two control has been used , one header control and another list box |
|
156 return 2; |
|
157 } |
|
158 |
|
159 // -------------------------------------------------------------------------- |
|
160 // CVIMPSTDetailsViewContainer::ComponentControl |
|
161 // -------------------------------------------------------------------------- |
|
162 // |
|
163 CCoeControl* CVIMPSTDetailsViewContainer::ComponentControl(TInt aIndex) const |
|
164 { |
|
165 switch ( aIndex ) |
|
166 { |
|
167 case 0: |
|
168 return iHeaderCtrl; |
|
169 case 1: |
|
170 return iListBox; |
|
171 default: |
|
172 return NULL; |
|
173 } |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CVIMPSTDetailsViewContainer::MopSupplyObject() |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 TTypeUid::Ptr CVIMPSTDetailsViewContainer::MopSupplyObject(TTypeUid aId) |
|
181 { |
|
182 // For skinning |
|
183 if ( iBackground && aId.iUid == MAknsControlContext::ETypeId ) |
|
184 { |
|
185 return MAknsControlContext::SupplyMopObject( aId, iBackground ); |
|
186 } |
|
187 return CCoeControl::MopSupplyObject( aId ); |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CVIMPSTDetailsViewContainer::FocusChanged() |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 void CVIMPSTDetailsViewContainer::FocusChanged( TDrawNow aDrawNow ) |
|
195 { |
|
196 // For enabling animated hilight (if in skin supports it) |
|
197 CCoeControl::FocusChanged( aDrawNow ); |
|
198 if( iListBox ) |
|
199 { |
|
200 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
201 } |
|
202 } |
|
203 |
|
204 // -------------------------------------------------------------------------- |
|
205 // CVIMPSTDetailsViewContainer::ListBox |
|
206 // -------------------------------------------------------------------------- |
|
207 // |
|
208 CAknFormDoubleGraphicStyleListBox& CVIMPSTDetailsViewContainer::ListBox() const |
|
209 { |
|
210 return *iListBox; |
|
211 } |
|
212 |
|
213 // -------------------------------------------------------------------------- |
|
214 // CVIMPSTDetailsViewContainer::ListBoxModel |
|
215 // -------------------------------------------------------------------------- |
|
216 // |
|
217 CVIMPSTDetailsViewListBoxModel& CVIMPSTDetailsViewContainer::ListBoxModel() const |
|
218 { |
|
219 return *iListBoxModel; |
|
220 } |
|
221 |
|
222 // -------------------------------------------------------------------------- |
|
223 // CVIMPSTDetailsViewContainer::OfferKeyEventL |
|
224 // -------------------------------------------------------------------------- |
|
225 // |
|
226 TKeyResponse CVIMPSTDetailsViewContainer::OfferKeyEventL( |
|
227 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
228 { |
|
229 //Temporary solution for handling key events. |
|
230 TKeyResponse result = EKeyWasNotConsumed; |
|
231 |
|
232 switch (aKeyEvent.iCode) |
|
233 { |
|
234 case EKeyLeftArrow: |
|
235 case EKeyRightArrow: |
|
236 return result; |
|
237 } |
|
238 |
|
239 result = iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
240 |
|
241 /* FIX for KBAA-7R3AXC bug */ |
|
242 if (result == EKeyWasNotConsumed && IsFocused()) |
|
243 { |
|
244 // Ignore Send Key up and down events to prevent Dialer appearance |
|
245 // on top of cca application. |
|
246 if ((aType == EEventKeyDown || aType == EEventKeyUp) |
|
247 && aKeyEvent.iScanCode == EStdKeyYes) |
|
248 { |
|
249 result = EKeyWasConsumed; |
|
250 } |
|
251 } |
|
252 |
|
253 return result; |
|
254 } |
|
255 |
|
256 // -------------------------------------------------------------------------- |
|
257 // CVIMPSTDetailsViewContainer::SizeChanged |
|
258 // -------------------------------------------------------------------------- |
|
259 // |
|
260 void CVIMPSTDetailsViewContainer::SizeChanged() |
|
261 { |
|
262 TRect drawRect( Rect() ); |
|
263 |
|
264 // Listbox and header |
|
265 if (!Layout_Meta_Data::IsLandscapeOrientation()) |
|
266 {// Portrait |
|
267 AknLayoutUtils::LayoutControl( |
|
268 iListBox, drawRect, AknLayoutScalable_Apps::cl_listscroll_pane(0)); |
|
269 TRect listRect = iListBox->Rect(); |
|
270 listRect.iTl.iX = Rect().iTl.iX; |
|
271 listRect.iBr.iX = Rect().iBr.iX; |
|
272 iListBox->SetRect(listRect); |
|
273 TAknLayoutRect headerRect; |
|
274 headerRect.LayoutRect(Rect(), AknLayoutScalable_Apps::cl_header_pane(0)); |
|
275 iHeaderCtrl->SetRect(headerRect.Rect()); |
|
276 } |
|
277 else |
|
278 {// Landscape |
|
279 AknLayoutUtils::LayoutControl( |
|
280 iListBox, drawRect, AknLayoutScalable_Apps::cl_listscroll_pane(1)); |
|
281 TRect listRect = iListBox->Rect(); |
|
282 listRect.iBr.iX = Rect().iBr.iX; |
|
283 iListBox->SetRect(listRect); |
|
284 TAknLayoutRect headerRect; |
|
285 headerRect.LayoutRect(Rect(), AknLayoutScalable_Apps::cl_header_pane(1)); |
|
286 iHeaderCtrl->SetRect(headerRect.Rect()); |
|
287 } |
|
288 // Background skin |
|
289 if ( iBackground ) |
|
290 { |
|
291 iBackground->SetRect( drawRect ); |
|
292 } |
|
293 |
|
294 DrawNow(); |
|
295 } |
|
296 |
|
297 // -------------------------------------------------------------------------- |
|
298 // CVIMPSTDetailsViewContainer::HandleResourceChange |
|
299 // -------------------------------------------------------------------------- |
|
300 // |
|
301 void CVIMPSTDetailsViewContainer::HandleResourceChange(TInt aType) |
|
302 { |
|
303 CCCAppViewPluginAknContainer::HandleResourceChange(aType); |
|
304 } |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // CVIMPSTDetailsViewContainer::GetHelpContext |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CVIMPSTDetailsViewContainer::GetHelpContext(TCoeHelpContext& aContext ) const |
|
311 { |
|
312 TUid KHelpUid = { KHELPUID }; |
|
313 aContext.iMajor = KHelpUid; |
|
314 aContext.iContext = KSERVTAB_HLP_CONTACT_DETAILS; |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CVIMPSTDetailsViewContainer::HandleListBoxEventL() |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 void CVIMPSTDetailsViewContainer::HandleListBoxEventL( |
|
322 CEikListBox* /*aListBox*/, TListBoxEvent /*aEventType*/ ) |
|
323 { |
|
324 // Handle pointer events |
|
325 } |
|
326 |
|
327 // -------------------------------------------------------------------------- |
|
328 // CVIMPSTDetailsViewContainer::PresenceChangedL |
|
329 // -------------------------------------------------------------------------- |
|
330 // |
|
331 void CVIMPSTDetailsViewContainer::PresenceChangedL() |
|
332 { |
|
333 iListBox->HandleItemRemovalL(); |
|
334 iListBoxModel->AddFieldsDataL(); |
|
335 iHeaderCtrl->LabelsSizeChangedL(); |
|
336 iHeaderCtrl->HeaderSizeChangedL(); |
|
337 } |
|
338 |
|
339 // -------------------------------------------------------------------------- |
|
340 // CVIMPSTDetailsViewContainer::GetTitleTextL |
|
341 // -------------------------------------------------------------------------- |
|
342 // |
|
343 HBufC* CVIMPSTDetailsViewContainer::GetTitleTextLC( TStoreType aStoreType ) |
|
344 { |
|
345 TInt count = 0; |
|
346 HBufC* titleText = NULL; |
|
347 |
|
348 if( iListBoxModel ) |
|
349 { |
|
350 count = iListBoxModel->FieldsCount(); |
|
351 } |
|
352 if( aStoreType == EStoreLocal && count >0 ) |
|
353 { |
|
354 CVIMPSTFieldPropertyArray& fieldArry = iListBoxModel->FieldsArray(); |
|
355 |
|
356 CVIMPSTFieldProperty* field = fieldArry.GetFieldById( EVIMPSTFieldIdFirstName ); |
|
357 TPtrC firstName = field ? field->FieldDataL() : KNullDesC; |
|
358 |
|
359 field = fieldArry.GetFieldById( EVIMPSTFieldIdLastName ); |
|
360 TPtrC lastName = field ? field->FieldDataL() : KNullDesC; |
|
361 if( firstName.Length() || lastName.Length() ) |
|
362 { |
|
363 titleText = HBufC::NewLC( firstName.Length() + lastName.Length() +1 ); // pushed on clean up stack |
|
364 if( titleText) |
|
365 { |
|
366 TPtr titleTextPtr( titleText->Des() ); |
|
367 titleTextPtr.Append(firstName); |
|
368 titleTextPtr.Append(KSpace); |
|
369 titleTextPtr.Append(lastName); |
|
370 } |
|
371 } |
|
372 } |
|
373 else if( count >0) |
|
374 { |
|
375 CVIMPSTFieldPropertyArray& fieldArry = iListBoxModel->FieldsArray(); |
|
376 CVIMPSTFieldProperty* field = fieldArry.GetFieldById( EVIMPSTFieldIdImpp ); |
|
377 TPtrC title = field ? field->FieldDataL() : KNullDesC; |
|
378 titleText = iListBoxModel->DisplayId( title ).AllocLC(); // pushed on clean up stack |
|
379 } |
|
380 return titleText; |
|
381 } |
|
382 // -------------------------------------------------------------------------- |
|
383 // CVIMPSTDetailsViewContainer::CreatePresentationL |
|
384 // -------------------------------------------------------------------------- |
|
385 // |
|
386 void CVIMPSTDetailsViewContainer::CreatePresentationL(MVPbkStoreContact& aContact,TDesC& aServiceName, TStoreType aStoreType ) |
|
387 { |
|
388 iListBoxModel->CreateListPresentationL( aContact, |
|
389 iFocusedListIndex, |
|
390 aServiceName, aStoreType); |
|
391 |
|
392 iHeaderCtrl->CreateHeaderPresentationL( aContact ); |
|
393 iHeaderCtrl->HeaderSizeChangedL(); |
|
394 } |
|
395 |
|
396 // -------------------------------------------------------------------------- |
|
397 // CVIMPSTDetailsViewContainer::CreateEmptyPresentationL |
|
398 // -------------------------------------------------------------------------- |
|
399 // |
|
400 void CVIMPSTDetailsViewContainer::CreateEmptyPresentationL() |
|
401 { |
|
402 if( !iListBoxModel->MdcaCount() ) |
|
403 { |
|
404 iListBoxModel->SetEmptyTextsToListboxL(); |
|
405 iHeaderCtrl->ClearL(); // clear the header data |
|
406 } |
|
407 } |
|
408 // End of File |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |