OSDN Git Service

Add option to alter tag selection behavior
authorRandy Baumgarte <randy@fbn.cx>
Mon, 14 Mar 2011 13:13:16 +0000 (09:13 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 3 Apr 2011 18:02:27 +0000 (14:02 -0400)
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/dialog/ConfigAppearancePage.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java
src/cx/fbn/nevernote/utilities/ListManager.java

index 9a6b495..6cceef6 100644 (file)
@@ -1556,6 +1556,30 @@ public class Global {
                settings.endGroup();    \r
     }\r
 \r
+    //*******************\r
+    // Index attachments\r
+    //*******************\r
+    public static boolean anyTagSelectionMatch() {\r
+               settings.beginGroup("General");\r
+               try {\r
+                       String value = (String)settings.value("anyTagSelectionMatch", "false");\r
+                       settings.endGroup();\r
+                       if (value.equals("true"))\r
+                               return true;\r
+                       else\r
+                               return false;\r
+               } catch (java.lang.ClassCastException e) {\r
+                       Boolean value = (Boolean) settings.value("anyTagSelectionMatch", false);\r
+                       settings.endGroup();\r
+                       return value;\r
+               }\r
+    }\r
+    public static void setAnyTagSelectionMatch(boolean value) {\r
+               settings.beginGroup("General");\r
+               settings.setValue("anyTagSelectionMatch", value);\r
+               settings.endGroup();    \r
+    }\r
+\r
     //***********************\r
     //* Database cache size\r
     //***********************\r
index c2f8d49..19a5a0c 100644 (file)
@@ -46,6 +46,7 @@ public class ConfigAppearancePage extends QWidget {
        private final QCheckBox showTrayIcon;\r
        private final QCheckBox verifyDelete;\r
        private final QCheckBox pdfPreview;\r
+       private final QCheckBox anyTagSelection;\r
        private final QCheckBox checkForUpdates;\r
        private final QCheckBox newNoteWithTags;\r
        private final QCheckBox mimicEvernote;\r
@@ -141,6 +142,7 @@ public class ConfigAppearancePage extends QWidget {
                pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));\r
                checkForUpdates = new QCheckBox(tr("Check For Updates At Startup"));\r
                newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));\r
+               anyTagSelection = new QCheckBox(tr("Display Notes Matching Any Selected Tags"));\r
                \r
                QHBoxLayout autoSaveLayout = new QHBoxLayout();\r
                autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));\r
@@ -162,6 +164,7 @@ public class ConfigAppearancePage extends QWidget {
                mainLayout.addWidget(verifyDelete);\r
                mainLayout.addWidget(pdfPreview);\r
                mainLayout.addWidget(newNoteWithTags);\r
+               mainLayout.addWidget(anyTagSelection);\r
                mainLayout.addWidget(checkForUpdates);\r
                mainLayout.addStretch(1);\r
                setLayout(mainLayout);\r
@@ -385,5 +388,15 @@ public class ConfigAppearancePage extends QWidget {
        public void setNewNoteWithTags(boolean val) {\r
                newNoteWithTags.setChecked(val);\r
        }\r
+       \r
+       //*****************************************\r
+       //* Set tag selection behavior\r
+       //*****************************************\r
+       public boolean getAnyTagSelection() {\r
+               return anyTagSelection.isChecked();\r
+       }\r
+       public void setAnyTagSelection(boolean val) {\r
+               anyTagSelection.setChecked(val);\r
+       }\r
 \r
 }\r
index 5b7f43f..43e85a1 100644 (file)
@@ -138,6 +138,11 @@ public class ConfigDialog extends QDialog {
                else\r
                        Global.setNewNoteWithSelectedTags(false);\r
                \r
+               if (appearancePage.getAnyTagSelection())\r
+                       Global.setAnyTagSelectionMatch(true);\r
+               else\r
+                       Global.setAnyTagSelectionMatch(false);\r
+               \r
                Global.setAutoSaveInterval(appearancePage.getAutoSaveInterval());\r
                                                \r
                Global.setAutomaticLogin(connectionPage.getAutomaticLogin());\r
@@ -307,6 +312,7 @@ public class ConfigDialog extends QDialog {
                appearancePage.setPdfPreview(Global.pdfPreview());\r
                appearancePage.setCheckForUpdates(Global.checkVersionUpgrade());\r
                appearancePage.setNewNoteWithTags(Global.newNoteWithSelectedTags());\r
+               appearancePage.setAnyTagSelection(Global.anyTagSelectionMatch());\r
                appearancePage.setShowSplashScreen(Global.isWindowVisible("SplashScreen"));\r
                appearancePage.setTagBehavior(Global.tagBehavior());\r
                appearancePage.setMinimizeOnClose(Global.minimizeOnClose());\r
index 69edc38..7a43767 100644 (file)
@@ -1038,12 +1038,21 @@ public class ListManager  {
                if (selectedTags.size() == 0) \r
                        return true;\r
                \r
-               for (int i=0; i<selectedTags.size(); i++) {\r
-                       String selectedGuid = selectedTags.get(i);\r
-                       if (noteTags.contains(selectedGuid))\r
-                                       return true;\r
+               if (!Global.anyTagSelectionMatch()) {\r
+                       for (int i=0; i<selectedTags.size(); i++) {\r
+                               String selectedGuid = selectedTags.get(i);\r
+                               if (!noteTags.contains(selectedGuid))\r
+                                       return false;\r
+                       }\r
+                       return true;\r
+               } else {\r
+                       for (int i=0; i<selectedTags.size(); i++) {\r
+                               String selectedGuid = selectedTags.get(i);\r
+                               if (noteTags.contains(selectedGuid))\r
+                                               return true;\r
+                       }\r
+                       return false;\r
                }\r
-               return false;\r
        }\r
 \r
        public void setNoteSynchronized(String guid, boolean value) {\r