Skip to content

Commit

Permalink
Add the ability to do multtilpe copy & paste of note links & add some…
Browse files Browse the repository at this point in the history
… debugging

information to the filewatcher to try to catch some errors of import & delete
actions.
  • Loading branch information
baumgarr committed Mar 16, 2017
1 parent d5ac388 commit 9dbef2e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 44 deletions.
71 changes: 41 additions & 30 deletions gui/nbrowserwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,37 +960,48 @@ void NBrowserWindow::pasteButtonPressed() {


if (urltext.toLower().mid(0,17) == "evernote:///view/") {
urltext = urltext.mid(17);
int pos = urltext.indexOf("/");
urltext = urltext.mid(pos+1);
pos = urltext.indexOf("/");
urltext = urltext.mid(pos+1);
pos = urltext.indexOf("/");
urltext = urltext.mid(pos+1);
pos = urltext.indexOf("/");
QString guid = urltext.mid(0,pos);
urltext = urltext.mid(pos);
pos = urltext.indexOf("/");
QString locguid = urltext.mid(pos);

Note n;
bool goodrc = false;
NoteTable ntable(global.db);
goodrc = ntable.get(n, guid,false, false);
if (!goodrc)
goodrc = ntable.get(n,locguid,false, false);

// If we have a good return, then we can paste the link, otherwise we fall out
// to a normal paste.
if (goodrc) {
QString url = QString("<a href=\"%1\" title=\"%2\">%3</a>").arg(QApplication::clipboard()->text(), n.title, n.title);
QLOG_DEBUG() << "HTML to insert:" << url;
QString script = QString("document.execCommand('insertHtml', false, '%1');").arg(url);
editor->page()->mainFrame()->evaluateJavaScript(script);
return;
} else {
QLOG_ERROR() << "Error retrieving note";
QStringList urlList = urltext.split(" ");
QString url = "";
for (int i=0; i<urlList.size(); i++) {
QLOG_DEBUG() << urlList[i];
urltext = urlList[i];
urltext = urltext.mid(17);
int pos = urltext.indexOf("/");
urltext = urltext.mid(pos+1);
pos = urltext.indexOf("/");
urltext = urltext.mid(pos+1);
pos = urltext.indexOf("/");
urltext = urltext.mid(pos+1);
pos = urltext.indexOf("/");
QString guid = urltext.mid(0,pos);
urltext = urltext.mid(pos);
pos = urltext.indexOf("/");
QString locguid = urltext.mid(pos);

Note n;
bool goodrc = false;
NoteTable ntable(global.db);
goodrc = ntable.get(n, guid,false, false);
if (!goodrc)
goodrc = ntable.get(n,locguid,false, false);

// If we have a good return, then we can paste the link, otherwise we fall out
// to a normal paste.
if (goodrc) {
url = url + QString("<a href=\"%1\" title=\"%2\">%3</a>").arg(urlList[i], n.title, n.title);
QLOG_DEBUG() << "HTML to insert:" << url;
if (i+1<urlList.size())
url = url+" <br> ";
} else {
if (urltext != "") {
QLOG_ERROR() << "Error retrieving note: " << urlList[i];
}
}
}
QLOG_DEBUG() << url;
QString script = QString("document.execCommand('insertHtml', false, '%1');").arg(url);
editor->page()->mainFrame()->evaluateJavaScript(script);
return;
}
}

Expand Down
29 changes: 16 additions & 13 deletions gui/ntableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,19 +924,22 @@ void NTableView::copyNoteLink() {

Note note;
NoteTable ntable(global.db);
ntable.get(note, lids[0], false, false);

QString guid = "";
if (note.guid.isSet())
guid = note.guid;
QString localid;
if (!note.updateSequenceNum.isSet() || note.updateSequenceNum == 0) {
syncneeded = true;
localid = QString::number(lids[0]);
} else
localid = guid;

QString lidUrl = "evernote:///view/" + userid +"/" +shard + "/" +guid + "/" +localid +"/";
QString lidUrl = "";
for (int i=0; i<lids.size(); i++) {
ntable.get(note, lids[i], false, false);

QString guid = "";
if (note.guid.isSet())
guid = note.guid;
QString localid;
if (!note.updateSequenceNum.isSet() || note.updateSequenceNum == 0) {
syncneeded = true;
localid = QString::number(lids[i]);
} else
localid = guid;

lidUrl = lidUrl+"evernote:///view/" + userid +"/" +shard + "/" +guid + "/" +localid +"/" + " ";
}
if (syncneeded) {
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Unsynchronized Note"));
Expand Down
7 changes: 6 additions & 1 deletion watcher/filewatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ void FileWatcher::saveFile(QString file) {
emit(fileImported(noteLid, lid));

if (scanType == FileWatcher::ImportDelete) {
QLOG_DEBUG() << f.remove();
bool retval = f.remove();
int count = 100;
while (!retval && count > 0) {
QLOG_ERROR() << tr("Error removing file:") << f.RemoveError;
count--;
}
}
}

Expand Down

0 comments on commit 9dbef2e

Please sign in to comment.