catch case that users tries to delete all items in the dialog list
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
# include <QMessageBox>
|
||||
# include <QAction>
|
||||
# include <QListWidget>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "ui_TaskDraftParameters.h"
|
||||
@@ -243,6 +244,12 @@ void TaskDraftParameters::onRefDeleted(void)
|
||||
// get the list of items to be deleted
|
||||
QList<QListWidgetItem*> selectedList = ui->listWidgetReferences->selectedItems();
|
||||
|
||||
// if all items are selected, we must stop because one must be kept to avoid that the feature gets broken
|
||||
if (selectedList.count() == ui->listWidgetReferences->model()->rowCount()) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("At least one item must be kept."));
|
||||
return;
|
||||
}
|
||||
|
||||
// delete the selection backwards to assure the list index keeps valid for the deletion
|
||||
for (int i = selectedList.count() - 1; i > -1; i--) {
|
||||
QListWidgetItem* item = selectedList.at(i);
|
||||
|
||||
Reference in New Issue
Block a user