COPASI API  4.16.103
Public Types | Public Member Functions | Private Attributes | List of all members
CQExperimentDataValidator Class Reference
Inheritance diagram for CQExperimentDataValidator:
Inheritance graph
[legend]
Collaboration diagram for CQExperimentDataValidator:
Collaboration graph
[legend]

Public Types

enum  Type { Name = 0, FirstRow, LastRow, HeaderRow }
 

Public Member Functions

 CQExperimentDataValidator (QLineEdit *parent, const char *name, CQExperimentData *pContext, const Type &type)
 
virtual State validate (QString &input, int &pos) const
 
- Public Member Functions inherited from CQValidatorNotEmpty
 CQValidatorNotEmpty (QLineEdit *parent, const char *name=0)
 
- Public Member Functions inherited from CQValidator< QLineEdit >
 CQValidator (QLineEdit *parent, QString(QLineEdit::*retrieve)(void) const, const char *name=0)
 
virtual void force (const QString &input) const
 
virtual State revalidate ()
 
virtual void saved () const
 

Private Attributes

CQExperimentDatampContext
 
QIntValidator * mpIntValidator
 
Type mType
 

Additional Inherited Members

- Protected Member Functions inherited from CQValidator< QLineEdit >
State setColor (const State &state) const
 
- Protected Attributes inherited from CQValidator< QLineEdit >
QString mLastAccepted
 
QLineEdit * mpContainer
 
QString(QLineEdit::* mRetrieve )(void) const
 

Detailed Description

Definition at line 104 of file CQExperimentData.cpp.

Member Enumeration Documentation

Constructor & Destructor Documentation

CQExperimentDataValidator::CQExperimentDataValidator ( QLineEdit *  parent,
const char *  name,
CQExperimentData pContext,
const Type type 
)
inline

Definition at line 117 of file CQExperimentData.cpp.

120  :
121  CQValidatorNotEmpty(parent, name),
122  mpIntValidator(new QIntValidator(1, std::numeric_limits< int >::max(), parent)),
123  mpContext(pContext),
124  mType(type)
125  {}
CQValidatorNotEmpty(QLineEdit *parent, const char *name=0)
Definition: CQValidator.cpp:21
CQExperimentData * mpContext
#define max(a, b)
Definition: f2c.h:176

Member Function Documentation

virtual State CQExperimentDataValidator::validate ( QString &  input,
int &  pos 
) const
inlinevirtual

Reimplemented from CQValidatorNotEmpty.

Definition at line 127 of file CQExperimentData.cpp.

References C_INT32, FirstRow, CExperimentFileInfo::getFirstUnusedSection(), CExperiment::getLastRow(), CExperimentFileInfo::getNextUnusedSection(), CCopasiParameterGroup::getParameter(), HeaderRow, LastRow, CQValidator< QLineEdit >::mLastAccepted, mpContext, CQExperimentData::mpExperiment, CQExperimentData::mpExperimentSetCopy, CQExperimentData::mpFileInfo, mpIntValidator, CQExperimentData::mpValidatorLast, CQExperimentData::mShown, mType, Name, CQValidator< Type >::revalidate(), CQValidator< QLineEdit >::setColor(), CExperiment::setFirstRow(), CExperiment::setHeaderRow(), CExperiment::setLastRow(), CExperimentFileInfo::sync(), CQExperimentData::syncExperiments(), TO_UTF8, CQValidatorNotEmpty::validate(), CExperimentFileInfo::validateFirst(), CExperimentFileInfo::validateHeader(), and CExperimentFileInfo::validateLast().

Referenced by CQExperimentData::saveExperiment().

128  {
129  if (mpContext->mShown == -1) return Acceptable;
130 
131  if (mType == Name)
132  {
133  if (input == "All")
134  {
135  setColor(Invalid);
136  return Intermediate;
137  }
138 
139  if (mLastAccepted != input &&
141  {
142  setColor(Invalid);
143  return Intermediate;
144  }
145  }
146  else
147  {
148  if (mpIntValidator->validate(input, pos) != Acceptable)
149  {
150  setColor(Invalid);
151  return Intermediate;
152  }
153 
154  size_t First, Last;
155 
156  switch (mType)
157  {
158  case FirstRow:
159 
160  if (!mpContext->mpFileInfo->validateFirst(mpContext->mShown, input.toULong()))
161  {
162  size_t NewFirst = input.toULong();
163 
165 
166  while (NewFirst > Last)
168 
169  if (First <= NewFirst && NewFirst <= Last)
170  {
171  if (First > mpContext->mpExperiment->getLastRow())
172  {
173  mpContext->mpExperiment->setLastRow((unsigned C_INT32) Last);
174  mpContext->mpExperiment->setFirstRow((unsigned C_INT32) First);
175  }
176  else
177  {
178  mpContext->mpExperiment->setFirstRow((unsigned C_INT32) First);
179  mpContext->mpExperiment->setLastRow((unsigned C_INT32) Last);
180  }
181 
183 
184  mpContext->mpEditFirst->setText(QString::number(First));
185  mpContext->mpEditLast->setText(QString::number(Last));
187 
188  return validate(input, pos);
189  }
190 
191  setColor(Invalid);
192  return Intermediate;
193  }
194 
195  mpContext->mpExperiment->setFirstRow(input.toULong());
197  mpContext->mpBtnExperimentAdd->setEnabled(mpContext->mpFileInfo->getFirstUnusedSection(First, Last));
198  break;
199 
200  case LastRow:
201 
202  if (!mpContext->mpFileInfo->validateLast(mpContext->mShown, input.toULong()))
203  {
204  setColor(Invalid);
205  return Intermediate;
206  }
207 
208  mpContext->mpExperiment->setLastRow(input.toULong());
210  mpContext->mpBtnExperimentAdd->setEnabled(mpContext->mpFileInfo->getFirstUnusedSection(First, Last));
211  break;
212 
213  case HeaderRow:
214 
215  if (!mpContext->mpFileInfo->validateHeader(mpContext->mShown, input.toULong()))
216  {
217  setColor(Invalid);
218  return Intermediate;
219  }
220 
221  mpContext->mpExperiment->setHeaderRow(input.toULong());
222  break;
223 
224  default:
225  break;
226  }
227  }
228 
229  return CQValidatorNotEmpty::validate(input, pos);
230  }
bool getFirstUnusedSection(size_t &First, size_t &Last)
bool validateLast(const size_t &index, const size_t &value)
bool setHeaderRow(const unsigned C_INT32 &headerRow)
#define C_INT32
Definition: copasi.h:90
virtual State revalidate()
Definition: CQValidator.h:63
CQExperimentData * mpContext
CExperiment * mpExperiment
bool getNextUnusedSection(size_t &First, size_t &Last)
bool validateFirst(const size_t &index, const size_t &value)
CExperimentFileInfo * mpFileInfo
CCopasiParameter * getParameter(const std::string &name)
virtual State validate(QString &input, int &pos) const
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool setFirstRow(const unsigned C_INT32 &firstRow)
virtual State validate(QString &input, int &pos) const
Definition: CQValidator.cpp:25
CExperimentSet * mpExperimentSetCopy
const unsigned C_INT32 & getLastRow() const
bool validateHeader(const size_t &index, const size_t &value)
bool setLastRow(const unsigned C_INT32 &lastRow)
State setColor(const State &state) const
Definition: CQValidator.h:84
CQExperimentDataValidator * mpValidatorLast

Member Data Documentation

CQExperimentData* CQExperimentDataValidator::mpContext
private

Definition at line 242 of file CQExperimentData.cpp.

Referenced by validate().

QIntValidator* CQExperimentDataValidator::mpIntValidator
private

Definition at line 240 of file CQExperimentData.cpp.

Referenced by validate().

Type CQExperimentDataValidator::mType
private

Definition at line 244 of file CQExperimentData.cpp.

Referenced by validate().


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