Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
doxygen-1.8.11
addon
doxywizard
inputbool.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
*
4
*
5
* Copyright (C) 1997-2015 by Dimitri van Heesch.
6
*
7
* Permission to use, copy, modify, and distribute this software and its
8
* documentation under the terms of the GNU General Public License is hereby
9
* granted. No representations are made about the suitability of this software
10
* for any purpose. It is provided "as is" without express or implied warranty.
11
* See the GNU General Public License for more details.
12
*
13
*/
14
15
#include "
inputbool.h
"
16
#include "
helplabel.h
"
17
18
#include <QCheckBox>
19
#include <QTextStream>
20
#include <QTextCodec>
21
#include <QGridLayout>
22
23
InputBool::InputBool
( QGridLayout *layout,
int
&
row
,
24
const
QString
&
id
,
bool
checked,
25
const
QString
&docs )
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
}
40
41
void
InputBool::help
()
42
{
43
showHelp
(
this
);
44
}
45
46
void
InputBool::setEnabled
(
bool
b
)
47
{
48
m_enabled
=
b
;
49
m_cb
->setEnabled(b);
50
m_lab
->setEnabled(b);
51
updateDefault
();
52
updateDependencies
();
53
}
54
55
void
InputBool::updateDependencies
()
56
{
57
for
(
int
i=0;i<
m_dependencies
.
count
();i++)
58
{
59
m_dependencies
[i]->setEnabled(
m_enabled
&&
m_state
);
60
}
61
}
62
63
void
InputBool::setValue
(
bool
s
)
64
{
65
if
(
m_state
!=s)
66
{
67
m_state
=
s
;
68
updateDefault
();
69
updateDependencies
();
70
m_cb
->setChecked( s );
71
m_value
=
m_state
;
72
emit
changed
();
73
}
74
}
75
76
void
InputBool::updateDefault
()
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
}
87
88
QVariant &
InputBool::value
()
89
{
90
return
m_value
;
91
}
92
93
void
InputBool::update
()
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
();
101
updateDependencies
();
102
}
103
104
void
InputBool::reset
()
105
{
106
setValue
(
m_default
);
107
}
108
109
void
InputBool::writeValue
(
QTextStream
&
t
,
QTextCodec
*codec)
110
{
111
if
(
m_state
)
112
t << codec->
fromUnicode
(
QString::fromLatin1
(
"YES"
));
113
else
114
t << codec->
fromUnicode
(
QString::fromLatin1
(
"NO"
));
115
}
116
InputBool::setEnabled
void setEnabled(bool)
Definition:
inputbool.cpp:46
InputBool::help
void help()
Definition:
inputbool.cpp:41
QTextCodec::fromUnicode
virtual QCString fromUnicode(const QString &uc, int &lenInOut) const
Definition:
qtextcodec.cpp:783
muoncounters.row
row
Definition:
muoncounters.py:36
QString
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition:
qstring.h:350
InputBool::m_lab
QLabel * m_lab
Definition:
inputbool.h:68
QString::fromLatin1
static QString fromLatin1(const char *, int len=-1)
Definition:
qstring.cpp:14539
InputBool::m_state
bool m_state
Definition:
inputbool.h:60
wirecell.dfp.graph.connect
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
Definition:
graph.py:30
InputBool::m_cb
QCheckBox * m_cb
Definition:
inputbool.h:64
InputBool::m_enabled
bool m_enabled
Definition:
inputbool.h:62
InputBool::writeValue
void writeValue(QTextStream &t, QTextCodec *codec)
Definition:
inputbool.cpp:109
InputBool::value
QVariant & value()
Definition:
inputbool.cpp:88
QList::count
uint count() const
Definition:
qlist.h:66
InputBool::setValue
void setValue(bool)
Definition:
inputbool.cpp:63
inputbool.h
reco_momentum_tuples.t
t
Definition:
reco_momentum_tuples.py:25
InputBool::updateDependencies
void updateDependencies()
Definition:
inputbool.cpp:55
InputBool::changed
void changed()
helplabel.h
InputBool::update
void update()
Definition:
inputbool.cpp:93
InputBool::showHelp
void showHelp(Input *)
QTextStream
The QTextStream class provides basic functions for reading and writing text using a QIODevice...
Definition:
qtextstream.h:53
InputBool::m_dependencies
QList< Input * > m_dependencies
Definition:
inputbool.h:66
InputBool::m_default
bool m_default
Definition:
inputbool.h:61
InputBool::reset
void reset()
Definition:
inputbool.cpp:104
HelpLabel
Definition:
helplabel.h:7
b
static bool * b
Definition:
config.cpp:1043
InputBool::m_id
QString m_id
Definition:
inputbool.h:67
InputBool::updateDefault
void updateDefault()
Definition:
inputbool.cpp:76
QTextCodec
Provides conversion between text encodings.
Definition:
qtextcodec.h:62
s
static QCString * s
Definition:
config.cpp:1042
InputBool::m_value
QVariant m_value
Definition:
inputbool.h:63
InputBool::InputBool
InputBool(QGridLayout *layout, int &row, const QString &id, bool enabled, const QString &docs)
Definition:
inputbool.cpp:23
Generated by
1.8.11