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

Method deleteCurrentNote

nixnote.cpp:3438–3480  ·  view source on GitHub ↗

Delete the note we are currently viewing

Source from the content-addressed store, hash-verified

3436
3437// Delete the note we are currently viewing
3438void NixNote::deleteCurrentNote() {
3439 qint32 lid = tabWindow->currentBrowser()->lid;
3440
3441 QString typeDelete;
3442 QString msg;
3443 FilterCriteria *f = global.filterCriteria[global.filterPosition];
3444 bool expunged = false;
3445 typeDelete = tr("Delete ");
3446
3447 if (f->isDeletedOnlySet() && f->getDeletedOnly()) {
3448 typeDelete = tr("Permanently delete ");
3449 expunged = true;
3450 }
3451
3452 msg = typeDelete + tr("this note?");
3453
3454 if (global.confirmDeletes()) {
3455 QMessageBox msgBox;
3456 msgBox.setWindowTitle(tr("Verify Delete"));
3457 msgBox.setText(msg);
3458 msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
3459 msgBox.setIcon(QMessageBox::Question);
3460 msgBox.setDefaultButton(QMessageBox::Yes);
3461 int rc = msgBox.exec();
3462 if (rc != QMessageBox::Yes)
3463 return;
3464 }
3465
3466 NoteTable ntable(global.db);
3467 NSqlQuery sql(global.db);
3468 sql.prepare("Delete from filter where lid=:lid");
3469 ntable.deleteNote(lid, true);
3470 if (expunged)
3471 ntable.expunge(lid);
3472 sql.bindValue(":lid", lid);
3473 sql.exec();
3474 sql.finish();
3475 delete global.cache[lid];
3476 global.cache.remove(lid);
3477 QList<qint32> lids;
3478 lids.append(lid);
3479 emit(notesDeleted(lids));
3480}
3481
3482
3483

Callers

nothing calls this directly

Calls 11

currentBrowserMethod · 0.80
isDeletedOnlySetMethod · 0.80
getDeletedOnlyMethod · 0.80
confirmDeletesMethod · 0.80
bindValueMethod · 0.80
removeMethod · 0.80
setTextMethod · 0.45
execMethod · 0.45
prepareMethod · 0.45
deleteNoteMethod · 0.45
expungeMethod · 0.45

Tested by

no test coverage detected