Process a tag
| 107 | //* Process a <note> tag |
| 108 | //*********************************************************** |
| 109 | qint32 BatchImport::addNoteNode() { |
| 110 | qint32 newLid = -1; |
| 111 | Note note; |
| 112 | note.title = QString(tr("Untitled Note")); |
| 113 | QUuid uuid; |
| 114 | qint32 tempLid = 0; |
| 115 | QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", ""); |
| 116 | note.guid = newGuid; |
| 117 | QStringList tagNames; |
| 118 | QStringList tagGuids; |
| 119 | QStringList resourceList; |
| 120 | QString resourceDelimiter; |
| 121 | QString newNoteBody = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")+ |
| 122 | QString("<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">")+ |
| 123 | QString("<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\"><br/></en-note>"); |
| 124 | note.active = true; |
| 125 | note.content = newNoteBody; |
| 126 | note.created = QDateTime::currentMSecsSinceEpoch(); |
| 127 | note.updated = QDateTime::currentMSecsSinceEpoch(); |
| 128 | |
| 129 | bool atEnd = false; |
| 130 | while(!atEnd) { |
| 131 | QString name = reader->name().toString().toLower(); |
| 132 | if (name == "lid" && !reader->isEndElement()) { |
| 133 | tempLid = intValue(); |
| 134 | } |
| 135 | if (name == "title" && !reader->isEndElement()) { |
| 136 | note.title = textValue(); |
| 137 | } |
| 138 | if (name == "created" && !reader->isEndElement()) { |
| 139 | QString dateString = textValue(); |
| 140 | //QDateTime date = QDateTime::fromString("2010-10-25T10:28:58.570Z", "yyyy-MM-ddTHH:mm:ss.zzzZ"); |
| 141 | QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ"); |
| 142 | note.created = date.toMSecsSinceEpoch(); |
| 143 | } |
| 144 | if (name == "updated" && !reader->isEndElement()) { |
| 145 | QString dateString = textValue(); |
| 146 | QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ"); |
| 147 | note.updated = date.toMSecsSinceEpoch(); |
| 148 | } |
| 149 | if (name == "reminder" && !reader->isEndElement()) { |
| 150 | QString dateString = textValue(); |
| 151 | QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ"); |
| 152 | if (date >= QDateTime::currentDateTime()) { |
| 153 | if (!note.attributes.isSet()) { |
| 154 | NoteAttributes na; |
| 155 | note.attributes = na; |
| 156 | } |
| 157 | note.attributes->reminderTime = date.toMSecsSinceEpoch(); |
| 158 | } |
| 159 | } |
| 160 | if (name == "notebook" && !reader->isEndElement()) { |
| 161 | QString notebookName = textValue(); |
| 162 | NotebookTable notebookTable(global.db); |
| 163 | qint32 lid = notebookTable.findByName(notebookName); |
| 164 | QString notebookGuid; |
| 165 | |
| 166 | // Do we need to add the notebook? |
nothing calls this directly
no test coverage detected