phonebookui/pbkcommonui/src/cntemaileditormodel.cpp
changeset 31 2a11b5b00470
parent 25 76a2435edfd4
child 40 b46a585f6909
equal deleted inserted replaced
27:de1630741fbe 31:2a11b5b00470
    40     }
    40     }
    41 
    41 
    42 void CntEmailEditorModel::insertDetailField()
    42 void CntEmailEditorModel::insertDetailField()
    43 {
    43 {
    44     QContactEmailAddress newAddr;
    44     QContactEmailAddress newAddr;
    45     
       
    46     CntDetailModelItem* item = new CntDetailModelItem( newAddr );
    45     CntDetailModelItem* item = new CntDetailModelItem( newAddr );
    47     appendDataFormItem( item, invisibleRootItem() );
    46     appendDataFormItem( item, invisibleRootItem() );
    48 }
    47 }
    49 
    48 
    50 void CntEmailEditorModel::saveContactDetails()
    49 void CntEmailEditorModel::saveContactDetails()
    51 {
    50 {
    52     HbDataFormModelItem* root = invisibleRootItem();
    51     HbDataFormModelItem* root = invisibleRootItem();
    53     int count( root->childCount() );
    52     int count( root->childCount() );
    54     for ( int i(0); i < count; i++ ) {
    53     for ( int i(0); i < count; i++ ) {
    55         CntDetailModelItem* item = static_cast<CntDetailModelItem*>( root->childAt(i) );
    54         CntDetailModelItem* item = static_cast<CntDetailModelItem*>( root->childAt(i) );
    56         QContactEmailAddress address = item->detail();
    55         QContactDetail address = item->detail();
    57         QString email = address.emailAddress();
    56         mContact->saveDetail( &address );
    58         if ( email.length() > 0 ) {
    57         
    59             mContact->saveDetail( &address );
    58         if ( address.value(QContactEmailAddress::FieldEmailAddress).isEmpty() ) {
       
    59             mContact->removeDetail( &address );
    60         }
    60         }
    61     }
    61     }
    62 }
    62 }
    63 
    63 
    64 // End of File
    64 // End of File