Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
doxygen-1.8.11
addon
doxywizard
inputint.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 "
inputint.h
"
16
#include "
helplabel.h
"
17
18
#include <QSpinBox>
19
#include <QGridLayout>
20
#include <QWheelEvent>
21
#include <QTextStream>
22
23
class
NoWheelSpinBox
:
public
QSpinBox
24
{
25
protected
:
26
void
wheelEvent
(QWheelEvent *
e
)
27
{
28
e->ignore();
29
}
30
};
31
32
InputInt::InputInt
( QGridLayout *layout,
int
&
row
,
33
const
QString
&
id
,
34
int
defVal,
int
minVal,
int
maxVal,
35
const
QString
& docs )
36
: m_default(defVal), m_minVal(minVal), m_maxVal(maxVal), m_docs(docs), m_id(id)
37
{
38
m_lab
=
new
HelpLabel
(
id
);
39
m_sp
=
new
NoWheelSpinBox
;
40
m_sp
->setMinimum(minVal);
41
m_sp
->setMaximum(maxVal);
42
m_sp
->setSingleStep(1);
43
m_val
=defVal-1;
// force update
44
setValue
(defVal);
45
46
layout->addWidget(
m_lab
, row, 0 );
47
layout->addWidget(
m_sp
, row, 1 );
48
49
connect
(
m_sp
, SIGNAL(valueChanged(
int
)),
50
this
, SLOT(
setValue
(
int
)) );
51
connect
(
m_lab
, SIGNAL(enter()), SLOT(
help
()) );
52
connect
(
m_lab
, SIGNAL(
reset
()), SLOT(
reset
()) );
53
row++;
54
}
55
56
void
InputInt::help
()
57
{
58
showHelp
(
this
);
59
}
60
61
62
void
InputInt::setValue
(
int
val
)
63
{
64
val = qMax(
m_minVal
,val);
65
val = qMin(
m_maxVal
,val);
66
if
(val!=
m_val
)
67
{
68
m_val
=
val
;
69
m_sp
->setValue(val);
70
m_value
=
m_val
;
71
updateDefault
();
72
}
73
}
74
75
void
InputInt::updateDefault
()
76
{
77
{
78
if
(
m_val
==
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
emit
changed
();
87
}
88
}
89
90
void
InputInt::setEnabled
(
bool
state)
91
{
92
m_lab
->setEnabled(state);
93
m_sp
->setEnabled(state);
94
updateDefault
();
95
}
96
97
QVariant &
InputInt::value
()
98
{
99
return
m_value
;
100
}
101
102
void
InputInt::update
()
103
{
104
setValue
(
m_value
.toInt());
105
}
106
107
void
InputInt::reset
()
108
{
109
setValue
(
m_default
);
110
}
111
112
void
InputInt::writeValue
(
QTextStream
&
t
,
QTextCodec
*)
113
{
114
t <<
m_val
;
115
}
116
InputInt::m_maxVal
int m_maxVal
Definition:
inputint.h:67
InputInt::writeValue
void writeValue(QTextStream &t, QTextCodec *codec)
Definition:
inputint.cpp:112
val
Definition:
registry_via_id_test_2.cc:15
InputInt::value
QVariant & value()
Definition:
inputint.cpp:97
InputInt::reset
void reset()
Definition:
inputint.cpp:107
InputInt::setEnabled
void setEnabled(bool)
Definition:
inputint.cpp:90
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
inputint.h
QString::fromLatin1
static QString fromLatin1(const char *, int len=-1)
Definition:
qstring.cpp:14539
InputInt::m_value
QVariant m_value
Definition:
inputint.h:68
InputInt::m_sp
QSpinBox * m_sp
Definition:
inputint.h:63
wirecell.dfp.graph.connect
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
Definition:
graph.py:30
InputInt::showHelp
void showHelp(Input *)
e
const double e
Definition:
gUpMuFluxGen.cxx:165
InputInt::updateDefault
void updateDefault()
Definition:
inputint.cpp:75
reco_momentum_tuples.t
t
Definition:
reco_momentum_tuples.py:25
InputInt::m_id
QString m_id
Definition:
inputint.h:70
InputInt::m_minVal
int m_minVal
Definition:
inputint.h:66
helplabel.h
InputInt::m_default
int m_default
Definition:
inputint.h:65
testsqlite3.val
list val
Definition:
testsqlite3.py:13
QTextStream
The QTextStream class provides basic functions for reading and writing text using a QIODevice...
Definition:
qtextstream.h:53
InputInt::changed
void changed()
InputInt::m_lab
QLabel * m_lab
Definition:
inputint.h:62
HelpLabel
Definition:
helplabel.h:7
InputInt::m_val
int m_val
Definition:
inputint.h:64
NoWheelSpinBox::wheelEvent
void wheelEvent(QWheelEvent *e)
Definition:
inputint.cpp:26
InputInt::help
void help()
Definition:
inputint.cpp:56
QTextCodec
Provides conversion between text encodings.
Definition:
qtextcodec.h:62
InputInt::update
void update()
Definition:
inputint.cpp:102
NoWheelSpinBox
Definition:
inputint.cpp:23
InputInt::InputInt
InputInt(QGridLayout *layout, int &row, const QString &id, int defVal, int minVal, int maxVal, const QString &docs)
Definition:
inputint.cpp:32
InputInt::setValue
void setValue(int val)
Definition:
inputint.cpp:62
Generated by
1.8.11