OSDN Git Service

Try (again) to correct problem where tag names
authorRandy Baumgarte <randy@fbn.cx>
Tue, 8 May 2012 12:37:06 +0000 (08:37 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 27 May 2012 20:49:02 +0000 (16:49 -0400)
in the note list are not properly sorted when the
name changes

src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/utilities/ListManager.java

index 866e6e2..e710b15 100644 (file)
@@ -1123,7 +1123,7 @@ public class NeverNote extends QMainWindow{
                logger.log(logger.HIGH, "Leaving NeverNote.closeEvent");
        }
 
-       @SuppressWarnings("unused")
+
        private void closeNeverNote() {
                closeAction = true;
                close();
@@ -2120,9 +2120,12 @@ public class NeverNote extends QMainWindow{
                                if (currentNote != null && currentNote.getTagGuids().contains(guid))
                                        browserWindow.setTag(getTagNamesForNote(currentNote));
                                logger.log(logger.HIGH, "Leaving NeverNote.editTag");
-                               return;
+                               //return;
                        }
                }
+               listManager.reloadNoteTagNames(guid, edit.getTag());
+               noteIndexUpdated(true);
+               refreshEvernoteNote(true);
                browserWindow.setTag(getTagNamesForNote(currentNote));
                logger.log(logger.HIGH, "Leaving NeverNote.editTag...");
        }
index 49036c1..7776d4e 100644 (file)
@@ -1255,4 +1255,27 @@ public class ListManager  {
        }\r
        \r
        \r
+       // Reload the note's tag names.  This is called when a tag's name changes by\r
+       // the user.  It updates all notes with that tag to the new tag name.\r
+       public void reloadNoteTagNames(String tagGuid, String newName) {\r
+               \r
+               // Set the master index\r
+               for (int i=0; i<getMasterNoteIndex().size(); i++) {\r
+                       for (int j=0; j<getMasterNoteIndex().get(i).getTagGuids().size(); j++) {\r
+                               if (getMasterNoteIndex().get(i).getTagGuids().get(j).equals(tagGuid)) {\r
+                                       getMasterNoteIndex().get(i).getTagNames().set(j, newName);\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               // Set the current index\r
+               for (int i=0; i<getNoteIndex().size(); i++) {\r
+                       for (int j=0; j<getNoteIndex().get(i).getTagGuids().size(); j++) {\r
+                               if (getNoteIndex().get(i).getTagGuids().get(j).equals(tagGuid)) {\r
+                                       getNoteIndex().get(i).getTagNames().set(j, newName);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       \r
 }\r