copasi/UI/CQUnitDetail.cpp
//! Slot for being activated whenever Delete button is clicked
Slot for being activated whenever Delete button is clicked
Slot for being activated whenever Delete button is clicked
void CQUnitDetail::slotBtnDelete()
{
  assert(mpDataModel != NULL);
  CModel * pModel = mpDataModel->getModel();
  if (pModel == NULL)
    return;
  CDataVectorN<CUnitDefinition>* pUnitDefs = CRootContainer::getUnitList();
  if (pUnitDefs == NULL)
    return;
  CUnitDefinition * pUnitDef = dynamic_cast<CUnitDefinition *>(mpObject);
  if (pUnitDef == NULL)
    return;
  CDataObject::DataObjectSet uses = pModel->getUnitSymbolUsage(pUnitDef->getSymbol());
  if (!uses.empty())
    {
      QString text = "It is required for . . .\n";
      CDataObject::DataObjectSet::const_iterator it = uses.begin();
      CDataObject::DataObjectSet::const_iterator end = uses.end();
      for (; it != end; ++it)
        {
          text += FROM_UTF8((*it)->getObjectName()) + "\n";
        }
      CQMessageBox::information(this,
                                "Unable to delete " + FROM_UTF8(pUnitDef->getObjectName()),
                                text,
                                QMessageBox::Ok, QMessageBox::Ok);
    }
  else
    {
      int ret = CQMessageBox::question(this, tr("Confirm Delete"), "Delete " + FROM_UTF8(pUnitDef->getObjectName()) + "?",
                                       QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
      if (ret == QMessageBox::Yes)
        {
          delete pUnitDef;
          protectedNotify(ListViews::UNIT, ListViews::DELETE, mObjectCN);
        }
    }
  return;
}
void CQUnitDetail :: slotBtnDelete ( ) { assert ( mpDataModel != NULL ) ; CModel * pModel = mpDataModel -> getModel ( ) ; if ( pModel == NULL ) return ; CDataVectorN < CUnitDefinition > * pUnitDefs = CRootContainer :: getUnitList ( ) ; if ( pUnitDefs == NULL ) return ; CUnitDefinition * pUnitDef = dynamic_cast < CUnitDefinition * > ( mpObject ) ; if ( pUnitDef == NULL ) return ; CDataObject :: DataObjectSet uses = pModel -> getUnitSymbolUsage ( pUnitDef -> getSymbol ( ) ) ; if ( ! uses . empty ( ) ) { QString text = " \n " ; CDataObject :: DataObjectSet :: const_iterator it = uses . begin ( ) ; CDataObject :: DataObjectSet :: const_iterator end = uses . end ( ) ; for ( ; it != end ; ++ it ) { text += FROM_UTF8 ( ( * it ) -> getObjectName ( ) ) + " \n " ; } CQMessageBox :: information ( this , " " + FROM_UTF8 ( pUnitDef -> getObjectName ( ) ) , text , QMessageBox :: Ok , QMessageBox :: Ok ) ; } else { int ret = CQMessageBox :: question ( this , tr ( " " ) , " " + FROM_UTF8 ( pUnitDef -> getObjectName ( ) ) + " " , QMessageBox :: Yes | QMessageBox :: No , QMessageBox :: No ) ; if ( ret == QMessageBox :: Yes ) { delete pUnitDef ; protectedNotify ( ListViews :: UNIT , ListViews :: DELETE , mObjectCN ) ; } } return ; }
Slot for being activated whenever Delete button is clicked
Slot for being activated whenever Delete button is clicked