DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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>
11
13 : QComboBox(parent)
14 , Valid(false)
15 , ValueChanged(false)
16{
17 connect(this, SIGNAL(editTextChanged(const QString&)), this, SLOT(TryValidate(const QString&)));
18 connect(this, SIGNAL(activated(const QString&)), this, SLOT(ChangeDetected(const QString&)));
19 connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(CheckDefaults(int)));
20}
21
23
24bool
26{
27 return Valid;
28}
29
30bool
35
36QStringList
38{
39 DataList.clear();
40 DataList << currentText();
41 return DataList;
42}
43
44void
46{
47 (void)event;
48 return;
49}
50
51void
52dbe::ValidatorComboBox::TryValidate(const QString& ValidateString)
53{
54 QString Tmp = ValidateString;
55 int index = 0;
56
57 if (this->validator() != nullptr) {
58 if (this->validator()->validate(Tmp, index) == QValidator::Acceptable) {
59 Valid = true;
60
61 if (CompareDefaults()) {
62 this->setPalette(StyleUtility::LoadedDefault);
63 } else {
64 this->setPalette(QApplication::palette(this));
65 }
66 } else if (this->validator()->validate(Tmp, index) == QValidator::Intermediate) {
67 Valid = false;
69 }
70 } else {
71 if (CompareDefaults()) {
72 this->setPalette(StyleUtility::LoadedDefault);
73 } else {
74 this->setPalette(QApplication::palette(this));
75 }
76 }
77}
78
79void
80dbe::ValidatorComboBox::ChangeDetected(const QString& StringChange)
81{
82 Q_UNUSED(StringChange)
83 ValueChanged = true;
84 emit ValueWasChanged();
85}
86
87void
89{
90 Q_UNUSED(DefaultIndex)
91
92 if (!Default.isEmpty()) {
93 TryValidate(this->currentText());
94 }
95}
96
97bool
99{
100 if (Default.isEmpty()) {
101 return false;
102 }
103
104 if (Default == this->currentText()) {
105 return true;
106 }
107
108 return false;
109}
static QPalette LoadedDefault
static QPalette WarningStatusBarPallete
void ChangeDetected(const QString &StringChange)
void wheelEvent(QWheelEvent *e)
void CheckDefaults(int Default)
ValidatorComboBox(QWidget *parent=nullptr)
Including QT Headers.
void TryValidate(const QString &ValidateString)