catch case that users tries to delete all items in the dialog list
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QListWidget>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "ui_TaskChamferParameters.h"
|
||||
@@ -169,6 +170,12 @@ void TaskChamferParameters::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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <QAction>
|
||||
# include <QKeyEvent>
|
||||
# include <QListWidget>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "ui_TaskFilletParameters.h"
|
||||
@@ -169,6 +170,12 @@ void TaskFilletParameters::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);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QListWidget>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "ui_TaskThicknessParameters.h"
|
||||
@@ -191,6 +192,12 @@ void TaskThicknessParameters::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