Surround multi-import and deletion by a transaction

This commit is contained in:
Christian Hohnstaedt 2018-03-08 18:47:38 +01:00
parent 2bf7fa6bf4
commit 6e0828bfe2
2 changed files with 14 additions and 2 deletions

View File

@ -152,10 +152,14 @@ void ImportMulti::on_butRemove_clicked()
void ImportMulti::on_butOk_clicked()
{
Transaction;
if (!TransBegin())
return;
while (mcont->rootItem->childCount()) {
QModelIndex idx = mcont->index(0, 0, QModelIndex());
import(idx);
}
TransCommit();
accept();
}
@ -163,13 +167,16 @@ void ImportMulti::on_butImport_clicked()
{
QItemSelectionModel *selectionModel = listView->selectionModel();
QModelIndexList indexes = selectionModel->selectedIndexes();
QModelIndex index;
foreach(index, indexes) {
Transaction;
if (!TransBegin())
return;
foreach(QModelIndex index, indexes) {
if (index.column() != 0)
continue;
import(index);
}
TransCommit();
}
void ImportMulti::on_deleteToken_clicked()

View File

@ -218,6 +218,10 @@ void XcaTreeView::deleteItems(void)
count++;
}
Transaction;
if (!TransBegin())
return;
if (count == 1)
msg = pki->getMsg(pki_base::msg_delete).arg(pki->getIntName());
else
@ -230,6 +234,7 @@ void XcaTreeView::deleteItems(void)
foreach(index, indexes) {
basemodel->deletePKI(index);
}
TransCommit();
}
void XcaTreeView::storeItems(void)