|
1 /* |
|
2 * Copyright (c) 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: List box model for the list-box used to display the Location |
|
15 * Centre pop-up. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 |
|
22 // USER INCLUDES |
|
23 #include "lcpopuplistboxmodel.h" |
|
24 #include "lclocationappinfo.h" |
|
25 #include "lcerrors.h" |
|
26 |
|
27 // CONSTANT DEFINTION |
|
28 const TInt KLcBufferSize = 128; |
|
29 |
|
30 // ========================= MEMBER FUNCTIONS ================================ |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CLcPopupListBoxModel::CLcPopupListBoxModel |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CLcPopupListBoxModel::CLcPopupListBoxModel( CLcLocationAppInfoArray& aAppArray ) |
|
37 :iAppArray( &aAppArray ) |
|
38 { |
|
39 // C++ Default constructor. No allocations or functions which can Leave |
|
40 // should be called from here. |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CLcPopupListBoxModel::~CLcPopupListBoxModel |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CLcPopupListBoxModel::~CLcPopupListBoxModel() |
|
48 { |
|
49 // C++ Destructor. Free all resources associated with this class. |
|
50 |
|
51 // Delete the MdcaPoint buffer |
|
52 delete iBuffer; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // void CLcPopupListBoxModel::ConstructL |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CLcPopupListBoxModel::ConstructL() |
|
60 { |
|
61 // Create the Buffer for packing the MdcaPoint |
|
62 iBuffer = HBufC16::NewL( KLcBufferSize ); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CLcPopupListBoxModel* CLcPopupListBoxModel::NewL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CLcPopupListBoxModel* CLcPopupListBoxModel::NewL( CLcLocationAppInfoArray& aAppArray ) |
|
70 { |
|
71 CLcPopupListBoxModel* self = new ( ELeave ) CLcPopupListBoxModel( aAppArray ); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // void CLcPopupListBoxModel::UpdateModel |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CLcPopupListBoxModel::UpdateModel( CLcLocationAppInfoArray& aAppArray ) |
|
83 { |
|
84 // Now assign the new one |
|
85 iAppArray = &aAppArray; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // TInt CLcPopupListBoxModel::MdcaCount |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 TInt CLcPopupListBoxModel::MdcaCount() const |
|
93 { |
|
94 return iAppArray->Count(); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // TPtrC16 CLcPopupListBoxModel::MdcaPoint |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 TPtrC16 CLcPopupListBoxModel::MdcaPoint( TInt aIndex ) const |
|
102 { |
|
103 // Pack the contents into the Buffer. We dont have to re-allocate the buffer |
|
104 // everytime because the length of the name field is restricted in the |
|
105 // Location Centre Registration API |
|
106 |
|
107 // Tabulator Defintion |
|
108 _LIT( KTab, "\t" ); |
|
109 |
|
110 // Create formatted item string. |
|
111 // list_single_large_pane: |
|
112 // list item string format: "0\tTextLabel" |
|
113 // where 0 is an index to icon array |
|
114 TPtr16 buf( iBuffer->Des()); |
|
115 buf.Zero(); |
|
116 |
|
117 // Append the Icon Index |
|
118 buf.AppendNum( aIndex ); |
|
119 |
|
120 // Append the Tab Key |
|
121 buf.Append( KTab ); |
|
122 |
|
123 // Append the Application Information |
|
124 buf.Append(( *iAppArray )[aIndex].Name()); |
|
125 |
|
126 return buf; |
|
127 } |