OSDN Git Service

Change behavior when switching notebooks & picking a new note to display.
authorRandy Baumgarte <randy@fbn.cx>
Tue, 11 Jan 2011 17:35:08 +0000 (12:35 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 30 Jan 2011 13:35:41 +0000 (08:35 -0500)
src/cx/fbn/nevernote/NeverNote.java

index 115a6c9..5842a5c 100644 (file)
@@ -3369,6 +3369,22 @@ public class NeverNote extends QMainWindow{
        refreshEvernoteNoteList();
        logger.log(logger.HIGH, "Calling note table reload in NeverNote.noteIndexUpdated() - "+reload);
        noteTableView.load(reload);
        refreshEvernoteNoteList();
        logger.log(logger.HIGH, "Calling note table reload in NeverNote.noteIndexUpdated() - "+reload);
        noteTableView.load(reload);
+       if (currentNoteGuid == null || currentNoteGuid.equals("")) {
+               int pos;
+               if (noteTableView.proxyModel.sortOrder() == SortOrder.AscendingOrder)
+                       pos = noteTableView.proxyModel.rowCount();
+               else 
+                       pos = 1;
+               if (noteTableView.proxyModel.rowCount() == 0)
+                       pos = 0;
+               if (pos>0)      {
+                       QModelIndex i = noteTableView.proxyModel.index(pos-1, Global.noteTableGuidPosition);
+                       if (i!=null) {
+                               currentNoteGuid = (String)i.data();
+                               noteTableView.selectRow(pos-1);
+                       }
+               }
+       }               
        scrollToGuid(currentNoteGuid);
                logger.log(logger.HIGH, "Leaving NeverNote.noteIndexUpdated");
     }
        scrollToGuid(currentNoteGuid);
                logger.log(logger.HIGH, "Leaving NeverNote.noteIndexUpdated");
     }
@@ -3406,14 +3422,10 @@ public class NeverNote extends QMainWindow{
                        browserWindow.setDisabled(true);
                } 
                
                        browserWindow.setDisabled(true);
                } 
                
-               if (saveCurrentNoteGuid.equals("") && listManager.getNoteIndex().size() > 0) {
-                       currentNote = listManager.getNoteIndex().get(listManager.getNoteIndex().size()-1);
-                       currentNoteGuid = currentNote.getGuid();
-                       refreshEvernoteNote(true);
-               } else {
-                       //we can reload if note not dirty
-//                     refreshEvernoteNote(!noteDirty);
+               if (!saveCurrentNoteGuid.equals("")) {
                        refreshEvernoteNote(false);
                        refreshEvernoteNote(false);
+               } else {
+                       currentNoteGuid = "";
                }
                reloadTagTree(false);
 
                }
                reloadTagTree(false);