OSDN Git Service

Add shared notebook editing & syncing logic.
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / xml / NoteFormatter.java
index 191a827..5867b53 100644 (file)
@@ -34,7 +34,8 @@ public class NoteFormatter {
        private final ApplicationLogger logger;\r
        private final DatabaseConnection conn;\r
        public boolean resourceError = false;\r
-       public boolean readOnly = false;\r
+       public boolean readOnly = false; \r
+       public boolean inkNote = false;\r
        public boolean addHighlight = true;\r
        private Note currentNote;\r
        private String currentNoteGuid;\r
@@ -53,11 +54,12 @@ public class NoteFormatter {
        public void setNote(Note note, boolean pdfPreview) {\r
                currentNote = note;\r
                this.pdfPreview = pdfPreview;\r
-               if (note != null)\r
-                       currentNoteGuid = note.getGuid();\r
-               else\r
-                       currentNoteGuid = null;\r
                readOnly = false;\r
+               currentNoteGuid = null;\r
+               if (note != null) {\r
+                       currentNoteGuid = note.getGuid();\r
+                       readOnly = conn.getNotebookTable().isReadOnly(note.getNotebookGuid());\r
+               } \r
                resourceError = false;\r
        }\r
        \r
@@ -203,8 +205,10 @@ public class NoteFormatter {
                Resource r = null;\r
                if (resGuid != null)\r
                        r = conn.getNoteTable().noteResourceTable.getNoteResource(resGuid,true);\r
-                       if (r==null || r.getData() == null || r.getData().getBody().length == 0)\r
-                               resourceError = true;;\r
+                       if (r==null || r.getData() == null || r.getData().getBody().length == 0) {\r
+                               resourceError = true;\r
+                               readOnly = true;\r
+                       }\r
                        if (r!= null && r.getData() != null && r.getData().getBody().length > 0) {\r
                                tfile.open(new QIODevice.OpenMode(QIODevice.OpenModeFlag.WriteOnly));\r
                                QByteArray binData = new QByteArray(r.getData().getBody());\r
@@ -358,7 +362,7 @@ public class NoteFormatter {
     private void modifyApplicationTags(QDomDocument doc, QDomElement docElem, QDomElement enmedia, QDomAttr hash, String appl) {\r
        logger.log(logger.HIGH, "Entering NeverNote.modifyApplicationTags");\r
        if (appl.equalsIgnoreCase("vnd.evernote.ink")) {\r
-               readOnly = true;\r
+               inkNote = true;\r
            if (buildInkNote(doc, docElem, enmedia, hash, appl))\r
                return;\r
        }\r