// Synchronize a new notebook with what is in the database. We basically // just delete the old one & give it a new entry qint32 LinkedNotebookTable::sync(qint32 lid, LinkedNotebook ¬ebook) { qint32 lastUSN = 0; NotebookTable ntable(db); SharedNotebookTable stable(db); if (lid == 0 && notebook.shareKey.isSet()) { lid = stable.findByShareKey(notebook.shareKey); } if (lid == 0 && notebook.uri.isSet()) { lid = ntable.findByUri(notebook.uri); } if (lid > 0) { lastUSN = getLastUpdateSequenceNumber(lid); // Delete the old record NSqlQuery query(*db); query.prepare("Delete from DataStore where lid=:lid and key>=3200 and key<3300"); query.bindValue(":lid", lid); query.exec(); query.finish(); } if (lid == 0) { lid = ntable.getLid(notebook.guid); if (lid == 0) { ConfigStore cs(db); lid = cs.incrementLidCounter(); NotebookTable ntable(db); // Build the dummy notebook entry Notebook book; book.guid = notebook.guid; book.name = notebook.shareName; book.updateSequenceNum = notebook.updateSequenceNum; book.published = true; Publishing publishing; publishing.uri = notebook.uri; book.publishing = publishing; if (notebook.stack.isSet()) { book.stack = notebook.stack; } ntable.sync(lid, book); } } add(lid, notebook, false); if (lastUSN > 0) { setLastUpdateSequenceNumber(lid, lastUSN); } return lid; }
void LocationEditor::buttonClicked() { const QWeakPointer<LocationDialog> dialogPtr(new LocationDialog(this)); if (LocationDialog *const dialog = dialogPtr.data()) { dialog->setLongitude(this->startLongitude); dialog->setLatitude(this->startLatitude); dialog->setAltitude(this->startAltitude); dialog->exec(); } if (LocationDialog *const dialog = dialogPtr.data()) { const double lon = dialog->getLongitude(); const double lat = dialog->getLatitude(); const double alt = dialog->getAltitude(); startAltitude = alt; startLongitude = lon; startLatitude = lat; if (dialog->okPressed()) { NoteTable ntable(global.db); if (lon == 0.0 && lat == 0.0) { setText(defaultText); ntable.resetGeography(currentLid, true); } else { setText(dialog->locationText()); ntable.setGeography(currentLid, lon,lat,alt, true); } } delete dialog; } }
//*********************************************** //* Permanently delete all notes //*********************************************** void NTrashTree::expungeAll() { QMessageBox msgBox; msgBox.setWindowTitle(tr("Verify Delete")); msgBox.setText(tr("Are you sure you want to permanently delete these notes?")); msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); msgBox.setIcon(QMessageBox::Question); msgBox.setDefaultButton(QMessageBox::Yes); int rc = msgBox.exec(); if (rc != QMessageBox::Yes) return; NoteTable ntable(global.db); QList<qint32> lids; ntable.getAllDeleted(lids); for (int i=0; i<lids.size(); i++) { Note n; ntable.get(n,lids[i],false,false); ntable.expunge(lids[i]); delete global.cache[lids[i]]; global.cache.remove(lids[i]); // Check to see if the note is synchronized. If so, we // need to keep it to let Evernote to delete it. if (n.updateSequenceNum.isSet() && n.updateSequenceNum>0) { ntable.addToDeleteQueue(lids[i],n); } } emit(updateSelectionRequested()); }
void Thumbnailer::pageReady(bool ok) { if (ok) { capturePage(page); } NoteTable ntable(db); ntable.setThumbnailNeeded(lid, false); idle = true; }
// Synchronize remote expunged linked notebooks void SyncRunner::syncRemoteExpungedLinkedNotebooks(QList<Guid> guids) { LinkedNotebookTable btable(db); for (int i=0; i<guids.size(); i++) { LinkedNotebookTable ntable(db); qint32 lid = ntable.getLid(guids[i]); btable.expunge(guids[i]); emit notebookExpunged(lid); } }
//*********************************************** //* Restore all notes from the trash //*********************************************** void NTrashTree::restoreAll() { NoteTable ntable(global.db); QList<qint32> lids; ntable.getAllDeleted(lids); for (int i=0; i<lids.size(); i++) { ntable.restoreNote(lids[i], true); delete global.cache[lids[i]]; global.cache.remove(lids[i]); } emit(updateSelectionRequested()); }
void Thumbnailer::capturePage(QWebPage *page) { page->mainFrame()->setZoomFactor(3); page->setViewportSize(QSize(300,300)); page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); QImage pix(QSize(300,300), QImage::Format_ARGB32); QPainter painter; painter.begin(&pix); page->mainFrame()->render(&painter); painter.end(); QString filename = global.fileManager.getThumbnailDirPath()+QString::number(lid) +".png"; pix.save(filename); NoteTable ntable(db); ntable.setThumbnail(lid, filename); }
// Find a shared notebook LID by its GUID qint32 SharedNotebookTable::findByNotebookGuid(QString id) { NSqlQuery query(db); db->lockForRead(); query.prepare("Select lid from DataStore where key=:key and data=:id"); query.bindValue(":key", SHAREDNOTEBOOK_NOTEBOOK_GUID); query.bindValue(":id", id); query.exec(); while (query.next()) { qint32 retval = query.value(0).toInt(); query.finish(); db->unlock(); return retval; } query.finish(); db->unlock(); NotebookTable ntable(db); return ntable.getLid(id); }
// Delete an item from the tree. We really just hide it. void NTagView::mergeRequested() { QList<QTreeWidgetItem*> items = selectedItems(); QMessageBox msgBox; msgBox.setIcon(QMessageBox::Question); msgBox.setText(tr("Are you sure you want to merge these tags?")); msgBox.setWindowTitle(tr("Verify Merge")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); int ret = msgBox.exec(); if (ret == QMessageBox::No) return; qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt(); NoteTable ntable(global.db); QList<qint32> notes; for (int j=1; j<items.size(); j++) { ntable.findNotesByTag(notes, items[j]->data(NAME_POSITION, Qt::UserRole).toInt()); for (int i=0; i<notes.size(); i++) { if (!ntable.hasTag(notes[i], lid)) { ntable.addTag(notes[i], lid, true); QString tagString = ntable.getNoteListTags(notes[i]); emit(updateNoteList(notes[i], NOTE_TABLE_TAGS_POSITION, tagString)); // qint64 dt = QDateTime::currentMSecsSinceEpoch(); // ntable.updateDate(notes[i], dt, NOTE_UPDATED_DATE, true); // emit(updateNoteList(notes[i], NOTE_TABLE_DATE_UPDATED_POSITION, dt)); } } } // Now delete the old tags. for (int i=1; i<items.size(); i++) { qint32 lid = items[i]->data(NAME_POSITION, Qt::UserRole).toInt(); TagTable table(global.db); table.deleteTag(lid); // Now remove it in the datastore NTagViewItem *ptr = dataStore.take(items[i]->data(NAME_POSITION, Qt::UserRole).toInt()); emit(tagDeleted(lid, ptr->data(NAME_POSITION, Qt::DisplayRole).toString())); delete ptr; } }
//*********************************************** //* Permanently delete all notes //*********************************************** void NTrashTree::expungeAll() { QMessageBox msgBox; msgBox.setWindowTitle(tr("Verify Delete")); msgBox.setText(tr("Are you sure you want to permanently delete these notes?")); msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); msgBox.setIcon(QMessageBox::Question); msgBox.setDefaultButton(QMessageBox::Yes); int rc = msgBox.exec(); if (rc != QMessageBox::Yes) return; NoteTable ntable(global.db); QList<qint32> lids; ntable.getAllDeleted(lids); for (int i=0; i<lids.size(); i++) { ntable.expunge(lids[i]); delete global.cache[lids[i]]; global.cache.remove(lids[i]); } emit(updateSelectionRequested()); }
void LocationEditor::setGeography(qint32 lid, double longitude, double latitude, double altitude, QString placeName) { this->startLongitude = longitude; this->startLatitude = latitude; this->startAltitude = altitude; currentLid = lid; Note n; NoteTable ntable(global.db); ntable.get(n, lid, false, false); NoteAttributes attributes; if (n.attributes.isSet()) attributes = n.attributes; if (!attributes.latitude.isSet() || !attributes.longitude.isSet()) return; if (placeName == "") { LocationDialog dialog; dialog.setLongitude(this->startLongitude); dialog.setLatitude(this->startLatitude); dialog.setAltitude(this->startAltitude); this->setText(dialog.locationText()); } else this->setText(placeName); }
void LocationEditor::buttonClicked() { LocationDialog dialog; dialog.setLongitude(this->startLongitude); dialog.setLatitude(this->startLatitude); dialog.setAltitude(this->startAltitude); dialog.exec(); double lon = dialog.getLongitude(); double lat = dialog.getLatitude(); double alt = dialog.getAltitude(); startAltitude = alt; startLongitude = lon; startLatitude = lat; if (dialog.okPressed()) { NoteTable ntable(global.db); if (lon == 0.0 && lat == 0.0) { setText(defaultText); ntable.resetGeography(currentLid, true); return; } this->setText(dialog.locationText()); ntable.setGeography(currentLid, lon,lat,alt, true); } }
WatchFolderAdd::WatchFolderAdd(qint32 lid, QWidget *parent) : QDialog(parent) { mainLayout = new QVBoxLayout(); okClicked = false; fileDialog = new QFileDialog(this); QString dir = QDir::home().absolutePath(); bool includeSubdirs = false; qint32 notebookLid = 0; FileWatcher::ScanType type = FileWatcher::ImportKeep; this->lid = lid; if (lid > 0) { FileWatcherTable ft(global.db); ft.get(lid, dir, type, notebookLid, includeSubdirs); } okButton = new QPushButton(this); okButton->setText(tr("OK")); connect(okButton, SIGNAL(clicked()), this, SLOT(onClicked())); cancelButton = new QPushButton(this); cancelButton->setText(tr("Cancel")); connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancel())); folderButton = new QPushButton(this); folderButton->setText(tr("Directory")); connect(folderButton, SIGNAL(clicked()), this, SLOT(folderButtonClicked())); directory = new QLabel(this); directory->setText(dir); keep = new QComboBox(this); keep->addItem(tr("Keep"),"keep"); keep->addItem(tr("Delete"),"delete"); if (type == FileWatcher::ImportKeep) keep->setCurrentIndex(0); else keep->setCurrentIndex(1); subdirs = new QCheckBox(this); subdirs->setChecked(includeSubdirs); books = new QComboBox(this); NotebookTable ntable(global.db); QList<qint32> lids; ntable.getAll(lids); for (int i=0; i<lids.size(); i++) { Notebook n; ntable.get(n, lids[i]); books->addItem(n.name, lids[i]); } books->model()->sort(0); grid = new QGridLayout(); grid->addWidget(directory,0,1); grid->addWidget(folderButton,0,0); grid->addWidget(new QLabel(tr("Notebook")),1,0); grid->addWidget(books,1,1); grid->addWidget(new QLabel(tr("After import")), 2,0); grid->addWidget(keep,2,1); grid->addWidget(new QLabel(tr("Include subdirectories")),3,0); grid->addWidget(subdirs, 3, 1); buttonLayout = new QHBoxLayout(); buttonLayout->addStretch(1); buttonLayout->addWidget(okButton); buttonLayout->addWidget(cancelButton); setWindowTitle(tr("Add Import Folder")); mainLayout->addLayout(grid); mainLayout->addSpacing(1); mainLayout->addLayout(buttonLayout); setLayout(mainLayout); this->setFont(global.getGuiFont(font())); }
// Given a notebook's name as a std::string, we return the lid qint32 LinkedNotebookTable::findByName(string &name) { NotebookTable ntable(db); return ntable.findByName(name); }
void LocationEditor::clearClicked() { NoteTable ntable(global.db); ntable.resetGeography(currentLid, true); }
// Synchronize remote linked notebooks bool SyncRunner::syncRemoteLinkedNotebooksActual() { LinkedNotebookTable ltable(db); QList<qint32> lids; ltable.getAll(lids); bool fs; for (int i=0; i<lids.size(); i++) { LinkedNotebook book; qint32 usn = ltable.getLastUpdateSequenceNumber(lids[i]); qint32 startingUSN = usn; ltable.get(book, lids[i]); int chunkSize = 5000; // If the share key is set, we need to authenticate if (!comm->authenticateToLinkedNotebookShard(book)) { // If we can't authenticate, we just gid of the notebook // because the user probably stopped sharing. qint32 linkedLid=0; LinkedNotebookTable ntable(db); linkedLid = ntable.getLid(book.guid); ntable.expunge(book.guid); emit notebookExpunged(linkedLid); return true; //this->communicationErrorHandler(); //error = true; //return false; } bool more = true; SyncState syncState; if (!comm->getLinkedNotebookSyncState(syncState, book)) { this->communicationErrorHandler(); error = true; return false; } if (syncState.updateCount <= usn) more=false; qint32 startingSequenceNumber = usn; if (usn == 0) fs = true; else fs = false; // ***** STARTING PASS #1 while (more && keepRunning) { SyncChunk chunk; if (!comm->getLinkedNotebookSyncChunk(chunk, book, usn, chunkSize, fs)) { more = false; if (comm->error.type == CommunicationError::EDAMNotFoundException) { ltable.expunge(lids[i]); if (!finalSync) emit(notebookExpunged(lids[i])); } else { this->communicationErrorHandler(); error = true; return false; } } else { processSyncChunk(chunk, lids[i]); usn = chunk.chunkHighUSN; if (chunk.updateCount > 0 && chunk.updateCount > startingSequenceNumber) { int pct = (usn-startingSequenceNumber)*100/(chunk.updateCount-startingSequenceNumber); QString sharename = ""; if (book.shareName.isSet()) sharename = book.shareName; emit setMessage(tr("Downloading ") +QString::number(pct) + tr("% complete for tags in shared notebook ") +sharename + tr("."), defaultMsgTimeout); } if (!chunk.chunkHighUSN.isSet()|| chunk.chunkHighUSN >= chunk.updateCount) more = false; } } //************* STARTING PASS 2 usn = startingUSN; more = true; chunkSize = 50; if (error == true) more=false; QString sharename = ""; if (book.shareName.isSet()) sharename = book.shareName; emit setMessage(tr("Downloading notes for shared notebook ") +sharename + tr("."), defaultMsgTimeout); while (more && keepRunning) { SyncChunk chunk; if (!comm->getLinkedNotebookSyncChunk(chunk, book, usn, chunkSize, fs)) { more = false; if (comm->error.type == CommunicationError::EDAMNotFoundException) { ltable.expunge(lids[i]); if (!finalSync) emit(notebookExpunged(lids[i])); } else { this->communicationErrorHandler(); error = true; return false; } } else { processSyncChunk(chunk, lids[i]); usn = chunk.chunkHighUSN; if (chunk.updateCount > 0 && chunk.updateCount > startingSequenceNumber) { int pct = (usn-startingSequenceNumber)*100/(chunk.updateCount-startingSequenceNumber); QString sharename = ""; if (book.shareName.isSet()) sharename = book.shareName; emit setMessage(tr("Downloading ") +QString::number(pct) + tr("% complete for shared notebook ") +sharename + tr("."), defaultMsgTimeout); } if (!chunk.chunkHighUSN.isSet() || chunk.chunkHighUSN >= chunk.updateCount) { more = false; ltable.setLastUpdateSequenceNumber(lids[i], syncState.updateCount); } } } qint32 noteUSN = uploadLinkedNotes(lids[i]); if (noteUSN > usn) ltable.setLastUpdateSequenceNumber(lids[i], noteUSN); } TagTable tagTable(db); tagTable.cleanupLinkedTags(); return true; }
//*********************************************************** //* 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; }
// Implement of dropEvent so dropMimeData gets called void FavoritesView::dropEvent(QDropEvent *event) { QTreeView::dropEvent(event); const QMimeData* data = event->mimeData(); QModelIndex droppedIndex = indexAt( event->pos() ); if (!droppedIndex.isValid()) return; int row = droppedIndex.row(); qint32 lid = 0; if (data->hasFormat("application/x-nixnote-tag")) { QByteArray d = data->data("application/x-nixnote-tag"); lid = d.trimmed().toInt(); addRecord(lid, FavoritesRecord::Tag, row); } if (data->hasFormat("application/x-nixnote-note")) { QByteArray d = data->data("application/x-nixnote-note"); lid = d.trimmed().toInt(); addRecord(lid, FavoritesRecord::Note, row); } if (data->hasFormat("application/x-nixnote-search")) { QByteArray d = data->data("application/x-nixnote-search"); lid = d.trimmed().toInt(); addRecord(lid, FavoritesRecord::Search, row); } if (data->hasFormat("application/x-nixnote-favorite")) { QByteArray d = data->data("application/x-nixnote-favorite"); lid = d.trimmed().toInt(); FavoritesTable ftable(global.db); FavoritesRecord rec; if (ftable.get(rec,lid)) { ftable.expunge(lid); rec.order = row; ftable.insert(rec); } } if (data->hasFormat("application/x-nixnote-notebook")) { QString d = data->data("application/x-nixnote-notebook"); int pos = d.indexOf("/"); if (pos == -1) return; int type = d.mid(0,pos).toInt(); d = d.mid(pos+1); pos = d.indexOf("/"); if (pos == -1) return; lid= d.mid(0,pos).toInt(); QString stack = d.mid(pos+1); FavoritesRecord::FavoritesRecordType rectype = FavoritesRecord::LocalNotebook; switch (type) { case NNotebookViewItem::Local : rectype = FavoritesRecord::LocalNotebook; break; case NNotebookViewItem::Synchronized : rectype = FavoritesRecord::SynchronizedNotebook; break; case NNotebookViewItem::LinkedStack : rectype = FavoritesRecord::LinkedStack; break; case NNotebookViewItem::Conflict : rectype = FavoritesRecord::ConflictNotebook; break; case NNotebookViewItem::Stack : rectype = FavoritesRecord::NotebookStack; break; case NNotebookViewItem::Shared: rectype = FavoritesRecord::SharedNotebook; break; case NNotebookViewItem::Linked : rectype = FavoritesRecord::LinkedNotebook; break; } if (lid > 0) addRecord(lid, rectype, row); else { FavoritesTable table(global.db); FavoritesRecord record; record.type = rectype; record.target= stack; record.lid = 0; record.order = row; record.parent = 0; qint32 newLid = table.insert(record); QList<qint32> lids; NotebookTable ntable(global.db); ntable.findByStack(lids, stack); for (int i=0; i<lids.size(); i++) { Notebook book; if (ntable.get(book, lids[i])) { FavoritesRecord rec; rec.parent = newLid; if (book.name.isSet()) rec.displayName = book.name; rec.type = FavoritesRecord::SynchronizedNotebook; if (ntable.isLocal(lids[i])) rec.type = FavoritesRecord::LocalNotebook; LinkedNotebookTable ltable(global.db); if (ltable.exists(lids[i])) rec.type = FavoritesRecord::LinkedNotebook; SharedNotebookTable stable(global.db); if (stable.exists(lids[i])) rec.type = FavoritesRecord::SharedNotebook; rec.target = lids[i]; rec.order = 1; table.add(rec); } } } } rebuildFavoritesTreeNeeded = true; this->loadData(); }
void FileWatcher::saveFile(QString file) { QFileInfo fileInfo(file); // If we have a dbi import file QLOG_DEBUG() << fileInfo.dir().absolutePath() + QDir::separator(); QLOG_DEBUG() << global.fileManager.getDbiDirPath(); if ((fileInfo.dir().absolutePath() + QDir::separator()) == global.fileManager.getDbiDirPath()) { BatchImport importer; importer.import(file); emit(nnexImported()); QFile f(file); f.remove(); return; } // If we have a user-import file QFile f(file); f.open(QIODevice::ReadOnly); QByteArray data = f.readAll(); f.close(); if (f.size() == 0) return; Note newNote; NoteTable ntable(global.db); ConfigStore cs(global.db); qint32 lid = cs.incrementLidCounter(); QCryptographicHash md5hash(QCryptographicHash::Md5); QByteArray hash = md5hash.hash(data, QCryptographicHash::Md5); // * Start setting up the new note newNote.guid = QString::number(lid); newNote.title = file; NotebookTable bookTable(global.db); QString notebook; bookTable.getGuid(notebook, notebookLid); newNote.notebookGuid = notebook; 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;\">"); MimeReference mimeRef; QString mime = mimeRef.getMimeFromFileName(file); QString enMedia =QString("<en-media hash=\"") +hash.toHex() +QString("\" border=\"0\"") +QString(" type=\"" +mime +"\" ") +QString("/>"); newNoteBody.append(enMedia + QString("</en-note>")); newNote.content = newNoteBody; newNote.active = true; newNote.created = QDateTime::currentMSecsSinceEpoch();; newNote.updated = newNote.created; newNote.updateSequenceNum = 0; NoteAttributes na; na.sourceURL = "file://" + file; newNote.attributes = na; qint32 noteLid = lid; ntable.add(lid, newNote, true); QString noteGuid = ntable.getGuid(lid); lid = cs.incrementLidCounter(); // Start creating the new resource Resource newRes; Data d; d.body = data; d.bodyHash = hash; d.size = data.size(); newRes.data = d; newRes.mime = mime; ResourceAttributes ra; ra.fileName = file; if (mime.startsWith("image", Qt::CaseInsensitive) || mime.endsWith("pdf", Qt::CaseInsensitive)) ra.attachment = false; else ra.attachment = true; newRes.active = true; newRes.guid = QString::number(lid); newRes.noteGuid = noteGuid; newRes.updateSequenceNum = 0; ResourceTable restable(global.db); restable.add(lid, newRes, true, noteLid); emit(fileImported(noteLid, lid)); if (scanType == FileWatcher::ImportDelete) { QLOG_DEBUG() << f.remove(); } }
bool LinkedNotebookTable::findGuidByName(QString &retval, QString &guid) { NotebookTable ntable(db); return ntable.findGuidByName(retval, guid); }
bool LinkedNotebookTable::isDeleted(qint32 lid) { NotebookTable ntable(db); return ntable.isDeleted(lid); }