136 } |
137 } |
137 |
138 |
138 void CMemSpyViewServerList::SetListBoxModelL() |
139 void CMemSpyViewServerList::SetListBoxModelL() |
139 { |
140 { |
140 TInt err = KErrNone; |
141 TInt err = KErrNone; |
141 iModel = NULL; |
142 |
142 |
143 RArray<CMemSpyApiServer*> servers; |
143 TRAP( err, iMemSpySession.GetServersL( iServers, iSort ) ); |
144 iMemSpySession.GetServersL( servers, iSort ); |
144 |
145 CleanupClosePushL( servers ); |
145 if ( err == KErrNone ) |
146 |
146 { |
147 // copy servers to iServers array |
147 iModel = new (ELeave) CDesC16ArrayFlat( iServers.Count() ); //array for formated items |
148 iServers.ResetAndDestroy(); |
148 _LIT(KSession, "session"); |
149 for (TInt i=0; i<servers.Count(); i++) |
149 |
150 { |
150 for( TInt i = 0; i < iServers.Count(); i++ ) |
151 iServers.Append(servers[i]); |
151 { |
152 } |
152 HBufC* combined = HBufC::NewLC( iServers[i]->Name().Length() + 128 ); |
153 |
153 |
154 CleanupStack::PopAndDestroy( &servers ); |
154 TPtr pCombined( combined->Des() ); |
155 |
155 pCombined.Zero(); |
156 CDesCArrayFlat* model = new (ELeave) CDesC16ArrayFlat( iServers.Count() ); //array for formated items |
156 pCombined.Copy( _L("\t") ); |
157 CleanupStack::PushL( model ); |
157 |
158 |
158 if( iServers[i]->Name() != KNullDesC ) |
159 _LIT(KSession, "session"); |
159 { |
160 |
160 pCombined.Append( iServers[i]->Name() ); |
161 for( TInt i = 0; i < iServers.Count(); i++ ) |
161 } |
162 { |
162 |
163 HBufC* combined = HBufC::NewLC( iServers[i]->Name().Length() + 128 ); |
163 pCombined.Append( _L("\t\t") ); |
164 |
164 TBuf<16> count; |
165 TPtr pCombined( combined->Des() ); |
165 _LIT( KCount, "%d session"); |
166 pCombined.Zero(); |
166 |
167 pCombined.Copy( _L("\t") ); |
167 count.Format( KCount, iServers[i]->SessionCount() ); |
168 |
168 pCombined.Append( count ); |
169 if( iServers[i]->Name() != KNullDesC ) |
169 |
170 { |
170 if( iServers[i]->SessionCount() != 1 ) |
171 pCombined.Append( iServers[i]->Name() ); |
171 { |
172 } |
172 _LIT( KS, "s" ); |
173 |
173 pCombined.Append( KS ); |
174 pCombined.Append( _L("\t\t") ); |
174 } |
175 TBuf<16> count; |
175 |
176 _LIT( KCount, "%d session"); |
176 iModel->AppendL( pCombined ); |
177 |
177 |
178 count.Format( KCount, iServers[i]->SessionCount() ); |
178 CleanupStack::PopAndDestroy(combined); |
179 pCombined.Append( count ); |
179 } |
180 |
180 } |
181 if( iServers[i]->SessionCount() != 1 ) |
181 |
182 { |
182 // |
183 _LIT( KS, "s" ); |
|
184 pCombined.Append( KS ); |
|
185 } |
|
186 |
|
187 model->AppendL( pCombined ); |
|
188 |
|
189 CleanupStack::PopAndDestroy( combined ); |
|
190 } |
|
191 |
183 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
192 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
184 listbox->Model()->SetItemTextArray( iModel ); |
193 listbox->Model()->SetItemTextArray( model ); |
185 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
194 listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
195 |
|
196 CleanupStack::Pop( model ); |
186 } |
197 } |
187 |
198 |
188 |
199 |
189 void CMemSpyViewServerList::HandleListBoxItemActionedL( TInt aCurrentIndex ) |
200 void CMemSpyViewServerList::HandleListBoxItemActionedL( TInt aCurrentIndex ) |
190 { |
201 { |
191 if ( aCurrentIndex >= 0 && aCurrentIndex < iServers.Count() ) |
202 if ( aCurrentIndex >= 0 && aCurrentIndex < iListBox->Model()->NumberOfItems() ) |
192 { |
203 { |
193 iActionedItemIndex = aCurrentIndex; |
204 iActionedItemIndex = aCurrentIndex; |
194 } |
205 } |
195 else |
206 else |
196 { |
207 { |