COPASI API  4.16.103
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
CQValidator< Type > Class Template Reference

#include <CQValidator.h>

Inheritance diagram for CQValidator< Type >:
Inheritance graph
[legend]
Collaboration diagram for CQValidator< Type >:
Collaboration graph
[legend]

Public Member Functions

 CQValidator (Type *parent, QString(Type::*retrieve)(void) const, const char *name=0)
 
virtual void force (const QString &input) const
 
virtual State revalidate ()
 
virtual void saved () const
 
virtual State validate (QString &input, int &) const
 

Protected Member Functions

State setColor (const State &state) const
 

Protected Attributes

QString mLastAccepted
 
Type * mpContainer
 
QString(Type::* mRetrieve )(void) const
 

Private Attributes

QColor mAcceptableColor
 
QColor mErrorColor
 
QColor mSavedColor
 

Detailed Description

template<typename Type>
class CQValidator< Type >

Definition at line 26 of file CQValidator.h.

Constructor & Destructor Documentation

template<typename Type>
CQValidator< Type >::CQValidator ( Type *  parent,
QString(Type::*)(void) const  retrieve,
const char *  name = 0 
)
inline

Definition at line 30 of file CQValidator.h.

30  :
31  QValidator(parent),
32  mpContainer(parent),
33  mRetrieve(retrieve),
34  mLastAccepted("")
35  {
36  setObjectName(QString::fromUtf8(name));
37  int h, s, v;
38 
39  QPalette palette = mpContainer->palette();
40  QBrush brush = palette.brush(QPalette::Active, QPalette::Base);
41  mSavedColor = brush.color();
42 // mSavedColor = mpLineEdit->paletteBackgroundColor();
43  mSavedColor.getHsv(&h, &s, &v);
44 
45  if (s < 20) s = 20;
46 
47  mAcceptableColor.setHsv(240, s, v);
48  mErrorColor.setHsv(0, s, v);
49  }
QColor mAcceptableColor
Definition: CQValidator.h:111
QColor mSavedColor
Definition: CQValidator.h:109
QString(Type::* mRetrieve)(void) const
Definition: CQValidator.h:104
QString mLastAccepted
Definition: CQValidator.h:106
Type * mpContainer
Definition: CQValidator.h:99
QColor mErrorColor
Definition: CQValidator.h:113

Member Function Documentation

template<typename Type>
virtual void CQValidator< Type >::force ( const QString &  input) const
inlinevirtual

Reimplemented in CQValidatorBound.

Definition at line 77 of file CQValidator.h.

Referenced by CQValidatorBound::force().

78  {
79  const_cast<CQValidator *>(this)->mLastAccepted = input;
80  setColor(Acceptable);
81  }
QString mLastAccepted
Definition: CQValidator.h:106
State setColor(const State &state) const
Definition: CQValidator.h:84
template<typename Type>
virtual State CQValidator< Type >::revalidate ( )
inlinevirtual
template<typename Type>
virtual void CQValidator< Type >::saved ( ) const
inlinevirtual
template<typename Type>
State CQValidator< Type >::setColor ( const State &  state) const
inlineprotected

Definition at line 84 of file CQValidator.h.

Referenced by CQValidator< QTextEdit >::force(), and CQValidator< QTextEdit >::validate().

85  {
86  if (state == Invalid)
87  {
88  mpContainer->setStyleSheet(QString(mpContainer->metaObject()->className()) + " {background-color:" + mErrorColor.name() + ";}");
89  }
90  else
91  {
92  mpContainer->setStyleSheet(QString(mpContainer->metaObject()->className()) + " {background-color:" + mAcceptableColor.name() + ";}");
93  }
94 
95  return state;
96  }
QColor mAcceptableColor
Definition: CQValidator.h:111
Type * mpContainer
Definition: CQValidator.h:99
QColor mErrorColor
Definition: CQValidator.h:113
template<typename Type>
virtual State CQValidator< Type >::validate ( QString &  input,
int &   
) const
inlinevirtual

Reimplemented in CQValidatorInt, CQValidatorDouble, CQValidatorBound, CQExperimentDataValidator, CQValidatorNotEmpty, CQValidatorFunction, CQValidatorExpression, and CQValidatorXML.

Definition at line 51 of file CQValidator.h.

Referenced by CQValidator< QTextEdit >::revalidate(), CQExpressionWidget::slotTextChanged(), CQValidatorXML::validate(), CQValidatorExpression::validate(), CQValidatorFunction::validate(), and CQValidatorNotEmpty::validate().

52  {
53  if (input == mLastAccepted)
54  {
55  mpContainer->setStyleSheet(QString(mpContainer->metaObject()->className()) + " {background-color:" + mSavedColor.name() + ";}");
56  }
57  else
58  setColor(Acceptable);
59 
60  return Acceptable;
61  }
QColor mSavedColor
Definition: CQValidator.h:109
QString mLastAccepted
Definition: CQValidator.h:106
Type * mpContainer
Definition: CQValidator.h:99
State setColor(const State &state) const
Definition: CQValidator.h:84

Member Data Documentation

template<typename Type>
QColor CQValidator< Type >::mAcceptableColor
private
template<typename Type>
QColor CQValidator< Type >::mErrorColor
private
template<typename Type>
QString CQValidator< Type >::mLastAccepted
protected
template<typename Type>
Type* CQValidator< Type >::mpContainer
protected
template<typename Type>
QString(Type::* CQValidator< Type >::mRetrieve)(void) const
protected

Method to retrieve the content of the container as a QString

Definition at line 104 of file CQValidator.h.

Referenced by CQValidator< QTextEdit >::revalidate(), and CQValidator< QTextEdit >::saved().

template<typename Type>
QColor CQValidator< Type >::mSavedColor
private

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