Delete the note we are currently viewing
| 3436 | |
| 3437 | // Delete the note we are currently viewing |
| 3438 | void 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 |
nothing calls this directly
no test coverage detected