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>
10#include "dbe/StyleUtility.hpp"
11
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
28
30{
31 return Valid;
32}
33
35{
36 return ValueChanged;
37}
38
40{
41 DataList.clear();
42 DataList << currentText();
43 return DataList;
44}
45
46void dbe::ValidatorComboBox::wheelEvent ( QWheelEvent * event )
47{
48 ( void ) event;
49 return;
50}
51
52void 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
91void dbe::ValidatorComboBox::ChangeDetected ( const QString & StringChange )
92{
93 Q_UNUSED ( StringChange )
94 ValueChanged = true;
95 emit ValueWasChanged();
96}
97
99{
100 Q_UNUSED ( DefaultIndex )
101
102 if ( !Default.isEmpty() )
103 {
104 TryValidate ( this->currentText() );
105 }
106}
107
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}
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)