OSDN Git Service

Added ability to customize db cache.
authorRandy Baumgarte <randy@fbn.cx>
Fri, 7 Jan 2011 18:20:07 +0000 (13:20 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Mon, 10 Jan 2011 01:15:15 +0000 (20:15 -0500)
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/dialog/ConfigDebugPage.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java
src/cx/fbn/nevernote/sql/DatabaseConnection.java

index d676199..d7e067c 100644 (file)
@@ -131,6 +131,7 @@ public class Global {
        public static boolean mimicEvernoteInterface;\r
        public static HashMap<String,String> resourceMap;\r
        public static String cipherPassword = "";\r
        public static boolean mimicEvernoteInterface;\r
        public static HashMap<String,String> resourceMap;\r
        public static String cipherPassword = "";\r
+       public static String databaseCache = "16384";\r
        \r
        static Calendar startTraceTime;\r
        static Calendar intervalTraceTime;\r
        \r
        static Calendar startTraceTime;\r
        static Calendar intervalTraceTime;\r
@@ -165,6 +166,8 @@ public class Global {
                        shortcutKeys = new ShortcutKeys();\r
                        mimicEvernoteInterface = getMimicEvernoteInterface();\r
                        resourceMap = new HashMap<String,String>();\r
                        shortcutKeys = new ShortcutKeys();\r
                        mimicEvernoteInterface = getMimicEvernoteInterface();\r
                        resourceMap = new HashMap<String,String>();\r
+                       \r
+                       databaseCache = getDatabaseCacheSize();\r
                                \r
     }\r
 \r
                                \r
     }\r
 \r
@@ -1529,6 +1532,21 @@ public class Global {
                settings.endGroup();    \r
     }\r
 \r
                settings.endGroup();    \r
     }\r
 \r
+    //***********************\r
+    //* Database cache size\r
+    //***********************\r
+    public static String getDatabaseCacheSize() {\r
+               settings.beginGroup("Debug");\r
+               String text = (String)settings.value("databaseCache", "16384");\r
+               settings.endGroup();    \r
+               return text;\r
+    }\r
+    public static void setDatabaseCache(String value) {\r
+               settings.beginGroup("Debug");\r
+               settings.setValue("databaseCache", value);\r
+               settings.endGroup();    \r
+    }\r
+\r
 \r
 }\r
 \r
 \r
 }\r
 \r
index b97a758..3719d26 100644 (file)
@@ -24,10 +24,13 @@ import com.trolltech.qt.gui.QComboBox;
 import com.trolltech.qt.gui.QGroupBox;\r
 import com.trolltech.qt.gui.QHBoxLayout;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QGroupBox;\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.QTextBrowser;\r
 import com.trolltech.qt.gui.QVBoxLayout;\r
 import com.trolltech.qt.gui.QWidget;\r
 \r
 import com.trolltech.qt.gui.QTextBrowser;\r
 import com.trolltech.qt.gui.QVBoxLayout;\r
 import com.trolltech.qt.gui.QWidget;\r
 \r
+import cx.fbn.nevernote.Global;\r
+\r
 public class ConfigDebugPage extends QWidget {\r
        \r
        QComboBox messageCombo;\r
 public class ConfigDebugPage extends QWidget {\r
        \r
        QComboBox messageCombo;\r
@@ -35,6 +38,7 @@ public class ConfigDebugPage extends QWidget {
        QCheckBox disableUploads;\r
        QCheckBox carriageReturnFix;\r
        QCheckBox enableThumbnails;\r
        QCheckBox disableUploads;\r
        QCheckBox carriageReturnFix;\r
        QCheckBox enableThumbnails;\r
+       QSpinBox  databaseCache;\r
        \r
        public ConfigDebugPage(QWidget parent) {\r
                super(parent);\r
        \r
        public ConfigDebugPage(QWidget parent) {\r
                super(parent);\r
@@ -53,7 +57,6 @@ public class ConfigDebugPage extends QWidget {
                serverLayout.addWidget(disableUploads);\r
                serverGroup.setLayout(serverLayout);\r
 \r
                serverLayout.addWidget(disableUploads);\r
                serverGroup.setLayout(serverLayout);\r
 \r
-               QGroupBox messageGroup = new QGroupBox(tr("Debug Messages"));\r
                QLabel messageLevelLabel = new QLabel(tr("Message Level"));\r
                messageCombo = new QComboBox();\r
                messageCombo.addItem(tr("Low"),"Low");\r
                QLabel messageLevelLabel = new QLabel(tr("Message Level"));\r
                messageCombo = new QComboBox();\r
                messageCombo.addItem(tr("Low"),"Low");\r
@@ -65,20 +68,29 @@ public class ConfigDebugPage extends QWidget {
                messageLayout.addWidget(messageLevelLabel);\r
                messageLayout.addWidget(messageCombo);\r
                messageLayout.setStretch(1, 100);\r
                messageLayout.addWidget(messageLevelLabel);\r
                messageLayout.addWidget(messageCombo);\r
                messageLayout.setStretch(1, 100);\r
-               messageGroup.setLayout(messageLayout);\r
+               \r
+               \r
+               QHBoxLayout databaseCacheLayout = new QHBoxLayout();\r
+               databaseCache = new QSpinBox();\r
+               databaseCacheLayout.addWidget(new QLabel(tr("Database Cache (MB) - Requires restart")));\r
+               databaseCache.setMinimum(4);\r
+               databaseCache.setMaximum(128);\r
+               databaseCache.setValue(new Integer(Global.databaseCache)/1024);\r
+               databaseCacheLayout.addWidget(databaseCache);\r
+               databaseCacheLayout.setStretch(1, 100);\r
                \r
                QVBoxLayout mainLayout = new QVBoxLayout();\r
                \r
                QVBoxLayout mainLayout = new QVBoxLayout();\r
-               mainLayout.addWidget(serverGroup);\r
-               mainLayout.addWidget(messageGroup);\r
+               mainLayout.addLayout(messageLayout);\r
+               mainLayout.addLayout(databaseCacheLayout);\r
                \r
                \r
-               QGroupBox thumbnailGroup = new QGroupBox(tr("Thumbnails"));\r
                QHBoxLayout thumbnailLayout = new QHBoxLayout();\r
                QLabel thumbnailLabel = new QLabel(tr("Enable Thumbnails (experimental)"));\r
                thumbnailLayout.addWidget(thumbnailLabel);\r
                enableThumbnails = new QCheckBox(this);\r
                thumbnailLayout.addWidget(enableThumbnails);\r
                QHBoxLayout thumbnailLayout = new QHBoxLayout();\r
                QLabel thumbnailLabel = new QLabel(tr("Enable Thumbnails (experimental)"));\r
                thumbnailLayout.addWidget(thumbnailLabel);\r
                enableThumbnails = new QCheckBox(this);\r
                thumbnailLayout.addWidget(enableThumbnails);\r
-               thumbnailGroup.setLayout(thumbnailLayout);\r
-               mainLayout.addWidget(thumbnailGroup);\r
+               mainLayout.addLayout(thumbnailLayout);\r
+               \r
+               mainLayout.addWidget(serverGroup);\r
                \r
                QGroupBox crlfGroup = new QGroupBox(tr("Carriage Return Fix"));\r
                String crlfMessage = new String(tr("Note: The carriage return is a test fix.  If you " +\r
                \r
                QGroupBox crlfGroup = new QGroupBox(tr("Carriage Return Fix"));\r
                String crlfMessage = new String(tr("Note: The carriage return is a test fix.  If you " +\r
@@ -89,18 +101,16 @@ public class ConfigDebugPage extends QWidget {
                "you edit a note, this fix is PERMANENT and will be sent to Evernote on the next sync.  I haven't" +\r
                "had any issues with this, but please be aware of this condition."));\r
                carriageReturnFix = new QCheckBox(this);\r
                "you edit a note, this fix is PERMANENT and will be sent to Evernote on the next sync.  I haven't" +\r
                "had any issues with this, but please be aware of this condition."));\r
                carriageReturnFix = new QCheckBox(this);\r
-               QHBoxLayout crlfLayout = new QHBoxLayout();\r
-               QLabel carriageReturnLabel = new QLabel(tr("Enable Carriage Return Fix"));\r
-               crlfLayout.addWidget(carriageReturnLabel);\r
+               QVBoxLayout crlfLayout = new QVBoxLayout();\r
+               carriageReturnFix.setText(tr("Enable Carriage Return Fix"));\r
                crlfLayout.addWidget(carriageReturnFix);\r
                crlfGroup.setLayout(crlfLayout);\r
 \r
                QTextBrowser msg = new QTextBrowser(this);\r
                msg.setText(crlfMessage);\r
                crlfLayout.addWidget(carriageReturnFix);\r
                crlfGroup.setLayout(crlfLayout);\r
 \r
                QTextBrowser msg = new QTextBrowser(this);\r
                msg.setText(crlfMessage);\r
+               crlfLayout.addWidget(msg);\r
                mainLayout.addWidget(crlfGroup);\r
 \r
                mainLayout.addWidget(crlfGroup);\r
 \r
-               mainLayout.addWidget(msg);\r
-               \r
                mainLayout.addStretch(1);\r
                setLayout(mainLayout);\r
                \r
                mainLayout.addStretch(1);\r
                setLayout(mainLayout);\r
                \r
@@ -166,5 +176,9 @@ public class ConfigDebugPage extends QWidget {
                return enableThumbnails.isChecked();\r
        }\r
 \r
                return enableThumbnails.isChecked();\r
        }\r
 \r
+       \r
+       public String getDatabaseCacheSize() {\r
+               return new Integer(databaseCache.value()*1024).toString();\r
+       }\r
 \r
 }\r
 \r
 }\r
index 472ad73..5b7f43f 100644 (file)
@@ -204,6 +204,7 @@ public class ConfigDialog extends QDialog {
                Global.setOverrideDefaultFont(fontPage.overrideFont());\r
                Global.setDefaultFont(fontPage.getFont());\r
                Global.setDefaultFontSize(fontPage.getFontSize());\r
                Global.setOverrideDefaultFont(fontPage.overrideFont());\r
                Global.setDefaultFont(fontPage.getFont());\r
                Global.setDefaultFontSize(fontPage.getFontSize());\r
+               Global.setDatabaseCache(debugPage.getDatabaseCacheSize());\r
                                \r
                close();\r
        }\r
                                \r
                close();\r
        }\r
index d3c8186..25b5d3e 100644 (file)
@@ -105,7 +105,9 @@ public class DatabaseConnection {
                                passwordString = userPassword;
                        else
                                passwordString = cypherPassword+" "+userPassword;
                                passwordString = userPassword;
                        else
                                passwordString = cypherPassword+" "+userPassword;
-                       conn = DriverManager.getConnection(url+";CACHE_SIZE=65536",userid,passwordString);
+//                     conn = DriverManager.getConnection(url,userid,passwordString);
+//                     conn = DriverManager.getConnection(url+";CACHE_SIZE=4096",userid,passwordString);
+                       conn = DriverManager.getConnection(url+";CACHE_SIZE="+Global.databaseCache,userid,passwordString);
 //                     conn = DriverManager.getConnection(url+";AUTO_SERVER=TRUE",userid,passwordString);
                } catch (SQLException e) {
                        e.printStackTrace();
 //                     conn = DriverManager.getConnection(url+";AUTO_SERVER=TRUE",userid,passwordString);
                } catch (SQLException e) {
                        e.printStackTrace();