summaryrefslogtreecommitdiffstats
path: root/mappingtreewidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mappingtreewidget.cpp')
-rw-r--r--mappingtreewidget.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/mappingtreewidget.cpp b/mappingtreewidget.cpp
index ba175ba..01582e5 100644
--- a/mappingtreewidget.cpp
+++ b/mappingtreewidget.cpp
@@ -72,7 +72,7 @@ MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){
mAddChildA = new QAction(tr("Add..."), this);
connect(mAddChildA, SIGNAL(triggered()), this, SLOT(addChild()));
mTree->addAction(mAddChildA);
- mDeleteChildA = new QAction(tr("Delete"), this);
+ mDeleteChildA = new QAction(tr("Delete..."), this);
connect(mDeleteChildA, SIGNAL(triggered()), this, SLOT(deleteChild()));
mTree->addAction(mDeleteChildA);
mEditChildA = new QAction(tr("Edit..."), this);
@@ -141,17 +141,20 @@ void MappingTreeWidget::addType(){
void MappingTreeWidget::deleteChild(){
QModelIndex sel = selected();
- if(!sel.isValid()){
- QMessageBox::critical(this, tr("Error"), tr("No item selected!"));
- return;
- }
QModelIndex real = mProxy->mapToSource(sel);
if(mModel->rowCount(real) > 0){
QString msg = QString(tr("Cannot delete item %1, because it has %2 children!")).arg(real.data().toString()).arg(QString::number(mModel->rowCount(real)));
QMessageBox::critical(this, tr("Error"), msg);
return;
}
- mModel->deleteChild(real);
+ QString question = QString(tr("Really delete %1?")).arg(real.data(MappingTreeModel::NameRole).toString());
+ int retval = QMessageBox::question(this, tr("Question"), question, QMessageBox::Yes | QMessageBox::No);
+ if(retval == QMessageBox::Yes){
+ if(!mModel->deleteChild(real)){
+ QString msg = QString(tr("Failed to delete %1. Most likely there are still items mapped.")).arg(real.data().toString());
+ QMessageBox::critical(this, tr("Error"), msg);
+ }
+ }
}
void MappingTreeWidget::deleteType(){