// Delete the selected notes void NTableView::deleteSelectedNotes() { QList<qint32> lids; this->getSelectedLids(lids); if (lids.size() == 0) return; QString typeDelete; QString msg; FilterCriteria *f = global.filterCriteria[global.filterPosition]; bool expunged = false; typeDelete = tr("Delete "); if (f->isDeletedOnlySet() && f->getDeletedOnly()) { typeDelete = tr("Permanently delete "); expunged = true; } if (lids.size() == 1) msg = typeDelete + tr("selected note?"); else msg = typeDelete +QString::number(lids.size()) + " notes?"; QMessageBox msgBox; msgBox.setWindowTitle(tr("Verify Delete")); msgBox.setText(msg); msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); msgBox.setIcon(QMessageBox::Question); msgBox.setDefaultButton(QMessageBox::Yes); int rc = msgBox.exec(); if (rc != QMessageBox::Yes) return; NoteTable ntable(global.db); QSqlQuery sql(*global.db); QSqlQuery transaction(*global.db); //transaction.exec("begin"); sql.prepare("Delete from filter where lid=:lid"); for (int i=0; i<lids.size(); i++) { ntable.deleteNote(lids[i], true); if (expunged) ntable.expunge(lids[i]); sql.bindValue(":lid", lids[i]); sql.exec(); delete global.cache[lids[i]]; global.cache.remove(lids[i]); } //transaction.exec("commit"); emit(notesDeleted(lids, expunged)); }
//************************************************************* // This function is called from the main NixNote class. // it will reset the items which are selected based upon // what the user did somewhere else (outside this widget). //************************************************************* void NTrashTree::updateSelection() { blockSignals(true); FilterCriteria *criteria = global.filterCriteria[global.filterPosition]; if (global.filterPosition != filterPosition) { QList<QTreeWidgetItem*> selectedItems = this->selectedItems(); for (int i=0; i<selectedItems.size() && criteria->resetDeletedOnly; i++) { selectedItems[i]->setSelected(false); } if (criteria->isDeletedOnlySet() && criteria->getDeletedOnly()) { root->setSelected(true); } } filterPosition = global.filterPosition; blockSignals(false); }