MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / viewNoteHistory

Method viewNoteHistory

nixnote.cpp:2334–2436  ·  view source on GitHub ↗

View the current note's history.

Source from the content-addressed store, hash-verified

2332//* View the current note's history.
2333//**********************************************
2334void NixNote::viewNoteHistory() {
2335 this->saveContents();
2336 statusBar()->clearMessage();
2337
2338 qint32 lid = this->tabWindow->currentBrowser()->lid;
2339 NoteTable ntable(global.db);
2340 Note n;
2341 ntable.get(n,lid,false,false);
2342 if (n.updateSequenceNum.isSet() && n.updateSequenceNum == 0) {
2343 QMessageBox::information(0,tr("Unsynchronized Note"), tr("This note has never been synchronized with Evernote"));
2344 return;
2345 }
2346
2347 if (!global.accountsManager->oauthTokenFound()) {
2348 QString consumerKey = "baumgarr-3523";
2349 QString consumerSecret = "8d5ee175f8a5d3ec";
2350 EvernoteOAuthDialog d(consumerKey, consumerSecret, global.server);
2351 d.setWindowTitle(tr("Log in to Evernote"));
2352 if(d.exec() != QDialog::Accepted) {
2353 QMessageBox::critical(0, tr("NixNote"), "Login failed.\n" + d.oauthError());
2354 return;
2355 }
2356 QString token = QString("oauth_token=") +d.oauthResult().authenticationToken +
2357 QString("&oauth_token_secret=&edam_shard=")+d.oauthResult().shardId +
2358 QString("&edam_userId=") +QString::number(d.oauthResult().userId) +
2359 QString("&edam_expires=") +QString::number(d.oauthResult().expires) +
2360 QString("&edam_noteStoreUrl=") + d.oauthResult().noteStoreUrl +
2361 QString("&edam_webApiUrlPrefix=") +d.oauthResult().webApiUrlPrefix;
2362
2363 global.accountsManager->setOAuthToken(token);
2364 }
2365
2366 UserTable userTable(global.db);
2367 User user;
2368 userTable.getUser(user);
2369 bool normalUser = false;
2370 if (user.privilege == PrivilegeLevel::NORMAL)
2371 normalUser = true;
2372
2373 NoteHistorySelect dialog;
2374 QString guid = ntable.getGuid(tabWindow->currentBrowser()->lid);
2375 QList<NoteVersionId> versions;
2376
2377 CommunicationManager comm(global.db);
2378 if (comm.enConnect()) {
2379 QList<NoteVersionId> versions;
2380 NoteTable ntable(global.db);
2381 QString guid = ntable.getGuid(tabWindow->currentBrowser()->lid);
2382 if (!normalUser)
2383 comm.listNoteVersions(versions, guid);
2384 }
2385 dialog.loadData(versions);
2386 dialog.exec();
2387 if (!dialog.importPressed)
2388 return;
2389 Note note;
2390 if (dialog.usn > 0 && !comm.getNoteVersion(note, guid, dialog.usn)) {
2391 QMessageBox mbox;

Callers

nothing calls this directly

Calls 15

saveContentsMethod · 0.95
currentBrowserMethod · 0.80
oauthTokenFoundMethod · 0.80
setOAuthTokenMethod · 0.80
enConnectMethod · 0.80
replaceCurrentNoteMethod · 0.80
QStringClass · 0.50
getMethod · 0.45
isSetMethod · 0.45
execMethod · 0.45
oauthErrorMethod · 0.45
oauthResultMethod · 0.45

Tested by

no test coverage detected