From: Randy Baumgarte Date: Mon, 29 Nov 2010 00:32:39 +0000 (-0500) Subject: Cleanup of initial sync with ink notes and added the ability to highlight words in... X-Git-Tag: version0.1.1~278 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8bf99212fa081e668888a630803da98081302cfd;p=neighbornote%2FNeighborNote.git Cleanup of initial sync with ink notes and added the ability to highlight words in images. --- diff --git a/src/cx/fbn/nevernote/Global.java b/src/cx/fbn/nevernote/Global.java index 2581e33..90f9cc9 100644 --- a/src/cx/fbn/nevernote/Global.java +++ b/src/cx/fbn/nevernote/Global.java @@ -563,7 +563,7 @@ public class Global { settings.beginGroup("General"); Integer len; try { - len = (Integer)settings.value("recognitionWeight", 80); + len = (Integer)settings.value("recognitionWeight", 30); } catch (Exception e) { len = 80; } diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index 0de1986..e4d8397 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -696,7 +696,7 @@ public class NeverNote extends QMainWindow{ dbConn = setupDatabaseConnection(); // Must be last stage of setup - only safe once DB is open hence we know we are the only instance running - Global.getFileManager().purgeResDirectory(); + Global.getFileManager().purgeResDirectory(true); } catch (InitializationException e) { // Fatal @@ -2478,9 +2478,18 @@ public class NeverNote extends QMainWindow{ // Text in the search bar has been cleared private void searchFieldCleared() { saveNote(); + + // This is done because we want to force a reload of + // images. Some images we may want to highlight the text. + readOnlyCache.clear(); + noteCache.clear(); + QWebSettings.setMaximumPagesInCache(0); + QWebSettings.setObjectCacheCapacities(0, 0, 0); + searchField.setEditText(""); saveNoteColumnPositions(); saveNoteIndexWidth(); + loadNoteBrowserInformation(browserWindow); } // text in the search bar changed. We only use this to tell if it was cleared, // otherwise we trigger off searchFieldChanged. @@ -2489,11 +2498,15 @@ public class NeverNote extends QMainWindow{ if (text.trim().equals("")) { searchFieldCleared(); if (searchPerformed) { + + // This is done because we want to force a reload of + // images. Some images we may want to highlight the text. noteCache.clear(); readOnlyCache.clear(); + QWebSettings.setMaximumPagesInCache(0); + QWebSettings.setObjectCacheCapacities(0, 0, 0); + listManager.setEnSearch(""); -///// listManager.clearNoteIndexSearch(); - //noteIndexUpdated(true); listManager.loadNotesIndex(); refreshEvernoteNote(true); noteIndexUpdated(false); @@ -3901,7 +3914,7 @@ public class NeverNote extends QMainWindow{ } private void loadNoteBrowserInformation(BrowserWindow browser) { - NoteFormatter formatter = new NoteFormatter(logger, conn, tempFiles); + NoteFormatter formatter = new NoteFormatter(logger, conn, tempFiles); formatter.setNote(currentNote, Global.pdfPreview()); formatter.setHighlight(listManager.getEnSearch()); QByteArray js; diff --git a/src/cx/fbn/nevernote/config/FileManager.java b/src/cx/fbn/nevernote/config/FileManager.java index eda582b..5f51497 100644 --- a/src/cx/fbn/nevernote/config/FileManager.java +++ b/src/cx/fbn/nevernote/config/FileManager.java @@ -265,7 +265,7 @@ public class FileManager { * * @throws InitializationException for file deletion failures */ - private static void deleteTopLevelFiles(File dir) throws InitializationException { + private static void deleteTopLevelFiles(File dir, boolean exitOnFail) throws InitializationException { File[] toDelete = dir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { @@ -273,7 +273,7 @@ public class FileManager { } }); for (File f : toDelete) { - if (!f.delete()) { + if (!f.delete() && exitOnFail) { throw new InitializationException("Failed to delete file: '" + f + "'"); } } @@ -330,7 +330,7 @@ public class FileManager { /** * Called at startup to purge files from 'res' directory. */ - public void purgeResDirectory() throws InitializationException { - deleteTopLevelFiles(resDir); + public void purgeResDirectory(boolean exitOnFail) throws InitializationException { + deleteTopLevelFiles(resDir, exitOnFail); } } diff --git a/src/cx/fbn/nevernote/sql/DatabaseConnection.java b/src/cx/fbn/nevernote/sql/DatabaseConnection.java index 50bd215..807282b 100644 --- a/src/cx/fbn/nevernote/sql/DatabaseConnection.java +++ b/src/cx/fbn/nevernote/sql/DatabaseConnection.java @@ -215,7 +215,6 @@ public class DatabaseConnection { invalidXMLTable.createTable(); wordsTable.createTable(); syncTable.createTable(); - inkImagesTable.createTable(); } public Connection getConnection() { diff --git a/src/cx/fbn/nevernote/sql/NotebookTable.java b/src/cx/fbn/nevernote/sql/NotebookTable.java index b60b02d..332c100 100644 --- a/src/cx/fbn/nevernote/sql/NotebookTable.java +++ b/src/cx/fbn/nevernote/sql/NotebookTable.java @@ -54,7 +54,7 @@ public class NotebookTable { dbName = "Notebook"; } // Create the table - public void createTable(boolean addDefault) { + public void createTable(boolean addDefaulte) { NSqlQuery query = new NSqlQuery(db.getConnection()); logger.log(logger.HIGH, "Creating table "+dbName+"..."); if (!query.exec("Create table "+dbName+" (guid varchar primary key, " + @@ -75,9 +75,6 @@ public class NotebookTable { newnote.setPublished(false); newnote.setGuid("1"); - if (!addDefault) - return; - // Setup an initial notebook SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); query = new NSqlQuery(db.getConnection()); @@ -643,7 +640,7 @@ public class NotebookTable { public List> getNotebookCounts() { List> counts = new ArrayList>(); NSqlQuery query = new NSqlQuery(db.getConnection()); - if (!query.exec("select notebookGuid, count(guid) from "+dbName+" where active=1 group by notebookguid;")) { + if (!query.exec("select notebookGuid, count(guid) from note where active=1 group by notebookguid;")) { logger.log(logger.EXTREME, "NoteTags SQL getTagCounts has failed."); logger.log(logger.MEDIUM, query.lastError()); return null; diff --git a/src/cx/fbn/nevernote/threads/SyncRunner.java b/src/cx/fbn/nevernote/threads/SyncRunner.java index 29a2afb..912e63a 100644 --- a/src/cx/fbn/nevernote/threads/SyncRunner.java +++ b/src/cx/fbn/nevernote/threads/SyncRunner.java @@ -1076,12 +1076,14 @@ public class SyncRunner extends QObject implements Runnable { if (saveNeeded) conn.getNoteTable().noteResourceTable.updateNoteResource(r, false); + if (r.getMime().equalsIgnoreCase("application/vnd.evernote.ink")) + downloadInkNoteImage(r.getGuid()); } } logger.log(logger.EXTREME, "Leaving SyncRunner.syncRemoteResources"); } - // Sync remote notebooks + // Sync remote notes private void syncRemoteNotes(List note, boolean fullSync) { logger.log(logger.EXTREME, "Entering SyncRunner.syncRemoteNotes"); if (note != null) { @@ -1117,6 +1119,8 @@ public class SyncRunner extends QObject implements Runnable { for (int q=0; q= Global.getRecognitionWeight()) { // Are we above the maximum? + + // Check to see if this word matches something we were searching for. + for (int k=0; k