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

#include <MyLineEdit.h>

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

Public Slots

virtual void setText (const QString &text)
 
void slotForceUpdate ()
 

Signals

void edited ()
 

Public Member Functions

bool isValid ()
 
 MyLineEdit (QWidget *parent=0, const char *name=0)
 
 MyLineEdit (const QString &contents, QWidget *parent, const char *name=0)
 

Protected Slots

void slotLostFocus ()
 
void slotReturnPressed ()
 
void slotTextChanged (const QString &text)
 

Protected Member Functions

void process ()
 
void setupWidget ()
 
virtual void updateColor ()
 

Protected Attributes

QColor mErrorColor
 
QColor mNewColor
 
QColor mOldColor
 

Detailed Description

Definition at line 20 of file MyLineEdit.h.

Constructor & Destructor Documentation

MyLineEdit::MyLineEdit ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 18 of file MyLineEdit.cpp.

References setupWidget().

19  : QLineEdit(parent)
20 {
21  setObjectName(name);
22  setupWidget();
23 }
void setupWidget()
Definition: MyLineEdit.cpp:32
MyLineEdit::MyLineEdit ( const QString &  contents,
QWidget *  parent,
const char *  name = 0 
)

Definition at line 25 of file MyLineEdit.cpp.

References setupWidget().

26  : QLineEdit(contents, parent)
27 {
28  setObjectName(name);
29  setupWidget();
30 }
void setupWidget()
Definition: MyLineEdit.cpp:32

Member Function Documentation

void MyLineEdit::edited ( )
signal

Referenced by process().

bool MyLineEdit::isValid ( )

Definition at line 103 of file MyLineEdit.cpp.

References mErrorColor.

104 {return (palette().color(backgroundRole()) != mErrorColor);}
QColor mErrorColor
Definition: MyLineEdit.h:31
void MyLineEdit::process ( )
protected

Definition at line 49 of file MyLineEdit.cpp.

References edited(), and updateColor().

Referenced by slotForceUpdate(), slotLostFocus(), and slotReturnPressed().

50 {
51  if (isModified())
52  {
53  setModified(false);
54  updateColor();
55  emit edited();
56  }
57 }
virtual void updateColor()
Definition: MyLineEdit.cpp:73
void edited()
void MyLineEdit::setText ( const QString &  text)
virtualslot

Definition at line 97 of file MyLineEdit.cpp.

References updateColor().

98 {
99  QLineEdit::setText(text);
100  updateColor();
101 }
virtual void updateColor()
Definition: MyLineEdit.cpp:73
void MyLineEdit::setupWidget ( )
protected

Definition at line 32 of file MyLineEdit.cpp.

References mErrorColor, mNewColor, mOldColor, slotLostFocus(), slotReturnPressed(), and slotTextChanged().

Referenced by MyLineEdit().

33 {
34  connect(this, SIGNAL(editingFinished()), this, SLOT(slotLostFocus()));
35  connect(this, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
36  connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(slotTextChanged(const QString &)));
37 
38  mOldColor = palette().color(backgroundRole());
39  int h, s, v;
40  mOldColor.getHsv(&h, &s, &v);
41 
42  if (s < 20) s = 20;
43 
44  mNewColor.setHsv(240, s, v);
45 
46  mErrorColor.setHsv(0, s, v);
47 }
void slotTextChanged(const QString &text)
Definition: MyLineEdit.cpp:68
void slotReturnPressed()
Definition: MyLineEdit.cpp:62
QColor mOldColor
Definition: MyLineEdit.h:29
void slotLostFocus()
Definition: MyLineEdit.cpp:59
QColor mErrorColor
Definition: MyLineEdit.h:31
QColor mNewColor
Definition: MyLineEdit.h:30
void MyLineEdit::slotForceUpdate ( )
slot

Definition at line 65 of file MyLineEdit.cpp.

References process().

66 {process();}
void process()
Definition: MyLineEdit.cpp:49
void MyLineEdit::slotLostFocus ( )
protectedslot

Definition at line 59 of file MyLineEdit.cpp.

References process().

Referenced by setupWidget().

60 {process();}
void process()
Definition: MyLineEdit.cpp:49
void MyLineEdit::slotReturnPressed ( )
protectedslot

Definition at line 62 of file MyLineEdit.cpp.

References process().

Referenced by setupWidget().

63 {process();}
void process()
Definition: MyLineEdit.cpp:49
void MyLineEdit::slotTextChanged ( const QString &  text)
protectedslot

Definition at line 68 of file MyLineEdit.cpp.

References updateColor().

Referenced by setupWidget().

69 {
70  updateColor();
71 }
virtual void updateColor()
Definition: MyLineEdit.cpp:73
void MyLineEdit::updateColor ( )
protectedvirtual

Definition at line 73 of file MyLineEdit.cpp.

References mErrorColor, mNewColor, and mOldColor.

Referenced by process(), setText(), and slotTextChanged().

74 {
75  if (isModified())
76  {
77  setStyleSheet("background-color:" + mNewColor.name() + ";");
78  }
79  else
80  {
81  setStyleSheet("background-color:" + mOldColor.name() + ";");
82  }
83 
84  const QValidator * val = validator();
85 
86  int dummy = 0;
87 
88  QString ttt = text();
89 
90  if (val)
91  if (val->validate(ttt, dummy) == QValidator::Intermediate)
92  {
93  setStyleSheet("background-color:" + mErrorColor.name() + ";");
94  }
95 }
QColor mOldColor
Definition: MyLineEdit.h:29
QColor mErrorColor
Definition: MyLineEdit.h:31
QColor mNewColor
Definition: MyLineEdit.h:30

Member Data Documentation

QColor MyLineEdit::mErrorColor
protected

Definition at line 31 of file MyLineEdit.h.

Referenced by isValid(), setupWidget(), and updateColor().

QColor MyLineEdit::mNewColor
protected

Definition at line 30 of file MyLineEdit.h.

Referenced by setupWidget(), and updateColor().

QColor MyLineEdit::mOldColor
protected

Definition at line 29 of file MyLineEdit.h.

Referenced by setupWidget(), and updateColor().


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