OSDN Git Service

Added more thumbnail logic & correct search bugs.
authorRandy Baumgarte <randy@fbn.cx>
Thu, 28 Oct 2010 20:53:30 +0000 (16:53 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Thu, 28 Oct 2010 20:53:30 +0000 (16:53 -0400)
49 files changed:
lib/evernote.jar
lib/libthrift.jar
shortcuts_sample.txt
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/dialog/AccountDialog.java
src/cx/fbn/nevernote/dialog/ConfigDebugPage.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java
src/cx/fbn/nevernote/dialog/DBEncryptDialog.java
src/cx/fbn/nevernote/dialog/DatabaseLoginDialog.java
src/cx/fbn/nevernote/dialog/DatabaseStatus.java
src/cx/fbn/nevernote/dialog/EnCryptDialog.java
src/cx/fbn/nevernote/dialog/EnDecryptDialog.java
src/cx/fbn/nevernote/dialog/FindDialog.java
src/cx/fbn/nevernote/dialog/GeoDialog.java
src/cx/fbn/nevernote/dialog/InsertLinkDialog.java
src/cx/fbn/nevernote/dialog/LoginDialog.java
src/cx/fbn/nevernote/dialog/NotebookArchive.java
src/cx/fbn/nevernote/dialog/NotebookEdit.java
src/cx/fbn/nevernote/dialog/OnlineNoteHistory.java
src/cx/fbn/nevernote/dialog/SavedSearchEdit.java
src/cx/fbn/nevernote/dialog/SpellCheck.java
src/cx/fbn/nevernote/dialog/TableDialog.java
src/cx/fbn/nevernote/dialog/TagAssign.java
src/cx/fbn/nevernote/dialog/TagEdit.java
src/cx/fbn/nevernote/dialog/WatchFolder.java
src/cx/fbn/nevernote/dialog/WatchFolderAdd.java
src/cx/fbn/nevernote/filters/NoteSortFilterProxyModel.java
src/cx/fbn/nevernote/gui/BrowserWindow.java
src/cx/fbn/nevernote/gui/NoteTableModel.java
src/cx/fbn/nevernote/gui/NotebookTreeWidget.java
src/cx/fbn/nevernote/gui/TableView.java
src/cx/fbn/nevernote/gui/TableViewHeader.java
src/cx/fbn/nevernote/gui/Thumbnailer.java
src/cx/fbn/nevernote/icons/account.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/books.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/config.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/database.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/folder.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/library.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/link.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/password.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/table.png [new file with mode: 0644]
src/cx/fbn/nevernote/signals/NoteSignal.java
src/cx/fbn/nevernote/sql/NoteTable.java
src/cx/fbn/nevernote/sql/REnSearch.java
src/cx/fbn/nevernote/threads/IndexRunner.java
src/cx/fbn/nevernote/threads/ThumbnailRunner.java
src/cx/fbn/nevernote/utilities/ListManager.java

index 9d38d66..1e705c3 100644 (file)
Binary files a/lib/evernote.jar and b/lib/evernote.jar differ
index 39aa952..543c452 100644 (file)
Binary files a/lib/libthrift.jar and b/lib/libthrift.jar differ
index f7c00bd..d26794d 100644 (file)
@@ -38,7 +38,10 @@ Edit_Insert_Todo                             // Insert a todo checkbox (Popup menu)
 Edit_Encrypt_Text                              // Encrypt selected text (Popup menu)
 Edit_Insert_Table                              // Insert a table into a note (Popup menu)
 
-View_Extended_Information      F8              // View details on the current note
+View_List_Narrow                               // View with the list on the side
+View_List_Wide                                 // View with the list on the top
+View_Thumbnail                                 // Fullscreen preview
+View_Extended_Information      F8      // View details on the current note
 View_Show_Note_List            F10             // Show current notes
 View_Show_Notebooks                            // Show notebooks
 View_Show_Tags                                 // Show the tags window
index 0791c92..e7def24 100644 (file)
@@ -29,6 +29,8 @@ import java.util.Calendar;
 import java.util.HashMap;\r
 import java.util.List;\r
 \r
+import org.apache.commons.lang.StringEscapeUtils;\r
+\r
 import com.evernote.edam.type.Accounting;\r
 import com.evernote.edam.type.PrivilegeLevel;\r
 import com.evernote.edam.type.User;\r
@@ -68,9 +70,9 @@ public class Global {
     \r
     public static int View_List_Wide = 1;\r
     public static int View_List_Narrow = 2;\r
-    public static QSize smallThumbnailSize = new QSize(50,50);\r
-    public static QSize largeThumbnailSize = new QSize(160,160);\r
-    public static boolean listView = true;\r
+    public static QSize smallThumbnailSize = new QSize(100,75);\r
+    public static QSize largeThumbnailSize = new QSize(300,225);\r
+//    public static boolean listView = true;\r
     \r
     public static HashMap<String,Pair> passwordSafe = new HashMap<String, Pair>();\r
     public static List<Pair<String,String>> passwordRemember = new ArrayList<Pair<String,String>>();\r
@@ -371,18 +373,27 @@ public class Global {
     }\r
     public static void setSortColumn(int i) {\r
                settings.beginGroup("General");\r
-               settings.setValue("sortColumn", i);\r
+       if (Global.getListView() == Global.View_List_Wide)\r
+               settings.setValue("sortColumn", i);\r
+       else\r
+               settings.setValue("sortColumn-Narrow", i);\r
                settings.endGroup();\r
     }\r
     public static int getSortColumn() {;\r
+    String key;\r
+       if (Global.getListView() == Global.View_List_Wide)\r
+               key = "sortColumn";\r
+       else\r
+               key = "sortColumn-Narrow";\r
+\r
        settings.beginGroup("General");\r
        int order;      \r
        try {\r
-               String val  = settings.value("sortColumn", new Integer(0)).toString();\r
+               String val  = settings.value(key, new Integer(0)).toString();\r
                order = new Integer(val.trim());\r
        } catch (Exception e) {\r
                try {\r
-                       order = (Integer)settings.value("sortColumn", 0);\r
+                       order = (Integer)settings.value(key, 0);\r
                } catch (Exception e1) {\r
                    order = 0;\r
                }\r
@@ -599,12 +610,19 @@ public class Global {
                settings.endGroup();            \r
     }\r
     public static void setColumnWidth(String col, int width) {\r
-               settings.beginGroup("ColumnWidths");\r
-               settings.setValue(col, width);\r
-               settings.endGroup();\r
-    }\r
+       if (Global.getListView() == Global.View_List_Wide)\r
+               settings.beginGroup("ColumnWidths");\r
+       else \r
+               settings.beginGroup("ColumnWidths-Narrow");\r
+               settings.setValue(col, width);\r
+               settings.endGroup();\r
+       }\r
     public static int getColumnWidth(String col) {\r
-               settings.beginGroup("ColumnWidths");\r
+       int view = Global.getListView();\r
+       if (view == Global.View_List_Wide)\r
+               settings.beginGroup("ColumnWidths");\r
+       else\r
+               settings.beginGroup("ColumnWidths-Narrow");\r
                Integer width;\r
                try {\r
                        String val  = (String)settings.value(col, "0");\r
@@ -620,12 +638,18 @@ public class Global {
                return width;\r
     }\r
     public static void setColumnPosition(String col, int width) {\r
-               settings.beginGroup("ColumnPosition");\r
+       if (Global.getListView() == Global.View_List_Wide)\r
+               settings.beginGroup("ColumnPosition");\r
+       else\r
+               settings.beginGroup("ColumnPosition-Narrow");\r
                settings.setValue(col, width);\r
                settings.endGroup();\r
     }\r
     public static int getColumnPosition(String col) {\r
-               settings.beginGroup("ColumnPosition");\r
+       if (Global.getListView() == Global.View_List_Wide)\r
+               settings.beginGroup("ColumnPosition");\r
+       else\r
+               settings.beginGroup("ColumnPosition-Narrow");\r
                Integer width;\r
                try {\r
                        String val  = (String)settings.value(col, "-1");\r
@@ -713,11 +737,21 @@ public class Global {
     }\r
     public static boolean isColumnVisible(String window) {\r
        String defaultValue = "true";\r
-               settings.beginGroup("ColumnsVisible");\r
+       int view = Global.getListView();\r
+       if (Global.getListView() == Global.View_List_Wide)\r
+               settings.beginGroup("ColumnsVisible");\r
+       else\r
+               settings.beginGroup("ColumnsVisible-Narrow"); \r
+//             if (view == Global.View_List_Narrow)\r
+//                     defaultValue = "false";\r
+               if (window.equalsIgnoreCase("thumbnail") && view == Global.View_List_Wide)\r
+                       defaultValue = "false";\r
                if (window.equalsIgnoreCase("thumbnail"))\r
                        defaultValue = "false";\r
                if (window.equalsIgnoreCase("Guid"))\r
                        defaultValue = "false";\r
+//             if (window.equalsIgnoreCase("thumbnail") && view == Global.View_List_Narrow)\r
+//                     defaultValue = "true";\r
                String text = (String)settings.value(window, defaultValue);\r
                settings.endGroup();\r
                if (text.equalsIgnoreCase("true"))\r
@@ -726,7 +760,10 @@ public class Global {
                        return false;   \r
     }\r
     public static void saveColumnVisible(String column, boolean val) {\r
-               settings.beginGroup("ColumnsVisible");\r
+       if (Global.getListView() == Global.View_List_Wide)\r
+               settings.beginGroup("ColumnsVisible");\r
+       else\r
+               settings.beginGroup("ColumnsVisible-Narrow");                   \r
                if (val)\r
                        settings.setValue(column, "true");\r
                else\r
@@ -831,7 +868,7 @@ public class Global {
                settings.endGroup();\r
                return threads;\r
     }\r
-\r
+    \r
     public static boolean getMimicEvernoteInterface() {\r
                settings.beginGroup("General");\r
                String text = (String)settings.value("mimicEvernoteInterface", "true");\r
@@ -956,25 +993,39 @@ public class Global {
     }\r
     \r
     public static void saveState(String name, QByteArray state) {\r
+       int view = Global.getListView();\r
+       if (view == Global.View_List_Narrow)\r
+               name = name +"Narrow";\r
                settings.beginGroup("SaveState");\r
                settings.setValue(name, state);\r
                settings.endGroup();\r
     }\r
     \r
     public static QByteArray restoreState(String name) {\r
+       int view = Global.getListView();\r
+       if (view == Global.View_List_Narrow)\r
+               name = name +"Narrow";\r
                settings.beginGroup("SaveState");\r
                QByteArray state = (QByteArray)settings.value(name);\r
                settings.endGroup();\r
                return state;\r
     }\r
     public static void saveGeometry(String name, QByteArray state) {\r
-               settings.beginGroup("SaveGeometry");\r
+       int view = Global.getListView();\r
+       if (view == Global.View_List_Narrow)\r
+               settings.beginGroup("SaveGeometryNarrow");\r
+       else\r
+               settings.beginGroup("SaveGeometry");\r
                settings.setValue(name, state);\r
                settings.endGroup();\r
     }\r
     \r
     public static QByteArray restoreGeometry(String name) {\r
-               settings.beginGroup("SaveGeometry");\r
+       int view = Global.getListView();\r
+       if (view == Global.View_List_Narrow)\r
+               settings.beginGroup("SaveGeometryNarrow");\r
+       else\r
+               settings.beginGroup("SaveGeometry");\r
                QByteArray state = (QByteArray)settings.value(name);\r
                settings.endGroup();\r
                return state;\r
@@ -1127,6 +1178,24 @@ public class Global {
                settings.endGroup();\r
     }\r
        \r
+    \r
+    public static boolean enableThumbnails() {\r
+               settings.beginGroup("Debug");\r
+               String text = (String)settings.value("thumbnails", "false");\r
+               settings.endGroup();\r
+               if (text.equalsIgnoreCase("true"))\r
+                       return true;\r
+               else\r
+                       return false;   \r
+    }\r
+    public static void setEnableThumbnails(boolean val) {\r
+               settings.beginGroup("Debug");\r
+               if (val)\r
+                       settings.setValue("thumbnails", "true");\r
+               else\r
+                       settings.setValue("thumbnails", "false");\r
+               settings.endGroup();\r
+    }\r
        \r
        // Print date/time.  Used mainly for performance tracing\r
        public static void trace(boolean resetInterval) {\r
@@ -1168,6 +1237,29 @@ public class Global {
         return disableViewing;\r
     }\r
 \r
+    //**********************\r
+    //* Thumbnail zoom level\r
+    //**********************\r
+    public static int calculateThumbnailZoom(String content) {\r
+       int zoom = 1;\r
+               if (content.indexOf("application/pdf") == -1) {\r
+                       if (content.indexOf("image/") == -1) {\r
+                               String text =  StringEscapeUtils.unescapeHtml(content.replaceAll("\\<.*?\\>", ""));\r
+                               zoom = 2;\r
+                               if (text.length() < 500) \r
+                                       zoom = 2;\r
+                               if (text.length() < 250)\r
+                                       zoom = 3;\r
+                               if (text.length() < 100)\r
+                                       zoom = 4;\r
+                               if (text.length() < 50)\r
+                                       zoom = 5;\r
+                               if (text.length() < 10)\r
+                                       zoom = 6;\r
+                       }\r
+               }\r
+               return zoom;\r
+    }\r
     \r
     //**********************\r
     //* List View settings \r
index 9af637f..699e1fa 100644 (file)
@@ -194,7 +194,6 @@ public class NeverNote extends QMainWindow{
 
     public BrowserWindow       browserWindow;                          // Window containing browser & labels
     public QToolBar            toolBar;                                        // The tool bar under the menu
-//    QLineEdit                                searchField;                            // The search filter bar on the toolbar
     QComboBox                          searchField;                            // search filter bar on the toolbar;
     boolean                                    searchPerformed = false;        // Search was done?
     QProgressBar                       quotaBar;                                       // The current quota usage
@@ -287,7 +286,7 @@ public class NeverNote extends QMainWindow{
     int                                        historyPosition;                        // Position within the viewed items
     boolean                            fromHistory;                            // Is this from the history queue?
     String                             trashNoteGuid;                          // Guid to restore / set into or out of trash to save position
-    List<Thumbnailer>  previewList;                            // generate preview image
+    List<Thumbnailer>  thumbGenerators;                                // generate preview image
     ThumbnailViewer            thumbnailViewer;                        // View preview thumbnail; 
     boolean                            encryptOnShutdown;                      // should I encrypt when I close?
     boolean                            decryptOnShutdown;                      // should I decrypt on shutdown;
@@ -347,7 +346,7 @@ public class NeverNote extends QMainWindow{
                if (Global.useStandardPalette())
                        QApplication.setPalette(QApplication.style().standardPalette());
         setWindowTitle("NeverNote");
-        
+
         mainLeftRightSplitter = new QSplitter();
         setCentralWidget(mainLeftRightSplitter);
         leftSplitter1 = new QSplitter();
@@ -405,14 +404,14 @@ public class NeverNote extends QMainWindow{
                pdfReadyQueue = new ArrayList<String>();
                thumbnailRunner = new ThumbnailRunner("thumbnailRunner.log", Global.getDatabaseUrl(), Global.getDatabaseUserid(), Global.getDatabaseUserPassword(), Global.cipherPassword);
                thumbnailThread = new QThread(thumbnailRunner, "Thumbnail Thread");
-               thumbnailRunner.noteSignal.thumbnailPageReady.connect(this, "thumbnailHTMLReady(String,String)");
-//             thumbnailThread.start();
-               previewList = new ArrayList<Thumbnailer>();
+               thumbnailRunner.noteSignal.thumbnailPageReady.connect(this, "thumbnailHTMLReady(String,QByteArray,Integer)");
+               thumbnailThread.start();
+               thumbGenerators = new ArrayList<Thumbnailer>();
                thumbnailTimer = new QTimer();
                thumbnailTimer.timeout.connect(this, "thumbnailTimer()");
                thumbnailTimer();
-               thumbnailTimer.setInterval(30*1000);
-//             thumbnailTimer.start();
+               thumbnailTimer.setInterval(5*1000);  // Thumbnail every 2 min
+               thumbnailTimer.start();
                
                logger.log(logger.EXTREME, "Starting authentication timer");
                authTimer = new QTimer();
@@ -425,7 +424,6 @@ public class NeverNote extends QMainWindow{
                saveTimer.timeout.connect(this, "saveNote()");
                if (Global.getAutoSaveInterval() > 0) {
                        saveTimer.setInterval(1000*60*Global.getAutoSaveInterval()); 
-//                     saveTimer.setInterval(1000*10); // auto save every 10 seconds;
                        saveTimer.start();
                }
                listManager.saveRunner.noteSignals.noteSaveRunnerError.connect(this, "saveRunnerError(String, String)");
@@ -458,19 +456,16 @@ public class NeverNote extends QMainWindow{
         noteCache = new HashMap<String,String>();
         browserWindow = new BrowserWindow(conn);
 
+        mainLeftRightSplitter.addWidget(leftSplitter1);
+        mainLeftRightSplitter.addWidget(browserIndexSplitter);
+        
         if (Global.getListView() == Global.View_List_Wide) {
                browserIndexSplitter.addWidget(noteTableView);
                browserIndexSplitter.addWidget(browserWindow); 
-        }
-        
-        mainLeftRightSplitter.addWidget(leftSplitter1);
-        mainLeftRightSplitter.addWidget(browserIndexSplitter);
-
-        if (Global.getListView() == Global.View_List_Narrow) {
+        } else {
                mainLeftRightSplitter.addWidget(noteTableView);
                mainLeftRightSplitter.addWidget(browserWindow); 
         }
-
         
         searchField = new QComboBox();
         searchField.setEditable(true);
@@ -625,7 +620,7 @@ public class NeverNote extends QMainWindow{
        setupFolderImports();
        
        loadStyleSheet();
-       restoreWindowState();
+       restoreWindowState(true);
        
        if (Global.mimicEvernoteInterface) {
                notebookTree.selectGuid("");
@@ -640,29 +635,25 @@ public class NeverNote extends QMainWindow{
        
         if (Global.getListView() == Global.View_List_Narrow) { 
                menuBar.narrowListView.setChecked(true);
-               narrowListView();
+//             narrowListView();
         }
         else{ 
                menuBar.wideListView.setChecked(true);
-               wideListView();
+//             wideListView();
         }
 
-       
+        if (Global.getListView() == Global.View_List_Wide) {
+               browserIndexSplitter.addWidget(noteTableView);
+               browserIndexSplitter.addWidget(browserWindow); 
+        } else {
+               mainLeftRightSplitter.addWidget(noteTableView);
+               mainLeftRightSplitter.addWidget(browserWindow); 
+        }
+        
        int sortCol = Global.getSortColumn();
                int sortOrder = Global.getSortOrder();
                noteTableView.sortByColumn(sortCol, SortOrder.resolve(sortOrder));
 
-               /*
-               for (int i=0; i<listManager.getNoteIndex().size(); i++) {
-                       Note n = listManager.getNoteIndex().get(i);
-                       if (n.getNotebookGuid().equalsIgnoreCase("2")) {
-                               conn.getNoteTable().updateNoteSequence(n.getGuid(), 0);
-                               n = conn.getNoteTable().getNote(n.getGuid(), false, true, false, false, true);
-                               for (int j=0; j<n.getResourcesSize(); j++) {
-                                       conn.getNoteTable().noteResourceTable.resetUpdateSequenceNumber(n.getResources().get(j).getGuid(), true);       
-                               }
-                       }
-               } */
        }
 
        
@@ -895,32 +886,9 @@ public class NeverNote extends QMainWindow{
         syncRunner.notebookSignal.listChanged.disconnect();
         syncRunner.noteIndexSignal.listChanged.disconnect();
 
-
-               int position = noteTableView.header.visualIndex(Global.noteTableCreationPosition);
-               Global.setColumnPosition("noteTableCreationPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableTagPosition);
-               Global.setColumnPosition("noteTableTagPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableNotebookPosition);
-               Global.setColumnPosition("noteTableNotebookPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableChangedPosition);
-               Global.setColumnPosition("noteTableChangedPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableAuthorPosition);
-               Global.setColumnPosition("noteTableAuthorPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableSourceUrlPosition);
-               Global.setColumnPosition("noteTableSourceUrlPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableSubjectDatePosition);
-               Global.setColumnPosition("noteTableSubjectDatePosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableTitlePosition);
-               Global.setColumnPosition("noteTableTitlePosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableSynchronizedPosition);
-               Global.setColumnPosition("noteTableSynchronizedPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableGuidPosition);
-               Global.setColumnPosition("noteTableGuidPosition", position);
-               position = noteTableView.header.visualIndex(Global.noteTableThumbnailPosition);
-               Global.setColumnPosition("noteTableThumbnailPosition", position);
-
                if (isVisible())
                        Global.saveWindowVisible("toolBar", toolBar.isVisible());
+               saveNoteColumnPositions();
                saveNoteIndexWidth();
                
                int width = notebookTree.columnWidth(0);
@@ -1035,7 +1003,9 @@ public class NeverNote extends QMainWindow{
        @SuppressWarnings("unused")
        private void settings() {
                logger.log(logger.HIGH, "Entering NeverNote.settings");
+               saveNoteColumnPositions();
                saveNoteIndexWidth();
+               showColumns();
         ConfigDialog settings = new ConfigDialog(this);
         String dateFormat = Global.getDateFormat();
         String timeFormat = Global.getTimeFormat();
@@ -1068,7 +1038,7 @@ public class NeverNote extends QMainWindow{
         logger.log(logger.HIGH, "Leaving NeverNote.settings");
        }
        // Restore things to the way they were
-       private void restoreWindowState() {
+       private void restoreWindowState(boolean mainWindow) {
                // We need to name things or this doesn't work.
                setObjectName("NeverNote");
                mainLeftRightSplitter.setObjectName("mainLeftRightSplitter");
@@ -1076,7 +1046,8 @@ public class NeverNote extends QMainWindow{
                leftSplitter1.setObjectName("leftSplitter1");   
                
                // Restore the actual positions.
-               restoreGeometry(Global.restoreGeometry(objectName()));
+               if (mainWindow)
+                       restoreGeometry(Global.restoreGeometry(objectName()));
         mainLeftRightSplitter.restoreState(Global.restoreState(mainLeftRightSplitter.objectName()));
         browserIndexSplitter.restoreState(Global.restoreState(browserIndexSplitter.objectName()));
         leftSplitter1.restoreState(Global.restoreState(leftSplitter1.objectName()));
@@ -1098,6 +1069,32 @@ public class NeverNote extends QMainWindow{
                file.close();
                setStyleSheet(styleSheet);
        }
+       // Save column positions for the next time
+       private void saveNoteColumnPositions() {
+               int position = noteTableView.header.visualIndex(Global.noteTableCreationPosition);
+               Global.setColumnPosition("noteTableCreationPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableTagPosition);
+               Global.setColumnPosition("noteTableTagPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableNotebookPosition);
+               Global.setColumnPosition("noteTableNotebookPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableChangedPosition);
+               Global.setColumnPosition("noteTableChangedPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableAuthorPosition);
+               Global.setColumnPosition("noteTableAuthorPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableSourceUrlPosition);
+               Global.setColumnPosition("noteTableSourceUrlPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableSubjectDatePosition);
+               Global.setColumnPosition("noteTableSubjectDatePosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableTitlePosition);
+               Global.setColumnPosition("noteTableTitlePosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableSynchronizedPosition);
+               Global.setColumnPosition("noteTableSynchronizedPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableGuidPosition);
+               Global.setColumnPosition("noteTableGuidPosition", position);
+               position = noteTableView.header.visualIndex(Global.noteTableThumbnailPosition);
+               Global.setColumnPosition("noteTableThumbnailPosition", position);
+
+       }
        // Save column widths for the next time
        private void saveNoteIndexWidth() {
                int width;
@@ -2103,6 +2100,7 @@ public class NeverNote extends QMainWindow{
        // Text in the search bar has been cleared
        private void searchFieldCleared() {
                searchField.setEditText("");
+               saveNoteColumnPositions();
                saveNoteIndexWidth();
        }
        // text in the search bar changed.  We only use this to tell if it was cleared, 
@@ -2127,6 +2125,7 @@ public class NeverNote extends QMainWindow{
     private void searchFieldChanged() {
        logger.log(logger.HIGH, "Entering NeverNote.searchFieldChanged");
        noteCache.clear();
+       saveNoteColumnPositions();
        saveNoteIndexWidth();
        String text = searchField.currentText();
        listManager.setEnSearch(text.trim());
@@ -2216,7 +2215,7 @@ public class NeverNote extends QMainWindow{
        toggleNewButton(Global.isToolbarButtonVisible("new"));
        
        allNotesButton = toolBar.addAction("All Notes");
-       QIcon allIcon = new QIcon(iconPath+"allNotes3.png");
+       QIcon allIcon = new QIcon(iconPath+"books.png");
        allNotesButton.triggered.connect(this, "allNotes()");
        allNotesButton.setIcon(allIcon);
        toggleAllNotesButton(Global.isToolbarButtonVisible("allNotes"));
@@ -3238,6 +3237,7 @@ public class NeverNote extends QMainWindow{
                                i=listManager.getNoteTableModel().rowCount();
                }
        }
+       noteTableView.repaint();
     }
     // Show/Hide columns
     private void showColumns() {
@@ -3251,6 +3251,7 @@ public class NeverNote extends QMainWindow{
                noteTableView.setColumnHidden(Global.noteTableSynchronizedPosition, !Global.isColumnVisible("synchronized"));
                noteTableView.setColumnHidden(Global.noteTableGuidPosition, !Global.isColumnVisible("guid"));
                noteTableView.setColumnHidden(Global.noteTableThumbnailPosition, !Global.isColumnVisible("thumbnail"));
+               noteTableView.setColumnHidden(Global.noteTableTitlePosition, !Global.isColumnVisible("title"));                 
     }
     // Title color has changed
     @SuppressWarnings("unused")
@@ -3288,10 +3289,11 @@ public class NeverNote extends QMainWindow{
     }
     // Wide list was chosen
     public void narrowListView() {
-       if (!menuBar.narrowListView.isChecked()) {
-               wideListView();
-               return;
-       }
+       saveNoteColumnPositions();
+       saveNoteIndexWidth();
+       saveWindowState();
+       Global.setListView(Global.View_List_Narrow);
+       
        menuBar.wideListView.blockSignals(true);
        menuBar.narrowListView.blockSignals(true);
        
@@ -3300,17 +3302,23 @@ public class NeverNote extends QMainWindow{
        
        menuBar.wideListView.blockSignals(false);
        menuBar.narrowListView.blockSignals(false);
-//     browserIndexSplitter.setVisible(false);
        
-       Global.setListView(Global.View_List_Narrow);
        mainLeftRightSplitter.addWidget(noteTableView);
        mainLeftRightSplitter.addWidget(browserWindow);
+       restoreWindowState(false);
+       noteTableView.repositionColumns();
+       noteTableView.resizeColumnWidths();
+       noteTableView.resizeRowHeights();
+       showColumns();
+       noteTableView.load(false);
+       scrollToCurrentGuid();
     }
     public void wideListView() {
-       if (!menuBar.wideListView.isChecked()) {
-               narrowListView();
-               return;
-       }
+       saveWindowState();
+       saveNoteColumnPositions();
+       saveNoteIndexWidth();
+       Global.setListView(Global.View_List_Wide);
+
        menuBar.wideListView.blockSignals(true);
        menuBar.narrowListView.blockSignals(true);
        
@@ -3320,10 +3328,15 @@ public class NeverNote extends QMainWindow{
        menuBar.wideListView.blockSignals(false);
        menuBar.narrowListView.blockSignals(false);
        browserIndexSplitter.setVisible(true);
-       Global.setListView(Global.View_List_Wide);
-//     browserIndexSplitter.setVisible(true);
         browserIndexSplitter.addWidget(noteTableView);
         browserIndexSplitter.addWidget(browserWindow);
+        restoreWindowState(false);
+       noteTableView.repositionColumns();
+       noteTableView.resizeColumnWidths();
+       noteTableView.resizeRowHeights();
+       showColumns();
+       noteTableView.load(false);
+       scrollToCurrentGuid();
     }
     
     
@@ -3507,8 +3520,9 @@ public class NeverNote extends QMainWindow{
                NoteFormatter formatter = new NoteFormatter(logger, conn, tempFiles);
                formatter.setNote(currentNote, Global.pdfPreview());
                formatter.setHighlight(listManager.getEnSearch());
+               QByteArray js;
                if (!noteCache.containsKey(currentNoteGuid) || conn.getNoteTable().isThumbnailNeeded(currentNoteGuid)) {
-                       QByteArray js = new QByteArray();
+                       js = new QByteArray();
                        // We need to prepend the note with <HEAD></HEAD> or encoded characters are ugly 
                        js.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");               
                        js.append("<style type=\"text/css\">.en-crypt-temp { border-collapse:collapse; border-style:solid; border-color:blue; padding:0.0mm 0.0mm 0.0mm 0.0mm; }</style>");
@@ -3524,13 +3538,14 @@ public class NeverNote extends QMainWindow{
                        js.replace("<?xml version='1.0' encoding='UTF-8'?>", "");
                        browser.getBrowser().setContent(js);
                        noteCache.put(currentNoteGuid, js.toString());
-                       if (conn.getNoteTable().isThumbnailNeeded(currentNoteGuid)) {
-                               thumbnailRunner.addWork("GENERATE " +currentNoteGuid);
-                       }
                } else {
                        logger.log(logger.HIGH, "Note content is being pulled from the cache");
                        String cachedContent = formatter.modifyCachedTodoTags(noteCache.get(currentNoteGuid));
-                       browser.getBrowser().setContent(new QByteArray(cachedContent));
+                       js = new QByteArray(cachedContent);
+                       browser.getBrowser().setContent(js);
+               }
+               if (conn.getNoteTable().isThumbnailNeeded(currentNoteGuid)) {
+                       thumbnailHTMLReady(currentNoteGuid, js, Global.calculateThumbnailZoom(js.toString()));
                }
 
                if (formatter.resourceError)
@@ -4130,22 +4145,36 @@ public class NeverNote extends QMainWindow{
                        QMessageBox.information(this, tr("Error Saving Note"), tr(msg));
                }
        }
-       private void thumbnailHTMLReady(String guid,String file) {
-               Thumbnailer preview = null;
+       private void thumbnailHTMLReady(String guid, QByteArray html, Integer zoom) {
+               
+               logger.log(logger.HIGH, "Entering thumnailHTMLReady()");
+               logger.log(logger.HIGH, "Thumbnail ready for " +guid);
                // Find an idle preview object
-               for (int i=0; i<previewList.size(); i++) {
-                       if (previewList.get(i).idle) {
-                               preview = previewList.get(i);
-                               i=previewList.size();
+               for (int i=0; i<thumbGenerators.size(); i++) {
+                       if (thumbGenerators.get(i).mutex.tryLock()) {
+                               logger.log(logger.EXTREME, "Idle generator found - loading thumbnail for " +guid);
+                               thumbGenerators.get(i).loadContent(guid, html, zoom);
+                               return;
                        }
                } 
-               if (preview == null) {
-                       preview = new Thumbnailer(conn, listManager);
-                       previewList.add(preview);
+               if (thumbGenerators.size() >= 1) {
+                       logger.log(logger.EXTREME, "No available thumbnail generators.  Aborting " +guid);
+                       return;
                }
-               preview.loadContent(guid, file);
+               
+               logger.log(logger.EXTREME, "Creating new thumbnail generator " +guid);
+               Thumbnailer preview = new Thumbnailer(logger, conn, listManager, thumbnailRunner);
+               thumbGenerators.add(preview);
+
+               if (preview.mutex.tryLock()) {
+                       logger.log(logger.EXTREME, "Loading thumbnail for  " +guid);
+                       preview.loadContent(guid, html, zoom);
+               }
+               logger.log(logger.HIGH, "Exiting thumnailHTMLReady()");
        }
        
+       
+       
        //**********************************************************
     //**********************************************************
     //* Online user actions
@@ -4223,7 +4252,7 @@ public class NeverNote extends QMainWindow{
                int usn = 0;
                
                for (int i=0; i<versions.size(); i++) {
-                       StringBuilder versionDate = new StringBuilder(simple.format(versions.get(i).getServiceUpdated()));
+                       StringBuilder versionDate = new StringBuilder(simple.format(versions.get(i).getSaved()));
                        if (versionDate.toString().equals(selection))
                                index = i;
                }
@@ -4340,6 +4369,7 @@ public class NeverNote extends QMainWindow{
                        
                        if (syncThreadsReady > 0) {
                                saveNoteIndexWidth();
+                               saveNoteColumnPositions();
                                if (syncRunner.addWork("SYNC")) {
                                        syncRunning = true;
                                        syncRunner.syncNeeded = true;
@@ -4571,7 +4601,8 @@ public class NeverNote extends QMainWindow{
        }
 
        private void thumbnailTimer() {
-               thumbnailRunner.addWork("SCAN");
+               if (Global.enableThumbnails())
+                       thumbnailRunner.addWork("SCAN");
        }
        
        //**************************************************
index 94cd32d..1ac7d1f 100644 (file)
@@ -27,18 +27,20 @@ import com.trolltech.qt.gui.QDialog;
 import com.trolltech.qt.gui.QGridLayout;\r
 import com.trolltech.qt.gui.QGroupBox;\r
 import com.trolltech.qt.gui.QHBoxLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QPushButton;\r
 \r
 import cx.fbn.nevernote.Global;\r
 \r
 public class AccountDialog extends QDialog {\r
-\r
+    String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        private final QPushButton ok;\r
        \r
        // Constructor\r
        public AccountDialog() {\r
                setWindowTitle(tr("Account Information"));\r
+               setWindowIcon(new QIcon(new QIcon(iconPath+"account.png")));\r
                QGridLayout grid = new QGridLayout();\r
                setLayout(grid);\r
                QLabel premium;\r
index c1ca6f4..b97a758 100644 (file)
@@ -34,6 +34,8 @@ public class ConfigDebugPage extends QWidget {
        QComboBox serverCombo;\r
        QCheckBox disableUploads;\r
        QCheckBox carriageReturnFix;\r
+       QCheckBox enableThumbnails;\r
+       \r
        public ConfigDebugPage(QWidget parent) {\r
                super(parent);\r
                // Server settings\r
@@ -69,6 +71,15 @@ public class ConfigDebugPage extends QWidget {
                mainLayout.addWidget(serverGroup);\r
                mainLayout.addWidget(messageGroup);\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
+               thumbnailGroup.setLayout(thumbnailLayout);\r
+               mainLayout.addWidget(thumbnailGroup);\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
                "enable it, it will do some modifications to the notes you view to try and" +\r
@@ -144,7 +155,16 @@ public class ConfigDebugPage extends QWidget {
                return disableUploads.isChecked();\r
        }\r
        \r
+       //****************************************\r
+       //* Thumbnails\r
+       //****************************************\r
+       public void setEnableThumbnails(boolean val) {\r
+               enableThumbnails.setChecked(val);\r
+       }\r
        \r
+       public boolean getEnableThumbnails() {\r
+               return enableThumbnails.isChecked();\r
+       }\r
 \r
 \r
 }\r
index 41c7f33..f20def5 100644 (file)
@@ -50,10 +50,12 @@ public class ConfigDialog extends QDialog {
        private final ConfigAppearancePage              appearancePage;\r
        private final ConfigSpellPage                   spellPage;\r
        private final ConfigIndexPage                   indexPage;\r
+    private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        public ConfigDialog(QWidget parent) {\r
                \r
                contentsWidget = new QListWidget(this);\r
+               setWindowIcon(new QIcon(iconPath+"config.png"));\r
                contentsWidget.setViewMode(QListView.ViewMode.IconMode);\r
                contentsWidget.setIconSize(new QSize(96, 84));\r
                contentsWidget.setMovement(QListView.Movement.Static);\r
@@ -102,6 +104,7 @@ public class ConfigDialog extends QDialog {
        }\r
        public void okPushed() {\r
                Global.setServer(debugPage.getServer());\r
+               Global.setEnableThumbnails(debugPage.getEnableThumbnails());\r
                AESEncrypter aes = new AESEncrypter();\r
                aes.setUserid(connectionPage.getUserid().trim());\r
                \r
@@ -266,6 +269,7 @@ public class ConfigDialog extends QDialog {
                \r
                debugPage.setServer(Global.getServer());\r
                debugPage.setDisableUploads(Global.disableUploads);\r
+               debugPage.setEnableThumbnails(Global.enableThumbnails());\r
 //             if (Global.getUpdateSequenceNumber() > 0)\r
                        debugPage.serverCombo.setEnabled(false);\r
                \r
index 1c22766..95bd026 100644 (file)
@@ -22,6 +22,7 @@ package cx.fbn.nevernote.dialog;
 import com.trolltech.qt.gui.QComboBox;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -34,12 +35,14 @@ public class DBEncryptDialog extends QDialog {
        private final QPushButton ok;\r
        private final QComboBox encryptionType;\r
        private final QLabel encryptionLabel;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        \r
        // Constructor\r
        public DBEncryptDialog() {\r
                okPressed = false;\r
                setWindowTitle(tr("Database Encryption"));\r
+               setWindowIcon(new QIcon(iconPath+"password.png"));\r
                QGridLayout grid = new QGridLayout();\r
                setLayout(grid);\r
                QGridLayout passwordGrid = new QGridLayout();\r
index 6f85c52..e652056 100644 (file)
@@ -21,6 +21,7 @@ package cx.fbn.nevernote.dialog;
 \r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -30,12 +31,14 @@ public class DatabaseLoginDialog extends QDialog {
        private boolean         okPressed;\r
        private final QLineEdit password;\r
        private final QPushButton ok;\r
+    private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        \r
        // Constructor\r
        public DatabaseLoginDialog() {\r
                okPressed = false;\r
                setWindowTitle(tr("Database Password"));\r
+               setWindowIcon(new QIcon(iconPath+"password.png"));\r
                QGridLayout grid = new QGridLayout();\r
                setLayout(grid);\r
                QGridLayout passwordGrid = new QGridLayout();\r
index 817c6b9..402de0c 100644 (file)
@@ -23,6 +23,7 @@ import java.text.NumberFormat;
 \r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QPushButton;\r
 \r
@@ -36,10 +37,12 @@ public class DatabaseStatus extends QDialog {
        QLabel resourceCount;\r
        QLabel indexCount;\r
        private final QPushButton ok;\r
+    private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        // Constructor\r
        public DatabaseStatus() {\r
                setWindowTitle(tr("Current Database Status"));\r
+               setWindowIcon(new QIcon(iconPath+"database.png"));\r
                QGridLayout grid = new QGridLayout();\r
                setLayout(grid);\r
                noteCount = new QLabel();\r
index 1f728e9..a0e6a52 100644 (file)
@@ -22,6 +22,7 @@ package cx.fbn.nevernote.dialog;
 \r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -34,12 +35,14 @@ public class EnCryptDialog extends QDialog {
        private final QLineEdit hint;\r
        private final QPushButton ok;\r
        private final QLabel error;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        \r
        // Constructor\r
        public EnCryptDialog() {\r
                okPressed = false;\r
                setWindowTitle(tr("Encrypt Text"));\r
+               setWindowIcon(new QIcon(iconPath+"password.png"));\r
                QGridLayout grid = new QGridLayout();\r
                QGridLayout input = new QGridLayout();\r
                QGridLayout msgGrid = new QGridLayout();\r
index 60a3d61..5695901 100644 (file)
@@ -23,6 +23,7 @@ package cx.fbn.nevernote.dialog;
 import com.trolltech.qt.gui.QCheckBox;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -37,12 +38,13 @@ public class EnDecryptDialog extends QDialog {
        private final QLabel error;\r
        private final QCheckBox permanent;\r
        private final QCheckBox remember;\r
-       \r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        // Constructor\r
        public EnDecryptDialog() {\r
                okPressed = false;\r
                setWindowTitle(tr("Decrypt Text"));\r
+               setWindowIcon(new QIcon(iconPath+"password.png"));\r
                QGridLayout grid = new QGridLayout();\r
                QGridLayout input = new QGridLayout();\r
                QGridLayout msgGrid = new QGridLayout();\r
index 9d50daf..713ce01 100644 (file)
@@ -23,6 +23,7 @@ package cx.fbn.nevernote.dialog;
 import com.trolltech.qt.gui.QCheckBox;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -36,10 +37,12 @@ public class FindDialog extends QDialog {
        private final QCheckBox backward;\r
        private final QCheckBox caseSensitive;\r
        private final QPushButton ok;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        // Constructor\r
        public FindDialog() {\r
                setWindowTitle(tr("Find"));\r
+               setWindowIcon(new QIcon(iconPath+"search.png"));\r
                QGridLayout grid = new QGridLayout();\r
                setLayout(grid);\r
 \r
index 515272b..a1acb61 100644 (file)
@@ -23,6 +23,7 @@ import com.trolltech.qt.gui.QDialog;
 import com.trolltech.qt.gui.QDoubleValidator;\r
 import com.trolltech.qt.gui.QDoubleValidator.Notation;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -34,12 +35,14 @@ public class GeoDialog extends QDialog {
        private final QLineEdit latitude;\r
        private final QLineEdit longitude;\r
        private final QPushButton ok;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        \r
        // Constructor\r
        public GeoDialog() {\r
                okPressed = false;\r
-               setWindowTitle(tr("NeverNote Login"));\r
+               setWindowTitle(tr("Geo Location"));\r
+               setWindowIcon(new QIcon(iconPath+"globe.png"));\r
                QGridLayout grid = new QGridLayout();\r
                setLayout(grid);\r
                QGridLayout passwordGrid = new QGridLayout();\r
index 20e75ec..8f5339b 100644 (file)
@@ -23,6 +23,7 @@ package cx.fbn.nevernote.dialog;
 import com.trolltech.qt.core.Qt;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -33,12 +34,14 @@ public class InsertLinkDialog extends QDialog {
        private final QLineEdit url;\r
        private final QPushButton ok;\r
        private String          urlText;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        \r
        // Constructor\r
        public InsertLinkDialog() {\r
                okPressed = false;\r
                setWindowTitle(tr("Insert Link"));\r
+               setWindowIcon(new QIcon(iconPath+"link.png"));\r
                QGridLayout grid = new QGridLayout();\r
                QGridLayout input = new QGridLayout();\r
                QGridLayout button = new QGridLayout();\r
index 3e2f728..35e4ae1 100644 (file)
@@ -21,6 +21,7 @@ package cx.fbn.nevernote.dialog;
 \r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QPushButton;\r
@@ -33,12 +34,13 @@ public class LoginDialog extends QDialog {
        private final QLineEdit userid;\r
        private final QLineEdit password;\r
        private final QPushButton ok;\r
-       \r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        // Constructor\r
        public LoginDialog() {\r
                okPressed = false;\r
                setWindowTitle(tr("NeverNote Login"));\r
+               setWindowIcon(new QIcon(iconPath+"password.png"));\r
                QGridLayout grid = new QGridLayout();\r
                setLayout(grid);\r
                QGridLayout passwordGrid = new QGridLayout();\r
index 5adedfa..8ae7fc3 100644 (file)
@@ -44,6 +44,7 @@ public class NotebookArchive extends QDialog {
        private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        public NotebookArchive(List<Notebook> allBooks, List<Notebook> archive) {\r
+               setWindowIcon(new QIcon(iconPath+"notebook-green.png"));\r
                okClicked = false;\r
                openBookList = new QListWidget();\r
                openBookList.setSortingEnabled(true);\r
index d326088..bcc6b04 100644 (file)
@@ -25,6 +25,7 @@ import com.evernote.edam.type.Notebook;
 import com.trolltech.qt.gui.QCheckBox;
 import com.trolltech.qt.gui.QDialog;
 import com.trolltech.qt.gui.QGridLayout;
+import com.trolltech.qt.gui.QIcon;
 import com.trolltech.qt.gui.QLabel;
 import com.trolltech.qt.gui.QLineEdit;
 import com.trolltech.qt.gui.QPushButton;
@@ -38,11 +39,13 @@ public class NotebookEdit extends QDialog {
        private final QCheckBox         isDefault;
        private boolean startDefault;
        private String startText;
-               
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");        
+       
        // Constructor
        public NotebookEdit() {
                okPressed = false;
                setWindowTitle(tr("Add Notebook"));
+               setWindowIcon(new QIcon(iconPath+"notebook-green.png"));
                QGridLayout grid = new QGridLayout();
                setLayout(grid);
                
index 6b1b468..bacd4de 100644 (file)
@@ -30,6 +30,7 @@ import com.trolltech.qt.core.Qt.ContextMenuPolicy;
 import com.trolltech.qt.gui.QComboBox;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QHBoxLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QPushButton;\r
 import com.trolltech.qt.gui.QVBoxLayout;\r
@@ -48,10 +49,12 @@ public class OnlineNoteHistory extends QDialog {
        private final BrowserWindow     browser;\r
        private final ApplicationLogger logger;\r
        List<QTemporaryFile>    tempFiles;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        // Constructor\r
        public OnlineNoteHistory(ApplicationLogger l, DatabaseConnection c) {\r
                setWindowTitle(tr("Online Note History"));\r
+               setWindowIcon(new QIcon(iconPath+"notebook-green.png"));\r
                QVBoxLayout main = new QVBoxLayout();\r
                setLayout(main);\r
                historyCombo = new QComboBox(this);\r
@@ -119,7 +122,7 @@ public class OnlineNoteHistory extends QDialog {
                SimpleDateFormat simple = new SimpleDateFormat(dateTimeFormat);\r
                \r
                for (int i=0; i<versions.size(); i++) {\r
-                       StringBuilder versionDate = new StringBuilder(simple.format(versions.get(i).getServiceUpdated()));\r
+                       StringBuilder versionDate = new StringBuilder(simple.format(versions.get(i).getSaved()));\r
                        historyCombo.addItem(versionDate.toString());\r
                }\r
        }\r
index 577db8a..b48e883 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 import com.evernote.edam.type.SavedSearch;
 import com.trolltech.qt.gui.QDialog;
 import com.trolltech.qt.gui.QGridLayout;
+import com.trolltech.qt.gui.QIcon;
 import com.trolltech.qt.gui.QLabel;
 import com.trolltech.qt.gui.QLineEdit;
 import com.trolltech.qt.gui.QPushButton;
@@ -34,12 +35,13 @@ public class SavedSearchEdit extends QDialog {
        private final QLineEdit query;
        QPushButton                     ok;
        List<SavedSearch>               currentSearches;
-       
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
        
        // Constructor
        public SavedSearchEdit() {
                okPressed = false;
                setWindowTitle(tr("Add a search"));
+               setWindowIcon(new QIcon(iconPath+"search.png"));
                QGridLayout grid = new QGridLayout();
                setLayout(grid);
                
index beb3ced..17bac03 100644 (file)
@@ -26,6 +26,7 @@ import com.swabunga.spell.event.SpellChecker;
 import com.trolltech.qt.core.Qt.AlignmentFlag;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QListWidget;\r
@@ -44,10 +45,12 @@ public class SpellCheck extends QDialog {
        private final QPushButton addToDictionary;\r
        private final QListWidget suggestions;\r
        private final SpellChecker checker;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        \r
        // Constructor\r
        public SpellCheck(SpellChecker checker) {\r
+               setWindowIcon(new QIcon(iconPath+"spellCheck.png"));\r
                replacePressed = false;\r
                cancelPressed = false;\r
                this.checker = checker;\r
index fd48177..3a0c5d3 100644 (file)
@@ -23,6 +23,7 @@ package cx.fbn.nevernote.dialog;
 import com.trolltech.qt.gui.QComboBox;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QGridLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QIntValidator;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QLineEdit;\r
@@ -39,12 +40,13 @@ public class TableDialog extends QDialog {
        private final QLabel            error;\r
        private final QIntValidator     widthValidator;\r
        private final QComboBox          unit;\r
-       \r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        // Constructor\r
        public TableDialog() {\r
                okPressed = false;\r
                setWindowTitle(tr("Insert Table"));\r
+               setWindowIcon(new QIcon(iconPath+"table.png"));\r
                QGridLayout grid = new QGridLayout();\r
                QGridLayout input = new QGridLayout();\r
                QGridLayout msgGrid = new QGridLayout();\r
index 05f49cd..3152569 100644 (file)
@@ -26,6 +26,7 @@ import com.evernote.edam.type.Tag;
 import com.trolltech.qt.gui.QAbstractItemView;\r
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QHBoxLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLineEdit;\r
 import com.trolltech.qt.gui.QListWidget;\r
 import com.trolltech.qt.gui.QListWidgetItem;\r
@@ -40,10 +41,12 @@ public class TagAssign extends QDialog {
        private final QPushButton               newTagButton;\r
        private boolean                                 okClicked;\r
        private final List<String>              tags;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        public TagAssign(List<Tag> allTags, List<String> selectedTags) {\r
                okClicked = false;\r
                tags = new ArrayList<String>();\r
+               setWindowIcon(new QIcon(iconPath+"tag.png"));\r
                \r
                tagList = new QListWidget();\r
                tagList.setSortingEnabled(true);\r
index 7e6b67d..7a43821 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 import com.evernote.edam.type.Tag;
 import com.trolltech.qt.gui.QDialog;
 import com.trolltech.qt.gui.QGridLayout;
+import com.trolltech.qt.gui.QIcon;
 import com.trolltech.qt.gui.QLabel;
 import com.trolltech.qt.gui.QLineEdit;
 import com.trolltech.qt.gui.QPushButton;
@@ -33,13 +34,14 @@ public class TagEdit extends QDialog {
        private final QLineEdit tag;
        QPushButton ok;
        List<Tag>               currentTags;
-       
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
        
        // Constructor
        public TagEdit() {
                okPressed = false;
                setWindowTitle(tr("Add Tag"));
                QGridLayout grid = new QGridLayout();
+               setWindowIcon(new QIcon(iconPath+"tag.png"));
                setLayout(grid);
                
                QGridLayout textGrid = new QGridLayout();
index 2941291..b05d67b 100644 (file)
@@ -31,6 +31,7 @@ import com.trolltech.qt.gui.QApplication;
 import com.trolltech.qt.gui.QDialog;\r
 import com.trolltech.qt.gui.QFontMetrics;\r
 import com.trolltech.qt.gui.QHBoxLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QPushButton;\r
 import com.trolltech.qt.gui.QTableWidget;\r
 import com.trolltech.qt.gui.QTableWidgetItem;\r
@@ -48,8 +49,10 @@ public class WatchFolder extends QDialog {
        public final QTableWidget               table;\r
        private final List<Notebook>    notebooks;\r
        private final List<WatchFolderRecord> records;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        public WatchFolder(List<WatchFolderRecord> w, List<Notebook> n) {\r
+               setWindowIcon(new QIcon(iconPath+"folder.png"));\r
                okClicked = false;\r
                notebooks = n;\r
                records = w;\r
index c7e323d..d622978 100644 (file)
@@ -28,6 +28,7 @@ import com.trolltech.qt.gui.QFileDialog;
 import com.trolltech.qt.gui.QFileDialog.FileMode;\r
 import com.trolltech.qt.gui.QGridLayout;\r
 import com.trolltech.qt.gui.QHBoxLayout;\r
+import com.trolltech.qt.gui.QIcon;\r
 import com.trolltech.qt.gui.QLabel;\r
 import com.trolltech.qt.gui.QPushButton;\r
 import com.trolltech.qt.gui.QVBoxLayout;\r
@@ -43,8 +44,10 @@ public class WatchFolderAdd extends QDialog {
        public final QLabel                     directory;\r
        public final QComboBox          keep;\r
        public final QComboBox          books;\r
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        public WatchFolderAdd(WatchFolderRecord w, List<Notebook> n) {\r
+               setWindowIcon(new QIcon(iconPath+"folder.png"));\r
                okClicked = false;\r
                notebooks = n;\r
                record = w;\r
index 74974d1..bb17512 100644 (file)
@@ -25,6 +25,8 @@ import java.util.Map;
 import com.trolltech.qt.core.QAbstractItemModel;\r
 import com.trolltech.qt.core.QModelIndex;\r
 import com.trolltech.qt.core.QObject;\r
+import com.trolltech.qt.core.Qt;\r
+import com.trolltech.qt.gui.QImage;\r
 import com.trolltech.qt.gui.QSortFilterProxyModel;\r
 \r
 import cx.fbn.nevernote.Global;\r
@@ -65,11 +67,20 @@ public class NoteSortFilterProxyModel extends QSortFilterProxyModel {
                        return false;\r
        }\r
        \r
+       \r
+       @Override\r
+       public void sort(int col, Qt.SortOrder order) {\r
+               if (col != Global.noteTableThumbnailPosition)\r
+                       super.sort(col,order);\r
+       }\r
+       \r
        @Override\r
        protected boolean lessThan(QModelIndex left, QModelIndex right) {\r
                Object leftData = sourceModel().data(left);\r
                Object rightData = sourceModel().data(right);\r
                \r
+               if (leftData instanceof QImage && rightData instanceof QImage)\r
+                       return true;\r
                if (leftData instanceof Long && rightData instanceof Long) {\r
                          Long leftLong = (Long)leftData;\r
                          Long rightLong = (Long)rightData;\r
index 6f3280a..3368242 100644 (file)
@@ -2129,6 +2129,8 @@ public class BrowserWindow extends QWidget {
                // Strip URL prefix and base dir\r
                guid = guid.replace("nnres://", "")\r
                        .replace(FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath()), "");\r
+               guid = guid.replace("file://", "").replace("/", "")\r
+               .replace(FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath()), "");\r
 \r
                pos = guid.lastIndexOf('.');\r
                if (pos > 0)\r
index 3961b4b..a72ac2d 100644 (file)
@@ -10,8 +10,10 @@ import com.trolltech.qt.core.QDateTime;
 import com.trolltech.qt.core.QModelIndex;\r
 import com.trolltech.qt.core.Qt;\r
 import com.trolltech.qt.core.Qt.AspectRatioMode;\r
+import com.trolltech.qt.core.Qt.TransformationMode;\r
 import com.trolltech.qt.gui.QAbstractTableModel;\r
 import com.trolltech.qt.gui.QColor;\r
+import com.trolltech.qt.gui.QImage;\r
 import com.trolltech.qt.gui.QPixmap;\r
 \r
 import cx.fbn.nevernote.Global;\r
@@ -167,12 +169,25 @@ public class NoteTableModel extends QAbstractTableModel {
                        return note.getGuid();\r
                }\r
                if (col == Global.noteTableThumbnailPosition) {\r
-                       if (listManager.getThumbnails().get(note.getGuid()) == null)\r
+                       if (!Global.enableThumbnails())\r
                                return null;\r
-                       if (Global.listView)\r
-                               return QPixmap.fromImage(listManager.getThumbnails().get(note.getGuid())).scaled(Global.smallThumbnailSize, AspectRatioMode.KeepAspectRatio);\r
-                       else\r
-                               return QPixmap.fromImage(listManager.getThumbnails().get(note.getGuid())).scaled(Global.largeThumbnailSize, AspectRatioMode.KeepAspectRatio);\r
+                       if (Global.getListView() == Global.View_List_Wide) {\r
+//                             QImage img = listManager.getThumbnail(note.getGuid());\r
+                               QPixmap img = listManager.getThumbnailPixmap(note.getGuid());\r
+                               if (img != null)\r
+                                       return img.scaled(Global.smallThumbnailSize, \r
+                                               AspectRatioMode.KeepAspectRatio, TransformationMode.SmoothTransformation);\r
+                               else\r
+                                       return null;\r
+                       }\r
+                       else {\r
+                               QImage img = listManager.getThumbnail(note.getGuid());\r
+                               if (img != null)\r
+                                       return img.scaled(Global.largeThumbnailSize,\r
+                                               AspectRatioMode.KeepAspectRatio, TransformationMode.SmoothTransformation);\r
+                               else\r
+                                       return null;\r
+                       }\r
                                \r
                }\r
                return "";\r
index 32bcc54..fcd9222 100644 (file)
@@ -128,7 +128,7 @@ public class NotebookTreeWidget extends QTreeWidget {
        QIcon greenIcon = new QIcon(iconPath+"notebook-green.png");\r
        QIcon redIcon = new QIcon(iconPath+"notebook-red.png");\r
        QIcon yellowIcon = new QIcon(iconPath+"notebook-yellow.png");\r
-//             QIcon icon = new QIcon(iconPath+"nevernote.png");\r
+       \r
        if (books == null)\r
                return;\r
        Qt.Alignment ra = new Qt.Alignment(Qt.AlignmentFlag.AlignRight);\r
index 900eea8..71ce21f 100644 (file)
@@ -91,6 +91,7 @@ public class TableView extends QTableView {
                header.synchronizedAction.toggled.connect(this, "toggleSynchronized(Boolean)");\r
                header.guidAction.toggled.connect(this, "toggleGuid(Boolean)");\r
                header.thumbnailAction.toggled.connect(this, "toggleThumbnail(Boolean)");\r
+               header.titleAction.toggled.connect(this, "toggleTitle(Boolean)");\r
                \r
                noteSignal = new NoteSignal();\r
                setAcceptDrops(true);\r
@@ -158,13 +159,14 @@ public class TableView extends QTableView {
                proxyModel.clear();\r
                setSortingEnabled(false);\r
                QFontMetrics f = QApplication.fontMetrics();\r
-               if (Global.listView) {\r
-                       if (!Global.isColumnVisible("thumbnail"))\r
+               if (!Global.isColumnVisible("thumbnail"))\r
                                verticalHeader().setDefaultSectionSize(f.height());\r
-                       else\r
+               else {\r
+                       if (Global.getListView() == Global.View_List_Wide)\r
                                verticalHeader().setDefaultSectionSize(Global.smallThumbnailSize.height());\r
-               } else\r
-                       verticalHeader().setDefaultSectionSize(Global.largeThumbnailSize.height());\r
+                       else\r
+                               verticalHeader().setDefaultSectionSize(Global.largeThumbnailSize.height());\r
+               }\r
                for (int i=0; i<runner.getNoteIndex().size(); i++) {\r
                        if (Global.showDeleted == true && !runner.getNoteIndex().get(i).isActive())\r
                                proxyModel.addGuid(runner.getNoteIndex().get(i).getGuid());\r
@@ -188,28 +190,16 @@ public class TableView extends QTableView {
                } \r
                proxyModel.invalidate();\r
                \r
-               int width;\r
-               width = Global.getColumnWidth("noteTableCreationPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableCreationPosition, width);\r
-               width = Global.getColumnWidth("noteTableChangedPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableChangedPosition, width);\r
-               width = Global.getColumnWidth("noteTableTitlePosition");\r
-               if (width>0) setColumnWidth(Global.noteTableTitlePosition, width);\r
-               width = Global.getColumnWidth("noteTableTagPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableTagPosition, width);\r
-               width = Global.getColumnWidth("noteTableGuidPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableGuidPosition, width);\r
-               width = Global.getColumnWidth("noteTableNotebookPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableNotebookPosition, width);\r
-               width = Global.getColumnWidth("noteTableSourceUrlPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableSourceUrlPosition, width);\r
-               width = Global.getColumnWidth("noteTableAuthorPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableAuthorPosition, width);\r
-               width = Global.getColumnWidth("noteTableSubjectDatePosition");\r
-               if (width>0) setColumnWidth(Global.noteTableSubjectDatePosition, width);\r
-               width = Global.getColumnWidth("noteTableSynchronizedPosition");\r
-               if (width>0) setColumnWidth(Global.noteTableSynchronizedPosition, width);\r
+               resizeColumnWidths();\r
+               repositionColumns();\r
+               \r
+               proxyModel.filter();\r
                \r
+               setSortingEnabled(true);\r
+               resetViewport.emit();\r
+       }\r
+       \r
+       public void repositionColumns() {\r
                int from = header.visualIndex(Global.noteTableCreationPosition);\r
                int to = Global.getColumnPosition("noteTableCreationPosition");\r
                if (to>=0) header.moveSection(from, to);\r
@@ -246,12 +236,67 @@ public class TableView extends QTableView {
                to = Global.getColumnPosition("noteTableSynchronizedPosition");\r
                if (to>=0) header.moveSection(from, to);\r
 \r
-               proxyModel.filter();\r
                \r
-               setSortingEnabled(true);\r
-               resetViewport.emit();\r
+               from = header.visualIndex(Global.noteTableGuidPosition);\r
+               to = Global.getColumnPosition("noteTableGuidPosition");\r
+               if (to>=0) header.moveSection(from, to);\r
+               \r
+               \r
+               from = header.visualIndex(Global.noteTableThumbnailPosition);\r
+               to = Global.getColumnPosition("noteTableThumbnailPosition");\r
+               if (to>=0) header.moveSection(from, to);\r
+\r
        }\r
+       \r
+       public void resizeColumnWidths() {\r
+               int width;\r
+               width = Global.getColumnWidth("noteTableCreationPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableCreationPosition, width);\r
+               width = Global.getColumnWidth("noteTableChangedPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableChangedPosition, width);\r
+               width = Global.getColumnWidth("noteTableTitlePosition");\r
+               if (width>0) setColumnWidth(Global.noteTableTitlePosition, width);\r
+               width = Global.getColumnWidth("noteTableTagPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableTagPosition, width);\r
+               width = Global.getColumnWidth("noteTableGuidPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableGuidPosition, width);\r
+               width = Global.getColumnWidth("noteTableNotebookPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableNotebookPosition, width);\r
+               width = Global.getColumnWidth("noteTableSourceUrlPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableSourceUrlPosition, width);\r
+               width = Global.getColumnWidth("noteTableAuthorPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableAuthorPosition, width);\r
+               width = Global.getColumnWidth("noteTableSubjectDatePosition");\r
+               if (width>0) setColumnWidth(Global.noteTableSubjectDatePosition, width);\r
+               width = Global.getColumnWidth("noteTableSynchronizedPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableSynchronizedPosition, width);\r
+               width = Global.getColumnWidth("noteTableThumbnailPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableThumbnailPosition, width);\r
+               width = Global.getColumnWidth("noteTableGuidPosition");\r
+               if (width>0) setColumnWidth(Global.noteTableGuidPosition, width);\r
 \r
+       }\r
+       \r
+       public void resizeRowHeights() {\r
+               int height;\r
+               if (!Global.isColumnVisible("thumbnail") || !Global.enableThumbnails()) {\r
+                       QFontMetrics f = QApplication.fontMetrics();\r
+                       verticalHeader().setDefaultSectionSize(f.height());\r
+                       height = fontHeight;\r
+               } else {\r
+                       if (Global.getListView() == Global.View_List_Wide) {\r
+                               verticalHeader().setDefaultSectionSize(Global.smallThumbnailSize.height());\r
+                               height = Global.smallThumbnailSize.height();\r
+                       } else {\r
+                               verticalHeader().setDefaultSectionSize(Global.largeThumbnailSize.height());\r
+                               height = Global.largeThumbnailSize.height();\r
+                       }\r
+               }\r
+               for (int i=0; i<runner.getNoteTableModel().rowCount(); i++) {\r
+                       setRowHeight(i, height);\r
+               }\r
+       }\r
+       \r
        public void insertRow(Note tempNote, boolean newNote, int row) {\r
                if (newNote)\r
                        proxyModel.addGuid(tempNote.getGuid());\r
@@ -263,11 +308,7 @@ public class TableView extends QTableView {
                        runner.getNoteTableModel().insertRow(row);\r
                }\r
                if (newNote) {\r
-                       QFontMetrics f = QApplication.fontMetrics();\r
-                       fontHeight = f.height();\r
-                       for (int i=0; i<runner.getNoteTableModel().rowCount(); i++) {\r
-                               setRowHeight(i, fontHeight);\r
-                       }\r
+                       resizeRowHeights();\r
                }\r
        }\r
        protected boolean filterAcceptsRow(int sourceRow, QModelIndex sourceParent) {\r
@@ -462,7 +503,12 @@ public class TableView extends QTableView {
                Global.saveColumnVisible("notebook", toggle);\r
                setColumnHidden(Global.noteTableNotebookPosition, !toggle);\r
        }\r
-       \r
+\r
+       public void toggleTitle(Boolean toggle) {\r
+               Global.saveColumnVisible("title", toggle);\r
+               setColumnHidden(Global.noteTableTitlePosition, !toggle);\r
+       }\r
+\r
        public void toggleTags(Boolean toggle) {\r
                Global.saveColumnVisible("tags", toggle);\r
                setColumnHidden(Global.noteTableTagPosition, !toggle);\r
index d50195b..05d89eb 100644 (file)
@@ -1,5 +1,7 @@
 package cx.fbn.nevernote.gui;\r
 \r
+import java.util.List;\r
+\r
 import com.trolltech.qt.core.Qt.Orientation;\r
 import com.trolltech.qt.gui.QAction;\r
 import com.trolltech.qt.gui.QContextMenuEvent;\r
@@ -15,6 +17,7 @@ public class TableViewHeader extends QHeaderView {
        public QAction changedDateAction;\r
        public QAction subjectDateAction;\r
        public QAction tagsAction;\r
+       public QAction titleAction;\r
        public QAction notebookAction;\r
        public QAction synchronizedAction;\r
        public QAction authorAction;\r
@@ -31,70 +34,104 @@ public class TableViewHeader extends QHeaderView {
                \r
                contextMenu = new QMenu();\r
 \r
+               titleAction = new QAction(this);\r
+               titleAction.setText(tr("Title"));\r
+               titleAction.setCheckable(true);\r
+               contextMenu.addAction(titleAction);\r
+               \r
                createdDateAction = new QAction(this);\r
                createdDateAction.setText(tr("Date Created"));\r
                createdDateAction.setCheckable(true);\r
-               createdDateAction.setChecked(Global.isColumnVisible("dateCreated"));\r
                contextMenu.addAction(createdDateAction);\r
                \r
                changedDateAction = new QAction(this);\r
                changedDateAction.setText(tr("Date Changed"));\r
                changedDateAction.setCheckable(true);\r
-               changedDateAction.setChecked(Global.isColumnVisible("dateChanged"));\r
                contextMenu.addAction(changedDateAction);\r
                \r
                subjectDateAction = new QAction(this);\r
                subjectDateAction.setText(tr("Subject Date"));\r
                subjectDateAction.setCheckable(true);\r
-               subjectDateAction.setChecked(Global.isColumnVisible("dateSubject"));\r
                contextMenu.addAction(subjectDateAction);\r
                \r
                tagsAction = new QAction(this);\r
                tagsAction.setText(tr("Tags"));\r
                tagsAction.setCheckable(true);\r
-               tagsAction.setChecked(Global.isColumnVisible("tags"));\r
                contextMenu.addAction(tagsAction);\r
                \r
                notebookAction = new QAction(this);\r
                notebookAction.setText(tr("Notebook"));\r
                notebookAction.setCheckable(true);\r
-               notebookAction.setChecked(Global.isColumnVisible("notebook"));\r
                contextMenu.addAction(notebookAction);\r
                \r
                synchronizedAction = new QAction(this);\r
                synchronizedAction.setText(tr("Synchronized"));\r
                synchronizedAction.setCheckable(true);\r
-               synchronizedAction.setChecked(Global.isColumnVisible("synchronized"));\r
                contextMenu.addAction(synchronizedAction);\r
                \r
                authorAction = new QAction(this);\r
                authorAction.setText(tr("Author"));\r
                authorAction.setCheckable(true);\r
-               authorAction.setChecked(Global.isColumnVisible("author"));\r
                contextMenu.addAction(authorAction);\r
                \r
                urlAction = new QAction(this);\r
                urlAction.setText(tr("Source URL"));\r
                urlAction.setCheckable(true);\r
-               urlAction.setChecked(Global.isColumnVisible("sourceUrl"));\r
                contextMenu.addAction(urlAction);\r
                \r
                thumbnailAction = new QAction(this);\r
                thumbnailAction.setText(tr("Thumbnail"));\r
                thumbnailAction.setCheckable(true);\r
-               thumbnailAction.setChecked(Global.isColumnVisible("thumbnail"));\r
-//             contextMenu.addAction(thumbnailAction);\r
+               contextMenu.addAction(thumbnailAction);\r
                \r
                guidAction = new QAction(this);\r
                guidAction.setText(tr("Guid"));\r
                guidAction.setCheckable(true);\r
-               guidAction.setChecked(Global.isColumnVisible("guid"));\r
 //             contextMenu.addAction(guidAction);\r
+               setMouseTracking(true);\r
+               sectionEntered.connect(this, "sectionClicked(Integer)");\r
                \r
+               checkActions();\r
+       }\r
+\r
+       private void checkActions() {\r
+               titleAction.setChecked(Global.isColumnVisible("title"));\r
+               createdDateAction.setChecked(Global.isColumnVisible("dateCreated"));\r
+               changedDateAction.setChecked(Global.isColumnVisible("dateChanged"));\r
+               subjectDateAction.setChecked(Global.isColumnVisible("dateSubject"));\r
+               tagsAction.setChecked(Global.isColumnVisible("tags"));\r
+               notebookAction.setChecked(Global.isColumnVisible("notebook"));\r
+               synchronizedAction.setChecked(Global.isColumnVisible("synchronized"));\r
+               authorAction.setChecked(Global.isColumnVisible("author"));\r
+               urlAction.setChecked(Global.isColumnVisible("sourceUrl"));\r
+               thumbnailAction.setChecked(Global.isColumnVisible("thumbnail"));\r
+               guidAction.setChecked(Global.isColumnVisible("guid"));\r
+       }\r
+       \r
+       public void sectionClicked(Integer position) {\r
+               System.out.println(position);\r
+               if (position == Global.noteTableThumbnailPosition)\r
+                       setClickable(false);\r
+               else\r
+                       setClickable(true);\r
        }\r
        \r
        @Override\r
        public void contextMenuEvent(QContextMenuEvent event) {\r
+               checkActions();\r
+               List<QAction> actions = contextMenu.actions();\r
+               int count = 0;\r
+               for (int i=0; i<actions.size(); i++) {\r
+                       actions.get(i).setEnabled(true);\r
+                       if (actions.get(i).isChecked()) \r
+                               count++;\r
+               }\r
+               if (count <= 1) {\r
+                       for (int i=0; i<actions.size(); i++) {\r
+                               if (actions.get(i).isChecked()) \r
+                                       actions.get(i).setEnabled(false);\r
+                       }\r
+               }\r
                contextMenu.exec(event.globalPos());\r
        }\r
 }\r
index 1dda121..753044a 100644 (file)
 package cx.fbn.nevernote.gui;\r
 \r
 import com.trolltech.qt.core.QBuffer;\r
+import com.trolltech.qt.core.QByteArray;\r
 import com.trolltech.qt.core.QIODevice;\r
+import com.trolltech.qt.core.QMutex;\r
 import com.trolltech.qt.core.QObject;\r
 import com.trolltech.qt.core.QSize;\r
-import com.trolltech.qt.core.QUrl;\r
 import com.trolltech.qt.core.Qt.Orientation;\r
 import com.trolltech.qt.core.Qt.ScrollBarPolicy;\r
+import com.trolltech.qt.gui.QColor;\r
 import com.trolltech.qt.gui.QImage;\r
+import com.trolltech.qt.gui.QImage.Format;\r
 import com.trolltech.qt.gui.QPainter;\r
 import com.trolltech.qt.webkit.QWebPage;\r
 \r
 import cx.fbn.nevernote.sql.DatabaseConnection;\r
+import cx.fbn.nevernote.threads.ThumbnailRunner;\r
+import cx.fbn.nevernote.utilities.ApplicationLogger;\r
 import cx.fbn.nevernote.utilities.ListManager;\r
 \r
 public class Thumbnailer extends QObject {\r
-    public QWebPage page;\r
+    public QWebPage page = new QWebPage();\r
     public QImage image;\r
-    public QPainter painter;\r
-    public Signal1<String> finished;\r
+    public QPainter painter = new QPainter();\r
+    public QMutex mutex;\r
     public String guid;\r
-    private final DatabaseConnection conn;\r
     private final QSize size;\r
-    public boolean idle = false;\r
+    private int zoom;\r
+    private QBuffer buffer;\r
     private final ListManager listManager;\r
+    private final ThumbnailRunner runner;\r
+    private final ApplicationLogger logger;\r
+    private final DatabaseConnection conn;\r
     \r
-    public Thumbnailer(DatabaseConnection conn, ListManager l)\r
+    public Thumbnailer(ApplicationLogger logger, DatabaseConnection conn, ListManager l, ThumbnailRunner r)\r
     {\r
-       this.conn = conn;\r
-       finished = new Signal1<String>();\r
+       mutex = new QMutex();\r
+       zoom = 1;\r
+\r
+       this.runner = r;\r
+       this.logger = logger;\r
        page = new QWebPage();\r
        listManager = l;\r
-        painter = new QPainter();\r
+       this.conn = conn;\r
         size = new QSize(1024,768);\r
-       page.mainFrame().setScrollBarPolicy(Orientation.Horizontal, ScrollBarPolicy.ScrollBarAlwaysOff);\r
-       page.mainFrame().setScrollBarPolicy(Orientation.Vertical, ScrollBarPolicy.ScrollBarAlwaysOff);\r
+        image = new QImage(size, Format.Format_ARGB32_Premultiplied);\r
+       page.setViewportSize(size);\r
        page.loadFinished.connect(this, "loadFinished(Boolean)");\r
+       buffer = new QBuffer();\r
+        mutex.unlock();\r
     }\r
     \r
-    public void loadContent(String guid, String fileName) {\r
-       idle = false;\r
+    public void loadContent(String guid, QByteArray html, int zoom) {\r
+       this.zoom = zoom;\r
        this.guid = guid;\r
-       page.setViewportSize(size);\r
-       page.mainFrame().load(new QUrl(QUrl.fromLocalFile(fileName)));\r
+       page.mainFrame().setScrollBarPolicy(Orientation.Horizontal, ScrollBarPolicy.ScrollBarAlwaysOff);\r
+       page.mainFrame().setScrollBarPolicy(Orientation.Vertical, ScrollBarPolicy.ScrollBarAlwaysOff);\r
+               page.mainFrame().setContent(html);\r
     }\r
-    \r
-\r
-    \r
-       public void loadFinished(Boolean ok)\r
-    {\r
-               if (!ok)\r
-                       return;\r
-               \r
-       QSize size = page.currentFrame().contentsSize();\r
-       if (size.height() > 2000)\r
-               size.setHeight(800);\r
-       if (size.width() < 600)\r
-               size.setWidth(600);\r
-       if (size.width() > 2000)\r
-               size.setWidth(600);\r
-   \r
-       page.setViewportSize(size);\r
-       image = new QImage(size, QImage.Format.Format_RGB32);\r
+       \r
+       \r
+       public String loadFinished(Boolean ok) {\r
+               if (!ok) { \r
+                       mutex.unlock();\r
+                       return null;\r
+               }\r
+               logger.log(logger.EXTREME, "Creating painter");\r
+               painter = new QPainter();\r
+               logger.log(logger.EXTREME, "Creating image");\r
+               if (image == null) {\r
+                       System.out.println("Null image");\r
+                       image = new QImage(size, Format.Format_ARGB32_Premultiplied);\r
+                       if (image.isNull()) {\r
+                               logger.log(logger.EXTREME, "Image is null.  Aborting");\r
+                               mutex.unlock();\r
+                               return null;\r
+                       }\r
+               }\r
+               logger.log(logger.EXTREME, "Filling image");\r
+               image.fill(QColor.white.rgb());\r
+               logger.log(logger.EXTREME, "Beginning painter");\r
         painter.begin(image);\r
-\r
-        page.mainFrame().render(painter);             //<<<< THIS CAN LOCKUP if height too big!!!!\r
+        page.mainFrame().setZoomFactor(new Double(zoom));\r
+       if (painter.paintEngine() == null) {\r
+               logger.log(logger.EXTREME, "Bad paint engine.  Aborting");\r
+               painter.end();\r
+                       mutex.unlock();\r
+                       return null;\r
+       }\r
+               logger.log(logger.EXTREME, "Rendering image");\r
+        page.mainFrame().render(painter); \r
+               logger.log(logger.EXTREME, "Closing painter");\r
         painter.end();\r
         \r
-       image = image.scaled(new QSize(100,100));\r
-        \r
-        QBuffer buffer = new QBuffer();\r
-        buffer.open(QIODevice.OpenModeFlag.ReadWrite);\r
-        image.save(buffer);\r
-        conn.getNoteTable().setThumbnail(guid, buffer.data());\r
-        conn.getNoteTable().setThumbnailNeeded(guid, false);\r
-        \r
-        listManager.getThumbnails().remove(guid);\r
-               listManager.getThumbnails().put(guid, image);\r
-               finished.emit(guid); \r
-        \r
-        idle = true;\r
-        return;\r
+        if (image.isNull()) {\r
+               logger.log(logger.EXTREME, "Error rendering thumbnail image.  Aborting");\r
+               mutex.unlock();\r
+               return null;\r
+        }\r
+               logger.log(logger.EXTREME, "Adding to listManager");\r
+//        listManager.getThumbnails().remove(guid);\r
+//             listManager.getThumbnails().put(guid, image.clone());\r
+               logger.log(logger.EXTREME, "Saving image isNull=" +image.isNull() +" Size=" +image.size());\r
+               logger.log(logger.EXTREME, "Adding image to runner");\r
+               saveImage();\r
+               logger.log(logger.EXTREME, "Unlocking thumbnailer");\r
+        mutex.unlock();\r
+        return guid;\r
     }\r
+       \r
+       \r
+       private void saveImage() {\r
+               logger.log(logger.EXTREME, "Image found "+guid);\r
+                               \r
+               logger.log(logger.EXTREME, "Opening buffer");\r
+               if (buffer == null)\r
+                       buffer = new QBuffer();\r
+        if (!buffer.open(QIODevice.OpenModeFlag.ReadWrite)) {\r
+               logger.log(logger.EXTREME, "Failure to open buffer.  Aborting.");\r
+               mutex.unlock();\r
+               return;\r
+        }\r
+               \r
+               logger.log(logger.EXTREME, "Filling buffer");\r
+        if (!image.save(buffer, "PNG")) {\r
+               logger.log(logger.EXTREME, "Failure to write to buffer.  Aborting.");     \r
+               mutex.unlock();\r
+               return;\r
+        }\r
+        buffer.close();\r
+               \r
+               logger.log(logger.EXTREME, "Updating database");\r
+               QByteArray b = buffer.buffer();\r
+               conn.getNoteTable().setThumbnail(guid, b);\r
+               conn.getNoteTable().setThumbnailNeeded(guid, false);\r
+       }\r
 }\r
diff --git a/src/cx/fbn/nevernote/icons/account.png b/src/cx/fbn/nevernote/icons/account.png
new file mode 100644 (file)
index 0000000..b552d17
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/account.png differ
diff --git a/src/cx/fbn/nevernote/icons/books.png b/src/cx/fbn/nevernote/icons/books.png
new file mode 100644 (file)
index 0000000..92cd6af
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/books.png differ
diff --git a/src/cx/fbn/nevernote/icons/config.png b/src/cx/fbn/nevernote/icons/config.png
new file mode 100644 (file)
index 0000000..03cc9e8
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/config.png differ
diff --git a/src/cx/fbn/nevernote/icons/database.png b/src/cx/fbn/nevernote/icons/database.png
new file mode 100644 (file)
index 0000000..0f9b703
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/database.png differ
diff --git a/src/cx/fbn/nevernote/icons/folder.png b/src/cx/fbn/nevernote/icons/folder.png
new file mode 100644 (file)
index 0000000..ce71988
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/folder.png differ
diff --git a/src/cx/fbn/nevernote/icons/library.png b/src/cx/fbn/nevernote/icons/library.png
new file mode 100644 (file)
index 0000000..a99d251
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/library.png differ
diff --git a/src/cx/fbn/nevernote/icons/link.png b/src/cx/fbn/nevernote/icons/link.png
new file mode 100644 (file)
index 0000000..d7942a8
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/link.png differ
diff --git a/src/cx/fbn/nevernote/icons/password.png b/src/cx/fbn/nevernote/icons/password.png
new file mode 100644 (file)
index 0000000..ffe9b37
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/password.png differ
diff --git a/src/cx/fbn/nevernote/icons/table.png b/src/cx/fbn/nevernote/icons/table.png
new file mode 100644 (file)
index 0000000..b5255d0
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/table.png differ
index e38a7ca..2062457 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 \r
 import com.evernote.edam.type.Note;\r
 import com.trolltech.qt.QSignalEmitter;\r
+import com.trolltech.qt.core.QByteArray;\r
 import com.trolltech.qt.core.QDateTime;\r
 \r
 \r
@@ -45,7 +46,7 @@ public class NoteSignal extends QSignalEmitter {
        public Signal1<Integer>                         titleColorChanged = new Signal1<Integer>();\r
        public Signal2<Note, Boolean>           noteDownloaded = new Signal2<Note, Boolean>();\r
        public Signal2<String, String>          noteSaveRunnerError = new Signal2<String, String>();\r
-       public Signal2<String, String>          thumbnailPageReady = new Signal2<String,String>();\r
+       public Signal3<String,QByteArray,Integer>               thumbnailPageReady = new Signal3<String,QByteArray,Integer>();\r
 }\r
 \r
 \r
index 6298178..7290f38 100644 (file)
@@ -24,6 +24,7 @@ import java.text.DateFormat;
 import java.text.ParseException;\r
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
+import java.util.HashMap;\r
 import java.util.List;\r
 \r
 import com.evernote.edam.type.Note;\r
@@ -33,6 +34,7 @@ import com.evernote.edam.type.Tag;
 import com.trolltech.qt.core.QByteArray;\r
 import com.trolltech.qt.core.QDateTime;\r
 import com.trolltech.qt.core.QTextCodec;\r
+import com.trolltech.qt.gui.QPixmap;\r
 \r
 import cx.fbn.nevernote.Global;\r
 import cx.fbn.nevernote.evernote.EnmlConverter;\r
@@ -1090,6 +1092,7 @@ public class NoteTable {
                                        \r
                check = query.prepare("Update note set thumbnail = :thumbnail where guid=:guid");\r
                query.bindValue(":guid", guid);\r
+               int x = thumbnail.size();\r
                query.bindValue(":thumbnail", thumbnail.toByteArray());\r
                check = query.exec();\r
                if (!check) \r
@@ -1119,14 +1122,40 @@ public class NoteTable {
                }\r
                return null;\r
        }\r
+       // Get all thumbnails\r
+       public HashMap<String, QPixmap> getThumbnails() {\r
+               boolean check;                  \r
+        NSqlQuery query = new NSqlQuery(db.getConnection());\r
+        HashMap<String, QPixmap> map = new HashMap<String,QPixmap>();\r
+                                       \r
+               check = query.prepare("Select guid,thumbnail from note where thumbnailneeded=false and isExpunged=false");\r
+               check = query.exec();\r
+               if (!check) \r
+                       logger.log(logger.EXTREME, "Note SQL get thumbail failed: " +query.lastError().toString());\r
+               // Get a list of the notes\r
+               while (query.next())  {\r
+                       try {\r
+                               if (query.getBlob(1) != null) {\r
+                                       QByteArray data = new QByteArray(query.getBlob(1));\r
+                                       QPixmap img = new QPixmap();\r
+                                       if (img.loadFromData(data)) {\r
+                                               img = img.scaled(Global.largeThumbnailSize);\r
+                                               map.put(query.valueString(0), img);\r
+                                       }\r
+                               }       \r
+                       } catch (java.lang.IllegalArgumentException e) {\r
+                               logger.log(logger.HIGH, "Error retrieving thumbnail " +e.getMessage());\r
+                       }\r
+               }\r
+               return map;\r
+       }\r
        // Get a list of notes that need thumbnails\r
-       // Is a thumbail needed for this guid?\r
        public List<String> findThumbnailsNeeded() {\r
                \r
                boolean check;\r
         NSqlQuery query = new NSqlQuery(db.getConnection());\r
                                        \r
-               check = query.prepare("select guid from note where thumbnailneeded = true limit 100");\r
+               check = query.prepare("select guid from note where thumbnailneeded=true and isExpunged=false limit 5");\r
                check = query.exec();\r
                if (!check) \r
                        logger.log(logger.EXTREME, "Note SQL findThumbnailsNeeded query failed: " +query.lastError().toString());\r
index 3378af8..27a907d 100644 (file)
@@ -132,13 +132,16 @@ public class REnSearch {
                        if (tagNames.size() == 0 && negative)\r
                                return true;\r
                        \r
-                       for (int i=0; i<tagNames.size(); i++) {         \r
+                       boolean good = false;\r
+                       for (int i=0; i<tagNames.size() && !good; i++) {                \r
                                boolean matches = Pattern.matches(filterName.toLowerCase(),tagNames.get(i).toLowerCase());\r
-                               if (matches && negative)\r
-                                       return false;\r
-                               if (!matches && !negative)\r
-                                       return false;\r
+                               if (matches && !negative)\r
+                                       good = true;\r
+                               if (!matches && negative)\r
+                                       good = true;\r
                        }\r
+                       if (!good)\r
+                               return false;\r
                }\r
                return true;\r
        }\r
index a8cab67..62820c2 100644 (file)
@@ -142,7 +142,8 @@ public class IndexRunner extends QObject implements Runnable {
                ByteArrayInputStream is = new ByteArrayInputStream(html);\r
                ByteArrayOutputStream os = new ByteArrayOutputStream();\r
                tidy.parse(is, os);\r
-               String text =  StringEscapeUtils.unescapeHtml(os.toString().replaceAll("\\<.*?\\>", ""));\r
+               String text =  StringEscapeUtils.unescapeHtml(os.toString().replaceAll("\\<.*?\\>", "")) +" "+\r
+               n.getTitle();\r
                                \r
                logger.log(logger.EXTREME, "Splitting words");\r
                String[] result = text.toString().split(regex);\r
index f8d9c43..fccbeb5 100644 (file)
@@ -24,11 +24,13 @@ import java.util.List;
 import java.util.concurrent.LinkedBlockingQueue;\r
 \r
 import com.evernote.edam.type.Note;\r
+import com.trolltech.qt.core.QBuffer;\r
 import com.trolltech.qt.core.QByteArray;\r
-import com.trolltech.qt.core.QFile;\r
-import com.trolltech.qt.core.QIODevice.OpenModeFlag;\r
+import com.trolltech.qt.core.QIODevice;\r
+import com.trolltech.qt.core.QMutex;\r
 import com.trolltech.qt.core.QObject;\r
 import com.trolltech.qt.core.QTemporaryFile;\r
+import com.trolltech.qt.gui.QPixmap;\r
 \r
 import cx.fbn.nevernote.Global;\r
 import cx.fbn.nevernote.signals.NoteSignal;\r
@@ -36,6 +38,34 @@ import cx.fbn.nevernote.sql.DatabaseConnection;
 import cx.fbn.nevernote.utilities.ApplicationLogger;\r
 import cx.fbn.nevernote.xml.NoteFormatter;\r
 \r
+\r
+/*\r
+ * \r
+ * @author Randy Baumgarte\r
+ * \r
+ * Thumbnail Overview:\r
+ * \r
+ * How thumbnails are generated is a bit odd.  The problem is that \r
+ * process of creating the thumbnail involves actually creating an HTML\r
+ * version of the note & all of its resources.  That is very CPU intensive\r
+ * so we try to do it in a separate thread.  Unfortunately, the QWebPage class \r
+ * which actually creates the thumbnail must be in the main GUI thread.\r
+ * This is the odd way I've tried to get around the problem.\r
+ * \r
+ * First, the thumbail thread finds a note which needs a thumbnail.  This\r
+ * can be done by either scanning the database or specifically being told\r
+ * a note needs a new thumbnail.  \r
+ * \r
+ * When a note is found, this thread will read the database and write out\r
+ * the resources and create an HTML version of the note.  It then signals\r
+ * the main GUI thread that a note is ready.  \r
+ * \r
+ * Next, the main GUI thread will process the signal received from the \r
+ * thumbnail thread.  The GUI thread will create a QWebPage (via the\r
+ * Thumbnailer class) and will render the image.  The image is written to \r
+ * the database to be used in the thumbnail view.\r
+ * \r
+ */\r
 public class ThumbnailRunner extends QObject implements Runnable {\r
        \r
        private final ApplicationLogger                         logger;\r
@@ -45,6 +75,7 @@ public class ThumbnailRunner extends QObject implements Runnable {
        private final DatabaseConnection                        conn;\r
        private volatile LinkedBlockingQueue<String> workQueue;\r
        private static int                                                      MAX_QUEUED_WAITING = 1000;\r
+       public QMutex                                                           mutex;\r
 \r
 \r
 \r
@@ -54,6 +85,7 @@ public class ThumbnailRunner extends QObject implements Runnable {
                noteSignal = new NoteSignal();\r
                guid = null;\r
                keepRunning = true;\r
+               mutex = new QMutex();\r
                workQueue=new LinkedBlockingQueue<String>(MAX_QUEUED_WAITING);  \r
        }\r
        \r
@@ -74,6 +106,11 @@ public class ThumbnailRunner extends QObject implements Runnable {
                                if (work.startsWith("SCAN")) {\r
                                        scanDatabase();\r
                                }\r
+                               if (work.startsWith("IMAGE")) {\r
+                                       work = work.replace("IMAGE ", "");\r
+                                       guid = work;\r
+                                       processImage();\r
+                               }\r
                                if (work.startsWith("STOP")) {\r
                                        logger.log(logger.MEDIUM, "Stopping thumbail thread");\r
                                        keepRunning = false;\r
@@ -87,6 +124,47 @@ public class ThumbnailRunner extends QObject implements Runnable {
        }\r
        \r
        \r
+       private void processImage() {\r
+               boolean abort = true;\r
+               if (abort)\r
+                       return;\r
+               mutex.lock();\r
+               logger.log(logger.EXTREME, "Image found "+guid);\r
+                       \r
+               logger.log(logger.EXTREME, "Getting image");\r
+               QPixmap image = new QPixmap();\r
+               if (!image.load(Global.getFileManager().getResDirPath()+"thumbnail-"+guid+".png")) {\r
+                       logger.log(logger.EXTREME, "Failure to reload image. Aborting.");\r
+                       mutex.unlock();\r
+                       return;\r
+               }\r
+               \r
+               \r
+               logger.log(logger.EXTREME, "Opening buffer");\r
+        QBuffer buffer = new QBuffer();\r
+        if (!buffer.open(QIODevice.OpenModeFlag.WriteOnly)) {\r
+               logger.log(logger.EXTREME, "Failure to open buffer.  Aborting.");\r
+               mutex.unlock();\r
+               return;\r
+        }\r
+               \r
+               logger.log(logger.EXTREME, "Filling buffer");\r
+        if (!image.save(buffer, "PNG")) {\r
+               logger.log(logger.EXTREME, "Failure to write to buffer.  Aborting.");     \r
+               mutex.unlock();\r
+               return;\r
+        }\r
+        buffer.close();\r
+               \r
+               logger.log(logger.EXTREME, "Updating database");\r
+               QByteArray b = new QBuffer(buffer).buffer();\r
+               conn.getNoteTable().setThumbnail(guid, b);\r
+               conn.getNoteTable().setThumbnailNeeded(guid, false);\r
+               mutex.unlock();\r
+       }\r
+       \r
+       \r
+       \r
        private void scanDatabase() {\r
                // If there is already work in the queue, that takes priority\r
                logger.log(logger.HIGH, "Scanning database for notes needing thumbnail");\r
@@ -106,6 +184,7 @@ public class ThumbnailRunner extends QObject implements Runnable {
 \r
                \r
        public synchronized boolean addWork(String request) {\r
+\r
                if (workQueue.size() == 0) {\r
                        workQueue.offer(request);\r
                        return true;\r
@@ -137,13 +216,11 @@ public class ThumbnailRunner extends QObject implements Runnable {
                js.replace("<!DOCTYPE en-note SYSTEM 'http://xml.evernote.com/pub/enml.dtd'>", "");\r
                js.replace("<!DOCTYPE en-note SYSTEM 'http://xml.evernote.com/pub/enml2.dtd'>", "");\r
                js.replace("<?xml version='1.0' encoding='UTF-8'?>", "");\r
-               String fileName = Global.getFileManager().getResDirPath("thumbnail-" + guid + ".html");\r
-               QFile tFile = new QFile(fileName);\r
-               tFile.open(OpenModeFlag.WriteOnly);\r
-               tFile.write(js);\r
-               tFile.close();\r
+               int zoom = 1;\r
+               String content = currentNote.getContent();\r
+               zoom = Global.calculateThumbnailZoom(content);\r
                logger.log(logger.HIGH, "Thumbnail file ready");\r
-               noteSignal.thumbnailPageReady.emit(guid, fileName);\r
+               noteSignal.thumbnailPageReady.emit(guid, js, zoom);\r
        }\r
                \r
        \r
index 4399b7e..1e964ed 100644 (file)
@@ -35,6 +35,7 @@ import com.evernote.edam.type.Tag;
 import com.trolltech.qt.QThread;\r
 import com.trolltech.qt.core.QDateTime;\r
 import com.trolltech.qt.gui.QImage;\r
+import com.trolltech.qt.gui.QPixmap;\r
 import com.trolltech.qt.sql.QSqlQuery;\r
 import com.trolltech.qt.xml.QDomAttr;\r
 import com.trolltech.qt.xml.QDomDocument;\r
@@ -100,7 +101,7 @@ public class ListManager  {
     public SaveRunner                          saveRunner;                                     // Thread used to save content.  Used because the xml conversion is slowwwww\r
     QThread                                                    saveThread;\r
        \r
-    private final HashMap<String,QImage> thumbnailList;\r
+//    private final HashMap<String, QImage> thumbnailList;\r
     \r
        // Constructor\r
        public ListManager(DatabaseConnection d, ApplicationLogger l) {\r
@@ -152,17 +153,9 @@ public class ListManager  {
                saveThread = new QThread(saveRunner, "Save Runner Thread");\r
                saveThread.start();\r
                \r
-               thumbnailList = new HashMap<String, QImage>();\r
-/*             for (int i=0; i<getMasterNoteIndex().size(); i++) {\r
-                       QImage img = new QImage();\r
-                       QByteArray dbImage = conn.getNoteTable().getThumbnail(getMasterNoteIndex().get(i).getGuid());\r
-                       if (dbImage != null) {\r
-                               img.loadFromData(dbImage);\r
-                               img.scaled(new QSize(400,400));\r
-                               thumbnailList.put(getMasterNoteIndex().get(i).getGuid(), img);\r
-                       }\r
-               }\r
-*/\r
+//             thumbnailList = conn.getNoteTable().getThumbnails();\r
+//             thumbnailList = new HashMap<String,QImage>();\r
+               \r
                loadNoteTitleColors();\r
                                \r
        }\r
@@ -397,8 +390,30 @@ public class ListManager  {
                return noteModel.getMasterNoteIndex();\r
        }\r
        // Thumbnails\r
-       public HashMap<String, QImage> getThumbnails() {\r
-               return thumbnailList;\r
+//     public HashMap<String, QImage> getThumbnails() {\r
+//             return thumbnailList;\r
+//     }\r
+       public QImage getThumbnail(String guid) {\r
+//             if (getThumbnails().containsKey(guid))\r
+//                     return getThumbnails().get(guid);\r
+               \r
+               QImage img = new QImage();\r
+               img = QImage.fromData(conn.getNoteTable().getThumbnail(guid));\r
+               if (img == null || img.isNull()) \r
+                       return null;\r
+               //getThumbnails().put(guid, img);\r
+               return img;\r
+       }\r
+       public QPixmap getThumbnailPixmap(String guid) {\r
+//             if (getThumbnails().containsKey(guid))\r
+//                     return getThumbnails().get(guid);\r
+               \r
+               QPixmap img = new QPixmap();\r
+               img.loadFromData(conn.getNoteTable().getThumbnail(guid));\r
+               if (img == null || img.isNull()) \r
+                       return null;\r
+               //getThumbnails().put(guid, img);\r
+               return img;\r
        }\r
     //***************************************************************\r
     //***************************************************************\r