DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ValidatorComboBox.cpp
Go to the documentation of this file.
1
2#include <QApplication>
6
8 : QComboBox ( parent ),
9 Valid ( false ),
10 ValueChanged ( false )
11{
12 connect ( this, SIGNAL ( editTextChanged ( const QString & ) ), this,
13 SLOT ( TryValidate ( const QString & ) ) );
14 connect ( this, SIGNAL ( activated ( const QString & ) ), this,
15 SLOT ( ChangeDetected ( const QString & ) ) );
16 connect ( this, SIGNAL ( currentIndexChanged ( int ) ), this,
17 SLOT ( CheckDefaults ( int ) ) );
18}
19
23
25{
26 return Valid;
27}
28
30{
31 return ValueChanged;
32}
33
35{
36 DataList.clear();
37 DataList << currentText();
38 return DataList;
39}
40
41void dbe::ValidatorComboBox::wheelEvent ( QWheelEvent * event )
42{
43 ( void ) event;
44 return;
45}
46
47void dbe::ValidatorComboBox::TryValidate ( const QString & ValidateString )
48{
49 QString Tmp = ValidateString;
50 int index = 0;
51
52 if ( this->validator() != nullptr )
53 {
54 if ( this->validator()->validate ( Tmp, index ) == QValidator::Acceptable )
55 {
56 Valid = true;
57
58 if ( CompareDefaults() )
59 {
60 this->setPalette ( StyleUtility::LoadedDefault );
61 }
62 else
63 {
64 this->setPalette ( QApplication::palette ( this ) );
65 }
66 }
67 else if ( this->validator()->validate ( Tmp, index ) == QValidator::Intermediate )
68 {
69 Valid = false;
70 this->setPalette ( StyleUtility::WarningStatusBarPallete );
71 }
72 }
73 else
74 {
75 if ( CompareDefaults() )
76 {
77 this->setPalette ( StyleUtility::LoadedDefault );
78 }
79 else
80 {
81 this->setPalette ( QApplication::palette ( this ) );
82 }
83 }
84}
85
86void dbe::ValidatorComboBox::ChangeDetected ( const QString & StringChange )
87{
88 Q_UNUSED ( StringChange )
89 ValueChanged = true;
90 emit ValueWasChanged();
91}
92
94{
95 Q_UNUSED ( DefaultIndex )
96
97 if ( !Default.isEmpty() )
98 {
99 TryValidate ( this->currentText() );
100 }
101}
102
104{
105 if ( Default.isEmpty() )
106 {
107 return false;
108 }
109
110 if ( Default == this->currentText() )
111 {
112 return true;
113 }
114
115 return false;
116}
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)