本文整理汇总了C++中QUuid::createUuid方法的典型用法代码示例。如果您正苦于以下问题:C++ QUuid::createUuid方法的具体用法?C++ QUuid::createUuid怎么用?C++ QUuid::createUuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUuid
的用法示例。
在下文中一共展示了QUuid::createUuid方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: t
ImportEnex::ImportEnex(QObject *parent) : QObject(parent)
{
importTags = false;
importNotebooks = false;
NotebookTable t(global.db);
QString name = tr("Imported Notes");
qint32 lid=t.findByName(name);
if (lid == 0) {
// We have a new notebook to add
Notebook book;
book.name = name;
bool isSynchronized = true;
QUuid uuid;
notebookGuid = uuid.createUuid().toString().replace("{","").replace("}","");
book.guid = notebookGuid;
t.add(0,book,true, !isSynchronized);
} else {
t.getGuid(notebookGuid, lid);
}
TagTable tt(global.db);
tt.getNameMap(tagList);
progress = new QProgressDialog();
progress->setVisible(false);
stopNow = false;
}
示例2: t
//***********************************************************
//* Constructor. If full == true then this is a restore.
//* if full=false then this is considered an import. The
//* only real difference is that an import automatically
//* gets a new guid and is always considered "dirty"
//* where an import will keep the guid and will obey the
//* <dirty> tag in the note.
//***********************************************************
ImportData::ImportData(bool full, QObject *parent) : QObject(parent)
{
importTags = false;
importNotebooks = false;
backup = full;
createTags = false;
stopNow = false;
// get the
if (!full) {
NotebookTable t(global.db);
QString name = tr("Imported Notes");
qint32 lid=t.findByName(name);
if (lid == 0) {
// We have a new notebook to add
Notebook book;
book.name = name;
bool isSynchronized = true;
QUuid uuid;
notebookGuid = uuid.createUuid().toString().replace("{","").replace("}","");
book.guid = notebookGuid;
t.add(0,book,true, !isSynchronized);
} else {
t.getGuid(notebookGuid, lid);
}
}
progress = new QProgressDialog();
progress->setVisible(false);
}
示例3: okButtonPressed
void SavedSearchProperties::okButtonPressed() {
okPressed = true;
if (this->lid > 0) {
SavedSearch s;
SearchTable table(global.db);
table.get(s, lid);
s.name = this->name.text().trimmed();
s.query = this->query.text().trimmed();
table.update(lid, s, true);
close();
return;
}
// We have a new tag to add
SavedSearch s;
s.name = name.text().trimmed();
s.query = query.text().trimmed();
QUuid uuid;
QString g = uuid.createUuid().toString().replace("{","").replace("}","");
s.guid = g;
SearchTable t(global.db);
t.add(0,s,true);
close();
}
示例4: okButtonPressed
// This happens when the Ok button is pressed.
void NotebookProperties::okButtonPressed() {
okPressed = true;
bool isDefault = defaultNotebook.isChecked();
if (this->lid > 0) {
Notebook book;
NotebookTable table(global.db);
table.get(book, lid);
book.name = name.text().trimmed();
book.defaultNotebook = isDefault;
table.update(book, true);
close();
return;
}
// We have a new notebook to add
Notebook book;
book.name = name.text().trimmed();
bool isSynchronized = syncBox.isChecked();
QUuid uuid;
QString g = uuid.createUuid().toString().replace("{","").replace("}","");
book.guid = g;
NotebookTable t(global.db);
book.defaultNotebook = isDefault;
t.add(0,book,true, !isSynchronized);
close();
}
示例5: processResource
//***********************************************************
//* Process a <noteresource> node.
//***********************************************************
void ImportEnex::processResource(Resource &resource) {
bool atEnd = false;
resource.active = true;
while(!atEnd) {
if (reader->isStartElement()) {
QString name = reader->name().toString().toLower();
QUuid uuid;
QString g = uuid.createUuid().toString().replace("{","").replace("}","");
resource.guid = g;
if (name == "active") {
resource.active = booleanValue();
}
if (name == "mime") {
resource.mime = textValue();
}
if (name == "duration") {
resource.duration = shortValue();
}
if (name == "height") {
resource.height = shortValue();
}
if (name == "width") {
resource.width = shortValue();
}
if (name == "data") {
Data d;
resource.data = d;
processData("Data", resource.data);
}
if (name == "alternate-data") {
Data d;
resource.alternateData = d;
processData("AlternateData", resource.data);
}
if (name == "recognition-data") {
Data d;
resource.recognition = d;
processData("RecognitionData", resource.recognition);
}
if (name == "resource-attributes") {
ResourceAttributes ra;
resource.attributes = ra;
processResourceAttributes(resource.attributes);
}
}
reader->readNext();
QString endName = reader->name().toString().toLower();
if (endName == "resource" && reader->isEndElement())
atEnd = true;
}
}
示例6: createTable
//* Create the NoteTable table.
void DataStore::createTable() {
db->lockForWrite();
QLOG_TRACE() << "Entering DataStore::createTable()";
QLOG_DEBUG() << "Creating table DataStore";
NSqlQuery sql(db);
QString command("Create table DataStore (" +
QString("lid integer,") +
QString("key integer,") +
QString("data blob default null collate nocase)"));
if (!sql.exec(command)) {
QLOG_ERROR() << "Creation of DataStore table failed: " << sql.lastError();
}
sql.exec("CREATE INDEX DataStore_Lid on DataStore (lid)");
sql.exec("CREATE INDEX DataStore_Key on DataStore (key)");
sql.prepare("Create view SearchModel as select lid, data as name from DataStore where key=2001");
if (!sql.exec()) {
QLOG_ERROR() << "Creation of SearchModel table failed: " << sql.lastError();
}
sql.prepare("Create View TagModel as select a.lid, (select d.data from DataStore d where d.key=1000 and a.lid = d.lid) as guid, (select data from datastore b1 where b1.lid = (select b.data from DataStore b where b.key=1002 and a.lid = b.lid)) as parent_gid, (select c.data from DataStore c where c.key=1001 and a.lid = c.lid) as name, (select e.data from DataStore e where e.key=1006 and a.lid = e.lid) as account from DataStore a where a.key=1000;");
if (!sql.exec()) {
QLOG_ERROR() << "Creation of TagModel table failed: " << sql.lastError();
}
sql.prepare("Create View NotebookModel as select a.lid, (select b.data from DataStore b where b.key=3002 and a.lid = b.lid) as stack, (select c.data from DataStore c where c.key=3001 and a.lid = c.lid) as name, (select d.data from DataStore d where d.key=3201 and a.lid = d.lid) as username, (select e.data from DataStore e where e.key=3999 and a.lid = e.lid) as isClosed from DataStore a where a.key=3000;");
if (!sql.exec()) {
QLOG_ERROR() << "Creation of NotebookModel table failed: " << sql.lastError();
}
if (!sql.exec("Create virtual table SearchIndex using fts4 (lid int, weight int, source text, content text)")) {
QLOG_ERROR() << "Creation of SearchIndex table failed: " << sql.lastError();
}
sql.finish();
db->unlock();
Notebook notebook;
NotebookTable table(db);
notebook.name = "My Notebook";
notebook.defaultNotebook = true;
QUuid uuid;
notebook.guid = uuid.createUuid().toString().replace("{","").replace("}","");
table.add(0,notebook,true,false);
}
示例7: processResource
//***********************************************************
//* Process a <noteresource> node.
//***********************************************************
void ImportData::processResource(Resource &resource) {
QLOG_DEBUG() << "Processing Resource Node";
bool atEnd = false;
//bool isDirty = false;
while(!atEnd) {
if (reader->isStartElement()) {
QString name = reader->name().toString().toLower();
if (name == "guid") {
resource.guid = textValue();
}
if (!backup) {
QUuid uuid;
QString g = uuid.createUuid().toString().replace("{","").replace("}","");
resource.guid = g;
}
if (name == "noteguid") {
QString tx = textValue();
resource.noteGuid = tx;
}
if (name == "updatesequencenumber") {
resource.updateSequenceNum = intValue();
}
if (name == "active") {
resource.active = booleanValue();
}
if (name == "mime") {
resource.mime = textValue();
}
if (name == "duration") {
resource.duration = shortValue();
}
if (name == "height") {
resource.height = shortValue();
}
if (name == "width") {
resource.width = shortValue();
}
// if (name == "dirty")
// isDirty = booleanValue();
if (name == "data") {
Data data;
resource.data = data;
processData("Data", resource.data);
}
if (name == "alternatedata") {
processData("AlternateData", resource.data);
}
if (name == "recognitiondata") {
processData("RecognitionData", resource.recognition);
}
if (name == "noteresourceattributes") {
processResourceAttributes(resource.attributes);
}
}
reader->readNext();
QString endName = reader->name().toString().toLower();
if (endName == "noteresource" && reader->isEndElement())
atEnd = true;
}
}
示例8: processNoteNode
//***********************************************************
//* 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)) {
//.........这里部分代码省略.........
示例9: addNoteNode
//***********************************************************
//* Process a <note> tag
//***********************************************************
void BatchImport::addNoteNode() {
Note note;
note.title = QString(tr("Untitled Note"));
QUuid uuid;
QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
note.guid = newGuid;
QStringList tagNames;
QStringList tagGuids;
QString newNoteBody = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")+
QString("<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">")+
QString("<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\"><br/></en-note>");
note.active = true;
note.content = newNoteBody;
note.created = QDateTime::currentMSecsSinceEpoch();
note.updated = QDateTime::currentMSecsSinceEpoch();
bool atEnd = false;
while(!atEnd) {
QString name = reader->name().toString().toLower();
if (name == "title" && !reader->isEndElement()) {
note.title = textValue();
}
if (name == "created" && !reader->isEndElement()) {
QString dateString = textValue();
//QDateTime date = QDateTime::fromString("2010-10-25T10:28:58.570Z", "yyyy-MM-ddTHH:mm:ss.zzzZ");
QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ");
note.created = date.toMSecsSinceEpoch();
}
if (name == "updated" && !reader->isEndElement()) {
QString dateString = textValue();
QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ");
note.updated = date.toMSecsSinceEpoch();
}
if (name == "notebook" && !reader->isEndElement()) {
QString notebookName = textValue();
NotebookTable notebookTable(global.db);
qint32 lid = notebookTable.findByName(notebookName);
QString notebookGuid;
// Do we need to add the notebook?
if (lid == 0) {
Notebook book;
book.name = notebookName;
QUuid uuid;
QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
book.guid = newGuid;
notebookGuid = newGuid;
lid = notebookTable.add(0, book, true, false);
} else {
notebookTable.getGuid(notebookGuid, lid);
}
note.notebookGuid = notebookGuid;
}
if (name == "content" && !reader->isEndElement()) {
note.content = textValue();
}
if (name == "tag" && !reader->isEndElement()) {
QString tagName = textValue();
TagTable tagTable(global.db);
qint32 tagLid = tagTable.findByName(tagName, 0);
QString tagGuid;
// Do we need to add the tag?
if (tagLid == 0) {
Tag tag;
tag.name = tagName;
QUuid uuid;
tagGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
tag.guid = tagGuid;
tagTable.add(0, tag, true, 0);
} else {
tagTable.getGuid(tagGuid, tagLid);
}
tagNames.append(tagName);
tagGuids.append(tagGuid);
}
reader->readNext();
QString endName = reader->name().toString().toLower();
if (endName == "noteadd" && reader->isEndElement()) {
atEnd = true;
note.tagGuids = tagGuids;
note.tagNames = tagNames;
NoteTable ntable(global.db);
if (!note.notebookGuid.isSet()) {
NotebookTable bookTable(global.db);
QString book = bookTable.getDefaultNotebookGuid();
note.notebookGuid = book;
}
ntable.add(0, note, true);
}
}
return;
}
示例10: uploadPersonalNotes
// Upload notes that belong to me
qint32 SyncRunner::uploadPersonalNotes() {
qint32 usn;
qint32 maxUsn = 0;
NotebookTable notebookTable(db);
LinkedNotebookTable linkedNotebookTable(db);
NoteTable noteTable(db);
QList<qint32> lids, validLids, deletedLids, movedLids;
noteTable.getAllDirty(lids);
// Get a list of all notes that are both dirty and in an account we own and isn't deleted
for (int i=0; i<lids.size(); i++) {
qint32 notebookLid = noteTable.getNotebookLid(lids[i]);
if (!linkedNotebookTable.exists(notebookLid)) {
if (!notebookTable.isLocal(notebookLid)) {
if (noteTable.isDeleted(lids[i]))
deletedLids.append(lids[i]);
else
validLids.append(lids[i]);
} else {
// We have a note that is local. Check if it was once
// synchronized. If so, it was moved to a local notebook
// and now needs to be deleted on the remote end
Note n;
noteTable.get(n, lids[i], false, false);
if (n.updateSequenceNum.isSet() && n.updateSequenceNum > 0) {
movedLids.append(lids[i]);
}
}
}
}
// Start deleting notes
for (int i=0; i<deletedLids.size(); i++) {
QString guid = noteTable.getGuid(deletedLids[i]);
noteTable.setDirty(lids[i], false);
usn = comm->deleteNote(guid);
if (usn > maxUsn) {
maxUsn = usn;
noteTable.setUpdateSequenceNumber(deletedLids[i], usn);
noteTable.setDirty(deletedLids[i], false);
if (!finalSync)
emit(noteSynchronized(deletedLids[i], false));
}
}
// Start handling notes moved to a local notebook. What
// we do is to delete the note on Evernote, then give the
// note in the local notebook a new GUID & set the
// update sequence number to 0.
for (int i=0; i<movedLids.size(); i++) {
QUuid uuid;
Guid newGuid = uuid.createUuid().toString().replace("{","").replace("}","");
QString guid = noteTable.getGuid(movedLids[i]);
noteTable.setDirty(movedLids[i], false);
noteTable.updateGuid(movedLids[i], newGuid);
noteTable.setUpdateSequenceNumber(movedLids[0], 0);
usn = comm->deleteNote(guid);
if (usn > maxUsn) {
maxUsn = usn;
}
if (!finalSync)
emit(noteSynchronized(movedLids[i], false));
}
// Start uploading notes
for (int i=0; i<validLids.size(); i++) {
Note note;
noteTable.get(note, validLids[i],true, true);
qint32 oldUsn=0;
if (note.updateSequenceNum.isSet())
oldUsn = note.updateSequenceNum;
usn = comm->uploadNote(note);
if (usn == 0) {
this->communicationErrorHandler();
error = true;
return maxUsn;
}
if (usn > maxUsn) {
maxUsn = usn;
if (oldUsn == 0)
noteTable.updateGuid(validLids[i], note.guid);
noteTable.setUpdateSequenceNumber(validLids[i], usn);
noteTable.setDirty(validLids[i], false);
if (!finalSync)
emit(noteSynchronized(validLids[i], false));
} else {
error = true;
}
}
return maxUsn;
}
示例11: processNoteNode
//***********************************************************
//* Process a <note> tag
//***********************************************************
void ImportEnex::processNoteNode() {
Note note;
QUuid uuid;
QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
note.guid = newGuid;
note.active = true;
QList<Resource> resources;
//QList<QString> tagNames;
bool atEnd = false;
while(!atEnd) {
QString name = reader->name().toString().toLower();
if (name == "title" && !reader->isEndElement()) {
note.title = textValue();
}
if (name == "created" && !reader->isEndElement()) {
note.created = datetimeValue();
}
if (name == "updated" && !reader->isEndElement()) {
note.updated = datetimeValue();
}
if (name == "deleted" && !reader->isEndElement()) {
note.deleted = datetimeValue();
}
if (name == "active" && !reader->isEndElement()) {
note.active = booleanValue();
}
if (name == "content" && !reader->isEndElement()) {
note.content = textValue();
}
if (name == "note-attributes" && !reader->isEndElement()) {
NoteAttributes na;
note.attributes = na;
processNoteAttributes(note.attributes);
}
if (name == "resource" && !reader->isEndElement()) {
Resource newRes;
processResource(newRes);
newRes.noteGuid = note.guid;
newRes.updateSequenceNum = 0;
resources.append(newRes);
}
if (name == "tag" && !reader->isEndElement()) {
if (!note.tagNames.isSet())
note.tagNames = QStringList();
note.tagNames->append(textValue());
}
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
for (int i=0; i<resources.size(); i++) {
Resource *r = &resources[i];
r->noteGuid = note.guid;
}
// Loop through the tag names & find any matching tags.
if (note.tagNames.isSet()) {
note.tagGuids = QList< Guid >();
for (int i=0; i<note.tagNames->size(); i++) {
QString tagGuid = tagList[note.tagNames->at(i)];
if (tagGuid != "") {
note.tagGuids->append(tagGuid);
} else {
QUuid uuid;
QString g = uuid.createUuid().toString().replace("{","").replace("}","");
Tag newTag;
newTag.name = note.tagNames->at(i);
newTag.guid = g;
TagTable tt(global.db);
tt.add(0, newTag, true, 0);
tagList.insert(note.tagNames->at(i), g);
note.tagGuids->append(g);
}
}
}
note.resources = resources;
// note.tagNames = tagNames;
NoteTable noteTable(global.db);
note.updateSequenceNum = 0;
note.notebookGuid = notebookGuid;
if (note.created.isSet() == false) {
note.created = QDateTime::currentDateTime().toMSecsSinceEpoch();
}
if (note.updated.isSet() == false) {
note.updated = note.created;
}
if (metaData.contains(note.guid)) {
QLOG_ERROR() << "ERROR IN IMPORTING DATA: Metadata not yet supported";
}
//.........这里部分代码省略.........