Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
InputBool Class Reference

#include <inputbool.h>

Inheritance diagram for InputBool:
Input

Public Slots

void reset ()
 
void setValue (bool)
 

Signals

void changed ()
 
void toggle (QString, bool)
 
void showHelp (Input *)
 

Public Member Functions

 InputBool (QGridLayout *layout, int &row, const QString &id, bool enabled, const QString &docs)
 
QVariant & value ()
 
void update ()
 
Kind kind () const
 
QString docs () const
 
QString id () const
 
QString templateDocs () const
 
void addDependency (Input *option)
 
void setEnabled (bool)
 
void updateDependencies ()
 
void writeValue (QTextStream &t, QTextCodec *codec)
 
void setTemplateDocs (const QString &docs)
 
- Public Member Functions inherited from Input
virtual ~Input ()
 
virtual void reset ()=0
 

Private Slots

void help ()
 

Private Member Functions

void updateDefault ()
 

Private Attributes

bool m_state
 
bool m_default
 
bool m_enabled
 
QVariant m_value
 
QCheckBox * m_cb
 
QString m_docs
 
QList< Input * > m_dependencies
 
QString m_id
 
QLabel * m_lab
 
QString m_tdocs
 

Additional Inherited Members

- Public Types inherited from Input
enum  Kind {
  Bool, Int, String, StrList,
  Obsolete
}
 

Detailed Description

Definition at line 25 of file inputbool.h.

Constructor & Destructor Documentation

InputBool::InputBool ( QGridLayout *  layout,
int &  row,
const QString id,
bool  enabled,
const QString docs 
)

Definition at line 23 of file inputbool.cpp.

26  : m_default(checked), m_docs(docs), m_id(id)
27 {
28  m_lab = new HelpLabel(id);
29  m_cb = new QCheckBox;
30  layout->addWidget(m_lab,row, 0);
31  layout->addWidget(m_cb,row, 1);
32  m_enabled = true;
33  m_state=!checked; // force update
34  setValue(checked);
35  connect( m_cb, SIGNAL(toggled(bool)), SLOT(setValue(bool)) );
36  connect( m_lab, SIGNAL(enter()), SLOT(help()) );
37  connect( m_lab, SIGNAL(reset()), SLOT(reset()) );
38  row++;
39 }
QString m_docs
Definition: inputbool.h:65
void help()
Definition: inputbool.cpp:41
QLabel * m_lab
Definition: inputbool.h:68
bool m_state
Definition: inputbool.h:60
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
Definition: graph.py:30
QCheckBox * m_cb
Definition: inputbool.h:64
bool m_enabled
Definition: inputbool.h:62
void setValue(bool)
Definition: inputbool.cpp:63
bool m_default
Definition: inputbool.h:61
void reset()
Definition: inputbool.cpp:104
QString m_id
Definition: inputbool.h:67

Member Function Documentation

void InputBool::addDependency ( Input option)
inlinevirtual

Implements Input.

Definition at line 40 of file inputbool.h.

40 { m_dependencies+=option; }
QList< Input * > m_dependencies
Definition: inputbool.h:66
void InputBool::changed ( )
signal
QString InputBool::docs ( ) const
inlinevirtual

Implements Input.

Definition at line 37 of file inputbool.h.

37 { return m_docs; }
QString m_docs
Definition: inputbool.h:65
void InputBool::help ( )
privateslot

Definition at line 41 of file inputbool.cpp.

42 {
43  showHelp(this);
44 }
void showHelp(Input *)
QString InputBool::id ( ) const
inlinevirtual

Implements Input.

Definition at line 38 of file inputbool.h.

38 { return m_id; }
QString m_id
Definition: inputbool.h:67
Kind InputBool::kind ( ) const
inlinevirtual

Implements Input.

Definition at line 36 of file inputbool.h.

36 { return Bool; }
void InputBool::reset ( )
slot

Definition at line 104 of file inputbool.cpp.

105 {
107 }
void setValue(bool)
Definition: inputbool.cpp:63
bool m_default
Definition: inputbool.h:61
void InputBool::setEnabled ( bool  b)
virtual

Implements Input.

Definition at line 46 of file inputbool.cpp.

47 {
48  m_enabled = b;
49  m_cb->setEnabled(b);
50  m_lab->setEnabled(b);
51  updateDefault();
53 }
QLabel * m_lab
Definition: inputbool.h:68
QCheckBox * m_cb
Definition: inputbool.h:64
bool m_enabled
Definition: inputbool.h:62
void updateDependencies()
Definition: inputbool.cpp:55
static bool * b
Definition: config.cpp:1043
void updateDefault()
Definition: inputbool.cpp:76
void InputBool::setTemplateDocs ( const QString docs)
inlinevirtual

Implements Input.

Definition at line 44 of file inputbool.h.

44 { m_tdocs = docs; }
QString docs() const
Definition: inputbool.h:37
QString m_tdocs
Definition: inputbool.h:69
void InputBool::setValue ( bool  s)
slot

Definition at line 63 of file inputbool.cpp.

64 {
65  if (m_state!=s)
66  {
67  m_state=s;
68  updateDefault();
70  m_cb->setChecked( s );
71  m_value = m_state;
72  emit changed();
73  }
74 }
bool m_state
Definition: inputbool.h:60
QCheckBox * m_cb
Definition: inputbool.h:64
void updateDependencies()
Definition: inputbool.cpp:55
void changed()
void updateDefault()
Definition: inputbool.cpp:76
static QCString * s
Definition: config.cpp:1042
QVariant m_value
Definition: inputbool.h:63
void InputBool::showHelp ( Input )
signal
QString InputBool::templateDocs ( ) const
inlinevirtual

Implements Input.

Definition at line 39 of file inputbool.h.

39 { return m_tdocs; }
QString m_tdocs
Definition: inputbool.h:69
void InputBool::toggle ( QString  ,
bool   
)
signal
void InputBool::update ( )
virtual

Implements Input.

Definition at line 93 of file inputbool.cpp.

94 {
95  QString v = m_value.toString().toLower();
96  m_state = (v==QString::fromLatin1("yes") ||
97  v==QString::fromLatin1("true") ||
98  v==QString::fromLatin1("1"));
99  m_cb->setChecked( m_state );
100  updateDefault();
102 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
bool m_state
Definition: inputbool.h:60
QCheckBox * m_cb
Definition: inputbool.h:64
void updateDependencies()
Definition: inputbool.cpp:55
void updateDefault()
Definition: inputbool.cpp:76
QVariant m_value
Definition: inputbool.h:63
void InputBool::updateDefault ( )
private

Definition at line 76 of file inputbool.cpp.

77 {
78  if (m_state==m_default || !m_lab->isEnabled())
79  {
80  m_lab->setText(QString::fromLatin1("<qt>")+m_id+QString::fromLatin1("</qt"));
81  }
82  else
83  {
84  m_lab->setText(QString::fromLatin1("<qt><font color='red'>")+m_id+QString::fromLatin1("</font></qt>"));
85  }
86 }
QLabel * m_lab
Definition: inputbool.h:68
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
bool m_state
Definition: inputbool.h:60
bool m_default
Definition: inputbool.h:61
QString m_id
Definition: inputbool.h:67
void InputBool::updateDependencies ( )
virtual

Implements Input.

Definition at line 55 of file inputbool.cpp.

56 {
57  for (int i=0;i<m_dependencies.count();i++)
58  {
59  m_dependencies[i]->setEnabled(m_enabled && m_state);
60  }
61 }
bool m_state
Definition: inputbool.h:60
bool m_enabled
Definition: inputbool.h:62
uint count() const
Definition: qlist.h:66
QList< Input * > m_dependencies
Definition: inputbool.h:66
QVariant & InputBool::value ( )
virtual

Implements Input.

Definition at line 88 of file inputbool.cpp.

89 {
90  return m_value;
91 }
QVariant m_value
Definition: inputbool.h:63
void InputBool::writeValue ( QTextStream t,
QTextCodec codec 
)
virtual

Implements Input.

Definition at line 109 of file inputbool.cpp.

110 {
111  if (m_state)
112  t << codec->fromUnicode(QString::fromLatin1("YES"));
113  else
114  t << codec->fromUnicode(QString::fromLatin1("NO"));
115 }
virtual QCString fromUnicode(const QString &uc, int &lenInOut) const
Definition: qtextcodec.cpp:783
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
bool m_state
Definition: inputbool.h:60

Member Data Documentation

QCheckBox* InputBool::m_cb
private

Definition at line 64 of file inputbool.h.

bool InputBool::m_default
private

Definition at line 61 of file inputbool.h.

QList<Input*> InputBool::m_dependencies
private

Definition at line 66 of file inputbool.h.

QString InputBool::m_docs
private

Definition at line 65 of file inputbool.h.

bool InputBool::m_enabled
private

Definition at line 62 of file inputbool.h.

QString InputBool::m_id
private

Definition at line 67 of file inputbool.h.

QLabel* InputBool::m_lab
private

Definition at line 68 of file inputbool.h.

bool InputBool::m_state
private

Definition at line 60 of file inputbool.h.

QString InputBool::m_tdocs
private

Definition at line 69 of file inputbool.h.

QVariant InputBool::m_value
private

Definition at line 63 of file inputbool.h.


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