don't try to delete a default scheme
authorkoda
Tue, 23 Oct 2012 04:40:13 +0200
changeset 7792 5e7bdcc8cff3
parent 7791 b937274608ba
child 7793 3c21da93db9f
don't try to delete a default scheme
QTfrontend/hwform.cpp
QTfrontend/ui/page/pagescheme.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
     {
--- 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());
+        }
     }
 }