<commit_before>// Begin CVS Header
//   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CQFunctionDM.cpp,v $
//   $Revision: 1.8 $
//   $Name:  $
//   $Author: shoops $
//   $Date: 2011/03/07 19:38:00 $
// End CVS Header

// Copyright (C) 2011 - 2010 by <NAME>, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

// Copyright (C) 2008 by <NAME>, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.

#include <QString>
#include <QList>

#include "CopasiDataModel/CCopasiDataModel.h"
#include "report/CCopasiRootContainer.h"
#include "function/CFunctionDB.h"

#include "CQMessageBox.h"
#include "CQFunctionDM.h"
#include "qtUtilities.h"

CQFunctionDM::CQFunctionDM(QObject *parent)
    : CQBaseDataModel(parent)

{
}

int CQFunctionDM::rowCount(const QModelIndex& C_UNUSED(parent)) const
{
  return (int) CCopasiRootContainer::getFunctionList()->loadedFunctions().size() + 1;
}
int CQFunctionDM::columnCount(const QModelIndex& C_UNUSED(parent)) const
{
  return TOTAL_COLS_FUNCTIONS;
}

Qt::ItemFlags CQFunctionDM::flags(const QModelIndex &index) const
{
  if (!index.isValid())
    return Qt::ItemIsEnabled;

  if (!isDefaultRow(index) && isFunctionReadOnly(index))
    return QAbstractItemModel::flags(index);

  if (index.column() == COL_NAME_FUNCTIONS)
    return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
  else
    return QAbstractItemModel::flags(index);
}

bool CQFunctionDM::isFunctionReadOnly(const QModelIndex &index) const
{
  const CEvaluationTree *pFunc = CCopasiRootContainer::getFunctionList()->loadedFunctions()[index.row()];

  switch (pFunc->getType())
    {
      case CEvaluationTree::PreDefined:
      case CEvaluationTree::MassAction:
        return true;
        break;
      case CEvaluationTree::UserDefined:
      case CEvaluationTree::Function:
      case CEvaluationTree::Expression:
        return false;
        break;
    }<commit_msg>Fixed compiler warning.<commit_after>// Begin CVS Header
//   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CQFunctionDM.cpp,v $
//   $Revision: 1.9 $
//   $Name:  $
//   $Author: shoops $
//   $Date: 2011/03/23 16:37:26 $
// End CVS Header

// Copyright (C) 2011 - 2010 by <NAME>, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

// Copyright (C) 2008 by <NAME>, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.

#include <QString>
#include <QList>

#include "CopasiDataModel/CCopasiDataModel.h"
#include "report/CCopasiRootContainer.h"
#include "function/CFunctionDB.h"

#include "CQMessageBox.h"
#include "CQFunctionDM.h"
#include "qtUtilities.h"

CQFunctionDM::CQFunctionDM(QObject *parent)
    : CQBaseDataModel(parent)

{
}

int CQFunctionDM::rowCount(const QModelIndex& C_UNUSED(parent)) const
{
  return (int) CCopasiRootContainer::getFunctionList()->loadedFunctions().size() + 1;
}
int CQFunctionDM::columnCount(const QModelIndex& C_UNUSED(parent)) const
{
  return TOTAL_COLS_FUNCTIONS;
}

Qt::ItemFlags CQFunctionDM::flags(const QModelIndex &index) const
{
  if (!index.isValid())
    return Qt::ItemIsEnabled;

  if (!isDefaultRow(index) && isFunctionReadOnly(index))
    return QAbstractItemModel::flags(index);

  if (index.column() == COL_NAME_FUNCTIONS)
    return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
  else
    return QAbstractItemModel::flags(index);
}

bool CQFunctionDM::isFunctionReadOnly(const QModelIndex &index) const
{
  const CEvaluationTree *pFunc = CCopasiRootContainer::getFunctionList()->loadedFunctions()[index.row()];

  switch (pFunc->getType())
    {
      case CEvaluationTree::PreDefined:
      case CEvaluationTree::MassAction:
        return true;
        break;
      case CEvaluationTree::UserDefined:
      case CEvaluationTree::Function:
      case CEvaluationTree::Expression:
      case CEvaluationTree::MathExpression:
        return false;
        break;
    }
{'fraction_non_alphanumeric': 0.12766967252017086, 'fraction_numerical': 0.013763644992880873, 'mean_word_length': 4.459844559585492, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4008039', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1366, 'n_words': 300}