DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::CustomLineEdit Class Reference

#include <CustomLineEdit.hpp>

Inheritance diagram for dbe::CustomLineEdit:
[legend]
Collaboration diagram for dbe::CustomLineEdit:
[legend]

Public Slots

void TryValidate (QString Dummy)
void EmitDecSlot ()
void EmitOctSlot ()
void EmitHexSlot ()

Signals

void StringValidated ()
void ValueChanged ()
void DecChange ()
void HexChange ()
void OctChange ()

Public Member Functions

 CustomLineEdit (QWidget *parent=0, bool IsNull=true, bool IsMulti=false)
 Include Qt Headers.
 ~CustomLineEdit ()
void SetNullCheck (bool IsNull)
void SetMultiCheck (bool IsMulti)
bool IsNullCheck ()
bool IsValid ()
void SetCheckDefault (bool Default)
void SetDefaultValue (QString ValueDefault)
void ValidateText ()
void SetLoadedDefaultFlag (bool Loaded)
void SetValidator (QValidator *ValidatorSet)
void SetPopupMenu ()
void CreateActions ()

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *Event)

Private Attributes

bool Valid
bool NullCheck
bool CheckDefault
bool PopupMenu
bool IsMultiValue
QMenu * ContextMenu
QAction * Dec
QAction * Oct
QAction * Hex
QValidator * Validator
QString DefaultValue

Detailed Description

Definition at line 14 of file CustomLineEdit.hpp.

Constructor & Destructor Documentation

◆ CustomLineEdit()

dbe::CustomLineEdit::CustomLineEdit ( QWidget * parent = 0,
bool IsNull = true,
bool IsMulti = false )
explicit

Include Qt Headers.

Include DBE

Definition at line 15 of file CustomLineEdit.cpp.

16 : QLineEdit ( parent ),
17 Valid ( false ),
18 NullCheck ( IsNull ),
19 CheckDefault ( true ),
20 PopupMenu ( false ),
21 IsMultiValue ( IsMulti ),
22 ContextMenu ( nullptr ),
23 Dec ( nullptr ),
24 Oct ( nullptr ),
25 Hex ( nullptr ),
26 Validator ( nullptr )
27{
28 connect ( this, SIGNAL ( textChanged ( QString ) ), this,
29 SLOT ( TryValidate ( QString ) ) );
30 this->setFixedHeight ( 30 );
31 //this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
32}
void TryValidate(QString Dummy)

◆ ~CustomLineEdit()

dbe::CustomLineEdit::~CustomLineEdit ( )

Definition at line 34 of file CustomLineEdit.cpp.

35{
36 if ( Validator != nullptr )
37 {
38 delete Validator;
39 }
40}

Member Function Documentation

◆ contextMenuEvent()

void dbe::CustomLineEdit::contextMenuEvent ( QContextMenuEvent * Event)
protected

Definition at line 198 of file CustomLineEdit.cpp.

199{
200 if ( !PopupMenu )
201 {
202 return;
203 }
204
205 if ( ContextMenu == nullptr )
206 {
207 ContextMenu = new QMenu ( this );
209 }
210
211 ContextMenu->exec ( Event->globalPos() );
212}

◆ CreateActions()

void dbe::CustomLineEdit::CreateActions ( )

Definition at line 98 of file CustomLineEdit.cpp.

99{
100 Dec = new QAction ( tr ( "Dec" ), this );
101 Dec->setShortcutContext ( Qt::WidgetShortcut );
102 connect ( Dec, SIGNAL ( triggered() ), this, SLOT ( EmitDecSlot() ) );
103 Dec->setCheckable ( true );
104 Dec->setChecked ( false );
105 ContextMenu->addAction ( Dec );
106
107 Oct = new QAction ( tr ( "Oct" ), this );
108 Oct->setShortcutContext ( Qt::WidgetShortcut );
109 connect ( Oct, SIGNAL ( triggered() ), this, SLOT ( EmitOctSlot() ) );
110 Oct->setCheckable ( true );
111 Oct->setChecked ( false );
112 ContextMenu->addAction ( Oct );
113
114 Hex = new QAction ( tr ( "Hex" ), this );
115 Hex->setShortcutContext ( Qt::WidgetShortcut );
116 Hex->setCheckable ( true );
117 Hex->setChecked ( false );
118 connect ( Hex, SIGNAL ( triggered() ), this, SLOT ( EmitHexSlot() ) );
119 ContextMenu->addAction ( Hex );
120}

◆ DecChange

void dbe::CustomLineEdit::DecChange ( )
signal

◆ EmitDecSlot

void dbe::CustomLineEdit::EmitDecSlot ( )
slot

Definition at line 174 of file CustomLineEdit.cpp.

175{
176 Dec->setChecked ( true );
177 Oct->setChecked ( false );
178 Hex->setChecked ( false );
179 emit DecChange();
180}

◆ EmitHexSlot

void dbe::CustomLineEdit::EmitHexSlot ( )
slot

Definition at line 190 of file CustomLineEdit.cpp.

191{
192 Dec->setChecked ( false );
193 Oct->setChecked ( false );
194 Hex->setChecked ( true );
195 emit HexChange();
196}

◆ EmitOctSlot

void dbe::CustomLineEdit::EmitOctSlot ( )
slot

Definition at line 182 of file CustomLineEdit.cpp.

183{
184 Dec->setChecked ( false );
185 Oct->setChecked ( true );
186 Hex->setChecked ( false );
187 emit OctChange();
188}

◆ HexChange

void dbe::CustomLineEdit::HexChange ( )
signal

◆ IsNullCheck()

bool dbe::CustomLineEdit::IsNullCheck ( )

Definition at line 57 of file CustomLineEdit.cpp.

58{
59 return NullCheck;
60}

◆ IsValid()

bool dbe::CustomLineEdit::IsValid ( )

Definition at line 62 of file CustomLineEdit.cpp.

63{
64 return Valid;
65}

◆ OctChange

void dbe::CustomLineEdit::OctChange ( )
signal

◆ SetCheckDefault()

void dbe::CustomLineEdit::SetCheckDefault ( bool Default)

Definition at line 67 of file CustomLineEdit.cpp.

68{
69 CheckDefault = Default;
70}

◆ SetDefaultValue()

void dbe::CustomLineEdit::SetDefaultValue ( QString ValueDefault)

Definition at line 72 of file CustomLineEdit.cpp.

73{
74 DefaultValue = ValueDefault;
75}

◆ SetLoadedDefaultFlag()

void dbe::CustomLineEdit::SetLoadedDefaultFlag ( bool Loaded)

Definition at line 83 of file CustomLineEdit.cpp.

84{
85 setProperty ( "loadedDefaults", Loaded );
86}

◆ SetMultiCheck()

void dbe::CustomLineEdit::SetMultiCheck ( bool IsMulti)

Definition at line 52 of file CustomLineEdit.cpp.

53{
54 IsMultiValue = IsMulti;
55}

◆ SetNullCheck()

void dbe::CustomLineEdit::SetNullCheck ( bool IsNull)

Definition at line 42 of file CustomLineEdit.cpp.

43{
44 NullCheck = IsNull;
45
46 if ( NullCheck == false )
47 {
48 setPalette ( QApplication::palette ( this ) );
49 }
50}

◆ SetPopupMenu()

void dbe::CustomLineEdit::SetPopupMenu ( )

Definition at line 93 of file CustomLineEdit.cpp.

94{
95 PopupMenu = true;
96}

◆ SetValidator()

void dbe::CustomLineEdit::SetValidator ( QValidator * ValidatorSet)

Definition at line 88 of file CustomLineEdit.cpp.

89{
90 Validator = ValidatorSet;
91}

◆ StringValidated

void dbe::CustomLineEdit::StringValidated ( )
signal

◆ TryValidate

void dbe::CustomLineEdit::TryValidate ( QString Dummy)
slot

Definition at line 122 of file CustomLineEdit.cpp.

123{
124 Q_UNUSED ( Dummy )
125
126 QString tmp_st = this->text();
127 int i = 0;
128
129 if ( tmp_st.isEmpty() && NullCheck )
130 {
131 Valid = false;
132
133 if ( !IsMultiValue )
134 {
135 this->setPalette ( StyleUtility::WarningStatusBarPallete );
136 setToolTip ( QString ( "Field cannot be empty!" ) );
137 }
138
139 emit StringValidated(); // it is caught by EditStringAttrWidget
140 }
141 else if ( Validator != 0 )
142 {
143 if ( ( Validator->validate ( tmp_st, i ) ) == QValidator::Acceptable )
144 {
145 Valid = true;
146 this->setPalette ( QApplication::palette ( this ) );
147 setToolTip ( QString ( "This new object ID is unique" ) );
148 }
149 else if ( ( Validator->validate ( tmp_st, i ) ) == QValidator::Intermediate )
150 {
151 Valid = false;
152 this->setPalette ( StyleUtility::AlertStatusBarPallete );
153 setToolTip ( QString ( "This UID is already used" ) );
154 }
155 }
156 else if ( Validator == 0 )
157 {
158 Valid = true;
159 setPalette ( QApplication::palette ( this ) );
160
161 if ( tmp_st == DefaultValue && CheckDefault )
162 {
163 this->setPalette ( StyleUtility::LoadedDefault );
164 }
165 else
166 {
167 this->setPalette ( QApplication::palette ( this ) );
168 }
169
170 emit StringValidated();
171 }
172}
static QPalette AlertStatusBarPallete
static QPalette LoadedDefault
static QPalette WarningStatusBarPallete

◆ ValidateText()

void dbe::CustomLineEdit::ValidateText ( )

Definition at line 77 of file CustomLineEdit.cpp.

78{
79 QString Dummy ( "Dummy" );
80 TryValidate ( Dummy );
81}

◆ ValueChanged

void dbe::CustomLineEdit::ValueChanged ( )
signal

Member Data Documentation

◆ CheckDefault

bool dbe::CustomLineEdit::CheckDefault
private

Definition at line 47 of file CustomLineEdit.hpp.

◆ ContextMenu

QMenu* dbe::CustomLineEdit::ContextMenu
private

Definition at line 50 of file CustomLineEdit.hpp.

◆ Dec

QAction* dbe::CustomLineEdit::Dec
private

Definition at line 51 of file CustomLineEdit.hpp.

◆ DefaultValue

QString dbe::CustomLineEdit::DefaultValue
private

Definition at line 55 of file CustomLineEdit.hpp.

◆ Hex

QAction* dbe::CustomLineEdit::Hex
private

Definition at line 53 of file CustomLineEdit.hpp.

◆ IsMultiValue

bool dbe::CustomLineEdit::IsMultiValue
private

Definition at line 49 of file CustomLineEdit.hpp.

◆ NullCheck

bool dbe::CustomLineEdit::NullCheck
private

Definition at line 46 of file CustomLineEdit.hpp.

◆ Oct

QAction* dbe::CustomLineEdit::Oct
private

Definition at line 52 of file CustomLineEdit.hpp.

◆ PopupMenu

bool dbe::CustomLineEdit::PopupMenu
private

Definition at line 48 of file CustomLineEdit.hpp.

◆ Valid

bool dbe::CustomLineEdit::Valid
private

Definition at line 45 of file CustomLineEdit.hpp.

◆ Validator

QValidator* dbe::CustomLineEdit::Validator
private

Definition at line 54 of file CustomLineEdit.hpp.


The documentation for this class was generated from the following files: