fep/aknfep/UiPlugins/AknFepUiInterface/AvkonImpl/src/AknFepUserDictionaryEditDialog.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 2009 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:          
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 /*
       
    28  * ============================================================================
       
    29  *  Name     : CAknFepUserDictionaryEditDialog 
       
    30  * ============================================================================
       
    31  */
       
    32 
       
    33 #include <COEMAIN.H>
       
    34 #include <EIKENV.H>
       
    35 #include <eikclbd.h>
       
    36 #include <akntitle.h>
       
    37 #include "AknFepUserDictionaryEditDialog.h"
       
    38 
       
    39 //For help:
       
    40 #include <hlplch.h>
       
    41 //#include <csxhelp\predinput.hlp.hrh>
       
    42 
       
    43 //Uid of AknFep
       
    44 const TUid KUidAknFep = {0x101FD65A};
       
    45 
       
    46 CAknFepUserDictionaryEditDialog *CAknFepUserDictionaryEditDialog::NewL(
       
    47         TInt aOpenedItem,
       
    48         CArrayFixFlat<TInt> *aSelectedItems,
       
    49         MDesCArray *aArray)
       
    50     {
       
    51     CAknFepUserDictionaryEditDialog* self = CAknFepUserDictionaryEditDialog::NewLC(
       
    52             aOpenedItem, aSelectedItems, aArray );
       
    53     CleanupStack::Pop(self);
       
    54     return self;
       
    55     }
       
    56 
       
    57 CAknFepUserDictionaryEditDialog *CAknFepUserDictionaryEditDialog::NewLC(
       
    58         TInt aOpenedItem,
       
    59         CArrayFixFlat<TInt> *aSelectedItems,
       
    60         MDesCArray *aArray)
       
    61     {
       
    62     CAknFepUserDictionaryEditDialog* self = new (ELeave) CAknFepUserDictionaryEditDialog(
       
    63             aOpenedItem, aSelectedItems, aArray );
       
    64     CleanupStack::PushL(self);
       
    65     self->ConstructL(R_UDB_EDIT_OPTIONS_MENUBAR);
       
    66     return self;
       
    67     }
       
    68 
       
    69 CAknFepUserDictionaryEditDialog::CAknFepUserDictionaryEditDialog(
       
    70         TInt aOpenedItem,
       
    71         CArrayFixFlat<TInt> *aSelectedItems,
       
    72         MDesCArray *aArray )
       
    73     :CAknMarkableListDialog(aOpenedItem, aSelectedItems, aArray, R_UDB_EDIT_OPTIONS_MENUBAR, NULL, NULL), 
       
    74      iOpenedItem(aOpenedItem), iSelectedItems(aSelectedItems)
       
    75     {
       
    76     };
       
    77 
       
    78 CAknFepUserDictionaryEditDialog::~CAknFepUserDictionaryEditDialog()
       
    79     {
       
    80     delete iOwnWordsModel;
       
    81     iOwnWordsModel = NULL;
       
    82     iOwnWordsListBox = NULL;
       
    83     };
       
    84 
       
    85 void CAknFepUserDictionaryEditDialog::RunDlgLD()
       
    86     {
       
    87     CDesCArrayFlat* arrWords = new (ELeave) CDesCArrayFlat(1);
       
    88     CleanupStack::PushL( arrWords );
       
    89     //ownership of selectedItems is given to CAknFepUserDictionaryEditDialog
       
    90     CArrayFixFlat<TInt>* selectedItems = new (ELeave) CArrayFixFlat<TInt>(1);
       
    91     CleanupStack::PushL( selectedItems );
       
    92     
       
    93     TInt openedItem(0);
       
    94     CAknFepUserDictionaryEditDialog* dlg = CAknFepUserDictionaryEditDialog::NewL(
       
    95                         openedItem, selectedItems, arrWords);
       
    96     
       
    97     //Save old title pane and display title for user dictionary editing
       
    98     CCoeEnv* coeEnv = CCoeEnv::Static();
       
    99     CAknAppUi* appUi = static_cast<CAknAppUi*>(coeEnv->AppUi());
       
   100 
       
   101     CAknTitlePane* titlePane = 
       
   102         static_cast<CAknTitlePane*>( appUi->StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   103 
       
   104     const TDesC* appTitle = titlePane->Text();
       
   105     HBufC* oldTitle = appTitle->AllocL();
       
   106     CleanupStack::PushL(oldTitle);
       
   107     HBufC* title = StringLoader::LoadLC( R_AKNFEP_PRED_USERDICT_EDITING_TITLE );
       
   108     titlePane->SetTextL( *title );
       
   109     CleanupStack::PopAndDestroy(title);
       
   110 
       
   111     dlg->ExecuteLD(R_USER_DICTIONARY_EDITING_DIALOG);
       
   112     
       
   113     //workaround to prevent application from crashing in case a 3rd party fep 
       
   114     //was installed while the dialog was active. 
       
   115     if( KUidAknFep != CCoeEnv::Static()->FepUid() )
       
   116         {
       
   117         User::Leave(KErrNone);
       
   118         }
       
   119     titlePane->SetTextL( *oldTitle );
       
   120     CleanupStack::PopAndDestroy( 3, arrWords );
       
   121     }
       
   122 
       
   123 
       
   124 void CAknFepUserDictionaryEditDialog::PreLayoutDynInitL()
       
   125     {
       
   126     CAknMarkableListDialog::PreLayoutDynInitL();
       
   127     iOwnWordsListBox = (CEikColumnListBox*) ControlOrNull( ESelectionListControl );
       
   128     //Initialize the model for retrieving UDB entries
       
   129     iOwnWordsModel = CAknFepPredOwnWordsModel::NewL( iOwnWordsListBox->Model()->ItemTextArray() );
       
   130     iOwnWordsListBox->HandleItemAdditionL();
       
   131     
       
   132     //Set the empty listbox string
       
   133     HBufC* emptyListString_secondary = StringLoader::LoadLC( R_AKNFEP_PRED_USER_DICTIONARY_EMPTY );
       
   134     HBufC* emptyListString = StringLoader::LoadLC( R_AKNFEP_PRED_USER_DICTIONARY_HEADING_EMPTY );
       
   135     _LIT( KNewLine, "\n" );
       
   136     TInt newLength = emptyListString->Length() + KNewLine().Length() + emptyListString_secondary->Length();
       
   137     emptyListString = emptyListString->ReAllocL( newLength );
       
   138     CleanupStack::Pop(); //emptyListString could now be at a different location
       
   139     CleanupStack::PushL( emptyListString );
       
   140     TPtr ptr = emptyListString->Des();
       
   141     ptr.Append( KNewLine );
       
   142     ptr.Append( *emptyListString_secondary );
       
   143 
       
   144     iOwnWordsListBox->View()->SetListEmptyTextL( *emptyListString );
       
   145     CleanupStack::PopAndDestroy( 2, emptyListString_secondary );
       
   146     
       
   147     //Set the middle soft key:
       
   148     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   149     iMSKPosition = cba.PositionById( EAknSoftkeyContextOptions );
       
   150     UpdateMSKLabelL();
       
   151     
       
   152     //For viewing extra long words:
       
   153     iOwnWordsListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
       
   154     }
       
   155 
       
   156 void CAknFepUserDictionaryEditDialog::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane)
       
   157     {
       
   158     CAknMarkableListDialog::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   159     
       
   160     if ( iOwnWordsListBox->SelectionIndexes()->Count() >= 1
       
   161             && R_UDB_EDIT_OPTIONS_MENUPANE == aResourceId )
       
   162         {
       
   163         //At least one item in the list is marked. 
       
   164         //Hide the "Edit" option.
       
   165         aMenuPane->SetItemDimmed( EAknFepPredDictionaryCmdEdit, ETrue);
       
   166         }
       
   167     
       
   168     if ( iOwnWordsListBox->Model()->NumberOfItems() <= 0 
       
   169             && R_UDB_EDIT_OPTIONS_MENUPANE == aResourceId )
       
   170         {
       
   171         //No items available for editing/deletion:
       
   172         aMenuPane->SetItemDimmed( EAknFepPredDictionaryCmdEdit, ETrue);
       
   173         aMenuPane->SetItemDimmed( EAknFepPredDictionaryCmdDelete, ETrue);
       
   174         }
       
   175     
       
   176     }
       
   177 
       
   178 void CAknFepUserDictionaryEditDialog::ProcessCommandL( TInt aCommandId )
       
   179     {
       
   180     
       
   181     if ( MenuShowing() )
       
   182         {
       
   183         HideMenu();
       
   184         }
       
   185                 
       
   186     switch(aCommandId)
       
   187         {
       
   188         case EAknFepPredDictionaryCmdEdit :
       
   189             {
       
   190             HandleEditCommandL();
       
   191             break; 
       
   192             }              
       
   193             
       
   194         case EAknFepPredDictionaryCmdAdd :
       
   195             {
       
   196             HandleAddNewCommandL();
       
   197             break; 
       
   198             }
       
   199             
       
   200         case EAknFepPredDictionaryCmdDelete : 
       
   201             {
       
   202             HandleDeleteCommandL();
       
   203             break; 
       
   204             }
       
   205                         
       
   206         case EAknCmdMark :
       
   207         case EAknCmdUnmark :
       
   208         case EAknMarkAll :
       
   209         case EAknUnmarkAll :
       
   210             {
       
   211             SelectionListProcessCommandL(aCommandId);
       
   212             break;
       
   213             }
       
   214         
       
   215         case EAknSoftkeyEdit :
       
   216             {
       
   217             if ( iOwnWordsListBox->Model()->NumberOfItems() <= 0 )
       
   218                 {
       
   219                 //No entries in the list. So only option available is "Add new"
       
   220                 HandleAddNewCommandL();
       
   221                 }
       
   222             else if ( iOwnWordsListBox->SelectionIndexes()->Count() <= 0 )
       
   223                 {
       
   224                 //Words available and none are marked. So selection => "Edit"
       
   225                 HandleEditCommandL();
       
   226                 }
       
   227             else
       
   228                 {
       
   229                 //Words are available and at least one is marked. 
       
   230                 //So selection => "Options" menu is launched
       
   231                 DisplayMenuL();
       
   232                 }
       
   233             break;
       
   234             }
       
   235             
       
   236         case EAknCmdHelp:
       
   237             {
       
   238             CArrayFix<TCoeHelpContext>* helpContext = new (ELeave) CArrayFixFlat<TCoeHelpContext>( 1 );
       
   239             CleanupStack::PushL( helpContext );
       
   240             //THIS IS TEMPORARY AND NEEDS TO BE UPDATED WHEN HELP CONTENT IS AVAILABLE!!!
       
   241             TUid appuid = { 0x100058EC };
       
   242             _LIT( KAknFepPredUserDictHelp, "PREDINPUT_HLP_USERDICT" );
       
   243             helpContext->AppendL( TCoeHelpContext( appuid, KAknFepPredUserDictHelp() ) );
       
   244             HlpLauncher::LaunchHelpApplicationL( CEikonEnv::Static()->WsSession(), helpContext );
       
   245             CleanupStack::Pop( helpContext );  
       
   246             break;
       
   247             }
       
   248         
       
   249         case EAknCmdExit:
       
   250             {
       
   251             iAvkonAppUi->ProcessCommandL( aCommandId );
       
   252             break;
       
   253             }
       
   254         default: CAknMarkableListDialog::ProcessCommandL( aCommandId );
       
   255         }
       
   256     
       
   257     UpdateMSKLabelL();
       
   258     
       
   259     }
       
   260 
       
   261 TKeyResponse CAknFepUserDictionaryEditDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   262     {
       
   263     TKeyResponse response( EKeyWasNotConsumed );
       
   264     //Special handling required only for the clear/backspace/delete keys
       
   265     //AND only when find pane is empty AND there is at least one item in focus/selected
       
   266     if ( 
       
   267             ( aKeyEvent.iCode == EKeyBackspace 
       
   268                 ||  aKeyEvent.iCode == EKeyDelete )
       
   269         &&  ( 
       
   270                 FindBox()->TextLength() == 0 
       
   271                 && iOwnWordsListBox->Model()->NumberOfItems() > 0 
       
   272                 && (iOwnWordsListBox->SelectionIndexes()->Count() > 0 
       
   273                         || iOwnWordsListBox->CurrentItemIndex() >= 0 ) 
       
   274             )
       
   275         )
       
   276         {
       
   277         //Delete the item(s)
       
   278         HandleDeleteCommandL();
       
   279         response = EKeyWasConsumed;
       
   280         }
       
   281     else
       
   282         {
       
   283         response = CAknMarkableListDialog::OfferKeyEventL( aKeyEvent, aType );
       
   284         }
       
   285     
       
   286     //Update MSK only if key is not escape key (for exiting)
       
   287     if ( EKeyEscape != aKeyEvent.iCode )
       
   288         {
       
   289         UpdateMSKLabelL();
       
   290         }
       
   291     return response;
       
   292     }
       
   293 
       
   294 TBool CAknFepUserDictionaryEditDialog::OkToExitL(TInt aButtonId)
       
   295     {
       
   296     if ( EAknSoftkeyEdit == aButtonId || EAknSoftkeyContextOptions == aButtonId )
       
   297         {
       
   298         CAknFepUserDictionaryEditDialog::ProcessCommandL( EAknSoftkeyEdit );
       
   299         return EFalse;
       
   300         }
       
   301     else
       
   302         {
       
   303         return CAknMarkableListDialog::OkToExitL( aButtonId );
       
   304         }
       
   305     }
       
   306 
       
   307 void CAknFepUserDictionaryEditDialog::UpdateMSKLabelL()
       
   308     {
       
   309     if ( iOwnWordsListBox && iOwnWordsListBox->Model() )
       
   310         {
       
   311         CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   312         if ( iOwnWordsListBox->Model()->NumberOfItems() <= 0 )
       
   313             {
       
   314             //No entries in the list. So MSK is "Add new"
       
   315             HBufC* mskLabel = StringLoader::LoadLC( R_AKNFEP_PRED_MSK_ADD_NEW );
       
   316             cba.SetCommandL(iMSKPosition, EAknSoftkeyEdit, *mskLabel);    
       
   317             CleanupStack::PopAndDestroy( mskLabel );
       
   318             }
       
   319         else if ( iOwnWordsListBox->SelectionIndexes()->Count() > 0 )
       
   320             {
       
   321             //Words are available and at least one is marked. 
       
   322             //So on pressing MSK, "Options" menu is launched
       
   323             HBufC* mskLabel = StringLoader::LoadLC( R_AKNFEP_PRED_MSK_CONTEXT_OPTIONS );
       
   324             cba.SetCommandL(iMSKPosition, EAknSoftkeyContextOptions, *mskLabel);    
       
   325             CleanupStack::PopAndDestroy( mskLabel );
       
   326             }
       
   327         else
       
   328             {
       
   329             //Words available and none are marked. So MSK should be "Edit"
       
   330             HBufC* mskLabel = StringLoader::LoadLC( R_AKNFEP_PRED_MSK_EDIT );
       
   331             cba.SetCommandL(iMSKPosition, EAknSoftkeyEdit, *mskLabel);    
       
   332             CleanupStack::PopAndDestroy( mskLabel );
       
   333             }
       
   334         cba.DrawDeferred();
       
   335         }
       
   336     }
       
   337 
       
   338 void CAknFepUserDictionaryEditDialog::HandleEditCommandL()
       
   339     {
       
   340     CDesCArrayFlat* wordArray = (CDesCArrayFlat*)iOwnWordsListBox->Model()->ItemTextArray();
       
   341     //First Get the current focussed word's index
       
   342     TInt selectedWordIndex = iOwnWordsListBox->CurrentItemIndex();
       
   343     //Edit option will be available only for the currently 
       
   344     //focussed item. 
       
   345     
       
   346     //Get the indexed word and remove seperator ("\t")
       
   347     TPtrC oldWord = ( (*wordArray)[selectedWordIndex] ).Mid(1);
       
   348     HBufC* newWord = HBufC::NewLC( KMaxUDBLength );
       
   349     //Copy the old word to newWord for the "Edit word" prompt
       
   350     newWord->Des().Copy( oldWord );
       
   351     TPtr newWordPtr(newWord->Des());
       
   352     HBufC* queryTitle = StringLoader::LoadLC( R_AKNFEP_PRED_EDIT_QUERY );
       
   353     if ( QueryWordL( *queryTitle, newWordPtr ) )
       
   354         {
       
   355         //Remove old word
       
   356         if ( KErrNone == iOwnWordsModel->RemoveSelectedWordL( selectedWordIndex ) )
       
   357             {
       
   358             iOwnWordsListBox->HandleItemRemovalL();
       
   359             //Now add the new word:
       
   360             selectedWordIndex = iOwnWordsModel->AddNewWordL( newWordPtr );
       
   361             if ( selectedWordIndex >= 0 )
       
   362                 {
       
   363                 iOwnWordsListBox->HandleItemAdditionL();
       
   364                 if ( (iOwnWordsListBox->CurrentItemIndex() >= 0) && FindBox() && (FindBox()->TextLength() > 0) )
       
   365                     {
       
   366                     HandleAddNewIntoFilteredListL( selectedWordIndex );
       
   367                     }
       
   368                 if ( selectedWordIndex >=0 )
       
   369                     {
       
   370                     iOwnWordsListBox->SetCurrentItemIndex( selectedWordIndex );
       
   371                     }
       
   372                 iOwnWordsListBox->DrawNow();
       
   373                 }
       
   374             }
       
   375         }
       
   376     
       
   377     CleanupStack::PopAndDestroy( 2, newWord );
       
   378     }
       
   379 
       
   380 void CAknFepUserDictionaryEditDialog::HandleAddNewCommandL()
       
   381     {
       
   382     HBufC* newWord = HBufC::NewLC( KMaxUDBLength );
       
   383     TPtr newWordPtr(newWord->Des());
       
   384     //if there is some text in the find pane, include it in the query
       
   385     if ( FindBox()->TextLength() > 0 )
       
   386         {
       
   387         FindBox()->GetSearchText( newWordPtr );
       
   388         }
       
   389     HBufC* queryTitle = StringLoader::LoadLC( R_AKNFEP_PRED_ADD_QUERY );
       
   390     if ( QueryWordL( *queryTitle, newWordPtr ) )
       
   391         {
       
   392         TInt selectedWordIndex = iOwnWordsModel->AddNewWordL( newWordPtr );
       
   393         if ( selectedWordIndex >= 0 )
       
   394             {
       
   395             iOwnWordsListBox->HandleItemAdditionL();
       
   396             if ( (iOwnWordsListBox->CurrentItemIndex() >= 0) && FindBox() && (FindBox()->TextLength() > 0) )
       
   397                 {
       
   398                 HandleAddNewIntoFilteredListL( selectedWordIndex );
       
   399                 }
       
   400             if ( selectedWordIndex >=0 )
       
   401                 {
       
   402                 iOwnWordsListBox->SetCurrentItemIndex( selectedWordIndex );
       
   403                 }
       
   404             iOwnWordsListBox->DrawNow();
       
   405             }
       
   406         }
       
   407     CleanupStack::PopAndDestroy( 2, newWord );
       
   408     }
       
   409 void CAknFepUserDictionaryEditDialog::HandleDeleteCommandL()
       
   410     {
       
   411     if ( iOwnWordsListBox->Model()->NumberOfItems() <= 0 )
       
   412         {
       
   413         //safety check - no words to delete so return from here
       
   414         return;
       
   415         }
       
   416     
       
   417     TInt updatedIndex(-1);
       
   418     TInt numOfMarkedItems = iOwnWordsListBox->SelectionIndexes()->Count();
       
   419     TInt currentIndex = CurrentItemIndex();
       
   420     //If multiple items are marked:
       
   421     if ( numOfMarkedItems > 1 )
       
   422         {
       
   423         //Load the confirmation string for multiple item deletion
       
   424         HBufC* prompt = StringLoader::LoadLC( 
       
   425                             R_AKNFEP_PRED_DELETE_MANY_QUERY, numOfMarkedItems );
       
   426         if ( ConfirmDeleteL( *prompt ) )
       
   427             {
       
   428             const CArrayFix<TInt>* selectedItems = SelectedItemsL();/*(CArrayFix<TInt>*)filteredModel->Filter()->SelectionIndexes();*/
       
   429             updatedIndex = iOwnWordsModel->RemoveSelectedWordsL( selectedItems );
       
   430             }
       
   431         CleanupStack::PopAndDestroy( prompt );
       
   432         }
       
   433     else
       
   434         {
       
   435         //Load the confirmation string for single item deletion
       
   436         HBufC* prompt = StringLoader::LoadLC( R_AKNFEP_PRED_DELETE_1_QUERY );
       
   437         if ( ConfirmDeleteL( *prompt ) )
       
   438             {
       
   439             //Deleting marked item?
       
   440             if ( numOfMarkedItems == 1 )
       
   441                 {
       
   442                 updatedIndex = iOwnWordsModel->RemoveSelectedWordL( SelectedItemsL()->At(0) );
       
   443                 }
       
   444             //or deleting the currently focussed item
       
   445             else //just one entry to delete:
       
   446                 {
       
   447                 updatedIndex = iOwnWordsModel->RemoveSelectedWordL( currentIndex );
       
   448                 }
       
   449             }
       
   450         CleanupStack::PopAndDestroy( prompt );
       
   451         }
       
   452     
       
   453     if ( updatedIndex == KErrNone )
       
   454         {
       
   455         iOwnWordsListBox->HandleItemRemovalL();
       
   456                 
       
   457         CAknListBoxFilterItems* filter;
       
   458         TInt filteredNumOfItems(-1);
       
   459         if ( (iOwnWordsListBox->CurrentItemIndex() >= 0) && FindBox() && (FindBox()->TextLength() > 0) )
       
   460             {
       
   461             CAknFilteredTextListBoxModel* model = static_cast<CAknFilteredTextListBoxModel*>(iOwnWordsListBox->Model());
       
   462             filter = model->Filter();
       
   463             filter->HandleItemArrayChangeL();
       
   464             filter->UpdateCachedDataL();
       
   465             filteredNumOfItems = filter->FilteredNumberOfItems();
       
   466             }
       
   467         
       
   468         //retain the current selection position, unless
       
   469         //it refers to non-existant word. In this case, 
       
   470         //keep selection at the end of the list.
       
   471         TInt numOfItems = filteredNumOfItems>=0? filteredNumOfItems : iOwnWordsListBox->Model()->NumberOfItems();
       
   472                 
       
   473         if ( currentIndex >= numOfItems && numOfItems > 0 )
       
   474             {       
       
   475             iOwnWordsListBox->SetCurrentItemIndex( numOfItems - 1 );
       
   476             }
       
   477         
       
   478         
       
   479         UpdateMSKLabelL();
       
   480         iOwnWordsListBox->DrawNow();
       
   481         }
       
   482     
       
   483     }
       
   484 
       
   485 //Query for new word from user. Also used to edit existing word
       
   486 TBool CAknFepUserDictionaryEditDialog::QueryWordL( const TDesC& aTitle, TDes& aNewWord )
       
   487     {
       
   488     CAknTextQueryDialog* dialog = CAknTextQueryDialog::NewL( aNewWord  );
       
   489     dialog->PrepareLC( R_AKNFEP_PRED_USER_DICTIONARY_WORD_QUERY );
       
   490     dialog->SetPromptL(aTitle);
       
   491     //last char space has to be reserved for null terminator
       
   492     dialog->SetMaxLength( KMaxUDBLength - 1 );
       
   493     if ( EAknSoftkeyOk ==  dialog->RunLD() )
       
   494         {
       
   495         return ETrue;
       
   496         }
       
   497     else
       
   498         {
       
   499         return EFalse;
       
   500         }
       
   501     }
       
   502 
       
   503 TBool CAknFepUserDictionaryEditDialog::ConfirmDeleteL( const TDesC& aPrompt )
       
   504     {
       
   505     CAknQueryDialog* dialog = CAknQueryDialog::NewL();
       
   506     dialog->SetPromptL( aPrompt );
       
   507     if ( EAknSoftkeyYes ==  dialog->ExecuteLD( R_AKNFEP_PRED_DELETE_CONFIRMATION_QUERY ) )
       
   508         {
       
   509         return ETrue;
       
   510         }
       
   511     else
       
   512         {
       
   513         return EFalse;
       
   514         }
       
   515     }
       
   516 
       
   517 TInt CAknFepUserDictionaryEditDialog::CurrentItemIndex()
       
   518     {
       
   519     if ( (iOwnWordsListBox->CurrentItemIndex() >= 0) && FindBox() && (FindBox()->TextLength() > 0) )
       
   520         {
       
   521         CAknFilteredTextListBoxModel* model = static_cast<CAknFilteredTextListBoxModel*>(iOwnWordsListBox->Model());
       
   522         CAknListBoxFilterItems* filter = model->Filter(); 
       
   523         return filter->FilteredItemIndex(iOwnWordsListBox->CurrentItemIndex());
       
   524         }           
       
   525     else
       
   526         {
       
   527         return iOwnWordsListBox->CurrentItemIndex();
       
   528         }
       
   529     }
       
   530 
       
   531 const CArrayFix<TInt>* CAknFepUserDictionaryEditDialog::SelectedItemsL()
       
   532     {
       
   533     const CArrayFix<TInt>* selectedItems;
       
   534     if ( (iOwnWordsListBox->CurrentItemIndex() >= 0) && FindBox() && (FindBox()->TextLength() > 0) )
       
   535         {
       
   536         CAknFilteredTextListBoxModel* model = static_cast<CAknFilteredTextListBoxModel*>(iOwnWordsListBox->Model());
       
   537         CAknListBoxFilterItems* filter = model->Filter();
       
   538         filter->ResetFilteringL();
       
   539         selectedItems = filter->SelectionIndexes();
       
   540         }
       
   541     else
       
   542         {
       
   543         selectedItems = iOwnWordsListBox->SelectionIndexes();
       
   544         }
       
   545     TKeyArrayFix actNumKey(0,ECmpTInt);
       
   546     const_cast<CArrayFix<TInt>*>(selectedItems)->Sort(actNumKey);
       
   547     return selectedItems;
       
   548     }
       
   549 
       
   550 void CAknFepUserDictionaryEditDialog::HandleAddNewIntoFilteredListL( TInt &aOriginalItemIndex )
       
   551     {
       
   552     CAknFilteredTextListBoxModel* model = static_cast<CAknFilteredTextListBoxModel*>(iOwnWordsListBox->Model());
       
   553     CAknListBoxFilterItems* filter = model->Filter();
       
   554     filter->HandleItemArrayChangeL();
       
   555     filter->UpdateCachedDataL();
       
   556     TInt filteredNumOfItems = filter->FilteredNumberOfItems();
       
   557     aOriginalItemIndex = filter->VisibleItemIndex( aOriginalItemIndex );
       
   558     }