COPASI API  4.16.103
Signals | Public Member Functions | Protected Attributes | List of all members
CQValidatorFunction Class Reference

#include <CQExpressionWidget.h>

Inheritance diagram for CQValidatorFunction:
Inheritance graph
[legend]
Collaboration diagram for CQValidatorFunction:
Collaboration graph
[legend]

Signals

void stateChanged (bool) const
 

Public Member Functions

 CQValidatorFunction (QTextEdit *parent, const char *name=0)
 
virtual CFunctiongetFunction ()
 
virtual State validate (QString &input, int &pos) const
 
- Public Member Functions inherited from CQValidator< QTextEdit >
 CQValidator (QTextEdit *parent, QString(QTextEdit::*retrieve)(void) const, const char *name=0)
 
virtual void force (const QString &input) const
 
virtual State revalidate ()
 
virtual void saved () const
 

Protected Attributes

CFunction mFunction
 
- Protected Attributes inherited from CQValidator< QTextEdit >
QString mLastAccepted
 
QTextEdit * mpContainer
 
QString(QTextEdit::* mRetrieve )(void) const
 

Additional Inherited Members

- Protected Member Functions inherited from CQValidator< QTextEdit >
State setColor (const State &state) const
 

Detailed Description

The class for checking the validity of a given mathematical function

Definition at line 82 of file CQExpressionWidget.h.

Constructor & Destructor Documentation

CQValidatorFunction::CQValidatorFunction ( QTextEdit *  parent,
const char *  name = 0 
)

Specific constructor

Parameters
QTextEdit* parent
constchar * name (Default: NULL)

Definition at line 132 of file CQExpressionWidget.cpp.

References CCopasiRootContainer::getDatamodelList(), mFunction, and CCopasiObject::setObjectParent().

132  :
133  CQValidator< QTextEdit >(parent, &QTextEdit::toPlainText, name),
134  mFunction()
135 {
137  assert(pDataModel != NULL);
138 
139  mFunction.setObjectParent(pDataModel);
140 }
virtual bool setObjectParent(const CCopasiContainer *pParent)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()

Member Function Documentation

CFunction * CQValidatorFunction::getFunction ( )
virtual

Retrieve a pointer to the function object

Returns
CFunction * pFunction

Definition at line 181 of file CQExpressionWidget.cpp.

References mFunction.

Referenced by CQExpressionWidget::writeMathML().

182 {
183  return &mFunction;
184 }
void CQValidatorFunction::stateChanged ( bool  ) const
signal

Referenced by validate().

QValidator::State CQValidatorFunction::validate ( QString &  input,
int &  pos 
) const
virtual

Function to validate a string input

Parameters
QString& input
int& pos
Returns
State

This function ensures that any characters on Expression Widget are validated to go to further processes.

Reimplemented from CQValidator< QTextEdit >.

Definition at line 146 of file CQExpressionWidget.cpp.

References CQExpressionWidget::getFunction(), CMassAction::Infix, mFunction, CQValidator< QTextEdit >::mpContainer, CQValidator< QTextEdit >::mRetrieve, CQValidator< QTextEdit >::setColor(), stateChanged(), and CQValidator< Type >::validate().

147 {
148  // The input is the display version of the infix string.
149  // We must first convert the display string to infix.
150 
151  State CurrentState = Invalid;
152 
153  CQExpressionWidget * pExpressionWidget =
154  static_cast< CQExpressionWidget * >(parent());
155 
156  if (pExpressionWidget != NULL)
157  {
158  std::string Infix = pExpressionWidget->getFunction();
159 
160  if (Infix == CMassAction::Infix[0] ||
161  Infix == CMassAction::Infix[1] ||
162  (const_cast< CFunction * >(&mFunction)->setInfix(Infix) &&
163  const_cast< CFunction * >(&mFunction)->compile()))
164  {
165  QString Input = (*mpContainer.*mRetrieve)();
166  CurrentState = CQValidator< QTextEdit >::validate(input, pos);
167  }
168  }
169 
170  if (CurrentState != Acceptable)
171  {
172  setColor(Invalid);
173  CurrentState = Intermediate;
174  }
175 
176  emit stateChanged(CurrentState == Acceptable);
177 
178  return CurrentState;
179 }
static const char * Infix[]
Definition: CMassAction.h:34
std::string getFunction() const
void stateChanged(bool) const
QString(QTextEdit::* mRetrieve)(void) const
Definition: CQValidator.h:104
virtual State validate(QString &input, int &) const
Definition: CQValidator.h:51
State setColor(const State &state) const
Definition: CQValidator.h:84

Member Data Documentation

CFunction CQValidatorFunction::mFunction
protected

Definition at line 108 of file CQExpressionWidget.h.

Referenced by CQValidatorFunction(), getFunction(), and validate().


The documentation for this class was generated from the following files: