creator/src/creator_phonebookbase.cpp
branchRCL_3
changeset 22 fad26422216a
parent 0 d6fe6244b863
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
       
     1 /*
       
     2 * Copyright (c) 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "creator_phonebookbase.h"
       
    20 #include "creator_model.h"
       
    21 #include "creator_traces.h"
       
    22 
       
    23 TBool CCreatorPhonebookBase::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
       
    24     {
       
    25     LOGSTRING("Creator: CCreatorPhonebook::AskDataFromUserL");
       
    26     
       
    27     if( aCommand == ECmdDeleteContacts )
       
    28         {
       
    29         return iEngine->YesNoQueryDialogL(_L("Delete all contacts?") );
       
    30         }
       
    31     if( aCommand == ECmdDeleteCreatorContacts )
       
    32         {
       
    33         return iEngine->YesNoQueryDialogL(_L("Delete all contacts created with Creator?") ); 
       
    34         }
       
    35     if( aCommand == ECmdDeleteContactGroups )
       
    36         {
       
    37         return iEngine->YesNoQueryDialogL(_L("Delete all contact groups?") );
       
    38         }
       
    39     if( aCommand == ECmdDeleteCreatorContactGroups )
       
    40         {
       
    41         return iEngine->YesNoQueryDialogL(_L("Delete all contact groups created with Creator?") ); 
       
    42         }    
       
    43     // display queries
       
    44     if (iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"))) // ask number of entries to create
       
    45         {
       
    46         if (aCommand == ECmdCreatePhoneBookEntryContacts)
       
    47             {
       
    48             TInt index = 0;
       
    49             CAknListQueryDialog* dlg1 = new(ELeave) CAknListQueryDialog(&index);
       
    50             if (dlg1->ExecuteLD(R_CONTACT_CREATION_TYPE_QUERY))
       
    51                 {
       
    52                 if (index == 0) //first item
       
    53                     {
       
    54                     iDefaultFieldsSelected = ETrue;
       
    55                     return ETrue;    
       
    56                     }
       
    57                 else  // detailed mode selected
       
    58                     {
       
    59                     iDefaultFieldsSelected = EFalse;
       
    60                     if (iEngine->EntriesQueryDialogL(iNumberOfPhoneNumberFields, _L("Amount of phone number fields in one contact?"), ETrue))
       
    61                         {
       
    62                         if (iEngine->EntriesQueryDialogL(iNumberOfURLFields, _L("Amount of URL fields in one contact?"), ETrue))
       
    63                             {
       
    64                             if (iEngine->EntriesQueryDialogL(iNumberOfEmailAddressFields, _L("Amount of email fields in one contact?"), ETrue))
       
    65                                 {                                
       
    66                                 return ETrue;
       
    67                                 }
       
    68                             else
       
    69                                 return EFalse;
       
    70                             }
       
    71                             else
       
    72                                 return EFalse;
       
    73                         }
       
    74                     else
       
    75                         return EFalse;
       
    76                     }
       
    77                 }
       
    78             else
       
    79                 return EFalse;
       
    80             }
       
    81         else if (aCommand == ECmdCreatePhoneBookEntryGroups)
       
    82             {
       
    83             TInt index = 0;
       
    84             CAknListQueryDialog* dlg1 = new(ELeave) CAknListQueryDialog(&index);
       
    85             if (dlg1->ExecuteLD(R_GROUP_CREATION_TYPE_QUERY))
       
    86                 {
       
    87                 if (index == 0) //first item
       
    88                     {
       
    89                     iContactsInGroup = KCreateRandomAmountOfGroups;
       
    90                     return ETrue;
       
    91                     }
       
    92                 else
       
    93                     {
       
    94                     if (iEngine->EntriesQueryDialogL(iContactsInGroup, _L("Amount of contacts in one group?"), ETrue))
       
    95                         {
       
    96                         return ETrue;
       
    97                         }
       
    98                     else
       
    99                         return EFalse;
       
   100                     }
       
   101                 }
       
   102             else
       
   103                 return EFalse;
       
   104             }
       
   105         else
       
   106             return ETrue;
       
   107         }
       
   108     else
       
   109         return EFalse;
       
   110     }
       
   111 
       
   112 void CCreatorPhonebookBase::SetDefaultParameters()
       
   113     {
       
   114     iNumberOfPhoneNumberFields = 1;
       
   115     iNumberOfURLFields = 0;
       
   116     iNumberOfEmailAddressFields = 0;
       
   117     iContactsInGroup = 50;
       
   118     iDefaultFieldsSelected = EFalse;
       
   119     }