OSDN Git Service

Allow users to specify sleep interval between looking for unindexed notes.
authorRandy Baumgarte <randy@fbn.cx>
Tue, 28 Sep 2010 12:41:44 +0000 (08:41 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Fri, 1 Oct 2010 16:43:30 +0000 (12:43 -0400)
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java
src/cx/fbn/nevernote/dialog/ConfigIndexPage.java

index 0090c4d..0375cde 100644 (file)
@@ -901,6 +901,29 @@ public class Global {
                settings.endGroup();\r
     }\r
     \r
+    // Get/Set interval when the index thread wakes up.\r
+    public static void setIndexThreadSleepInterval(int sleep) {\r
+               settings.beginGroup("General");\r
+               settings.setValue("IndexThreadSleepInterval", sleep);\r
+               settings.endGroup();\r
+    }\r
+    public static int getIndexThreadSleepInterval() {\r
+               settings.beginGroup("General");\r
+               Integer sleep;\r
+               try {\r
+                       String val  = (String)settings.value("IndexThreadSleepInterval", "300");\r
+                       sleep = new Integer(val.trim());\r
+               } catch (Exception e) {\r
+                       try {\r
+                               sleep = (Integer)settings.value("IndexThreadSleepInterval", 0);\r
+                       } catch (Exception e1) {\r
+                               sleep = 300;\r
+                       }\r
+               }\r
+               settings.endGroup();\r
+               return sleep;\r
+    }\r
+    \r
     public static void saveState(String name, QByteArray state) {\r
                settings.beginGroup("SaveState");\r
                settings.setValue(name, state);\r
index ceba208..5a5a956 100644 (file)
@@ -349,8 +349,7 @@ public class NeverNote extends QMainWindow{
         synchronizeAnimationTimer.timeout.connect(this, "updateSyncButton()");
         
                indexTimer = new QTimer();
-               indexTime = 1000*60*5;     // look for unindexed every 5 minutes
-//             indexTime = 1000*5;
+               indexTime = 1000*Global.getIndexThreadSleepInterval();  
                indexTimer.start(indexTime);  // Start indexing timer
                indexTimer.timeout.connect(this, "indexTimer()");
                indexDisabled = false;
@@ -851,6 +850,9 @@ public class NeverNote extends QMainWindow{
         String dateFormat = Global.getDateFormat();
         String timeFormat = Global.getTimeFormat();
         
+               indexTime = 1000*Global.getIndexThreadSleepInterval();  
+               indexTimer.start(indexTime);  // reset indexing timer
+        
         settings.exec();
         if (Global.showTrayIcon())
                trayIcon.show();
index 45237a8..81ba193 100644 (file)
@@ -147,6 +147,7 @@ public class ConfigDialog extends QDialog {
                Global.setMinimumWordLength(indexPage.getWordLength());\r
                Global.minimumWordCount = indexPage.getWordLength();    \r
                Global.setIndexThreads(indexPage.getIndexThreads());\r
+               Global.setIndexThreadSleepInterval(indexPage.getSleepInterval());\r
                Global.setMessageLevel( debugPage.getDebugLevel());\r
                Global.saveCarriageReturnFix(debugPage.getCarriageReturnFix());\r
                Global.enableCarriageReturnFix = debugPage.getCarriageReturnFix();\r
@@ -265,6 +266,7 @@ public class ConfigDialog extends QDialog {
                indexPage.setRegex(Global.getWordRegex());\r
                indexPage.setWordLength(Global.getMinimumWordLength());\r
                indexPage.setIndexThreads(Global.getIndexThreads());\r
+               indexPage.setSleepInterval(Global.getIndexThreadSleepInterval());\r
                connectionPage.setSyncInterval(Global.getSyncInterval());\r
                \r
                appearancePage.setDateFormat(Global.getDateFormat());\r
index 6b73c20..7b29789 100644 (file)
@@ -34,6 +34,7 @@ public class ConfigIndexPage extends QWidget {
        private final QSpinBox  indexThreadSpinner;\r
        private final QSpinBox lengthSpinner;\r
        private final QSpinBox weightSpinner;\r
+       private final QSpinBox sleepSpinner;\r
        private final QLineEdit regexEdit;\r
        \r
        public ConfigIndexPage(QWidget parent) {\r
@@ -81,7 +82,22 @@ public class ConfigIndexPage extends QWidget {
                weightLayout.addWidget(weightSpinner);\r
                weightGroup.setLayout(weightLayout);\r
                \r
-       \r
+\r
+               // Index sleep interval\r
+               QGroupBox sleepGroup = new QGroupBox(tr("Index Interval"));\r
+               QLabel sleepLabel = new QLabel(tr("Seconds between looking for unindexed notes"));\r
+               sleepSpinner = new QSpinBox();\r
+               sleepSpinner.setRange(30,600);\r
+               sleepSpinner.setSingleStep(1);\r
+               sleepSpinner.setValue(Global.getIndexThreadSleepInterval());\r
+\r
+               QHBoxLayout sleepLayout = new QHBoxLayout();\r
+               sleepLayout.addWidget(sleepLabel);\r
+               sleepLayout.addWidget(sleepSpinner);\r
+               sleepGroup.setLayout(sleepLayout);\r
+\r
+               \r
+               \r
                // Regular Expressions for word parsing\r
                QGroupBox regexGroup = new QGroupBox(tr("Word Parse"));\r
                QLabel regexLabel = new QLabel(tr("Regular Expression"));\r
@@ -97,6 +113,7 @@ public class ConfigIndexPage extends QWidget {
                QVBoxLayout mainLayout = new QVBoxLayout();\r
                mainLayout.addWidget(threadsGroup);\r
                mainLayout.addWidget(wordLengthGroup);\r
+               mainLayout.addWidget(sleepGroup);\r
                mainLayout.addWidget(weightGroup);\r
                mainLayout.addWidget(regexGroup);\r
                mainLayout.addStretch(1);\r
@@ -114,6 +131,18 @@ public class ConfigIndexPage extends QWidget {
        public int getWordLength() {\r
                return lengthSpinner.value();\r
        }\r
+       \r
+       \r
+       //*****************************************\r
+       //* Word length get/set methods \r
+       //*****************************************\r
+       public void setSleepInterval(int len) {\r
+               sleepSpinner.setValue(len);\r
+       }\r
+       public int getSleepInterval() {\r
+               return sleepSpinner.value();\r
+       }\r
+\r
 \r
        \r
        //*****************************************\r