|
1 /* |
|
2 * Copyright (c) 2006 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 CDestListboxModel |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknIconArray.h> |
|
19 #include <aknlists.h> |
|
20 #include <StringLoader.h> |
|
21 #include <cmmanager.rsg> |
|
22 |
|
23 #include "destlistboxmodel.h" |
|
24 #include "destlistitem.h" |
|
25 #include "destlistitemlist.h" |
|
26 #include <cmcommonconstants.h> |
|
27 |
|
28 using namespace CMManager; |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CDestListboxModel::CDestListboxModel |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CDestListboxModel::CDestListboxModel() |
|
35 : iOffset( 0 ) |
|
36 { |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CDestListboxModel::~CDestListboxModel |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CDestListboxModel::~CDestListboxModel() |
|
44 { |
|
45 ResetAndDestroy(); // deletes all elements... |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CDestListboxModel::MdcaCount |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 TInt CDestListboxModel::MdcaCount() const |
|
53 { |
|
54 return Count(); |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CDestListboxModel::SetOwnIconOffset |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CDestListboxModel::SetOwnIconOffset( TInt aOffset ) |
|
62 { |
|
63 iOffset = aOffset; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CDestListboxModel::MdcaPoint |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 TPtrC CDestListboxModel::MdcaPoint( TInt aIndex ) const |
|
71 { |
|
72 // We need to cast away the const-ness from the buffer. |
|
73 // It was definitely made for formatting! |
|
74 FormatListboxText( aIndex, |
|
75 ( MUTABLE_CAST( TBuf<KMaxDestListboxName>&, iBuf ) ) ); |
|
76 |
|
77 return iBuf; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CDestListboxModel::FormatListboxTextL |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CDestListboxModel::FormatListboxTextL( TInt aIndex, |
|
85 TDes& aBuf ) const |
|
86 { |
|
87 aBuf.Zero(); |
|
88 HBufC* secondLine; |
|
89 if ( At(aIndex)->NumOfCMs() ) |
|
90 { |
|
91 if ( At(aIndex)->NumOfCMs() == 1 ) |
|
92 { |
|
93 secondLine = |
|
94 StringLoader::LoadLC( R_CMMANAGERUI_CONN_METHODS_AMOUNT_ONE ); |
|
95 } |
|
96 else |
|
97 { |
|
98 secondLine = |
|
99 StringLoader::LoadLC( R_CMMANAGERUI_CONN_METHODS_AMOUNT_MANY, |
|
100 At( aIndex )->NumOfCMs() ); |
|
101 } |
|
102 } |
|
103 else |
|
104 { |
|
105 if ( At( aIndex )->Uid() == KDestItemNewConnection ) |
|
106 { |
|
107 //add cm if list is empty |
|
108 secondLine = |
|
109 StringLoader::LoadLC( R_CMMANAGERUI_ADD_CONNECTION_METHOD ); |
|
110 } |
|
111 else |
|
112 { |
|
113 secondLine = |
|
114 StringLoader::LoadLC( R_CMMANAGERUI_CONN_METHODS_AMOUNT_NONE ); |
|
115 } |
|
116 } |
|
117 |
|
118 if ( At( aIndex )->IsDefault() ) |
|
119 { |
|
120 aBuf.Format( KListItemFormatDestProt, |
|
121 At(aIndex)->IconIndex(), |
|
122 &At(aIndex)->Name(), |
|
123 secondLine, |
|
124 KDestReservedIconIndexDefaultConn ); |
|
125 } |
|
126 else |
|
127 { |
|
128 // Protected icon must be put only if the protection level is 1 |
|
129 if ( At( aIndex )->GetProtectionLevel() == EProtLevel1 ) |
|
130 { |
|
131 aBuf.Format( KListItemFormatDestProt, |
|
132 At(aIndex)->IconIndex(), |
|
133 &At(aIndex)->Name(), |
|
134 secondLine, |
|
135 KDestReservedIconIndexProtected ); |
|
136 } |
|
137 else |
|
138 { |
|
139 aBuf.Format( KListItemFormatDest, |
|
140 At(aIndex)->IconIndex(), |
|
141 &At(aIndex)->Name(), |
|
142 secondLine ); |
|
143 } |
|
144 } |
|
145 CleanupStack::PopAndDestroy( secondLine ); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CDestListboxModel::FormatListboxText |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 |
|
153 void CDestListboxModel::FormatListboxText( TInt aIndex, |
|
154 TDes& aBuf ) const |
|
155 { |
|
156 TRAP_IGNORE( FormatListboxTextL( aIndex, aBuf ) ); |
|
157 } |