44
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-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: Implement method in dialog for user DB management
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
#include <aknlists.h> // CAknSingleStyleListBox
|
|
30 |
#include <barsread.h> // TResource Reader
|
|
31 |
#include <eikclbd.h> // CColumnListBoxData
|
|
32 |
#include <aknsfld.h> //CAknSearchField
|
|
33 |
#include <AknQueryDialog.h> //CAknTextQueryDialog
|
|
34 |
#include <AknUtils.h> //AknSelectionService , CAknFilteredTextListBoxModel
|
|
35 |
#include <StringLoader.h> //StringLoader
|
|
36 |
#include <aknnotewrappers.h> //CAknWarningNote
|
|
37 |
#include <AknProgressDialog.h> //CAknProgressDialog
|
|
38 |
#include <AknDialog.h> //CAknDialog
|
|
39 |
#include <akncontext.h> //CAknContextPane
|
|
40 |
#include <AknWaitDialog.h> //CAknWaitDialog
|
|
41 |
#include <AknProgressDialog.h> //CAknProgressDialog
|
|
42 |
#include <eikprogi.h> //CEikProgressInfo
|
|
43 |
#include <eikbtgpc.h> //CEikButtonGroupContainer
|
|
44 |
#include <eikmenub.h>
|
|
45 |
#include <charconv.h> //CCnvCharacterSetConverter
|
|
46 |
#include <f32file.h> //RFs
|
|
47 |
#include <eikedwin.h> //CEikEdwin
|
|
48 |
#include <akntitle.h> //CAknTitlePane
|
|
49 |
#include <aknfep.rsg>
|
|
50 |
#include "AknFep.hrh"
|
|
51 |
#include "aknfepuserdbdlg.h"
|
|
52 |
#include "dbmanagement.h"
|
|
53 |
#include "AknFepManagerUIInterface.h"
|
|
54 |
#include "AknFepManager.h"
|
|
55 |
#include "aknfepuserdbquerydlg.h"
|
|
56 |
|
|
57 |
const TInt KListBoxItemMaxLength = 8;
|
|
58 |
const TInt KErrMsgMaxLength = 60;
|
|
59 |
const TInt KFindBoxInputMaxLength = 7;
|
|
60 |
const TInt KCDesCArraySize = 1;
|
|
61 |
_LIT( KItemStart, "\t" );
|
|
62 |
_LIT( KSearchTextEmpty, "" );
|
|
63 |
|
|
64 |
CAknFepUserdbDlg::CAknFepUserdbDlg(
|
|
65 |
TInt &aValue, CArrayFix< TInt> *aSelectedItems, MDesCArray *aArray,
|
|
66 |
CPtiEngine* aPtiEngine, CAknFepManager* aOwner, MEikCommandObserver *aObserver) :
|
|
67 |
CAknMarkableListDialog( aValue, aSelectedItems, aArray, aObserver ),
|
|
68 |
iPtiEngine( aPtiEngine ),
|
|
69 |
iOwner( aOwner ),
|
|
70 |
iOldIndex( 0 ),
|
|
71 |
iOldLanguage( 0 ),
|
|
72 |
iOldCbaRes( 0 )
|
|
73 |
{
|
|
74 |
// No implementation required
|
|
75 |
}
|
|
76 |
|
|
77 |
CAknFepUserdbDlg::~CAknFepUserdbDlg()
|
|
78 |
{
|
|
79 |
delete iDBEngine;
|
|
80 |
iDBEngine = NULL;
|
|
81 |
iPtiEngine = NULL;
|
|
82 |
iOwner = NULL;
|
|
83 |
iQueryDlg = NULL;
|
|
84 |
if ( iEikonEnv && iContextMenuBar )
|
|
85 |
{
|
|
86 |
iEikonEnv->EikAppUi()->RemoveFromStack( iContextMenuBar );
|
|
87 |
delete iContextMenuBar;
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
CAknFepUserdbDlg* CAknFepUserdbDlg::NewL(
|
|
92 |
TInt &aOpenedItem, CArrayFix< TInt> *aSelectedItems, MDesCArray *aArray,
|
|
93 |
TInt aMenuBarResourceId, CPtiEngine* aPtiEngine, CAknFepManager* aOwner,
|
|
94 |
MEikCommandObserver *aObserver )
|
|
95 |
{
|
|
96 |
CAknFepUserdbDlg* self = new( ELeave ) CAknFepUserdbDlg( aOpenedItem,
|
|
97 |
aSelectedItems, aArray, aPtiEngine, aOwner, aObserver );
|
|
98 |
CleanupStack::PushL( self );
|
|
99 |
self->ConstructL( aMenuBarResourceId );
|
|
100 |
CleanupStack::Pop( self ); // self;
|
|
101 |
return self;
|
|
102 |
}
|
|
103 |
|
|
104 |
void CAknFepUserdbDlg::ConstructL( TInt aMenuBarResourceId )
|
|
105 |
{
|
|
106 |
CAknSelectionListDialog::ConstructL( aMenuBarResourceId );
|
|
107 |
this->PrepareLC( R_AKNFEP_LISTDLG_DIALOG );
|
|
108 |
HBufC* message = StringLoader::LoadLC( R_AKNFEP_USER_DB_LIST_NO_ITEM_TEXT );
|
|
109 |
ListBox()->View()->SetListEmptyTextL( *message );
|
|
110 |
ConstructContextMenuL();
|
|
111 |
|
|
112 |
//the DB engine init
|
|
113 |
iDBEngine = CDBManagement::NewL( iOwner );
|
|
114 |
CleanupStack::PopAndDestroy( message ); //message
|
|
115 |
}
|
|
116 |
|
|
117 |
TBool CAknFepUserdbDlg::InitListBoxItemL()
|
|
118 |
{
|
|
119 |
iItems = new( ELeave ) CDesCArrayFlat( KCDesCArraySize );
|
|
120 |
|
|
121 |
TBuf<KErrMsgMaxLength> errMsg;
|
|
122 |
|
|
123 |
//get the phrases from the DB
|
|
124 |
if ( !iDBEngine->GetPhraseFromDBL( *iItems ) )
|
|
125 |
{
|
|
126 |
iDBEngine->GetErrMsg( errMsg );
|
|
127 |
//note fot err message
|
|
128 |
CAknWarningNote* note = new( ELeave ) CAknWarningNote();
|
|
129 |
note->SetTone( CAknNoteDialog::EWarningTone );
|
|
130 |
note->ExecuteLD( errMsg );
|
|
131 |
}
|
|
132 |
else
|
|
133 |
{
|
|
134 |
InsertIconL( iItems );
|
|
135 |
}
|
|
136 |
CAknSingleStyleListBox* listBox=
|
|
137 |
static_cast<CAknSingleStyleListBox*>( Control( ESelectionListControl ) );
|
|
138 |
CTextListBoxModel* model = listBox->Model();
|
|
139 |
if ( iItems && iItems->Count() != 0 )
|
|
140 |
{
|
|
141 |
model->SetItemTextArray( iItems );
|
|
142 |
model->SetOwnershipType( ELbmOwnsItemArray );
|
|
143 |
ListBox()->HandleItemAdditionL();
|
|
144 |
return ETrue;
|
|
145 |
}
|
|
146 |
else
|
|
147 |
{
|
|
148 |
model->SetItemTextArray( iItems );
|
|
149 |
model->SetOwnershipType( ELbmOwnsItemArray );
|
|
150 |
return EFalse;
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
void CAknFepUserdbDlg::AddItemL()
|
|
155 |
{
|
|
156 |
CAknSingleStyleListBox* listbox =
|
|
157 |
static_cast<CAknSingleStyleListBox*>( Control( ESelectionListControl ) );
|
|
158 |
// New item text
|
|
159 |
TBuf<KListBoxItemMaxLength> itemText;
|
|
160 |
TBuf<KErrMsgMaxLength> errMsg;
|
|
161 |
if ( FindBox()->TextLength() != 0 )
|
|
162 |
{
|
|
163 |
FindBox()->GetSearchText( itemText );
|
|
164 |
}
|
|
165 |
FindBox()->SetFocus( EFalse );
|
|
166 |
HBufC* prompt = StringLoader::LoadLC( R_AKNFEP_USER_DB_LIST_ADD_ITEM_TEXT );
|
|
167 |
CAknFepUserDBQueryDlg* dialog =
|
|
168 |
CAknFepUserDBQueryDlg::NewL( iDBEngine, itemText, *prompt );
|
|
169 |
iQueryDlg = dialog;
|
|
170 |
CleanupStack::PopAndDestroy( prompt );
|
|
171 |
//Execute dialog,
|
|
172 |
//In the dialog it will check input and show waring not
|
|
173 |
if ( dialog->ExecuteLD( R_AKNFEP_LISTBOX_DATA_QUERY_DIALOG ) )
|
|
174 |
{
|
|
175 |
TInt currentIndex = 0;
|
|
176 |
CAknFilteredTextListBoxModel* model =
|
|
177 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
178 |
CDesCArray* itemArray =
|
|
179 |
static_cast<CDesC16ArrayFlat*>( model->ItemTextArray() );
|
|
180 |
|
|
181 |
//Add '\t' at the beginning of itemText for find
|
|
182 |
itemText.Insert( 0, KItemStart() );
|
|
183 |
//
|
|
184 |
TInt ret = itemArray->Find( itemText, currentIndex, ECmpCollated);
|
|
185 |
if ( ret != 0 )
|
|
186 |
{
|
|
187 |
//add the phrase to db
|
|
188 |
itemText.Trim();
|
|
189 |
if ( !iDBEngine->AddPhraseToDB( itemText ) )
|
|
190 |
{
|
|
191 |
iDBEngine->GetErrMsg( errMsg );
|
|
192 |
//note fot err message
|
|
193 |
CAknWarningNote* note = new( ELeave ) CAknWarningNote();
|
|
194 |
note->SetTone( CAknNoteDialog::EWarningTone );
|
|
195 |
note->ExecuteLD( errMsg );
|
|
196 |
// add by chen
|
|
197 |
return;
|
|
198 |
}
|
|
199 |
// Add '\t' in front of text
|
|
200 |
itemText.Insert( 0, KItemStart() );
|
|
201 |
// Insert item to the item array
|
|
202 |
if ( itemArray->Count() > 0 )
|
|
203 |
{
|
|
204 |
itemArray->InsertL( currentIndex, itemText );
|
|
205 |
}
|
|
206 |
else
|
|
207 |
{
|
|
208 |
itemArray->InsertL( 0, itemText );
|
|
209 |
}
|
|
210 |
// Update the listbox
|
|
211 |
listbox->HandleItemAdditionL();
|
|
212 |
itemArray->Sort(ECmpCollated);
|
|
213 |
|
|
214 |
FindBox()->SetSearchTextL( KSearchTextEmpty );
|
|
215 |
ResetSearchFieldL();
|
|
216 |
model->Filter()->HandleItemArrayChangeL();
|
|
217 |
|
|
218 |
//Highlight the item you have just edited
|
|
219 |
itemArray->Find( itemText, currentIndex, ECmpCollated );
|
|
220 |
listbox->SetCurrentItemIndexAndDraw( currentIndex );
|
|
221 |
|
|
222 |
}
|
|
223 |
else
|
|
224 |
{
|
|
225 |
FindBox()->SetSearchTextL( KSearchTextEmpty );
|
|
226 |
ResetSearchFieldL();
|
|
227 |
listbox->SetCurrentItemIndexAndDraw( currentIndex );
|
|
228 |
}
|
|
229 |
|
|
230 |
model->Filter()->UpdateCachedDataL();
|
|
231 |
UpdateListBoxL();
|
|
232 |
}
|
|
233 |
}
|
|
234 |
|
|
235 |
void CAknFepUserdbDlg::RemoveItemL()
|
|
236 |
{
|
|
237 |
//error message
|
|
238 |
TBuf<KErrMsgMaxLength> errMsg;
|
|
239 |
TBuf<KListBoxItemMaxLength> removePhrase;
|
|
240 |
TInt oldIndex = ListBox()->View()->CurrentItemIndex();
|
|
241 |
CAknFilteredTextListBoxModel* model =
|
|
242 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
243 |
CDesCArrayFlat* item =
|
|
244 |
static_cast<CDesCArrayFlat*>( model->ItemTextArray() );
|
|
245 |
model->Filter()->UpdateSelectionIndexesL();
|
|
246 |
TInt markItems = model->Filter()->SelectionIndexes()->Count();
|
|
247 |
if ( markItems )
|
|
248 |
{
|
|
249 |
HBufC * message = StringLoader::LoadLC(
|
|
250 |
R_AKNFEP_DELETE_CONFIRMATION_TEXT, markItems,
|
|
251 |
iEikonEnv ); //message
|
|
252 |
CAknQueryDialog* delsomenote =
|
|
253 |
CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
|
|
254 |
delsomenote->SetPromptL( *message );
|
|
255 |
if ( delsomenote->ExecuteLD( R_AKNFEP_DELETE_QUERY_DIALOG ) )
|
|
256 |
{
|
|
257 |
iProgressDialog = new (ELeave) CAknProgressDialog(
|
|
258 |
( REINTERPRET_CAST( CEikDialog**, &iProgressDialog ) ), ETrue );
|
|
259 |
iProgressDialog->PrepareLC( R_AKNFEP_WAIT_DIALOG );
|
|
260 |
iProgressInfo = iProgressDialog->GetProgressInfoL();
|
|
261 |
iProgressInfo->SetFinalValue( markItems );
|
|
262 |
iProgressDialog->RunLD();
|
|
263 |
CArrayFix<TInt>* selectionArray = new( ELeave ) CArrayFixFlat<TInt>( markItems );
|
|
264 |
CleanupStack::PushL( selectionArray ); //message, selectionArray
|
|
265 |
//loop for copy selection index
|
|
266 |
for ( TInt idx = markItems; idx > 0; idx-- )
|
|
267 |
{
|
|
268 |
selectionArray->AppendL( model->Filter()->SelectionIndexes()->At( idx-1 ) );
|
|
269 |
}
|
|
270 |
TKeyArrayFix* key= new (ELeave) TKeyArrayFix(0, ECmpTInt);
|
|
271 |
CleanupStack::PushL( key ); //message, selectionArray, key
|
|
272 |
//sort selection array
|
|
273 |
selectionArray->Sort( *key );
|
|
274 |
CleanupStack::PopAndDestroy( key ); //message, selectionArray
|
|
275 |
// loop throught the selected item indexes, and delete items
|
|
276 |
for ( TInt idx = markItems; idx > 0; idx-- )
|
|
277 |
{
|
|
278 |
// get the index of the selected item
|
|
279 |
TInt itemIndex = selectionArray->At( idx-1 );
|
|
280 |
//romve the phrase form the db
|
|
281 |
removePhrase.Copy( item->MdcaPoint( itemIndex ) );
|
|
282 |
removePhrase.Trim();
|
|
283 |
if( !iDBEngine->RemovePhraseFromDB( removePhrase ) )
|
|
284 |
{
|
|
285 |
iDBEngine->GetErrMsg( errMsg );
|
|
286 |
iProgressDialog->ProcessFinishedL();
|
|
287 |
iProgressDialog = NULL;
|
|
288 |
CleanupStack::PopAndDestroy( selectionArray ); //message
|
|
289 |
CleanupStack::PopAndDestroy( message );//
|
|
290 |
//note fot err message
|
|
291 |
CAknWarningNote* errnote = new( ELeave ) CAknWarningNote();
|
|
292 |
errnote->SetTone( CAknNoteDialog::EWarningTone );
|
|
293 |
errnote->ExecuteLD( errMsg );
|
|
294 |
return;
|
|
295 |
}
|
|
296 |
iProgressInfo->IncrementAndDraw(1);
|
|
297 |
//delte the item
|
|
298 |
item->Delete( itemIndex );
|
|
299 |
}
|
|
300 |
CleanupStack::PopAndDestroy( selectionArray ); //message
|
|
301 |
iProgressDialog->ProcessFinishedL();
|
|
302 |
iProgressDialog = NULL;
|
|
303 |
|
|
304 |
// Update the listbox
|
|
305 |
ResetSearchFieldL();
|
|
306 |
ListBox()->HandleItemRemovalL();
|
|
307 |
model->Filter()->HandleItemArrayChangeL();
|
|
308 |
model->Filter()->SelectionIndexes()->Reset();
|
|
309 |
ListBox()->View()->ClearSelection();
|
|
310 |
}
|
|
311 |
CleanupStack::PopAndDestroy( message );//
|
|
312 |
}
|
|
313 |
else
|
|
314 |
{
|
|
315 |
HBufC * message = StringLoader::LoadLC(
|
|
316 |
R_AKNFEP_DELETE_CONFIRMATION_TEXT, 1,
|
|
317 |
iEikonEnv );
|
|
318 |
CAknQueryDialog* delonenote =
|
|
319 |
CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
|
|
320 |
delonenote->SetPromptL( *message );
|
|
321 |
if ( delonenote->ExecuteLD( R_AKNFEP_DELETE_QUERY_DIALOG ) )
|
|
322 |
{
|
|
323 |
//remove from db
|
|
324 |
removePhrase.Copy( model->ItemText( ListBox()->CurrentItemIndex() ) );
|
|
325 |
removePhrase.Delete( 0, 1 );
|
|
326 |
if( !iDBEngine->RemovePhraseFromDB( removePhrase ) )
|
|
327 |
{
|
|
328 |
iDBEngine->GetErrMsg( errMsg );
|
|
329 |
//note fot err message
|
|
330 |
CAknWarningNote* errnote = new( ELeave ) CAknWarningNote();
|
|
331 |
errnote->ExecuteLD( errMsg );
|
|
332 |
CleanupStack::PopAndDestroy( message );
|
|
333 |
return;
|
|
334 |
}
|
|
335 |
TInt itemIndex = ListBox()->View()->CurrentItemIndex();
|
|
336 |
//get the actual index of list
|
|
337 |
TInt actualIndex = FindActualIndex( itemIndex );
|
|
338 |
// Remove highlighted item from the listbox.
|
|
339 |
item->Delete( actualIndex );
|
|
340 |
// Update the listbox
|
|
341 |
ResetSearchFieldL();
|
|
342 |
}
|
|
343 |
CleanupStack::PopAndDestroy( message );
|
|
344 |
}
|
|
345 |
// If focused item is out of range, bring it forth
|
|
346 |
if ( ( ( item->Count()-1 ) >= 0 ) && FindBox()->TextLength() == 0 )
|
|
347 |
{
|
|
348 |
if ( ( oldIndex > ( item->Count()-1 ) ))
|
|
349 |
{
|
|
350 |
ListBox()->SetCurrentItemIndexAndDraw( item->Count()-1 );
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
ListBox()->SetCurrentItemIndexAndDraw( oldIndex );
|
|
355 |
}
|
|
356 |
}
|
|
357 |
UpdateListBoxL();
|
|
358 |
}
|
|
359 |
|
|
360 |
void CAknFepUserdbDlg::EditItemL()
|
|
361 |
{
|
|
362 |
CAknSingleStyleListBox* listbox =
|
|
363 |
static_cast<CAknSingleStyleListBox*>( Control( ESelectionListControl ) );
|
|
364 |
|
|
365 |
// If we don't have items, do nothing and return
|
|
366 |
if ( listbox->Model()->NumberOfItems() < 1 )
|
|
367 |
{
|
|
368 |
return;
|
|
369 |
}
|
|
370 |
CTextListBoxModel* model = listbox->Model();
|
|
371 |
// New item text
|
|
372 |
TBuf<KListBoxItemMaxLength> itemText;
|
|
373 |
TBuf<KErrMsgMaxLength> errMsg;
|
|
374 |
TBuf<KListBoxItemMaxLength> itemOldText;
|
|
375 |
itemText.Copy( model->ItemText(listbox->CurrentItemIndex () ) );
|
|
376 |
itemText.Trim();
|
|
377 |
itemOldText.Copy( model->ItemText( listbox->CurrentItemIndex() ) );
|
|
378 |
itemOldText.Trim();
|
|
379 |
HBufC* prompt = StringLoader::LoadLC( R_AKNFEP_USER_DB_LIST_EDIT_ITEM_TEXT );
|
|
380 |
CAknFepUserDBQueryDlg* dialog =
|
|
381 |
CAknFepUserDBQueryDlg::NewL( iDBEngine, itemText, *prompt );
|
|
382 |
iQueryDlg = dialog;
|
|
383 |
CleanupStack::PopAndDestroy( prompt );
|
|
384 |
// Execute dialog
|
|
385 |
if ( dialog->ExecuteLD( R_AKNFEP_LISTBOX_DATA_QUERY_DIALOG ) )
|
|
386 |
{
|
|
387 |
TInt currentIndex = 0;
|
|
388 |
CDesCArray* itemArray =
|
|
389 |
static_cast<CDesC16ArrayFlat*>( model->ItemTextArray() );
|
|
390 |
|
|
391 |
// Add '\t' in front of text for find
|
|
392 |
itemText.Insert( 0, KItemStart() );
|
|
393 |
//Find if the text is exist
|
|
394 |
TInt ret = itemArray->Find( itemText, currentIndex, ECmpCollated );
|
|
395 |
if ( ret != 0 )
|
|
396 |
{
|
|
397 |
//edit the phrase from db
|
|
398 |
itemText.Trim();
|
|
399 |
if(!iDBEngine->EditPhraseFromDB( itemOldText, itemText ) )
|
|
400 |
{
|
|
401 |
iDBEngine->GetErrMsg( errMsg );
|
|
402 |
|
|
403 |
//note fot err message
|
|
404 |
CAknWarningNote* note = new( ELeave ) CAknWarningNote();
|
|
405 |
note->ExecuteLD( errMsg );
|
|
406 |
return;
|
|
407 |
}
|
|
408 |
currentIndex = ListBox()->CurrentItemIndex();
|
|
409 |
//get the actual index of list
|
|
410 |
TInt actualIndex = FindActualIndex( currentIndex );
|
|
411 |
|
|
412 |
// Remove highlighted item from the listbox.
|
|
413 |
itemArray->Delete( actualIndex );
|
|
414 |
|
|
415 |
// Add '\t' in front of text
|
|
416 |
itemText.Insert( 0, KItemStart() );
|
|
417 |
|
|
418 |
// Insert item to the item array
|
|
419 |
itemArray->InsertL( actualIndex, itemText );
|
|
420 |
|
|
421 |
// Update the listbox
|
|
422 |
listbox->HandleItemAdditionL();
|
|
423 |
itemArray->Sort(ECmpCollated);
|
|
424 |
|
|
425 |
if ( FindBox()->TextLength() != 0 )
|
|
426 |
{
|
|
427 |
FindBox()->SetSearchTextL( KSearchTextEmpty );
|
|
428 |
ResetSearchFieldL();
|
|
429 |
}
|
|
430 |
|
|
431 |
ListBox()->View()->ClearSelection();
|
|
432 |
CAknFilteredTextListBoxModel* filterModel =
|
|
433 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
434 |
filterModel->Filter()->HandleItemArrayChangeL();
|
|
435 |
filterModel->Filter()->UpdateCachedDataL();
|
|
436 |
|
|
437 |
//SetHightlight
|
|
438 |
itemArray->Find( itemText, currentIndex, ECmpCollated );
|
|
439 |
ListBox()->SetCurrentItemIndexAndDraw( currentIndex );
|
|
440 |
}
|
|
441 |
else
|
|
442 |
{
|
|
443 |
//get the actual index of list
|
|
444 |
TInt actualIndex = FindActualIndex( listbox->CurrentItemIndex() );
|
|
445 |
if ( currentIndex != actualIndex )
|
|
446 |
{
|
|
447 |
itemOldText.Copy( model->ItemText( listbox->CurrentItemIndex() ) );
|
|
448 |
itemOldText.Trim();
|
|
449 |
//Here need user db engine
|
|
450 |
if( !iDBEngine->RemovePhraseFromDB( itemOldText ) )
|
|
451 |
{
|
|
452 |
iDBEngine->GetErrMsg( errMsg );
|
|
453 |
|
|
454 |
//note fot err message
|
|
455 |
CAknWarningNote* note = new( ELeave ) CAknWarningNote();
|
|
456 |
note->ExecuteLD( errMsg );
|
|
457 |
return;
|
|
458 |
}
|
|
459 |
|
|
460 |
currentIndex = ListBox()->CurrentItemIndex();
|
|
461 |
|
|
462 |
//get the actual index of list
|
|
463 |
actualIndex = FindActualIndex( currentIndex );
|
|
464 |
|
|
465 |
// Remove highlighted item from the listbox.
|
|
466 |
itemArray->Delete( actualIndex );
|
|
467 |
|
|
468 |
listbox->HandleItemRemovalL();
|
|
469 |
itemArray->Sort(ECmpCollated);
|
|
470 |
|
|
471 |
if ( FindBox()->TextLength() != 0 )
|
|
472 |
{
|
|
473 |
FindBox()->SetSearchTextL( KSearchTextEmpty );
|
|
474 |
ResetSearchFieldL();
|
|
475 |
}
|
|
476 |
|
|
477 |
ListBox()->View()->ClearSelection();
|
|
478 |
CAknFilteredTextListBoxModel* filterModel =
|
|
479 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
480 |
filterModel->Filter()->HandleItemArrayChangeL();
|
|
481 |
filterModel->Filter()->UpdateCachedDataL();
|
|
482 |
|
|
483 |
//SetHightlight
|
|
484 |
itemArray->Find( itemText, currentIndex, ECmpCollated );
|
|
485 |
ListBox()->SetCurrentItemIndexAndDraw( currentIndex );
|
|
486 |
}
|
|
487 |
}
|
|
488 |
UpdateListBoxL();
|
|
489 |
}
|
|
490 |
}
|
|
491 |
|
|
492 |
void CAknFepUserdbDlg::CmdMarkL( TInt aItemIndex, TBool aMark )
|
|
493 |
{
|
|
494 |
CAknSingleStyleListBox* listbox =
|
|
495 |
static_cast<CAknSingleStyleListBox*>( Control( ESelectionListControl ) );
|
|
496 |
CTextListBoxModel* model = listbox->Model();
|
|
497 |
TInt itemCount = model->NumberOfItems();
|
|
498 |
CListBoxView* listBoxView = listbox->View();
|
|
499 |
if ( aMark )
|
|
500 |
{
|
|
501 |
for ( TInt i = 0; i < itemCount; i++ )
|
|
502 |
if ( aItemIndex == -1 || aItemIndex == i )
|
|
503 |
listBoxView->SelectItemL( i );
|
|
504 |
}
|
|
505 |
else
|
|
506 |
{
|
|
507 |
for ( TInt i = 0; i < itemCount; i++ )
|
|
508 |
{
|
|
509 |
if ( aItemIndex == -1 || aItemIndex == i )
|
|
510 |
{
|
|
511 |
listBoxView->DeselectItem( i );
|
|
512 |
}
|
|
513 |
}
|
|
514 |
}
|
|
515 |
CAknFilteredTextListBoxModel* filterModel =
|
|
516 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
517 |
filterModel->Filter()->UpdateCachedDataL();
|
|
518 |
}
|
|
519 |
|
|
520 |
void CAknFepUserdbDlg::ChangeCurrentCbaL ( TInt aCbaResourceId )
|
|
521 |
{
|
|
522 |
if ( iOwner->IsEntryPhrase() || iOldCbaRes == aCbaResourceId )
|
|
523 |
{
|
|
524 |
return;
|
|
525 |
}
|
|
526 |
CEikButtonGroupContainer& cba = ButtonGroupContainer();
|
|
527 |
cba.SetCommandSetL( aCbaResourceId );
|
|
528 |
cba.AddCommandSetToStackL( aCbaResourceId );
|
|
529 |
iOldCbaRes = aCbaResourceId;
|
|
530 |
cba.DrawNow();
|
|
531 |
}
|
|
532 |
|
|
533 |
void CAknFepUserdbDlg::ProcessCommandL( TInt aCommandId )
|
|
534 |
{
|
|
535 |
HideMenu();
|
|
536 |
|
|
537 |
iContextMenuBar->StopDisplayingMenuBar();
|
|
538 |
|
|
539 |
switch ( aCommandId )
|
|
540 |
{
|
|
541 |
case EAknCmdUserDBAdd:
|
|
542 |
{
|
|
543 |
AddItemL();
|
|
544 |
}
|
|
545 |
break;
|
|
546 |
case EAknCmdUserDBEdit:
|
|
547 |
{
|
|
548 |
EditItemL();
|
|
549 |
}
|
|
550 |
break;
|
|
551 |
case EAknCmdUserDBDelete:
|
|
552 |
{
|
|
553 |
RemoveItemL();
|
|
554 |
}
|
|
555 |
break;
|
|
556 |
case EAknCmdMark:
|
|
557 |
case EAknMarkAll:
|
|
558 |
case EAknCmdUnmark:
|
|
559 |
case EAknUnmarkAll:
|
|
560 |
{
|
|
561 |
AknSelectionService::HandleMarkableListProcessCommandL( aCommandId, ListBox() );
|
|
562 |
UpdateListBoxL( aCommandId );
|
|
563 |
}
|
|
564 |
break;
|
|
565 |
default:
|
|
566 |
{
|
|
567 |
break;
|
|
568 |
}
|
|
569 |
}
|
|
570 |
}
|
|
571 |
|
|
572 |
TBool CAknFepUserdbDlg::OkToExitL( TInt aButtonId )
|
|
573 |
{
|
|
574 |
switch ( aButtonId )
|
|
575 |
{
|
|
576 |
case EAknSoftkeyOptions:
|
|
577 |
{
|
|
578 |
CAknSelectionListDialog::DisplayMenuL(); // display the menu
|
|
579 |
}
|
|
580 |
break;
|
|
581 |
case EAknCmdUserDBAdd:
|
|
582 |
{
|
|
583 |
ProcessCommandL(EAknCmdUserDBAdd);
|
|
584 |
}
|
|
585 |
break;
|
|
586 |
case EAknSoftkeyMark:
|
|
587 |
{
|
|
588 |
TInt ItemCount = ListBox()->Model()->NumberOfItems();
|
|
589 |
TInt selectedItem = ListBox()->SelectionIndexes()->Count();
|
|
590 |
if ( selectedItem < 1 && ItemCount > 0 )
|
|
591 |
{
|
|
592 |
//Show options-context-exit cba
|
|
593 |
ChangeCurrentCbaL ( R_AKNFEP_SOFTKEYS_LIST_OPTIONS_EXIT_CONTEXT );
|
|
594 |
}
|
|
595 |
}
|
|
596 |
break;
|
|
597 |
case EAknSoftkeyUnmark:
|
|
598 |
{
|
|
599 |
TInt ItemCount = ListBox()->Model()->NumberOfItems();
|
|
600 |
TInt selectedItem = ListBox()->SelectionIndexes()->Count();
|
|
601 |
if ( selectedItem == 0 && ItemCount > 0 )
|
|
602 |
{
|
|
603 |
//Show options-context-exit cba
|
|
604 |
ChangeCurrentCbaL ( R_AKNFEP_SOFTKEYS_LIST_OPTIONS_EXIT_CONTEXT );
|
|
605 |
}
|
|
606 |
}
|
|
607 |
break;
|
|
608 |
case EAknSoftkeyContextOptions:
|
|
609 |
{
|
|
610 |
TInt items = ListBox()->Model()->NumberOfItems();
|
|
611 |
if ( items )
|
|
612 |
{
|
|
613 |
ShowContextMenuL();
|
|
614 |
}
|
|
615 |
}
|
|
616 |
break;
|
|
617 |
case EAknCmdMark:
|
|
618 |
case EAknMarkAll:
|
|
619 |
case EAknCmdUnmark:
|
|
620 |
case EAknUnmarkAll:
|
|
621 |
{
|
|
622 |
ProcessCommandL( aButtonId );
|
|
623 |
}
|
|
624 |
break;
|
|
625 |
case EAknSoftkeyExit:
|
|
626 |
{
|
|
627 |
return ETrue;
|
|
628 |
}
|
|
629 |
default:
|
|
630 |
{
|
|
631 |
break;
|
|
632 |
}
|
|
633 |
}
|
|
634 |
|
|
635 |
return EFalse;
|
|
636 |
}
|
|
637 |
|
|
638 |
void CAknFepUserdbDlg::FocusChanged(TDrawNow aDrawNow)
|
|
639 |
{
|
|
640 |
if ( aDrawNow == EDrawNow )
|
|
641 |
{
|
|
642 |
if ( ( FindBox()->IsVisible() && !iOwner->IsEntryPhrase()) )
|
|
643 |
{
|
|
644 |
FindBox()->SetFocus( ETrue );
|
|
645 |
}
|
|
646 |
}
|
|
647 |
}
|
|
648 |
|
|
649 |
void CAknFepUserdbDlg::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
|
|
650 |
{
|
|
651 |
if ( aResourceId == R_AKNFEP_USERDB_DLG_MENU )
|
|
652 |
{
|
|
653 |
const CArrayFix<TInt>* itemArray = ListBox()->SelectionIndexes();
|
|
654 |
if ( itemArray->Count() != 0 )
|
|
655 |
{
|
|
656 |
aMenuPane->SetItemDimmed( EAknCmdUserDBAdd, ETrue );
|
|
657 |
aMenuPane->SetItemDimmed( EAknCmdUserDBEdit, ETrue );
|
|
658 |
}
|
|
659 |
else
|
|
660 |
{
|
|
661 |
aMenuPane->SetItemDimmed( EAknCmdUserDBAdd, EFalse );
|
|
662 |
aMenuPane->SetItemDimmed( EAknCmdUserDBEdit, EFalse );
|
|
663 |
}
|
|
664 |
}
|
|
665 |
if ( aResourceId == R_AKNFEP_MARK_UNMARK_MENUPANE )
|
|
666 |
{
|
|
667 |
TInt currentIndex = ListBox()->CurrentItemIndex();
|
|
668 |
TInt selectedItem = ListBox()->SelectionIndexes()->Count();
|
|
669 |
TInt listItems = ListBox()->Model()->NumberOfItems();
|
|
670 |
|
|
671 |
// Display mark, mark all
|
|
672 |
if ( selectedItem == 0 )
|
|
673 |
{
|
|
674 |
aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue );
|
|
675 |
aMenuPane->SetItemDimmed( EAknUnmarkAll, ETrue );
|
|
676 |
return;
|
|
677 |
}
|
|
678 |
// Display unmark, unmark all
|
|
679 |
if ( selectedItem == listItems )
|
|
680 |
{
|
|
681 |
aMenuPane->SetItemDimmed( EAknCmdMark, ETrue );
|
|
682 |
aMenuPane->SetItemDimmed( EAknMarkAll, ETrue );
|
|
683 |
return;
|
|
684 |
}
|
|
685 |
TBool isMarked = EFalse;
|
|
686 |
|
|
687 |
for ( TInt i = 0; i < selectedItem; i++ )
|
|
688 |
{
|
|
689 |
TInt selectedId = ListBox()->SelectionIndexes()->At( i );
|
|
690 |
if ( selectedId == currentIndex )
|
|
691 |
{
|
|
692 |
isMarked = ETrue;
|
|
693 |
}
|
|
694 |
}
|
|
695 |
|
|
696 |
if ( isMarked )
|
|
697 |
{
|
|
698 |
aMenuPane->SetItemDimmed( EAknCmdMark, ETrue );
|
|
699 |
}
|
|
700 |
else
|
|
701 |
{
|
|
702 |
aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue );
|
|
703 |
}
|
|
704 |
}
|
|
705 |
}
|
|
706 |
|
|
707 |
TKeyResponse CAknFepUserdbDlg::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
708 |
TEventCode aType )
|
|
709 |
{
|
|
710 |
TKeyResponse ret(EKeyWasNotConsumed);
|
|
711 |
|
|
712 |
CAknFilteredTextListBoxModel* filterModel =
|
|
713 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
714 |
|
|
715 |
TInt ItemCount = ListBox()->Model()->NumberOfItems();
|
|
716 |
|
|
717 |
ListBoxItemsChanged( ListBox() );
|
|
718 |
|
|
719 |
if ( ret != EKeyWasConsumed && aKeyEvent.iCode == EKeyPhoneEnd )
|
|
720 |
{
|
|
721 |
TryExitL( EAknSoftkeyExit );
|
|
722 |
return EKeyWasConsumed;
|
|
723 |
}
|
|
724 |
|
|
725 |
TBool claerKeyPressed = ( aType == EEventKey ) && ( aKeyEvent.iCode == EKeyBackspace );
|
|
726 |
if( claerKeyPressed && ItemCount > 0 && FindBox()->TextLength() == 0 )
|
|
727 |
{
|
|
728 |
ProcessCommandL(EAknCmdUserDBDelete);
|
|
729 |
UpdateListBoxL();
|
|
730 |
ret = EKeyWasConsumed;
|
|
731 |
}
|
|
732 |
else
|
|
733 |
{
|
|
734 |
if ( FindBox()->IsVisible() )
|
|
735 |
{
|
|
736 |
ret = CAknMarkableListDialog::OfferKeyEventL( aKeyEvent, aType );
|
|
737 |
}
|
|
738 |
else
|
|
739 |
{
|
|
740 |
ret = ListBox()->OfferKeyEventL( aKeyEvent, aType );
|
|
741 |
}
|
|
742 |
}
|
|
743 |
|
|
744 |
if ( ret != EKeyWasConsumed && aType == EEventKey &&
|
|
745 |
aKeyEvent.iCode == EKeyOK )
|
|
746 |
{
|
|
747 |
iContextMenuBar->TryDisplayMenuBarL();
|
|
748 |
ret = EKeyWasConsumed;
|
|
749 |
}
|
|
750 |
|
|
751 |
return ret;
|
|
752 |
}
|
|
753 |
|
|
754 |
void CAknFepUserdbDlg::PostLayoutDynInitL()
|
|
755 |
{
|
|
756 |
CAknMarkableListDialog::PostLayoutDynInitL();
|
|
757 |
FindBox()->Editor().SetMaxLength( KFindBoxInputMaxLength );
|
|
758 |
ListBox()->SetObserver( this );
|
|
759 |
ListBox()->AddItemChangeObserverL( this );
|
|
760 |
|
|
761 |
InitListBoxItemL();
|
|
762 |
UpdateListBoxL();
|
|
763 |
|
|
764 |
return;
|
|
765 |
}
|
|
766 |
|
|
767 |
void CAknFepUserdbDlg::ConstructContextMenuL()
|
|
768 |
{
|
|
769 |
CEikMenuBar* newMenuBar = new ( ELeave ) CEikMenuBar();
|
|
770 |
CleanupStack::PushL( newMenuBar );
|
|
771 |
newMenuBar->ConstructL
|
|
772 |
( this, NULL, R_AKNFEP_USERDB_DLG_CONTEXT_MENUBAR );
|
|
773 |
iEikonEnv->EikAppUi()->AddToStackL( newMenuBar, ECoeStackPriorityMenu,
|
|
774 |
ECoeStackFlagRefusesFocus );
|
|
775 |
iContextMenuBar = newMenuBar;
|
|
776 |
CleanupStack::Pop( newMenuBar );
|
|
777 |
}
|
|
778 |
|
|
779 |
void CAknFepUserdbDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
|
|
780 |
{
|
|
781 |
CTextListBoxModel* model = static_cast<CTextListBoxModel*>( ListBox()->Model() );
|
|
782 |
CDesCArrayFlat* itemArray =
|
|
783 |
static_cast<CDesCArrayFlat*>( model->ItemTextArray() );
|
|
784 |
TInt listItems = itemArray->Count();
|
|
785 |
|
|
786 |
if ( !listItems )
|
|
787 |
{
|
|
788 |
return;
|
|
789 |
}
|
|
790 |
|
|
791 |
CAknSelectionListDialog::HandleListBoxEventL( ListBox(), aEventType );
|
|
792 |
|
|
793 |
switch ( aEventType )
|
|
794 |
{
|
|
795 |
case EEventItemDoubleClicked:
|
|
796 |
{
|
|
797 |
TInt selectItems = ListBox()->SelectionIndexes()->Count();
|
|
798 |
if ( selectItems )
|
|
799 |
{
|
|
800 |
iOldIndex = ListBox()->CurrentItemIndex();
|
|
801 |
MarkOrUnmarkItemL();
|
|
802 |
}
|
|
803 |
else
|
|
804 |
{
|
|
805 |
ShowContextMenuL();
|
|
806 |
}
|
|
807 |
}
|
|
808 |
break;
|
|
809 |
default:
|
|
810 |
break;
|
|
811 |
}
|
|
812 |
}
|
|
813 |
|
|
814 |
|
|
815 |
void CAknFepUserdbDlg::ResetSearchFieldL()
|
|
816 |
{
|
|
817 |
CAknFilteredTextListBoxModel* selectmodel =
|
|
818 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
819 |
selectmodel->Filter()->HandleItemArrayChangeL();
|
|
820 |
}
|
|
821 |
|
|
822 |
TInt CAknFepUserdbDlg::FindActualIndex( const TInt aItemIndex )
|
|
823 |
{
|
|
824 |
TInt itemIndex;
|
|
825 |
CTextListBoxModel* model =
|
|
826 |
static_cast<CTextListBoxModel*>( ListBox()->Model() );
|
|
827 |
CDesCArrayFlat* itemArray =
|
|
828 |
static_cast<CDesCArrayFlat*>( model->ItemTextArray() );
|
|
829 |
//get the real index of list
|
|
830 |
TBuf<KListBoxItemMaxLength> itemText;
|
|
831 |
itemText.Copy( model->ItemText(aItemIndex) );
|
|
832 |
itemArray->Find( itemText, itemIndex, ECmpCollated );
|
|
833 |
return itemIndex;
|
|
834 |
}
|
|
835 |
|
|
836 |
void CAknFepUserdbDlg::ShowContextMenuL()
|
|
837 |
{
|
|
838 |
iContextMenuBar->SetMenuTitleResourceId( R_AKNFEP_USERDB_DLG_CONTEXT_MENUBAR );
|
|
839 |
iContextMenuBar->SetMenuType( CEikMenuBar::EMenuContext );
|
|
840 |
iContextMenuBar->StopDisplayingMenuBar();
|
|
841 |
iContextMenuBar->TryDisplayMenuBarL();
|
|
842 |
iContextMenuBar->SetMenuTitleResourceId( R_AKNFEP_USERDB_DLG_MENUBAR );
|
|
843 |
iContextMenuBar->SetMenuType( CEikMenuBar::EMenuOptions );
|
|
844 |
}
|
|
845 |
|
|
846 |
void CAknFepUserdbDlg::MarkOrUnmarkItemL()
|
|
847 |
{
|
|
848 |
TInt selectIndex = 0;
|
|
849 |
TKeyArrayFix* key= new (ELeave) TKeyArrayFix( 0, ECmpTInt32 );
|
|
850 |
CleanupStack::PushL( key );
|
|
851 |
TInt index = ListBox()->CurrentItemIndex();
|
|
852 |
const CArrayFix<TInt>* selectitemArray = ListBox()->SelectionIndexes();
|
|
853 |
TInt ret = selectitemArray->Find( index, *key, selectIndex );
|
|
854 |
if ( ret == 0)
|
|
855 |
{
|
|
856 |
ProcessCommandL( EAknCmdUnmark );
|
|
857 |
}
|
|
858 |
else
|
|
859 |
{
|
|
860 |
ProcessCommandL( EAknCmdMark );
|
|
861 |
}
|
|
862 |
CleanupStack::PopAndDestroy( key );
|
|
863 |
}
|
|
864 |
|
|
865 |
void CAknFepUserdbDlg::InsertIconL( CDesC16Array* aDataArray )
|
|
866 |
{
|
|
867 |
TBuf<KListBoxItemMaxLength> itemText;
|
|
868 |
for ( TInt i = 0; i < aDataArray->Count(); i++ )
|
|
869 |
{
|
|
870 |
itemText = aDataArray->MdcaPoint( i );
|
|
871 |
itemText.Insert( 0, KItemStart );
|
|
872 |
aDataArray->Delete( i );
|
|
873 |
aDataArray->InsertL( i, itemText );
|
|
874 |
}
|
|
875 |
aDataArray->Sort( ECmpCollated );
|
|
876 |
}
|
|
877 |
|
|
878 |
void CAknFepUserdbDlg::OnChangeLanguageL( TInt aInputLanguage )
|
|
879 |
{
|
|
880 |
if ( aInputLanguage != ELangPrcChinese &&
|
|
881 |
aInputLanguage != ELangTaiwanChinese &&
|
|
882 |
aInputLanguage != ELangHongKongChinese )
|
|
883 |
{
|
|
884 |
if ( iQueryDlg && iQueryDlg->IsVisible() )
|
|
885 |
{
|
|
886 |
delete iQueryDlg;
|
|
887 |
iQueryDlg = NULL;
|
|
888 |
}
|
|
889 |
this->TryExitL( EAknSoftkeyExit );
|
|
890 |
return;
|
|
891 |
}
|
|
892 |
if ( iOldLanguage == aInputLanguage )
|
|
893 |
{
|
|
894 |
return;
|
|
895 |
}
|
|
896 |
iOldLanguage = aInputLanguage;
|
|
897 |
|
|
898 |
CAknFilteredTextListBoxModel* model =
|
|
899 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
900 |
CDesCArrayFlat* itemArray =
|
|
901 |
static_cast<CDesCArrayFlat*>( model->ItemTextArray() );
|
|
902 |
TBuf<KErrMsgMaxLength> errMsg;
|
|
903 |
|
|
904 |
AknSelectionService::HandleMarkableListProcessCommandL( EAknUnmarkAll, ListBox() );
|
|
905 |
itemArray->Reset();
|
|
906 |
|
|
907 |
//get the phrases from the DB
|
|
908 |
if ( !iDBEngine->GetPhraseFromDBL( *itemArray ) )
|
|
909 |
{
|
|
910 |
iDBEngine->GetErrMsg( errMsg );
|
|
911 |
//note fot err message
|
|
912 |
CAknWarningNote* note = new( ELeave ) CAknWarningNote();
|
|
913 |
note->SetTone( CAknNoteDialog::EWarningTone );
|
|
914 |
note->ExecuteLD( errMsg );
|
|
915 |
}
|
|
916 |
else
|
|
917 |
{
|
|
918 |
InsertIconL( itemArray );
|
|
919 |
ListBox()->HandleItemAdditionL();
|
|
920 |
ListBox()->ClearSelection();
|
|
921 |
FindBox()->SetFocus( ETrue );
|
|
922 |
FindBox()->SetFocusing( ETrue );
|
|
923 |
FindBox()->MakeVisible( ETrue );
|
|
924 |
}
|
|
925 |
if ( itemArray->Count() == 0 )
|
|
926 |
{
|
|
927 |
FindBox()->SetSearchTextL( KSearchTextEmpty );
|
|
928 |
FindBox()->SetFocus( EFalse );
|
|
929 |
FindBox()->SetFocusing( EFalse );
|
|
930 |
FindBox()->MakeVisible( EFalse );
|
|
931 |
ListBox()->SetRect( Rect() );
|
|
932 |
ListBox()->View()->DrawEmptyList( Rect() );
|
|
933 |
|
|
934 |
//Show add-add-exit cba
|
|
935 |
ChangeCurrentCbaL( R_AKNFEP_SOFTKEYS_LIST_ADD_EXIT );
|
|
936 |
}
|
|
937 |
else
|
|
938 |
{
|
|
939 |
ListBox()->SetCurrentItemIndex( 0 );
|
|
940 |
}
|
|
941 |
}
|
|
942 |
|
|
943 |
void CAknFepUserdbDlg::ListBoxItemsChanged( CEikListBox* aListBox )
|
|
944 |
{
|
|
945 |
CAknFilteredTextListBoxModel* filterModel =
|
|
946 |
static_cast<CAknFilteredTextListBoxModel*>( aListBox->Model() );
|
|
947 |
CDesCArrayFlat* itemArray =
|
|
948 |
static_cast<CDesCArrayFlat*>( filterModel->ItemTextArray() );
|
|
949 |
|
|
950 |
TInt ItemCount = aListBox->Model()->NumberOfItems();
|
|
951 |
TInt selectedItem = filterModel->Filter()->SelectionIndexes()->Count();
|
|
952 |
if ( ItemCount > 0 && selectedItem < 1 )
|
|
953 |
{
|
|
954 |
//Show options-context-exit cba
|
|
955 |
TRAP_IGNORE ( ChangeCurrentCbaL( R_AKNFEP_SOFTKEYS_LIST_OPTIONS_EXIT_CONTEXT ) );
|
|
956 |
}
|
|
957 |
else
|
|
958 |
{
|
|
959 |
if ( ItemCount == 0)
|
|
960 |
{
|
|
961 |
//Show add-add-exit cba
|
|
962 |
TRAP_IGNORE ( ChangeCurrentCbaL( R_AKNFEP_SOFTKEYS_LIST_ADD_EXIT ) );
|
|
963 |
if ( itemArray->Count() == 0 && FindBox()->TextLength() == 0 )
|
|
964 |
{
|
|
965 |
FindBox()->SetFocus( EFalse );
|
|
966 |
FindBox()->MakeVisible( EFalse );
|
|
967 |
}
|
|
968 |
|
|
969 |
if ( FindBox()->TextLength() == 0 )
|
|
970 |
{
|
|
971 |
ListBox()->SetRect( Rect() );
|
|
972 |
ListBox()->View()->DrawEmptyList( Rect() );
|
|
973 |
}
|
|
974 |
}
|
|
975 |
}
|
|
976 |
}
|
|
977 |
|
|
978 |
void CAknFepUserdbDlg::UpdateListBoxL( TInt aCommandId )
|
|
979 |
{
|
|
980 |
// Update the listbox
|
|
981 |
CAknFilteredTextListBoxModel* filterModel =
|
|
982 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
983 |
filterModel->Filter()->UpdateCachedDataL();
|
|
984 |
|
|
985 |
TInt selectedItem = ListBox()->SelectionIndexes()->Count();
|
|
986 |
|
|
987 |
|
|
988 |
CAknFilteredTextListBoxModel* model =
|
|
989 |
static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() );
|
|
990 |
CDesCArrayFlat* itemArray =
|
|
991 |
static_cast<CDesCArrayFlat*>( model->ItemTextArray() );
|
|
992 |
TInt listItems = model->NumberOfItems();
|
|
993 |
|
|
994 |
if ( listItems != 0 && selectedItem != 0)
|
|
995 |
{
|
|
996 |
TInt CurrentItemIndex = ListBox()->CurrentItemIndex();
|
|
997 |
if( ( aCommandId == EAknCmdMark || aCommandId == EAknMarkAll ) &&
|
|
998 |
ListBox()->View()->ItemIsSelected(CurrentItemIndex))
|
|
999 |
{
|
|
1000 |
//Show options-unmark-exit menu
|
|
1001 |
ChangeCurrentCbaL( R_AKNFEP_SOFTKEYS_LIST_OPTIONS_EXIT_MARK );
|
|
1002 |
}
|
|
1003 |
if( ( aCommandId == EAknCmdUnmark || aCommandId == EAknUnmarkAll ) &&
|
|
1004 |
!ListBox()->View()->ItemIsSelected(CurrentItemIndex))
|
|
1005 |
{
|
|
1006 |
//Show options-mark-exit menu
|
|
1007 |
ChangeCurrentCbaL( R_AKNFEP_SOFTKEYS_LIST_OPTIONS_EXIT_UNMARK );
|
|
1008 |
}
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
if ( listItems == 0 )
|
|
1012 |
{
|
|
1013 |
//Show add-add-exit cba
|
|
1014 |
ChangeCurrentCbaL( R_AKNFEP_SOFTKEYS_LIST_ADD_EXIT );
|
|
1015 |
if ( itemArray->Count() == 0 && FindBox()->TextLength() == 0 )
|
|
1016 |
{
|
|
1017 |
FindBox()->SetFocus( EFalse );
|
|
1018 |
FindBox()->MakeVisible( EFalse );
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
if ( FindBox()->TextLength() == 0 )
|
|
1022 |
{
|
|
1023 |
ListBox()->SetRect( Rect() );
|
|
1024 |
ListBox()->View()->DrawEmptyList( Rect() );
|
|
1025 |
}
|
|
1026 |
}
|
|
1027 |
if( selectedItem == 0 && listItems != 0 )
|
|
1028 |
{
|
|
1029 |
FindBox()->MakeVisible( ETrue );
|
|
1030 |
FindBox()->SetFocus( ETrue );
|
|
1031 |
FindBox()->DrawNow();
|
|
1032 |
TRect findpaneRect(FindBox()->Rect());
|
|
1033 |
TRect clientRect = Rect();
|
|
1034 |
TSize size = TSize(clientRect.Width(),
|
|
1035 |
clientRect.Height() - findpaneRect.Height());
|
|
1036 |
ListBox()->SetRect( TRect(clientRect.iTl, size) );
|
|
1037 |
ListBox()->View()->Draw();
|
|
1038 |
//Show options-context-exit cba
|
|
1039 |
ChangeCurrentCbaL( R_AKNFEP_SOFTKEYS_LIST_OPTIONS_EXIT_CONTEXT );
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
if ( FindBox()->IsVisible() )
|
|
1043 |
{
|
|
1044 |
FindBox()->SetFocus( ETrue );
|
|
1045 |
FindBox()->MakeVisible( ETrue );
|
|
1046 |
}
|
|
1047 |
}
|
|
1048 |
|
|
1049 |
CCoeControl* CAknFepUserdbDlg::ComponentControl(TInt aIndex) const
|
|
1050 |
{
|
|
1051 |
if ( aIndex == CAknMarkableListDialog::CountComponentControls() )
|
|
1052 |
{
|
|
1053 |
return ListBox();
|
|
1054 |
}
|
|
1055 |
else
|
|
1056 |
{
|
|
1057 |
return CAknMarkableListDialog::ComponentControl(aIndex);
|
|
1058 |
}
|
|
1059 |
}
|
|
1060 |
|
|
1061 |
TInt CAknFepUserdbDlg::CountComponentControls() const
|
|
1062 |
{
|
|
1063 |
if ( ListBox() )
|
|
1064 |
{
|
|
1065 |
return CAknMarkableListDialog::CountComponentControls() + 1;
|
|
1066 |
}
|
|
1067 |
else
|
|
1068 |
{
|
|
1069 |
return CAknMarkableListDialog::CountComponentControls();
|
|
1070 |
}
|
|
1071 |
}
|
|
1072 |
|
|
1073 |
|
|
1074 |
|
|
1075 |
void CAknFepUserdbDlg::SizeChanged()
|
|
1076 |
{
|
|
1077 |
TRAP_IGNORE(SizeChangedL());
|
|
1078 |
}
|
|
1079 |
void CAknFepUserdbDlg::SizeChangedL()
|
|
1080 |
{
|
|
1081 |
//Change title text
|
|
1082 |
CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane();
|
|
1083 |
CAknTitlePane* title = NULL;
|
|
1084 |
title = static_cast< CAknTitlePane* >(
|
|
1085 |
statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle) ) );
|
|
1086 |
|
|
1087 |
//Load the new title text
|
|
1088 |
HBufC* titletext = StringLoader::LoadLC( R_AKNFEP_USER_DB_MANAGEMENT_TITLE );
|
|
1089 |
//Set title to the new text
|
|
1090 |
title->SetTextL( *titletext );
|
|
1091 |
CleanupStack::PopAndDestroy( titletext );
|
|
1092 |
}
|
|
1093 |
// End of file
|