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

Method deleteSelectedNotes

gui/ntableview.cpp:653–703  ·  view source on GitHub ↗

Delete the selected notes

Source from the content-addressed store, hash-verified

651
652// Delete the selected notes
653void NTableView::deleteSelectedNotes() {
654 QList<qint32> lids;
655 this->getSelectedLids(lids);
656 if (lids.size() == 0)
657 return;
658
659 QString typeDelete;
660 QString msg;
661 FilterCriteria *f = global.filterCriteria[global.filterPosition];
662 bool expunged = false;
663 typeDelete = tr("Delete ");
664
665 if (f->isDeletedOnlySet() && f->getDeletedOnly()) {
666 typeDelete = tr("Permanently delete ");
667 expunged = true;
668 }
669
670
671 if (lids.size() == 1)
672 msg = typeDelete + tr("selected note?");
673 else
674 msg = typeDelete +QString::number(lids.size()) + " notes?";
675
676 QMessageBox msgBox;
677 msgBox.setWindowTitle(tr("Verify Delete"));
678 msgBox.setText(msg);
679 msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
680 msgBox.setIcon(QMessageBox::Question);
681 msgBox.setDefaultButton(QMessageBox::Yes);
682 int rc = msgBox.exec();
683 if (rc != QMessageBox::Yes)
684 return;
685
686 NoteTable ntable(global.db);
687 NSqlQuery sql(global.db);
688// NSqlQuery transaction(*global.db);
689 //transaction.exec("begin");
690 sql.prepare("Delete from filter where lid=:lid");
691 for (int i=0; i<lids.size(); i++) {
692 ntable.deleteNote(lids[i], true);
693 if (expunged)
694 ntable.expunge(lids[i]);
695 sql.bindValue(":lid", lids[i]);
696 sql.exec();
697 delete global.cache[lids[i]];
698 global.cache.remove(lids[i]);
699 }
700 //transaction.exec("commit");
701 sql.finish();
702 emit(notesDeleted(lids, expunged));
703}
704
705
706// Get a list of selected lids from the table

Callers

nothing calls this directly

Calls 10

getSelectedLidsMethod · 0.95
isDeletedOnlySetMethod · 0.80
getDeletedOnlyMethod · 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