QTfrontend/ui/page/pagescheme.cpp
branchphysfslayer
changeset 7928 88fde28bbda6
parent 7794 ab7b94c03bc9
child 8382 67e257b98422
equal deleted inserted replaced
7778:3331b30e4ef1 7928:88fde28bbda6
   514     selectScheme->setCurrentIndex(model->rowCount() - 1);
   514     selectScheme->setCurrentIndex(model->rowCount() - 1);
   515 }
   515 }
   516 
   516 
   517 void PageScheme::deleteRow()
   517 void PageScheme::deleteRow()
   518 {
   518 {
   519     QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel);
   519     int numberOfDefaultSchemes = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes;
   520 
   520     if (selectScheme->currentIndex() < numberOfDefaultSchemes)
   521     if (reallyDelete.exec() == QMessageBox::Ok)
       
   522     {
   521     {
   523         QAbstractItemModel * model = mapper->model();
   522         QMessageBox deniedMsg(this);
   524         model->removeRow(selectScheme->currentIndex());
   523         deniedMsg.setIcon(QMessageBox::Warning);
       
   524         deniedMsg.setWindowTitle(QMessageBox::tr("Schemes - Warning"));
       
   525         deniedMsg.setText(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(selectScheme->currentText()));
       
   526         deniedMsg.setWindowModality(Qt::WindowModal);
       
   527         deniedMsg.exec();
       
   528     }
       
   529     else
       
   530     {
       
   531         QMessageBox reallyDeleteMsg(this);
       
   532         reallyDeleteMsg.setIcon(QMessageBox::Question);
       
   533         reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Schemes - Are you sure?"));
       
   534         reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the game scheme '%1'?").arg(selectScheme->currentText()));
       
   535         reallyDeleteMsg.setWindowModality(Qt::WindowModal);
       
   536         reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
       
   537 
       
   538         if (reallyDeleteMsg.exec() == QMessageBox::Ok)
       
   539         {
       
   540             QAbstractItemModel * model = mapper->model();
       
   541             model->removeRow(selectScheme->currentIndex());
       
   542         }
   525     }
   543     }
   526 }
   544 }
   527 
   545 
   528 void PageScheme::schemeSelected(int n)
   546 void PageScheme::schemeSelected(int n)
   529 {
   547 {