OSDN Git Service

Fix hilight image with wild cards.
authorRandy Baumgarte <randy@fbn.cx>
Sun, 19 Dec 2010 20:03:43 +0000 (15:03 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 19 Dec 2010 20:21:27 +0000 (15:21 -0500)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/xml/NoteFormatter.java

index 30a200c..87e91fd 100644 (file)
@@ -2508,6 +2508,9 @@ public class NeverNote extends QMainWindow{
        // otherwise we trigger off searchFieldChanged.
        @SuppressWarnings("unused")
        private void searchFieldTextChanged(String text) {
+               QWebSettings.setMaximumPagesInCache(0);
+               QWebSettings.setObjectCacheCapacities(0, 0, 0);
+
                if (text.trim().equals("")) {
                        searchFieldCleared();
                        if (searchPerformed) {
@@ -2517,8 +2520,6 @@ public class NeverNote extends QMainWindow{
                                noteCache.clear();
                                readOnlyCache.clear();
                                inkNoteCache.clear();
-                               QWebSettings.setMaximumPagesInCache(0);
-                               QWebSettings.setObjectCacheCapacities(0, 0, 0);
                                
                                listManager.setEnSearch("");
                                listManager.loadNotesIndex();
index 121ca5a..922777f 100644 (file)
@@ -132,6 +132,8 @@ public class NoteFormatter {
                \r
                // Get the recognition XML that tells where to hilight on the image\r
                Resource recoResource = conn.getNoteTable().noteResourceTable.getNoteResourceRecognition(resGuid);\r
+               if (recoResource.getRecognition().getBody() == null)\r
+                       return;\r
                QByteArray recoData = new QByteArray(recoResource.getRecognition().getBody());\r
                String xml = recoData.toString();\r
                \r
@@ -172,7 +174,12 @@ public class NoteFormatter {
                                        \r
                                        // Check to see if this word matches something we were searching for.\r
                                        for (int k=0; k<enSearch.hilightWords.size(); k++) {\r
-                                               if (enSearch.hilightWords.get(k).equalsIgnoreCase(text))\r
+                                               String searchWord = enSearch.hilightWords.get(k).toLowerCase();\r
+                                               if (searchWord.startsWith("*"))\r
+                                                       searchWord = searchWord.substring(1);\r
+                                               if (searchWord.endsWith("*"))\r
+                                                       searchWord = searchWord.substring(0,searchWord.length()-1);\r
+                                               if (text.toLowerCase().contains(searchWord))\r
                                                        p2.drawRect(x,y,w,h);                           \r
                                        }\r
                                }\r