From 60d1413aeada792496774e4947f0d1afe39258c4 Mon Sep 17 00:00:00 2001 From: Randy Baumgarte Date: Sat, 12 Mar 2011 16:58:48 -0500 Subject: [PATCH] Rework some refresh logic to try in improve performance. --- src/cx/fbn/nevernote/NeverNote.java | 40 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index f09c79d..84a0732 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -584,8 +584,8 @@ public class NeverNote extends QMainWindow{ noteTableView.setNoteHistoryAction(menuBar.noteOnlineHistoryAction); noteTableView.noteSignal.titleColorChanged.connect(this, "titleColorChanged(Integer)"); noteTableView.setMergeNotesAction(menuBar.noteMergeAction); - noteTableView.rowChanged.connect(this, "scrollToGuid(String)"); - noteTableView.resetViewport.connect(this, "scrollToCurrentGuid()"); +/// noteTableView.rowChanged.connect(this, "scrollToGuid(String)"); +/// noteTableView.resetViewport.connect(this, "scrollToCurrentGuid()"); noteTableView.doubleClicked.connect(this, "listDoubleClick()"); listManager.trashSignal.countChanged.connect(trashTree, "updateCounts(Integer)"); @@ -935,11 +935,10 @@ public class NeverNote extends QMainWindow{ setMessage(tr("Performing synchronization before closing.")); syncRunner.syncNeeded = true; syncRunner.addWork("SYNC"); - syncRunner.addWork("STOP"); } else { - syncRunner.addWork("STOP"); syncRunner.keepRunning = false; } + syncRunner.addWork("STOP"); setMessage("Closing Program."); threadMonitorTimer.stop(); @@ -998,10 +997,9 @@ public class NeverNote extends QMainWindow{ e1.printStackTrace(); } - syncRunner.addWork("STOP"); - if (!syncRunner.isIdle()) { - //try { - logger.log(logger.MEDIUM, "Waiting for syncThread to stop"); + if (!syncRunner.thread().isAlive()) { + logger.log(logger.MEDIUM, "Waiting for syncThread to stop"); + if (syncRunner.thread().isAlive()) { System.out.println(tr("Synchronizing. Please be patient.")); for(;syncRunner.thread().isAlive();) { try { @@ -1010,10 +1008,8 @@ public class NeverNote extends QMainWindow{ e.printStackTrace(); } } - logger.log(logger.MEDIUM, "Sync thread has stopped"); - //} catch (InterruptedException e1) { - // e1.printStackTrace(); - //} + } + logger.log(logger.MEDIUM, "Sync thread has stopped"); } if (encryptOnShutdown) { @@ -2055,6 +2051,7 @@ public class NeverNote extends QMainWindow{ tagTree.setIcons(conn.getTagTable().getAllIcons()); tagTree.load(listManager.getTagIndex()); } + for (int i=selectedTagGUIDs.size()-1; i>=0; i--) { boolean found = tagTree.selectGuid(selectedTagGUIDs.get(i)); if (!found) @@ -2711,7 +2708,6 @@ public class NeverNote extends QMainWindow{ String text = searchField.currentText(); listManager.setEnSearch(text.trim()); listManager.loadNotesIndex(); -//--->>> noteIndexUpdated(true); noteIndexUpdated(false); refreshEvernoteNote(true); searchPerformed = true; @@ -3120,7 +3116,6 @@ public class NeverNote extends QMainWindow{ menuBar.noteRestoreAction.setVisible(false); listManager.loadNotesIndex(); -//--->>> noteIndexUpdated(true); noteIndexUpdated(false); } } @@ -3440,7 +3435,7 @@ public class NeverNote extends QMainWindow{ nextButton.setEnabled(false); fromHistory = false; - scrollToGuid(currentNoteGuid); +// scrollToGuid(currentNoteGuid); refreshEvernoteNote(true); logger.log(logger.HIGH, "Leaving NeverNote.noteTableSelection"); } @@ -3463,12 +3458,12 @@ public class NeverNote extends QMainWindow{ QModelIndex i = noteTableView.proxyModel.index(pos-1, Global.noteTableGuidPosition); if (i!=null) { currentNoteGuid = (String)i.data(); - noteTableView.selectRow(pos-1); } } } - showColumns(); - scrollToGuid(currentNoteGuid); + if (!noteTableView.isColumnHidden(Global.noteTableGuidPosition)) + showColumns(); + scrollToGuid(currentNoteGuid); logger.log(logger.HIGH, "Leaving NeverNote.noteIndexUpdated"); } // Called when the list of notes is updated @@ -3803,6 +3798,7 @@ public class NeverNote extends QMainWindow{ String guid = (String)index.model().index(row, Global.noteTableGuidPosition).data(); scrollToGuid(guid); } + // Scroll to the current GUID in tthe list. // Scroll to a particular index item private void scrollToGuid(String guid) { if (currentNote == null || guid == null) @@ -3816,7 +3812,6 @@ public class NeverNote extends QMainWindow{ } } } - if (!currentNote.isActive() && !Global.showDeleted) { for (int i=0; i<><><><><><><><><><><><><><><><><><><>"); updateQuotaBar(); listManager.refreshLists(currentNote, noteDirty, browserWindow.getContent()); tagIndexUpdated(true); -- 2.11.0