phonebookui/pbkcommonui/src/cntnoteeditormodel.cpp
changeset 31 2a11b5b00470
parent 27 de1630741fbe
child 40 b46a585f6909
--- a/phonebookui/pbkcommonui/src/cntnoteeditormodel.cpp	Mon May 03 12:24:20 2010 +0300
+++ b/phonebookui/pbkcommonui/src/cntnoteeditormodel.cpp	Fri May 14 15:42:23 2010 +0300
@@ -21,15 +21,8 @@
 CntNoteEditorModel::CntNoteEditorModel( QContact* aContact ) :
 CntDetailEditorModel( aContact )
     {
-    QList<QContactNote> noteList = mContact->details<QContactNote>();
-    if ( noteList.isEmpty() )
-        {
-        QContactNote emptyNote;
-        noteList.append( emptyNote );
-        }
-    
     HbDataFormModelItem* root = invisibleRootItem();
-    foreach ( QContactNote note, noteList )
+    foreach ( QContactNote note, mContact->details<QContactNote>() )
         {
         CntDetailModelItem* item = new CntDetailModelItem(note);
         appendDataFormItem( item, root );
@@ -53,9 +46,12 @@
     int count( root->childCount() );
     for ( int i(0); i < count; i++ ) {
         CntDetailModelItem* detail = static_cast<CntDetailModelItem*>( root->childAt(i) );
-        QContactNote note = detail->detail();
-        if ( note.note().length() > 0 ) {
-            mContact->saveDetail( &note );
+        QContactDetail note = detail->detail();
+        mContact->saveDetail( &note );
+        
+        if ( note.value(QContactNote::FieldNote).isEmpty() )
+        {
+            mContact->removeDetail( &note );
         }
     }
 }