Ejemplo n.º 1
0
bool CQReportDM::setData(const QModelIndex &index, const QVariant &value,
                         int role)
{
    if (index.isValid() && role == Qt::EditRole)
    {
        bool defaultRow = isDefaultRow(index);

        if (defaultRow)
        {
            if (index.data() != value)
            {
                mNewName = (index.column() == COL_NAME_REPORTS) ? value.toString() : "report";
                insertRow(rowCount(), index);
            }
            else
                return false;
        }

        CReportDefinition *pRepDef = &mpDataModel->getReportDefinitionList()->operator[](index.row());

        if (index.column() == COL_NAME_REPORTS)
            pRepDef->setObjectName(TO_UTF8(value.toString()));

        emit dataChanged(index, index);
        emit notifyGUI(ListViews::REPORT, ListViews::CHANGE, pRepDef->getKey());
    }

    return true;
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
0
CReportDefinition* CReportDefinitionVector::createReportDefinition(const std::string & name, const std::string & comment)
{
  size_t i;

  for (i = 0; i < size(); i++)
    if (operator[](i).getObjectName() == name)
      return NULL; // duplicate name

  CReportDefinition* pNewReportDef = new CReportDefinition(name, this);
  pNewReportDef->setComment(comment);
  pNewReportDef->setObjectName(name);

  add(pNewReportDef, true);
  return pNewReportDef;
}