//*********************************************************** //* Process an <attributes> node //*********************************************************** void ImportData::processNoteAttributes(NoteAttributes &attributes) { bool atEnd = false; while(!atEnd) { if (reader->isStartElement()) { QString name = reader->name().toString().toLower(); if (name == "author" && !reader->isEndElement()) { attributes.author = textValue().toStdString(); attributes.__isset.author = true; } if (name == "sourceurl" && !reader->isEndElement()) { attributes.sourceURL = textValue().toStdString(); attributes.__isset.sourceURL = true; } if (name == "source" && !reader->isEndElement()) { attributes.source = textValue().toStdString(); attributes.__isset.source = true; } if (name == "sourceapplication" && !reader->isEndElement()) { attributes.sourceApplication = textValue().toStdString(); attributes.__isset.sourceApplication = true; } if (name == "altitude" && !reader->isEndElement()) { attributes.altitude = doubleValue(); attributes.__isset.altitude = true; } if (name == "longitude" && !reader->isEndElement()) { attributes.longitude = doubleValue(); attributes.__isset.longitude = true; } if (name == "latitude" && !reader->isEndElement()) { attributes.latitude = doubleValue(); attributes.__isset.latitude = true; } if (name == "subjectdate" && !reader->isEndElement()) { attributes.subjectDate = longLongValue(); attributes.__isset.subjectDate = true; } } reader->readNext(); QString endName = reader->name().toString().toLower(); if (endName == "noteattributes" && reader->isEndElement()) atEnd = true; } return; }
//*********************************************************** //* Process a <note> tag //*********************************************************** void ImportData::processNoteNode() { QLOG_DEBUG() << "Processing Note Node"; Note note; QUuid uuid; QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", ""); note.guid = newGuid; NoteMetaData meta; bool noteIsDirty = false; bool atEnd = false; while(!atEnd) { QString name = reader->name().toString().toLower(); if (name == "guid" && !reader->isEndElement() && backup) { note.guid = textValue(); noteList.append(note.guid); } if (name == "updatesequencenumber" && !reader->isEndElement()) { note.updateSequenceNum = textValue().toLong(); } if (name == "title" && !reader->isEndElement()) { note.title = textValue(); } if (name == "created" && !reader->isEndElement()) { note.created = longLongValue(); } if (name == "updated" && !reader->isEndElement()) { note.updated = longLongValue(); } if (name == "deleted" && !reader->isEndElement()) { note.deleted = longLongValue(); } if (name == "active" && !reader->isEndElement()) { note.active = booleanValue(); } if (name == "notebookguid" && !reader->isEndElement()) { note.notebookGuid = textValue(); } if (name == "dirty" && !reader->isEndElement()) { noteIsDirty = booleanValue(); } if (name == "content" && !reader->isEndElement()) { note.content = textValue(); } if (name == "titlecolor" && !reader->isEndElement()) { meta.setColor(intValue()); } if (name == "notetags" && (createTags || backup) && !reader->isEndElement()) { QStringList names, guids; processNoteTagList(guids, names); QList<QString> tagGuids; QList<QString> tagNames; for (qint32 i=0; i<guids.size(); i++) { tagGuids.append(guids[i]); tagNames.append(names[i]); } note.tagNames = tagNames; note.tagGuids = tagGuids; } if (name == "noteattributes" && !reader->isEndElement()) { processNoteAttributes(note.attributes); } if (name == "noteresource" && !reader->isEndElement()) { Resource newRes; processResource(newRes); newRes.noteGuid = note.guid; if (!backup) newRes.updateSequenceNum = 0; QList<Resource> resources; if (note.resources.isSet()) resources = note.resources; resources.append(newRes); note.resources = resources; } reader->readNext(); QString endName = reader->name().toString().toLower(); if (endName == "note" && reader->isEndElement()) atEnd = true; } // Loop through the resources & make sure they all have the // proper guid for this note QList<Resource> resources; if (note.resources.isSet()) resources = note.resources; for (int i=0; i<resources.size(); i++) { resources[i].noteGuid = note.guid; } note.resources = resources; NoteTable noteTable(global.db); if (backup) noteTable.add(0,note, noteIsDirty); else { note.updateSequenceNum = 0; if (notebookGuid != NULL) note.notebookGuid = notebookGuid; noteTable.add(0,note, true); if (metaData.contains(note.guid)) { QLOG_ERROR() << "ERROR IN IMPORTING DATA: Metadata not yet supported"; } } return; }