OSDN Git Service

Correct problem where a note's title color would be lost the first time a note was...
authorRandy Baumgarte <randy@fbn.cx>
Fri, 3 Sep 2010 11:31:00 +0000 (07:31 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Tue, 14 Sep 2010 10:23:55 +0000 (06:23 -0400)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/sql/NoteTable.java

index 037418a..74ca1f3 100644 (file)
@@ -3366,7 +3366,12 @@ public class NeverNote extends QMainWindow{
                        i=listManager.getNoteIndex().size();
                }
        }
-               updateListGuid(oldGuid, newGuid);
+       if (listManager.getNoteTableModel().titleColors.containsKey(oldGuid)) {
+               int color = listManager.getNoteTableModel().titleColors.get(oldGuid);
+               listManager.getNoteTableModel().titleColors.put(newGuid, color);
+               listManager.getNoteTableModel().titleColors.remove(oldGuid);
+       }
+       
     }
     // Toggle the note editor button bar
     private void toggleEditorButtonBar() {
index 6ee42cb..4f89d08 100644 (file)
@@ -499,19 +499,6 @@ public class NoteTable {
                }\r
        }\r
 \r
-/*     \r
-       // Check a note to see if it passes the attribute selection criteria\r
-       public boolean checkAttributeSelection(Note n) {\r
-               if (Global.createdSinceFilter.check(n) &&\r
-                       Global.createdBeforeFilter.check(n) && \r
-                       Global.changedSinceFilter.check(n) &&\r
-                       Global.changedBeforeFilter.check(n) &&\r
-                       Global.containsFilter.check(this, n))\r
-                               return true;\r
-               \r
-               return false;\r
-       }\r
-*/\r
        // Delete a note\r
        public void deleteNote(String guid) {\r
         NSqlQuery query = new NSqlQuery(db.getConnection());\r
@@ -692,9 +679,11 @@ public class NoteTable {
        // Update a note\r
        public void updateNote(Note n, boolean isNew) {\r
                boolean isExpunged = isNoteExpunged(n.getGuid());\r
-               \r
+               int titleColor = getNoteTitleColor(n.getGuid());\r
                expungeNote(n.getGuid(), !isExpunged, false);\r
                addNote(n, false);\r
+               if (titleColor != -1)\r
+                       setNoteTitleColor(n.getGuid(), titleColor);\r
        }\r
        // Does a note exist?\r
        public boolean exists(String guid) {\r
@@ -1015,12 +1004,9 @@ public class NoteTable {
                        returnValue.add(pair); \r
                }       \r
 \r
-               \r
-               \r
                return returnValue;\r
        }\r
        // Set a title color\r
-       // Reset the dirty bit\r
        public void  setNoteTitleColor(String guid, int color) {\r
                NSqlQuery query = new NSqlQuery(db.getConnection());\r
                \r
@@ -1030,7 +1016,30 @@ public class NoteTable {
                if (!query.exec())\r
                        logger.log(logger.EXTREME, "Error updating title color.");\r
        }\r
+       // Get in individual note's title color\r
+       // Get the title color of all notes\r
+       public Integer getNoteTitleColor(String guid) {\r
+               List<Pair<String,Integer>> returnValue = new ArrayList<Pair<String,Integer>>();\r
+        NSqlQuery query = new NSqlQuery(db.getConnection());\r
+               \r
+               if (!query.exec("Select titleColor from Note where titleColor != -1 and guid=:guid"))\r
+                       logger.log(logger.EXTREME, "Note SQL retrieve has failed on getNoteTitleColor(guid).");\r
+\r
+               Integer color = -1;\r
+               \r
+               // Get a list of the notes\r
+               while (query.next()) {\r
+                       Pair<String, Integer> pair = new Pair<String,Integer>();\r
+                       guid = query.valueString(0);\r
+                       color = query.valueInteger(1);\r
+                       pair.setFirst(guid);\r
+                       pair.setSecond(color);\r
+                       returnValue.add(pair); \r
+               }       \r
 \r
+               \r
+               return color;\r
+       }\r
        \r
        \r
        //**********************************************************************************\r