# HG changeset patch # User koda # Date 1350960013 -7200 # Node ID 5e7bdcc8cff367d8e6a458b6e7555a41a0eb17ee # Parent b937274608ba203d712bb127ec7eec8bcd1ae27d don't try to delete a default scheme diff -r b937274608ba -r 5e7bdcc8cff3 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Mon Oct 22 22:30:03 2012 -0400 +++ b/QTfrontend/hwform.cpp Tue Oct 23 04:40:13 2012 +0200 @@ -908,7 +908,7 @@ ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex()); if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) { - QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Can not delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); + QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); } else { diff -r b937274608ba -r 5e7bdcc8cff3 QTfrontend/ui/page/pagescheme.cpp --- a/QTfrontend/ui/page/pagescheme.cpp Mon Oct 22 22:30:03 2012 -0400 +++ b/QTfrontend/ui/page/pagescheme.cpp Tue Oct 23 04:40:13 2012 +0200 @@ -516,12 +516,20 @@ void PageScheme::deleteRow() { - QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel); + int numberOfDefaultSchemes = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes; + if (selectScheme->currentIndex() < numberOfDefaultSchemes) + { + QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Cannot delete default scheme '%1'!").arg(selectScheme->currentText())); + } + else + { + QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel); - if (reallyDelete.exec() == QMessageBox::Ok) - { - QAbstractItemModel * model = mapper->model(); - model->removeRow(selectScheme->currentIndex()); + if (reallyDelete.exec() == QMessageBox::Ok) + { + QAbstractItemModel * model = mapper->model(); + model->removeRow(selectScheme->currentIndex()); + } } }