notes/notesui/notesmodel/src/notesmodel.cpp
changeset 75 7ac58b2aae6f
parent 57 bb2d3e476f29
child 83 5aadd1120515
--- a/notes/notesui/notesmodel/src/notesmodel.cpp	Mon Sep 06 15:58:44 2010 +0530
+++ b/notes/notesui/notesmodel/src/notesmodel.cpp	Mon Sep 20 12:44:39 2010 +0530
@@ -210,7 +210,7 @@
 				NotesNamespace::StatusRole).value<int>();
 
 		if (entry.status() == entryStatus) {
-			if (AgendaEntry::TodoNeedsAction == entryStatus) {
+			if (AgendaEntry::TodoCompleted != entryStatus) {
 				// Make sure that the old model index is removed.
 				mSourceModel->removeRow(foundIndex.row());
 				mInCompTodoCount--;
@@ -218,7 +218,7 @@
 				// Now insert the to-do.
 				insertInCompTodoToModel(foundIndex, id);
 
-			} else if (AgendaEntry::TodoCompleted == entryStatus) {
+			} else {
 				// Make sure that the old model index is removed.
 				mSourceModel->removeRow(foundIndex.row());
 				mCompTodoCount--;
@@ -228,7 +228,7 @@
 
 			}
 		} else {
-			if (AgendaEntry::TodoNeedsAction == entryStatus) {
+			if (AgendaEntry::TodoCompleted != entryStatus) {
 				// Here the to-do was marked completed. Hence we need to remove
 				// the incompleted to-do and insert a completed to-do.
 				mSourceModel->removeRow(foundIndex.row());
@@ -237,7 +237,7 @@
 				// Now insert the completed to-do.
 				insertCompTodoToModel(foundIndex, id);
 
-			} else if (AgendaEntry::TodoCompleted == entryStatus) {
+			} else {
 				// Here the to-do was marked incompleted. Hence we need to
 				// remove the completed to-do and insert an incompleted to-do.
 				mSourceModel->removeRow(foundIndex.row());
@@ -292,11 +292,11 @@
 		notify = insertNoteToModel(indexToNotify, id);
 
 	} else if (AgendaEntry::TypeTodo == entry.type()) {
-		if (AgendaEntry::TodoNeedsAction == entry.status()) {
+		if (AgendaEntry::TodoCompleted != entry.status()) {
 			// Try to insert the to-do at its appropriate position.
 			notify = insertInCompTodoToModel(indexToNotify, id);
 
-		} else if (AgendaEntry::TodoCompleted == entry.status()) {
+		} else {
 			// Try to insert the to-do at its appropriate position.
 			insertCompTodoToModel(indexToNotify, id);
 		}
@@ -340,7 +340,7 @@
 			} else if (entryType == AgendaEntry::TypeTodo) {
 				if (entryStatus == AgendaEntry::TodoCompleted) {
 					mCompTodoCount--;
-				} else if (entryStatus == AgendaEntry::TodoNeedsAction) {
+				} else {
 					mInCompTodoCount--;
 				}
 			}
@@ -436,7 +436,7 @@
 		} else {
 			stringList << entry.summary();
 		}
-		if (AgendaEntry::TodoNeedsAction == entry.status()) {
+		if (AgendaEntry::TodoCompleted != entry.status()) {
 			// Read due date from agenda entry
 			QString displayText;
 			QString timeText(hbTrId("txt_notes_dblist_val_due_on_1"));
@@ -595,10 +595,18 @@
 		AgendaEntry entry = agendaEntryList[idIter];
 
 		if (AgendaEntry::TypeTodo != entry.type()) {
+			// delete the inserted row in the model
+			mSourceModel->removeRow(modelIter);
+			// decrement the iterator
+			modelIter--;
 			continue;
 		}
 
-		if (AgendaEntry::TodoNeedsAction != entry.status()) {
+		if (AgendaEntry::TodoCompleted == entry.status()) {
+			// delete the inserted row in the model
+			mSourceModel->removeRow(modelIter);
+			// decrement the iterator
+			modelIter--;
 			continue;
 		}
 
@@ -624,7 +632,7 @@
 			stringList << entry.summary();
 		}
 
-		if (AgendaEntry::TodoNeedsAction == entry.status()) {
+		if (AgendaEntry::TodoCompleted != entry.status()) {
 			// Read due date from agenda entry
 			QString displayText;
 			QString timeText(hbTrId("txt_notes_dblist_val_due_on_1"));
@@ -897,7 +905,7 @@
 			} else {
 				stringList << entry.summary();
 			}
-			if (AgendaEntry::TodoNeedsAction == entry.status()) {
+			if (AgendaEntry::TodoCompleted != entry.status()) {
 				// Read due date from agenda entry
 				QString displayText;
 				QString timeText(hbTrId("txt_notes_dblist_val_due_on_1"));