OSDN Git Service

- Gui cleanup - Rework count threads to reduce SQL overhead & improve performance.
authorRandy Baumgarte <randy@fbn.cx>
Wed, 16 Mar 2011 17:32:35 +0000 (13:32 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 3 Apr 2011 18:02:33 +0000 (14:02 -0400)
17 files changed:
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/gui/AttributeTreeWidget.java
src/cx/fbn/nevernote/gui/MainMenuBar.java
src/cx/fbn/nevernote/gui/NotebookTreeWidget.java
src/cx/fbn/nevernote/gui/SavedSearchTreeWidget.java
src/cx/fbn/nevernote/gui/SearchPanel.java [new file with mode: 0644]
src/cx/fbn/nevernote/gui/TagTreeWidget.java
src/cx/fbn/nevernote/gui/TrashTreeWidget.java
src/cx/fbn/nevernote/icons/synchronize-0.png [deleted file]
src/cx/fbn/nevernote/icons/synchronize-1.png [deleted file]
src/cx/fbn/nevernote/icons/synchronize-2.png [deleted file]
src/cx/fbn/nevernote/icons/synchronize-3.png [deleted file]
src/cx/fbn/nevernote/sql/NoteTable.java
src/cx/fbn/nevernote/sql/NoteTagsTable.java
src/cx/fbn/nevernote/sql/NotebookTable.java
src/cx/fbn/nevernote/threads/CounterRunner.java
src/cx/fbn/nevernote/utilities/ListManager.java

index 84a0732..c541f33 100644 (file)
@@ -95,7 +95,6 @@ import com.trolltech.qt.gui.QApplication;
 import com.trolltech.qt.gui.QCloseEvent;
 import com.trolltech.qt.gui.QColor;
 import com.trolltech.qt.gui.QComboBox;
-import com.trolltech.qt.gui.QComboBox.InsertPolicy;
 import com.trolltech.qt.gui.QCursor;
 import com.trolltech.qt.gui.QDesktopServices;
 import com.trolltech.qt.gui.QDialog;
@@ -167,6 +166,7 @@ import cx.fbn.nevernote.gui.ExternalBrowse;
 import cx.fbn.nevernote.gui.MainMenuBar;
 import cx.fbn.nevernote.gui.NotebookTreeWidget;
 import cx.fbn.nevernote.gui.SavedSearchTreeWidget;
+import cx.fbn.nevernote.gui.SearchPanel;
 import cx.fbn.nevernote.gui.TableView;
 import cx.fbn.nevernote.gui.TagTreeWidget;
 import cx.fbn.nevernote.gui.Thumbnailer;
@@ -283,6 +283,8 @@ public class NeverNote extends QMainWindow{
     QSpinBox                   zoomSpinner;                            // Zoom zoom
     QAction                            searchClearButton;                      // Clear the search field
     
+    SearchPanel                        searchLayout;                           // Widget to hold search field, zoom, & quota
+    
     QSplitter                  mainLeftRightSplitter;          // main splitter for left/right side
     QSplitter                  leftSplitter1;                          // first left hand splitter
     QSplitter                  browserIndexSplitter;           // splitter between note index & note text
@@ -487,13 +489,39 @@ public class NeverNote extends QMainWindow{
         trashTree = new TrashTreeWidget();
         noteTableView = new TableView(logger, listManager);
         
+        
+        searchField = new QComboBox();
+        searchField.setObjectName("searchField");
+        //setStyleSheet("QComboBox#searchField { background-color: yellow }");
+        searchField.setEditable(true);
+       searchField.activatedIndex.connect(this, "searchFieldChanged()");
+       searchField.setDuplicatesEnabled(false);
+       searchField.editTextChanged.connect(this,"searchFieldTextChanged(String)");
+       searchShortcut = new QShortcut(this);
+       setupShortcut(searchShortcut, "Focus_Search");
+       searchShortcut.activated.connect(this, "focusSearch()");
+        
+       quotaBar = new QuotaProgressBar();
+       // Setup the zoom
+       zoomSpinner = new QSpinBox();
+       zoomSpinner.setMinimum(10);
+       zoomSpinner.setMaximum(1000);
+       zoomSpinner.setAccelerated(true);
+       zoomSpinner.setSingleStep(10);
+       zoomSpinner.setValue(100);
+       zoomSpinner.valueChanged.connect(this, "zoomChanged()");
+       
+       searchLayout = new SearchPanel(searchField, quotaBar, notebookTree, zoomSpinner);
+        
+        
         QGridLayout leftGrid = new QGridLayout();
+        leftSplitter1.setContentsMargins(5, 0, 0, 7);
         leftSplitter1.setLayout(leftGrid);
-        leftGrid.addWidget(notebookTree, 1, 1);
+       leftGrid.addWidget(searchLayout,1,1);
         leftGrid.addWidget(tagTree,2,1);
         leftGrid.addWidget(attributeTree,3,1);
         leftGrid.addWidget(savedSearchTree,4,1);
-        leftGrid.addWidget(trashTree, 5, 1);
+        leftGrid.addWidget(trashTree,5, 1);
         
         // Setup the browser window
         noteCache = new HashMap<String,String>();
@@ -511,17 +539,6 @@ public class NeverNote extends QMainWindow{
                mainLeftRightSplitter.addWidget(noteTableView);
                mainLeftRightSplitter.addWidget(browserWindow); 
         }
-        
-        searchField = new QComboBox();
-        searchField.setEditable(true);
-       searchField.activatedIndex.connect(this, "searchFieldChanged()");
-       searchField.setDuplicatesEnabled(false);
-       searchField.editTextChanged.connect(this,"searchFieldTextChanged(String)");
-       searchShortcut = new QShortcut(this);
-       setupShortcut(searchShortcut, "Focus_Search");
-       searchShortcut.activated.connect(this, "focusSearch()");
-        
-       quotaBar = new QuotaProgressBar();
        
        // Setup the thumbnail viewer
        thumbnailViewer = new ThumbnailViewer();
@@ -552,9 +569,15 @@ public class NeverNote extends QMainWindow{
                tagTree.setAddAction(menuBar.tagAddAction);
                tagTree.setIconAction(menuBar.tagIconAction);
                tagTree.setVisible(Global.isWindowVisible("tagTree"));
+               leftSplitter1.setVisible(Global.isWindowVisible("leftPanel"));
                tagTree.noteSignal.tagsAdded.connect(this, "tagsAdded(String, String)");
                menuBar.hideTags.setChecked(Global.isWindowVisible("tagTree"));
                listManager.tagSignal.listChanged.connect(this, "reloadTagTree()");
+               
+               if (!Global.isWindowVisible("zoom")) {
+                       searchLayout.hideZoom();
+                       menuBar.hideZoom.setChecked(false);
+               } 
        
                notebookTree.setDeleteAction(menuBar.notebookDeleteAction);
                notebookTree.setEditAction(menuBar.notebookEditAction);
@@ -584,8 +607,6 @@ 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.doubleClicked.connect(this, "listDoubleClick()");
                listManager.trashSignal.countChanged.connect(trashTree, "updateCounts(Integer)");
                
@@ -609,6 +630,15 @@ public class NeverNote extends QMainWindow{
                        menuBar.hideLeftSide.setChecked(true);
                if (Global.isWindowVisible("noteInformation"))
                        toggleNoteInformation();
+               quotaBar.setVisible(Global.isWindowVisible("quota"));
+               if (!quotaBar.isVisible())
+                       menuBar.hideQuota.setChecked(false);
+               searchField.setVisible(Global.isWindowVisible("searchField"));
+               if (!searchField.isVisible())
+                       menuBar.hideSearch.setChecked(false);
+               
+               if (searchField.isHidden() && quotaBar.isHidden() && zoomSpinner.isHidden() && notebookTree.isHidden())
+                       searchLayout.hide();
                
                setMenuBar(menuBar);
                setupToolBar();
@@ -1063,6 +1093,7 @@ public class NeverNote extends QMainWindow{
                        while (QApplication.overrideCursor() != null)
                                QApplication.restoreOverrideCursor();
                }
+               listManager.refreshCounters();
        }
        
        private void setupIndexListeners() {
@@ -1262,6 +1293,29 @@ public class NeverNote extends QMainWindow{
                Global.setColumnWidth("noteTableGuidPosition", width);
        }
        
+       private void toggleSearchWindow() {
+               logger.log(logger.HIGH, "Entering NeverNote.toggleSearchWindow");
+       searchLayout.toggleSearchField();
+       menuBar.hideSearch.setChecked(searchField.isVisible());
+       Global.saveWindowVisible("searchField", searchField.isVisible());
+       logger.log(logger.HIGH, "Leaving NeverNote.toggleSearchWindow");
+    }  
+       private void toggleQuotaWindow() {
+               logger.log(logger.HIGH, "Entering NeverNote.toggleQuotaWindow");
+       searchLayout.toggleQuotaBar();
+       menuBar.hideQuota.setChecked(quotaBar.isVisible());
+       Global.saveWindowVisible("quota", quotaBar.isVisible());
+       logger.log(logger.HIGH, "Leaving NeverNote.toggleQuotaWindow");
+    }  
+       private void toggleZoomWindow() {
+               logger.log(logger.HIGH, "Entering NeverNote.toggleZoomWindow");
+       searchLayout.toggleZoom();
+       menuBar.hideZoom.setChecked(zoomSpinner.isVisible());
+       Global.saveWindowVisible("zoom", zoomSpinner.isVisible());
+       logger.log(logger.HIGH, "Leaving NeverNote.toggleZoomWindow");
+    }  
+       
+       
        
     //***************************************************************
     //***************************************************************
@@ -1329,6 +1383,8 @@ public class NeverNote extends QMainWindow{
        listManager.setSelectedNotebooks(selectedNotebookGUIDs);
        listManager.loadNotesIndex();
        noteIndexUpdated(false);
+       listManager.refreshCounters = true;
+       listManager.refreshCounters();
                logger.log(logger.HIGH, "Leaving NeverNote.notebookTreeSelection");
 
     }
@@ -1371,6 +1427,8 @@ public class NeverNote extends QMainWindow{
                if (!found)
                        selectedNotebookGUIDs.remove(i);
        }
+       listManager.refreshCounters = true;
+       listManager.refreshCounters();
        notebookTree.blockSignals(false);
        
                logger.log(logger.HIGH, "Leaving NeverNote.notebookIndexUpdated");
@@ -1378,10 +1436,7 @@ public class NeverNote extends QMainWindow{
     // Show/Hide note information
        private void toggleNotebookWindow() {
                logger.log(logger.HIGH, "Entering NeverNote.toggleNotebookWindow");
-       if (notebookTree.isVisible())
-               notebookTree.hide();
-       else
-               notebookTree.show();
+               searchLayout.toggleNotebook();
        menuBar.hideNotebooks.setChecked(notebookTree.isVisible());
        Global.saveWindowVisible("notebookTree", notebookTree.isVisible());
        logger.log(logger.HIGH, "Leaving NeverNote.toggleNotebookWindow");
@@ -2032,6 +2087,8 @@ public class NeverNote extends QMainWindow{
        listManager.setSelectedTags(selectedTagGUIDs);
        listManager.loadNotesIndex();
        noteIndexUpdated(false);
+       listManager.refreshCounters = true;
+       listManager.refreshCounters();
        logger.log(logger.HIGH, "Leaving NeverNote.tagTreeSelection");
     }
     // trigger the tag index to be refreshed
@@ -2554,16 +2611,10 @@ public class NeverNote extends QMainWindow{
                hidden = !menuBar.hideLeftSide.isChecked();
                menuBar.hideLeftSide.setChecked(!hidden);
                
-               if (notebookTree.isVisible() != hidden)
-                       toggleNotebookWindow();
-               if (savedSearchTree.isVisible() != hidden)
-                       toggleSavedSearchWindow();
-               if (tagTree.isVisible() != hidden)
-                       toggleTagWindow();
-               if (attributeTree.isVisible() != hidden)
-                       toggleAttributesWindow();
-               if (trashTree.isVisible() != hidden)
-                       toggleTrashWindow();
+               if (!hidden) 
+                       leftSplitter1.setHidden(true);
+               else
+                       leftSplitter1.setHidden(false);
                
                Global.saveWindowVisible("leftPanel", hidden);
                
@@ -2724,6 +2775,9 @@ public class NeverNote extends QMainWindow{
        else
                toolBar.setVisible(true);
 
+//     toolBar.addWidget(menuBar);
+//     menuBar.setSizePolicy(Policy.Minimum, Policy.Minimum);
+//     toolBar.addSeparator();
        prevButton = toolBar.addAction("Previous");
        QIcon prevIcon = new QIcon(iconPath+"back.png");
        prevButton.setIcon(prevIcon);
@@ -2797,38 +2851,32 @@ public class NeverNote extends QMainWindow{
        allNotesButton.setIcon(allIcon);
        toggleAllNotesButton(Global.isToolbarButtonVisible("allNotes"));
        
-       toolBar.addSeparator();
-       toolBar.addWidget(new QLabel(tr("Quota:")));
-       toolBar.addWidget(quotaBar);
+       //toolBar.addSeparator();
+       //toolBar.addWidget(new QLabel(tr("Quota:")));
+       //toolBar.addWidget(quotaBar);
        //quotaBar.setSizePolicy(Policy.Minimum, Policy.Minimum);
        updateQuotaBar();
-       toolBar.addSeparator();
+       //toolBar.addSeparator();
        
-       // Setup the zoom
-       zoomSpinner = new QSpinBox();
-       zoomSpinner.setMinimum(10);
-       zoomSpinner.setMaximum(1000);
-       zoomSpinner.setAccelerated(true);
-       zoomSpinner.setSingleStep(10);
-       zoomSpinner.setValue(100);
-       zoomSpinner.valueChanged.connect(this, "zoomChanged()");
-       toolBar.addWidget(new QLabel(tr("Zoom")));
-       toolBar.addWidget(zoomSpinner);
+       //toolBar.addWidget(new QLabel(tr("Zoom")));
+       //toolBar.addWidget(zoomSpinner);
        
        //toolBar.addWidget(new QLabel("                    "));
-       toolBar.addSeparator();
-       toolBar.addWidget(new QLabel(tr("  Search:")));
-       toolBar.addWidget(searchField);
+       //toolBar.addSeparator();
+       //toolBar.addWidget(new QLabel(tr("  Search:")));
+       //toolBar.addWidget(searchField);
        QSizePolicy sizePolicy = new QSizePolicy();
        sizePolicy.setHorizontalPolicy(Policy.MinimumExpanding);
-       searchField.setSizePolicy(sizePolicy);
-       searchField.setInsertPolicy(InsertPolicy.InsertAtTop);
+       QLabel spacer = new QLabel("");
+       spacer.setSizePolicy(sizePolicy);
+       toolBar.addWidget(spacer);
+       //searchField.setInsertPolicy(InsertPolicy.InsertAtTop);
 
-       searchClearButton = toolBar.addAction("Search Clear");
-       QIcon searchClearIcon = new QIcon(iconPath+"searchclear.png");
-       searchClearButton.setIcon(searchClearIcon);
-       searchClearButton.triggered.connect(this, "searchFieldCleared()");
-       toggleSearchClearButton(Global.isToolbarButtonVisible("searchClear"));
+       //searchClearButton = toolBar.addAction("Search Clear");
+       //QIcon searchClearIcon = new QIcon(iconPath+"searchclear.png");
+       //searchClearButton.setIcon(searchClearIcon);
+       //searchClearButton.triggered.connect(this, "searchFieldCleared()");
+       //toggleSearchClearButton(Global.isToolbarButtonVisible("searchClear"));
 
        logger.log(logger.HIGH, "Leaving NeverNote.setupToolBar");
     }
@@ -2948,7 +2996,8 @@ public class NeverNote extends QMainWindow{
                allNotesButton.setVisible(toggle);
                Global.saveToolbarButtonsVisible("allNotes", toggle);
     }
-    private void toggleSearchClearButton(Boolean toggle) {
+    @SuppressWarnings("unused")
+       private void toggleSearchClearButton(Boolean toggle) {
                searchClearButton.setVisible(toggle);
                Global.saveToolbarButtonsVisible("searchClear", toggle);
     }
@@ -3435,7 +3484,7 @@ public class NeverNote extends QMainWindow{
                nextButton.setEnabled(false);
                
        fromHistory = false;
-//     scrollToGuid(currentNoteGuid);
+       scrollToGuid(currentNoteGuid);
        refreshEvernoteNote(true);
                logger.log(logger.HIGH, "Leaving NeverNote.noteTableSelection");
     }    
@@ -4132,7 +4181,6 @@ public class NeverNote extends QMainWindow{
                currentNote = conn.getNoteTable().getNote(currentNoteGuid, true,true,false,false,true);
                if (currentNote == null) 
                        return;
-               
                loadNoteBrowserInformation(browserWindow);
        }
 
@@ -4180,7 +4228,6 @@ public class NeverNote extends QMainWindow{
                if (conn.getNoteTable().isThumbnailNeeded(currentNoteGuid)) {
                        thumbnailHTMLReady(currentNoteGuid, js, Global.calculateThumbnailZoom(js.toString()));
                }
-
                if (readOnly || inkNote)
                        browser.getBrowser().page().setContentEditable(false);  // We don't allow editing of ink notes
                else
@@ -4216,7 +4263,7 @@ public class NeverNote extends QMainWindow{
                browser.setTitle(currentNote.getTitle());
                browser.setTag(getTagNamesForNote(currentNote));
                browser.setAuthor(currentNote.getAttributes().getAuthor());
-               
+
                browser.setAltered(currentNote.getUpdated());
                browser.setCreation(currentNote.getCreated());
                if (currentNote.getAttributes().getSubjectDate() > 0)
@@ -4231,7 +4278,7 @@ public class NeverNote extends QMainWindow{
                
                browser.setCurrentTags(currentNote.getTagNames());
                noteDirty = false;
-//             scrollToGuid(currentNoteGuid);
+               scrollToGuid(currentNoteGuid);
                
                browser.loadingData(false);
                if (thumbnailViewer.isActiveWindow())
@@ -4333,11 +4380,23 @@ public class NeverNote extends QMainWindow{
                return;
        if (currentNoteGuid.equals(""))
                return;
-       
+       String title = null;
+       if (selectedNoteGUIDs.size() == 1)
+               title = conn.getNoteTable().getNote(selectedNoteGUIDs.get(0),false,false,false,false,false).getTitle();
+
        // If we are deleting non-trash notes
        if (currentNote.isActive()) { 
                if (Global.verifyDelete()) {
-                       if (QMessageBox.question(this, tr("Confirmation"), tr("Delete selected note(s)?"),
+                       String msg;
+                       if (selectedNoteGUIDs.size() > 1) {
+                               msg = new String(tr("Delete ") +selectedNoteGUIDs.size() +" notes?");
+                       } else {
+                               if (title != null)
+                                       msg = new String(tr("Delete note \"") +title +"\"?");
+                               else                            
+                                       msg = new String(tr("Delete note selected note?"));
+                       }
+                       if (QMessageBox.question(this, tr("Confirmation"), msg,
                                        QMessageBox.StandardButton.Yes, 
                                        QMessageBox.StandardButton.No)==StandardButton.No.value() && Global.verifyDelete() == true) {
                                        return;
@@ -4351,7 +4410,16 @@ public class NeverNote extends QMainWindow{
        } else { 
                // If we are deleting from the trash.
                if (Global.verifyDelete()) {
-                       if (QMessageBox.question(this, "Confirmation", "Permanently delete selected note(s)?",
+                       String msg;
+                       if (selectedNoteGUIDs.size() > 1) {
+                               msg = new String(tr("Permanently delete ") +selectedNoteGUIDs.size() +" notes?");
+                       } else {
+                               if (title != null)
+                               msg = new String(tr("Permanently delete note \"") +title +"\"?");
+                               else
+                                       msg = new String(tr("Permanently delete note selected note?"));
+                       }
+                       if (QMessageBox.question(this, "Confirmation", msg,
                                QMessageBox.StandardButton.Yes, 
                                        QMessageBox.StandardButton.No)==StandardButton.No.value()) {
                                        return;
index 5ebf260..7707b36 100644 (file)
@@ -34,7 +34,8 @@ public class AttributeTreeWidget extends QTreeWidget {
        public AttributeTreeWidget() {\r
        setHeaderLabel(tr("Attributes"));\r
        setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
\r
+       header().setStyleSheet("QHeaderView::section {border: 0.0em;}");\r
+       \r
        setHeaderLabel(tr("Attributes"));\r
        setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection);\r
        \r
index 450ab24..943759a 100644 (file)
@@ -67,6 +67,9 @@ public class MainMenuBar extends QMenuBar {
        public QAction                  narrowListView;                         // View with list on the side\r
        public QAction                  thumbnailView;                          // view thumbnails\r
        public QAction                  hideSavedSearches;                      // show/hide saved searches\r
+       public QAction                  hideZoom;                                       // show/hide the zoom spinner\r
+       public QAction                  hideSearch;                                     // Show/hide the search window\r
+       public QAction                  hideQuota;                                      // show/hide the quota window\r
        public QAction                  hideNotebooks;                          // show/hide notebooks\r
        public QAction                  hideTags;                                       // show/hide tags\r
        public QAction                  hideAttributes;                         // show/hide note information\r
@@ -301,6 +304,27 @@ public class MainMenuBar extends QMenuBar {
                hideNotebooks.setCheckable(true);\r
                hideNotebooks.setChecked(true);\r
                setupShortcut(hideNotebooks, "View_Show_Notebooks");\r
+               \r
+               hideZoom = new QAction(tr("Show Zoom"), this);\r
+               hideZoom.setToolTip("Show/Hide Zoom");\r
+               hideZoom.triggered.connect(parent, "toggleZoomWindow()");\r
+               hideZoom.setCheckable(true);\r
+               hideZoom.setChecked(true);\r
+               setupShortcut(hideZoom, "View_Show_Zoom");\r
+               \r
+               hideQuota = new QAction(tr("Show Quota Bar"), this);\r
+               hideQuota.setToolTip("Show/Hide Quota");\r
+               hideQuota.triggered.connect(parent, "toggleQuotaWindow()");\r
+               hideQuota.setCheckable(true);\r
+               hideQuota.setChecked(true);\r
+               setupShortcut(hideQuota, "View_Show_Quota");\r
+               \r
+               hideSearch = new QAction(tr("Show Search Box"), this);\r
+               hideSearch.setToolTip("Show/Hide Search Box");\r
+               hideSearch.triggered.connect(parent, "toggleSearchWindow()");\r
+               hideSearch.setCheckable(true);\r
+               hideSearch.setChecked(true);\r
+               setupShortcut(hideSearch, "View_Show_Search");\r
 \r
                wideListView = new QAction(tr("Wide List View"), this);\r
                wideListView.setToolTip("Wide List Viwe");\r
@@ -652,6 +676,9 @@ public class MainMenuBar extends QMenuBar {
                viewMenu.addAction(thumbnailView);\r
                viewMenu.addSeparator();\r
                viewMenu.addAction(hideNoteList);\r
+               viewMenu.addAction(hideSearch);\r
+               viewMenu.addAction(hideQuota);\r
+               viewMenu.addAction(hideZoom);\r
                viewMenu.addAction(hideNotebooks);\r
                viewMenu.addAction(hideTags);\r
                viewMenu.addAction(hideAttributes);\r
index b894d80..2e82288 100644 (file)
@@ -106,6 +106,7 @@ public class NotebookTreeWidget extends QTreeWidget {
                header().setResizeMode(0, QHeaderView.ResizeMode.ResizeToContents);\r
                header().setResizeMode(1, QHeaderView.ResizeMode.Stretch);\r
                header().setMovable(false);\r
+               header().setStyleSheet("QHeaderView::section {border: 0.0em;}");\r
                setHeaderLabels(labels);\r
                setDragDropMode(QAbstractItemView.DragDropMode.DragDrop);\r
                // If we want to mimic Evernote's notebook selection\r
index 5024d3f..d0fd615 100644 (file)
@@ -45,6 +45,7 @@ public class SavedSearchTreeWidget extends QTreeWidget {
 //             setAcceptDrops(true);\r
 //             setDragEnabled(true);\r
                setProperty("hideTree", true);\r
+               header().setStyleSheet("QHeaderView::section {border: 0.0em;}");\r
                setAcceptDrops(false);\r
                setDragEnabled(false);\r
 //             setDragDropMode(QAbstractItemView.DragDropMode.DragDrop);\r
diff --git a/src/cx/fbn/nevernote/gui/SearchPanel.java b/src/cx/fbn/nevernote/gui/SearchPanel.java
new file mode 100644 (file)
index 0000000..d0d1c34
--- /dev/null
@@ -0,0 +1,93 @@
+package cx.fbn.nevernote.gui;\r
+\r
+import com.trolltech.qt.gui.QComboBox;\r
+import com.trolltech.qt.gui.QHBoxLayout;\r
+import com.trolltech.qt.gui.QLabel;\r
+import com.trolltech.qt.gui.QSpinBox;\r
+import com.trolltech.qt.gui.QVBoxLayout;\r
+import com.trolltech.qt.gui.QWidget;\r
+\r
+import cx.fbn.nevernote.gui.controls.QuotaProgressBar;\r
+\r
+public class SearchPanel extends QWidget {\r
+       private final QLabel zoomLabel;\r
+       private final QSpinBox zoomSpinner;\r
+       private final NotebookTreeWidget notebook;\r
+       private final QComboBox search;\r
+       private final QuotaProgressBar bar;\r
+       \r
+       public SearchPanel(QComboBox search, QuotaProgressBar bar, NotebookTreeWidget notebook, QSpinBox zoom) {\r
+               QVBoxLayout mainLayout = new QVBoxLayout();\r
+               QVBoxLayout subLayout = new QVBoxLayout();\r
+               zoomSpinner = zoom;\r
+               this.bar = bar;\r
+               this.search = search;\r
+               this.notebook = notebook;\r
+               \r
+               setLayout(mainLayout);\r
+               subLayout.addWidget(search);\r
+               subLayout.addWidget(bar);\r
+               QHBoxLayout zoomLayout = new QHBoxLayout();\r
+               zoomLabel = new QLabel(tr("Zoom:"));\r
+               zoomLayout.addWidget(zoomLabel);\r
+               zoomLayout.addWidget(zoom);\r
+               zoomLayout.setStretch(1, 100);\r
+               subLayout.addLayout(zoomLayout);\r
+               mainLayout.addLayout(subLayout);\r
+               mainLayout.addWidget(notebook);\r
+               //setStyleSheet("QTreeView {border: 0.0em;}");\r
+               mainLayout.setContentsMargins(0, 0, 0, 0);\r
+       }\r
+       \r
+       public void hideZoom() {\r
+               zoomLabel.hide();\r
+               zoomSpinner.hide();\r
+       }\r
+       public void showZoom() {\r
+               zoomLabel.show();\r
+               zoomSpinner.show();\r
+       }\r
+       \r
+       public void toggleNotebook() {\r
+               show();\r
+               if (notebook.isVisible())\r
+                       notebook.hide();\r
+               else\r
+                       notebook.show();\r
+               \r
+               checkVisibility();\r
+       }\r
+       \r
+       public void toggleSearchField() {\r
+               show();\r
+               if (search.isVisible())\r
+                       search.hide();\r
+               else\r
+                       search.show();\r
+               checkVisibility();\r
+       }\r
+       \r
+       private void checkVisibility() {\r
+               if (notebook.isHidden() && bar.isHidden() && search.isHidden() && zoomSpinner.isHidden()) {\r
+                       hide();\r
+               }\r
+       }\r
+       \r
+       public void toggleQuotaBar() {\r
+               show();\r
+               if (bar.isVisible())\r
+                       bar.hide();\r
+               else\r
+                       bar.show();\r
+               checkVisibility();\r
+       }\r
+       \r
+       public void toggleZoom() {\r
+               show();\r
+               if (zoomSpinner.isVisible())\r
+                       zoomSpinner.hide();\r
+               else\r
+                       zoomSpinner.show();\r
+               checkVisibility();\r
+       }\r
+}\r
index ee4d161..46f55f6 100644 (file)
@@ -78,6 +78,7 @@ public class TagTreeWidget extends QTreeWidget {
                header().setResizeMode(0, QHeaderView.ResizeMode.ResizeToContents);\r
                header().setResizeMode(1, QHeaderView.ResizeMode.Stretch);\r
                header().setMovable(false);\r
+               header().setStyleSheet("QHeaderView::section {border: 0.0em;}");\r
                db = d;\r
                selectionSignal = new Signal0();\r
                tagSignal = new TagSignal();\r
index adc2d98..ebecb45 100644 (file)
@@ -55,6 +55,7 @@ public class TrashTreeWidget extends QTreeWidget {
        iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
         trashIcon = new QIcon(iconPath+"trash.png");\r
         trashFullIcon = new QIcon(iconPath+"trash-full.png");\r
+        header().hide();\r
        }\r
        \r
        public void updateCounts(Integer cnt) {\r
diff --git a/src/cx/fbn/nevernote/icons/synchronize-0.png b/src/cx/fbn/nevernote/icons/synchronize-0.png
deleted file mode 100644 (file)
index f23edb0..0000000
Binary files a/src/cx/fbn/nevernote/icons/synchronize-0.png and /dev/null differ
diff --git a/src/cx/fbn/nevernote/icons/synchronize-1.png b/src/cx/fbn/nevernote/icons/synchronize-1.png
deleted file mode 100644 (file)
index bc141c7..0000000
Binary files a/src/cx/fbn/nevernote/icons/synchronize-1.png and /dev/null differ
diff --git a/src/cx/fbn/nevernote/icons/synchronize-2.png b/src/cx/fbn/nevernote/icons/synchronize-2.png
deleted file mode 100644 (file)
index 6acb7fd..0000000
Binary files a/src/cx/fbn/nevernote/icons/synchronize-2.png and /dev/null differ
diff --git a/src/cx/fbn/nevernote/icons/synchronize-3.png b/src/cx/fbn/nevernote/icons/synchronize-3.png
deleted file mode 100644 (file)
index 6034544..0000000
Binary files a/src/cx/fbn/nevernote/icons/synchronize-3.png and /dev/null differ
index f0dcb64..f0529ca 100644 (file)
@@ -63,7 +63,6 @@ public class NoteTable {
                noteTagsTable = new NoteTagsTable(logger, db);\r
                getQueryWithContent = null;\r
                getQueryWithoutContent = null;\r
-               \r
        }\r
        // Create the table\r
        public void createTable() {\r
@@ -168,6 +167,8 @@ public class NoteTable {
        } \r
        // Setup queries for get to save time later\r
        private void prepareQueries() {\r
+               if (getQueryWithContent != null)\r
+                       return;\r
                getQueryWithContent = new NSqlQuery(db.getConnection());\r
                getQueryWithoutContent = new NSqlQuery(db.getConnection());\r
                getAllQueryWithoutContent = new NSqlQuery(db.getConnection());\r
@@ -257,7 +258,6 @@ public class NoteTable {
                DateFormat indfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");\r
 //             indfm = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");\r
 \r
-               \r
                Note n = new Note();\r
                NoteAttributes na = new NoteAttributes();\r
                n.setAttributes(na);\r
@@ -295,7 +295,7 @@ public class NoteTable {
                if (loadTags) {\r
                        n.setTagGuids(noteTagsTable.getNoteTags(n.getGuid()));\r
                        List<String> tagNames = new ArrayList<String>();\r
-                       TagTable tagTable = new TagTable(logger, db);\r
+                       TagTable tagTable = db.getTagTable();\r
                        for (int i=0; i<n.getTagGuids().size(); i++) {\r
                                String currentGuid = n.getTagGuids().get(i);\r
                                Tag tag = tagTable.getTag(currentGuid);\r
@@ -305,7 +305,6 @@ public class NoteTable {
                }\r
                \r
                if (loadContent) {\r
-                                               \r
                        QTextCodec codec = QTextCodec.codecForLocale();\r
                        codec = QTextCodec.codecForName("UTF-8");\r
                String unicode =  codec.fromUnicode(query.valueString(16)).toString();\r
index 2b71bb4..75585ce 100644 (file)
@@ -30,6 +30,7 @@ import cx.fbn.nevernote.utilities.Pair;
 public class NoteTagsTable {\r
        private final ApplicationLogger                 logger;\r
        DatabaseConnection                                              db;\r
+       NSqlQuery                                                               getNoteTagsQuery;\r
 \r
        \r
        // Constructor\r
@@ -55,22 +56,26 @@ public class NoteTagsTable {
        public List<String> getNoteTags(String noteGuid) {\r
                if (noteGuid == null)\r
                        return null;\r
-               boolean check;\r
                List<String> tags = new ArrayList<String>();\r
                \r
-               NSqlQuery query = new NSqlQuery(db.getConnection());\r
-               check = query.exec("Select "\r
-                               +"TagGuid from NoteTags where noteGuid = '" +noteGuid +"'");\r
-               if (!check) {\r
+               if (getNoteTagsQuery == null)\r
+                       prepareGetNoteTagsQuery();\r
+               \r
+               getNoteTagsQuery.bindValue(":guid", noteGuid);\r
+               if (!getNoteTagsQuery.exec()) {\r
                        logger.log(logger.EXTREME, "NoteTags SQL select has failed.");\r
-                       logger.log(logger.MEDIUM, query.lastError());\r
+                       logger.log(logger.MEDIUM, getNoteTagsQuery.lastError());\r
                        return null;\r
                }\r
-               while (query.next()) {\r
-                       tags.add(query.valueString(0));\r
+               while (getNoteTagsQuery.next()) {\r
+                       tags.add(getNoteTagsQuery.valueString(0));\r
                }       \r
                return tags;\r
        }\r
+       void prepareGetNoteTagsQuery() {\r
+               getNoteTagsQuery = new NSqlQuery(db.getConnection());\r
+               getNoteTagsQuery.prepare("Select TagGuid from NoteTags where noteGuid = :guid");\r
+       }\r
        // Get a note tags by the note's Guid\r
        public List<NoteTagsRecord> getAllNoteTags() {\r
                List<NoteTagsRecord> tags = new ArrayList<NoteTagsRecord>();\r
index 3cf3ab0..85ce7fb 100644 (file)
@@ -46,6 +46,7 @@ public class NotebookTable {
        private final ApplicationLogger                 logger;\r
        DatabaseConnection                                              db;\r
        private final String                                    dbName;\r
+       NSqlQuery                                                               notebookCountQuery;\r
        \r
        // Constructor\r
        public NotebookTable(ApplicationLogger l, DatabaseConnection d) {\r
@@ -671,16 +672,19 @@ public class NotebookTable {
        // Get a note tag counts\r
        public List<Pair<String,Integer>> getNotebookCounts() {\r
                List<Pair<String,Integer>> counts = new ArrayList<Pair<String,Integer>>();              \r
-               NSqlQuery query = new NSqlQuery(db.getConnection());\r
-               if (!query.exec("select notebookGuid, count(guid) from note where active=1 group by notebookguid;")) {\r
+               if (notebookCountQuery == null) {\r
+                       notebookCountQuery = new NSqlQuery(db.getConnection());\r
+                       notebookCountQuery.prepare("select notebookGuid, count(guid) from note where active=1 group by notebookguid;");\r
+               }\r
+               if (!notebookCountQuery.exec()) {\r
                        logger.log(logger.EXTREME, "NoteTags SQL getTagCounts has failed.");\r
-                       logger.log(logger.MEDIUM, query.lastError());\r
+                       logger.log(logger.MEDIUM, notebookCountQuery.lastError());\r
                        return null;\r
                }\r
-               while (query.next()) {\r
+               while (notebookCountQuery.next()) {\r
                        Pair<String,Integer> newCount = new Pair<String,Integer>();\r
-                       newCount.setFirst(query.valueString(0));\r
-                       newCount.setSecond(query.valueInteger(1));\r
+                       newCount.setFirst(notebookCountQuery.valueString(0));\r
+                       newCount.setSecond(notebookCountQuery.valueInteger(1));\r
                        counts.add(newCount);\r
                }       \r
                return counts;\r
index 1917cf3..7978804 100644 (file)
@@ -25,12 +25,9 @@ import java.util.Vector;
 import java.util.concurrent.LinkedBlockingQueue;\r
 \r
 import com.evernote.edam.type.Note;\r
-import com.evernote.edam.type.Notebook;\r
-import com.evernote.edam.type.Tag;\r
 import com.trolltech.qt.core.QMutex;\r
 import com.trolltech.qt.core.QObject;\r
 \r
-import cx.fbn.nevernote.Global;\r
 import cx.fbn.nevernote.filters.NotebookCounter;\r
 import cx.fbn.nevernote.filters.TagCounter;\r
 import cx.fbn.nevernote.signals.NotebookSignal;\r
@@ -38,19 +35,25 @@ import cx.fbn.nevernote.signals.TagSignal;
 import cx.fbn.nevernote.signals.TrashSignal;\r
 import cx.fbn.nevernote.sql.DatabaseConnection;\r
 import cx.fbn.nevernote.utilities.ApplicationLogger;\r
-import cx.fbn.nevernote.utilities.Pair;\r
 \r
 public class CounterRunner extends QObject implements Runnable {\r
         \r
+       private class NoteRecord {\r
+               public String notebookGuid;\r
+               public Vector<String> tags;\r
+               public boolean active;\r
+               \r
+               public NoteRecord()  {\r
+                       tags = new Vector<String>();\r
+               }\r
+       }\r
        private final ApplicationLogger         logger;\r
        private volatile boolean                        keepRunning;\r
        public int                                                      ID;\r
        public volatile NotebookSignal          notebookSignal;\r
        public volatile TrashSignal                     trashSignal;\r
        public volatile TagSignal                       tagSignal;\r
-       private volatile Vector<String>         notebookIndex;\r
-       private volatile Vector<String>         noteIndex;\r
-       private volatile Vector<Boolean>        activeIndex;\r
+       private volatile Vector<NoteRecord> records;\r
        public int                                                      type;\r
        public QMutex                                           threadLock;\r
        \r
@@ -58,8 +61,6 @@ public class CounterRunner extends QObject implements Runnable {
        public static int                                       NOTEBOOK=1;\r
        public static int                                       TAG=2;\r
        public static int                                       TRASH=3;\r
-       public static int                                       TAG_ALL = 4;\r
-       public static int                                       NOTEBOOK_ALL = 5;\r
        \r
        public boolean                                          ready = false;\r
        public boolean                                          abortCount = false;\r
@@ -83,9 +84,7 @@ public class CounterRunner extends QObject implements Runnable {
                tagSignal = new TagSignal();\r
                trashSignal = new TrashSignal();\r
                \r
-               notebookIndex = new Vector<String>();\r
-               activeIndex = new Vector<Boolean>();\r
-               noteIndex = new Vector<String>();\r
+               records = new Vector<NoteRecord>();\r
        }\r
        \r
        \r
@@ -108,12 +107,8 @@ public class CounterRunner extends QObject implements Runnable {
                                        keepRunning = false;\r
                                if (type == NOTEBOOK)\r
                                        countNotebookResults();\r
-                               if (type == NOTEBOOK_ALL)\r
-                                       countNotebookResults();\r
                                if (type == TAG)\r
                                        countTagResults();\r
-                               if (type == TAG_ALL)\r
-                                       countTagResults();\r
                                if (type == TRASH)\r
                                        countTrashResults();\r
                                threadLock.unlock();\r
@@ -128,21 +123,20 @@ public class CounterRunner extends QObject implements Runnable {
                abortCount = true;\r
                threadLock.lock();\r
                abortCount = false;\r
-               notebookIndex.clear();\r
-               activeIndex.clear();\r
-               noteIndex.clear();\r
+               records.clear();\r
                if (idx != null) {\r
                        for (int i=0; i<idx.size(); i++) {\r
-                               if (Global.showDeleted && !idx.get(i).isActive()) {\r
-                                       notebookIndex.add(new String(idx.get(i).getNotebookGuid()));\r
-                                       noteIndex.add(new String(idx.get(i).getGuid()));\r
-                                       activeIndex.add(new Boolean(idx.get(i).isActive()));\r
-                               }  \r
-                               if (!Global.showDeleted && idx.get(i).isActive()) {\r
-                                       notebookIndex.add(new String(idx.get(i).getNotebookGuid()));\r
-                                       noteIndex.add(new String(idx.get(i).getGuid()));\r
-                                       activeIndex.add(new Boolean(idx.get(i).isActive()));                                    \r
+                               if (abortCount)\r
+                                       return;\r
+                               NoteRecord record = new NoteRecord();\r
+                               record.notebookGuid = new String(idx.get(i).getNotebookGuid());\r
+                               record.active = idx.get(i).isActive();\r
+                               for (int j=0; j<idx.get(i).getTagGuidsSize(); j++) {\r
+                                       if (abortCount)\r
+                                               return;\r
+                                       record.tags.add(new String(idx.get(i).getTagGuids().get(j)));\r
                                }\r
+                               records.add(record);\r
                        }\r
                }\r
                threadLock.unlock();\r
@@ -171,70 +165,22 @@ public class CounterRunner extends QObject implements Runnable {
                if (abortCount)\r
                        return;\r
                List<NotebookCounter> nCounter = new ArrayList<NotebookCounter>();\r
-               if (abortCount)\r
-                       return;\r
-               List<Notebook> books = conn.getNotebookTable().getAll();\r
-                               \r
-               if (abortCount)\r
-                       return;\r
-\r
-               if (type == NOTEBOOK_ALL) {\r
-                       for (int i=0; i<books.size(); i++) {\r
-                               if (abortCount)\r
-                                       return;\r
-\r
-                               nCounter.add(new NotebookCounter());\r
-                               nCounter.get(i).setCount(0);\r
-                               nCounter.get(i).setGuid(books.get(i).getGuid());\r
-                       }\r
+               for (int i=0; i<records.size(); i++) {\r
                        if (abortCount)\r
                                return;\r
-                       List<Pair<String, Integer>> notebookCounts = conn.getNotebookTable().getNotebookCounts();\r
-                       if (abortCount)\r
-                               return;\r
-                       for (int i=0; notebookCounts != null && i<notebookCounts.size(); i++) {\r
+                       boolean found = false;\r
+                       for (int j=0; j<nCounter.size(); j++) {\r
                                if (abortCount)\r
                                        return;\r
-                               for (int j=0; j<nCounter.size(); j++) {\r
-                                       if (abortCount)\r
-                                               return;\r
-\r
-                                       if (notebookCounts.get(i).getFirst().equals(nCounter.get(j).getGuid())) {\r
-                                               nCounter.get(j).setCount(notebookCounts.get(i).getSecond());\r
-                                               j=nCounter.size();\r
-                                       }\r
-                               }\r
-                       }\r
-                       if (abortCount)\r
-                               return;\r
-\r
-                       notebookSignal.countsChanged.emit(nCounter);\r
-                       return;\r
-               }\r
-               \r
-               if (abortCount)\r
-                       return;\r
-               for (int i=notebookIndex.size()-1; i>=0 && keepRunning; i--) {\r
-                       if (abortCount)\r
-                               return;\r
-                       boolean notebookFound = false;\r
-                       for (int j=0; j<nCounter.size() && keepRunning; j++) {\r
-                               if (abortCount)\r
-                                       return;\r
-                               if (nCounter.get(j).getGuid().equals(notebookIndex.get(i))) {\r
-                                       notebookFound = true;\r
-                                       if (activeIndex.get(i)) {\r
-                                               int c = nCounter.get(j).getCount()+1;\r
-                                               nCounter.get(j).setCount(c);\r
-                                       }\r
+                               if (nCounter.get(j).getGuid().equals(records.get(i).notebookGuid)) {\r
+                                       nCounter.get(j).setCount(nCounter.get(j).getCount()+1);\r
+                                       found = true;\r
                                        j=nCounter.size();\r
                                }\r
                        }\r
-                       if (abortCount)\r
-                               return;\r
-                       if (!notebookFound) {\r
+                       if (!found) {\r
                                NotebookCounter newCounter = new NotebookCounter();\r
-                               newCounter.setGuid(notebookIndex.get(i));\r
+                               newCounter.setGuid(records.get(i).notebookGuid);\r
                                newCounter.setCount(1);\r
                                nCounter.add(newCounter);\r
                        }\r
@@ -246,6 +192,7 @@ public class CounterRunner extends QObject implements Runnable {
        }\r
        \r
        \r
+       /*\r
        private void countTagResults() {\r
                logger.log(logger.EXTREME, "Entering ListManager.countTagResults");             \r
                List<TagCounter> counter = new ArrayList<TagCounter>();\r
@@ -312,6 +259,41 @@ public class CounterRunner extends QObject implements Runnable {
                        return;\r
                tagSignal.countsChanged.emit(counter);\r
                logger.log(logger.EXTREME, "Leaving ListManager.countTagResults()");\r
+       } */\r
+       private void countTagResults() {\r
+               logger.log(logger.EXTREME, "Entering ListManager.countTagResults");     \r
+               if (abortCount)\r
+                       return;\r
+               List<TagCounter> tCounter = new ArrayList<TagCounter>();\r
+               for (int i=0; i<records.size(); i++) {\r
+                       if (abortCount)\r
+                               return;\r
+                       \r
+                       // Loop through the list of tags so we can count them\r
+                       Vector<String> tags = records.get(i).tags;\r
+                       for (int z=0; z<tags.size(); z++) {\r
+                               boolean found = false;\r
+                               for (int j=0; j<tCounter.size(); j++) {\r
+                                       if (abortCount)\r
+                                               return;\r
+                                       if (tCounter.get(j).getGuid().equals(tags.get(z))) {\r
+                                               tCounter.get(j).setCount(tCounter.get(j).getCount()+1);\r
+                                               found = true;\r
+                                               j=tCounter.size();\r
+                                       }\r
+                               }\r
+                               if (!found) {\r
+                                       TagCounter newCounter = new TagCounter();\r
+                                       newCounter.setGuid(tags.get(z));\r
+                                       newCounter.setCount(1);\r
+                                       tCounter.add(newCounter);\r
+                               }\r
+                       }\r
+               }\r
+               if (abortCount)\r
+                       return;\r
+               tagSignal.countsChanged.emit(tCounter);\r
+               logger.log(logger.EXTREME, "Leaving ListManager.countTagResults");      \r
        }\r
        \r
        \r
@@ -320,7 +302,13 @@ public class CounterRunner extends QObject implements Runnable {
                if (abortCount)\r
                        return;\r
 \r
-               Integer tCounter = conn.getNoteTable().getDeletedCount();\r
+               int tCounter = 0;\r
+               for (int i=0; i<records.size(); i++) {\r
+                       if (abortCount)\r
+                               return;\r
+                       if (!records.get(i).active)\r
+                               tCounter++;\r
+               }\r
                \r
                if (abortCount)\r
                        return;\r
index 7a43767..9193f96 100644 (file)
@@ -100,6 +100,7 @@ public class ListManager  {
        public HashMap<String, String>  wordMap;\r
        public TagSignal                                tagSignal;\r
        public NotebookSignal                   notebookSignal;\r
+       public boolean                                  refreshCounters;                        // Used to control when to recount lists\r
        private int                                             trashCount;\r
     public SaveRunner                          saveRunner;                                     // Thread used to save content.  Used because the xml conversion is slowwwww\r
     QThread                                                    saveThread;\r
@@ -152,7 +153,7 @@ public class ListManager  {
                trashCounterRunner.trashSignal.countChanged.connect(this, "trashSignalReceiver(Integer)");\r
                trashThread = new QThread(trashCounterRunner, "Trash Counter Thread");\r
                trashThread.start();\r
-               reloadTrashCount();\r
+//             reloadTrashCount();\r
                \r
                wordMap = new HashMap<String, String>();\r
                tagSignal = new TagSignal();\r
@@ -169,6 +170,8 @@ public class ListManager  {
                \r
                linkedNotebookIndex = conn.getLinkedNotebookTable().getAll();\r
                loadNoteTitleColors();\r
+               refreshCounters = true;\r
+               refreshCounters();\r
                                \r
        }\r
        \r
@@ -257,7 +260,7 @@ public class ListManager  {
        }\r
 \r
        public void reloadTagIndex() {\r
-               conn.getTagTable().cleanupTags();\r
+//             conn.getTagTable().cleanupTags();\r
                setTagIndex(conn.getTagTable().getAll());       \r
        }\r
        public void reloadIndexes() {\r
@@ -959,12 +962,23 @@ public class ListManager  {
                return false;\r
        }\r
        \r
-       // Load the note index based upon what the user wants.\r
-       public void loadNotesIndex() {\r
-               logger.log(logger.EXTREME, "Entering ListManager.loadNotesIndex()");\r
+       // Trigger a recount of counters\r
+       public void refreshCounters() {\r
+//             refreshCounters= false;\r
+               if (!refreshCounters)\r
+                       return;\r
+               refreshCounters = false;\r
                tagCounterRunner.abortCount = true;\r
                notebookCounterRunner.abortCount = true;\r
                trashCounterRunner.abortCount = true;\r
+               countNotebookResults(getNoteIndex());\r
+               countTagResults(getNoteIndex());\r
+               reloadTrashCount();\r
+\r
+       }\r
+       // Load the note index based upon what the user wants.\r
+       public void loadNotesIndex() {\r
+               logger.log(logger.EXTREME, "Entering ListManager.loadNotesIndex()");\r
                \r
                List<Note> matches;\r
                if (enSearchChanged || getMasterNoteIndex() == null)\r
@@ -980,37 +994,34 @@ public class ListManager  {
                        if (filterRecord(matches.get(i)))\r
                                getNoteIndex().add(matches.get(i));\r
                }\r
-               countNotebookResults(getNoteIndex());\r
-               countTagResults(getNoteIndex());\r
+               refreshCounters = true;\r
                enSearchChanged = false;\r
-               reloadTrashCount();\r
                logger.log(logger.EXTREME, "Leaving ListManager.loadNotesIndex()");\r
        }\r
        public void countNotebookResults(List<Note> index) {\r
                logger.log(logger.EXTREME, "Entering ListManager.countNotebookResults()");\r
-               if (!Global.mimicEvernoteInterface) {\r
+               notebookCounterRunner.abortCount = true;\r
+               if (!Global.mimicEvernoteInterface) \r
                        notebookCounterRunner.setNoteIndex(index);\r
-                       notebookCounterRunner.release(CounterRunner.NOTEBOOK);\r
-               } else {\r
+               else \r
                        notebookCounterRunner.setNoteIndex(getMasterNoteIndex());\r
-                       notebookCounterRunner.release(CounterRunner.NOTEBOOK_ALL);\r
-               }\r
+               notebookCounterRunner.release(CounterRunner.NOTEBOOK);\r
                logger.log(logger.EXTREME, "Leaving ListManager.countNotebookResults()");\r
        }\r
        public void countTagResults(List<Note> index) {\r
                logger.log(logger.EXTREME, "Entering ListManager.countTagResults");\r
-               if (!Global.tagBehavior().equalsIgnoreCase("DoNothing")) {\r
+               trashCounterRunner.abortCount = true;\r
+               if (!Global.tagBehavior().equalsIgnoreCase("DoNothing")) \r
                        tagCounterRunner.setNoteIndex(index);\r
-                       tagCounterRunner.release(CounterRunner.TAG);\r
-               } else {\r
-                       tagCounterRunner.setNoteIndex(null);\r
-                       tagCounterRunner.release(CounterRunner.TAG_ALL);\r
-               }\r
+               else\r
+                       tagCounterRunner.setNoteIndex(getMasterNoteIndex());\r
+               tagCounterRunner.release(CounterRunner.TAG);\r
                logger.log(logger.EXTREME, "Leaving ListManager.countTagResults()");\r
        }\r
        // Update the count of items in the trash\r
        public void reloadTrashCount() {\r
                logger.log(logger.EXTREME, "Entering ListManager.reloadTrashCount");\r
+               trashCounterRunner.abortCount = true;\r
                trashCounterRunner.setNoteIndex(getNoteIndex());\r
                trashCounterRunner.release(CounterRunner.TRASH);\r
                logger.log(logger.EXTREME, "Leaving ListManager.reloadTrashCount");\r