Пример #1
0
void CQReportDefinition::btnCopyReportClicked()
{
  btnCommitClicked();

  CCopasiDataModel* pDataModel = mpObject->getObjectDataModel();

  if (pDataModel == NULL) return;

  CReportDefinition * pRep = new CReportDefinition(*dynamic_cast<CReportDefinition*>(CCopasiRootContainer::getKeyFactory()->get(mKey)));

  std::string baseName = pRep->getObjectName() + "_copy";
  std::string name = baseName;

  int i = 1;

  while (pDataModel->getReportDefinitionList()->getIndex(name) != C_INVALID_INDEX)
    {
      i++;
      name = baseName + TO_UTF8(QString::number(i));
    }

  pRep->setObjectName(name);

  pDataModel->getReportDefinitionList()->add(pRep, true);

  std::string key = pRep->getKey();
  protectedNotify(ListViews::REPORT, ListViews::ADD, key);
  enter(key);
  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
Пример #2
0
void CQReportDefinition::btnNewReportClicked()
{
    btnCommitClicked();

    std::string Name = "report";

    int i = 0;
    CReportDefinition* pRep;
    assert(CCopasiRootContainer::getDatamodelList()->size() > 0);

    while (!(pRep = (*CCopasiRootContainer::getDatamodelList())[0]->getReportDefinitionList()->createReportDefinition(Name, "")))
    {
        i++;
        Name = "report_";
        Name += TO_UTF8(QString::number(i));
    }

    std::string key = pRep->getKey();
    protectedNotify(ListViews::REPORT, ListViews::ADD, key);
    enter(key);
    mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}