DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
src
object
ValidatorComboBox.cpp
Go to the documentation of this file.
1
// DUNE DAQ modification notice:
2
// This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3
// Fork baseline commit: dbe-02-12-17 (2022-05-12).
4
// Renamed since fork: no.
5
7
#include <QApplication>
9
#include "
dbe/ValidatorComboBox.hpp
"
10
#include "
dbe/StyleUtility.hpp
"
11
12
dbe::ValidatorComboBox::ValidatorComboBox
( QWidget * parent )
13
: QComboBox ( parent ),
14
Valid
( false ),
15
ValueChanged
( false )
16
{
17
connect (
this
, SIGNAL ( editTextChanged (
const
QString & ) ),
this
,
18
SLOT (
TryValidate
(
const
QString & ) ) );
19
connect (
this
, SIGNAL ( activated (
const
QString & ) ),
this
,
20
SLOT (
ChangeDetected
(
const
QString & ) ) );
21
connect (
this
, SIGNAL ( currentIndexChanged (
int
) ),
this
,
22
SLOT (
CheckDefaults
(
int
) ) );
23
}
24
25
dbe::ValidatorComboBox::~ValidatorComboBox
()
26
{
27
}
28
29
bool
dbe::ValidatorComboBox::IsValid
()
const
30
{
31
return
Valid
;
32
}
33
34
bool
dbe::ValidatorComboBox::IsChanged
()
const
35
{
36
return
ValueChanged
;
37
}
38
39
QStringList
dbe::ValidatorComboBox::GetDataList
()
40
{
41
DataList
.clear();
42
DataList
<< currentText();
43
return
DataList
;
44
}
45
46
void
dbe::ValidatorComboBox::wheelEvent
( QWheelEvent * event )
47
{
48
( void ) event;
49
return
;
50
}
51
52
void
dbe::ValidatorComboBox::TryValidate
(
const
QString & ValidateString )
53
{
54
QString Tmp = ValidateString;
55
int
index = 0;
56
57
if
( this->validator() !=
nullptr
)
58
{
59
if
( this->validator()->
validate
( Tmp, index ) == QValidator::Acceptable )
60
{
61
Valid
=
true
;
62
63
if
(
CompareDefaults
() )
64
{
65
this->setPalette (
StyleUtility::LoadedDefault
);
66
}
67
else
68
{
69
this->setPalette ( QApplication::palette (
this
) );
70
}
71
}
72
else
if
( this->validator()->
validate
( Tmp, index ) == QValidator::Intermediate )
73
{
74
Valid
=
false
;
75
this->setPalette (
StyleUtility::WarningStatusBarPallete
);
76
}
77
}
78
else
79
{
80
if
(
CompareDefaults
() )
81
{
82
this->setPalette (
StyleUtility::LoadedDefault
);
83
}
84
else
85
{
86
this->setPalette ( QApplication::palette (
this
) );
87
}
88
}
89
}
90
91
void
dbe::ValidatorComboBox::ChangeDetected
(
const
QString & StringChange )
92
{
93
Q_UNUSED ( StringChange )
94
ValueChanged
=
true
;
95
emit
ValueWasChanged
();
96
}
97
98
void
dbe::ValidatorComboBox::CheckDefaults
(
int
DefaultIndex )
99
{
100
Q_UNUSED ( DefaultIndex )
101
102
if
( !
Default
.isEmpty() )
103
{
104
TryValidate
( this->currentText() );
105
}
106
}
107
108
bool
dbe::ValidatorComboBox::CompareDefaults
()
109
{
110
if
(
Default
.isEmpty() )
111
{
112
return
false
;
113
}
114
115
if
(
Default
== this->currentText() )
116
{
117
return
true
;
118
}
119
120
return
false
;
121
}
StyleUtility.hpp
ValidatorComboBox.hpp
dbe::StyleUtility::LoadedDefault
static QPalette LoadedDefault
Definition
StyleUtility.hpp:34
dbe::StyleUtility::WarningStatusBarPallete
static QPalette WarningStatusBarPallete
Definition
StyleUtility.hpp:31
dbe::ValidatorComboBox::IsChanged
bool IsChanged() const
Definition
ValidatorComboBox.cpp:34
dbe::ValidatorComboBox::ChangeDetected
void ChangeDetected(const QString &StringChange)
Definition
ValidatorComboBox.cpp:91
dbe::ValidatorComboBox::Default
QString Default
Definition
ValidatorComboBox.hpp:25
dbe::ValidatorComboBox::IsValid
bool IsValid() const
Definition
ValidatorComboBox.cpp:29
dbe::ValidatorComboBox::wheelEvent
void wheelEvent(QWheelEvent *e)
Definition
ValidatorComboBox.cpp:46
dbe::ValidatorComboBox::ValueWasChanged
void ValueWasChanged()
dbe::ValidatorComboBox::CheckDefaults
void CheckDefaults(int Default)
Definition
ValidatorComboBox.cpp:98
dbe::ValidatorComboBox::~ValidatorComboBox
~ValidatorComboBox()
Definition
ValidatorComboBox.cpp:25
dbe::ValidatorComboBox::Valid
bool Valid
Definition
ValidatorComboBox.hpp:26
dbe::ValidatorComboBox::DataList
QStringList DataList
Definition
ValidatorComboBox.hpp:24
dbe::ValidatorComboBox::ValueChanged
bool ValueChanged
Definition
ValidatorComboBox.hpp:27
dbe::ValidatorComboBox::ValidatorComboBox
ValidatorComboBox(QWidget *parent=nullptr)
Including QT Headers.
Definition
ValidatorComboBox.cpp:12
dbe::ValidatorComboBox::GetDataList
QStringList GetDataList()
Definition
ValidatorComboBox.cpp:39
dbe::ValidatorComboBox::TryValidate
void TryValidate(const QString &ValidateString)
Definition
ValidatorComboBox.cpp:52
dbe::ValidatorComboBox::CompareDefaults
bool CompareDefaults()
Definition
ValidatorComboBox.cpp:108
validate
Definition
validate.py:1
Generated on
for DUNE-DAQ by
1.17.0