Ejemplo n.º 1
0
// virtual
int CQTaskMethodParametersDM::rowCount(const QModelIndex & parent) const
{
  if (!parent.isValid())
    {
      QVector< CCopasiMethod * >::const_iterator it = mMethods.constBegin();
      QVector< CCopasiMethod * >::const_iterator end = mMethods.constEnd();

      int size = 0;

      for (; it != end; ++it)
        size += (int)(*it)->size();

      return size;
    }

  CCopasiParameter * pParent = nodeFromIndex(parent);

  switch (pParent->getType())
    {
      case CCopasiParameter::GROUP:
        return (int) static_cast< CCopasiParameterGroup * >(pParent)->size();
        break;

      default:
        break;
    }

  return 0;
}
Ejemplo n.º 2
0
void CQParameterGroupView::slotPushButtonClicked(const QModelIndex & index)
{
  QModelIndex Source = index;

  while (Source.model()->inherits("QSortFilterProxyModel"))
    {
      Source = static_cast< const QSortFilterProxyModel *>(Source.model())->mapToSource(index);
    }

  if (this->itemDelegateForRow(Source.row()) != mpPushButtonDelegate) return;

  CCopasiParameter * pParameter = CQParameterGroupDM::nodeFromIndex(Source);

  if (pParameter->getType() != CCopasiParameter::Type::GROUP) return;

  CCopasiParameterGroup * pGroup = static_cast< CCopasiParameterGroup * >(pParameter);

  CCopasiParameterGroup::elements::const_iterator it = pGroup->getElementTemplates().beginIndex();
  CCopasiParameterGroup::elements::const_iterator end = pGroup->getElementTemplates().endIndex();

  for (; it != end; ++it)
    {
      switch ((*it)->getType())
        {
          case CCopasiParameter::Type::CN:
            modifySelectCNs(*pGroup, **it);
            break;

          default:
            break;
        }
    }
}
Ejemplo n.º 3
0
// virtual
Qt::ItemFlags CQTaskMethodParametersDM::flags(const QModelIndex &index) const
{
  CCopasiParameter * pNode = nodeFromIndex(index);

  if (pNode == NULL)
    {
      return Qt::ItemIsEnabled;
    }

  if (index.column() == COL_VALUE)
    {
      if (pNode->getType() == CCopasiParameter::BOOL)
        return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;;

      if (pNode->hasValidValues())
        {
          emit signalCreateComboBox(index);
        }
      else if (pNode->getType() == CCopasiParameter::GROUP &&
               static_cast< CCopasiParameterGroup * >(pNode)->getElementTemplates().size() > 0)
        {
          emit signalCreatePushButton(index);
        }
      else
        {
          emit signalCloseEditor(index);
        }

      if (pNode->getType() == CCopasiParameter::CN)
        {
          return (QAbstractItemModel::flags(index) | Qt::ItemIsEnabled) & ~Qt::ItemIsEditable;
        }

      return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
    }

  return QAbstractItemModel::flags(index) & ~Qt::ItemIsEditable;
}
Ejemplo n.º 4
0
// virtual
bool COPASIHandler::processEnd(const XML_Char * pszName)
{
  bool finished = false;

  switch (mCurrentElement.first)
    {
      case COPASI:
      {
        // We need to handle the unmapped parameters of type key.
        std::vector< std::string >::iterator it = mpData->UnmappedKeyParameters.begin();
        std::vector< std::string >::iterator end = mpData->UnmappedKeyParameters.end();

        for (; it != end; ++it)
          {
            CCopasiParameter * pParameter =
              dynamic_cast< CCopasiParameter * >(CCopasiRootContainer::getKeyFactory()->get(*it));

            if (pParameter != NULL &&
                pParameter->getType() == CCopasiParameter::KEY)
              {
                CCopasiObject * pObject =
                  mpData->mKeyMap.get(pParameter->getValue< std::string >());

                if (pObject != NULL)
                  pParameter->setValue(pObject->getKey());
                else
                  pParameter->setValue(std::string(""));
              }
          }

        // We need to remove the no longer needed expression "Objective Function" from the function list.
        if (mpData->pFunctionList != NULL &&
            mpData->pFunctionList->getIndex("Objective Function") != C_INVALID_INDEX)
          {
            mpData->pFunctionList->remove("Objective Function");
          }
      }

      finished = true;
      break;

      case ParameterGroup:
        finished = true;
        break;

      case ListOfFunctions:
      case Model:
      case ListOfTasks:
      case ListOfReports:
      case ListOfPlots:
      case ListOfLayouts:
      case SBMLReference:
      case ListOfUnitDefinitions:
        break;

      case GUI:
        if (mpData->pGUI == NULL)
          {
            CCopasiMessage::getLastMessage();
          }

        break;

      default:
        CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 2,
                       mpParser->getCurrentLineNumber(), mpParser->getCurrentColumnNumber(), pszName);
        break;
    }

  return finished;
}