OSDN Git Service

- Gui cleanup - Rework count threads to reduce SQL overhead & improve performance.
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / NoteTable.java
index 4e888f6..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
@@ -697,9 +696,8 @@ public class NoteTable {
        }\r
        // Update a note\r
        public void updateNote(Note n, boolean isNew) {\r
-               boolean isExpunged = isNoteExpunged(n.getGuid());\r
                int titleColor = getNoteTitleColor(n.getGuid());\r
-               expungeNote(n.getGuid(), !isExpunged, false);\r
+               expungeNote(n.getGuid(), true, false);\r
                addNote(n, false);\r
                if (titleColor != -1)\r
                        setNoteTitleColor(n.getGuid(), titleColor);\r