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 9 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 10 of file CustomLineEdit.cpp.

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

◆ ~CustomLineEdit()

dbe::CustomLineEdit::~CustomLineEdit ( )

Definition at line 29 of file CustomLineEdit.cpp.

30{
31 if ( Validator != nullptr )
32 {
33 delete Validator;
34 }
35}

Member Function Documentation

◆ contextMenuEvent()

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

Definition at line 193 of file CustomLineEdit.cpp.

194{
195 if ( !PopupMenu )
196 {
197 return;
198 }
199
200 if ( ContextMenu == nullptr )
201 {
202 ContextMenu = new QMenu ( this );
204 }
205
206 ContextMenu->exec ( Event->globalPos() );
207}

◆ CreateActions()

void dbe::CustomLineEdit::CreateActions ( )

Definition at line 93 of file CustomLineEdit.cpp.

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

◆ DecChange

void dbe::CustomLineEdit::DecChange ( )
signal

◆ EmitDecSlot

void dbe::CustomLineEdit::EmitDecSlot ( )
slot

Definition at line 169 of file CustomLineEdit.cpp.

170{
171 Dec->setChecked ( true );
172 Oct->setChecked ( false );
173 Hex->setChecked ( false );
174 emit DecChange();
175}

◆ EmitHexSlot

void dbe::CustomLineEdit::EmitHexSlot ( )
slot

Definition at line 185 of file CustomLineEdit.cpp.

186{
187 Dec->setChecked ( false );
188 Oct->setChecked ( false );
189 Hex->setChecked ( true );
190 emit HexChange();
191}

◆ EmitOctSlot

void dbe::CustomLineEdit::EmitOctSlot ( )
slot

Definition at line 177 of file CustomLineEdit.cpp.

178{
179 Dec->setChecked ( false );
180 Oct->setChecked ( true );
181 Hex->setChecked ( false );
182 emit OctChange();
183}

◆ HexChange

void dbe::CustomLineEdit::HexChange ( )
signal

◆ IsNullCheck()

bool dbe::CustomLineEdit::IsNullCheck ( )

Definition at line 52 of file CustomLineEdit.cpp.

53{
54 return NullCheck;
55}

◆ IsValid()

bool dbe::CustomLineEdit::IsValid ( )

Definition at line 57 of file CustomLineEdit.cpp.

58{
59 return Valid;
60}

◆ OctChange

void dbe::CustomLineEdit::OctChange ( )
signal

◆ SetCheckDefault()

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

Definition at line 62 of file CustomLineEdit.cpp.

63{
64 CheckDefault = Default;
65}

◆ SetDefaultValue()

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

Definition at line 67 of file CustomLineEdit.cpp.

68{
69 DefaultValue = ValueDefault;
70}

◆ SetLoadedDefaultFlag()

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

Definition at line 78 of file CustomLineEdit.cpp.

79{
80 setProperty ( "loadedDefaults", Loaded );
81}

◆ SetMultiCheck()

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

Definition at line 47 of file CustomLineEdit.cpp.

48{
49 IsMultiValue = IsMulti;
50}

◆ SetNullCheck()

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

Definition at line 37 of file CustomLineEdit.cpp.

38{
39 NullCheck = IsNull;
40
41 if ( NullCheck == false )
42 {
43 setPalette ( QApplication::palette ( this ) );
44 }
45}

◆ SetPopupMenu()

void dbe::CustomLineEdit::SetPopupMenu ( )

Definition at line 88 of file CustomLineEdit.cpp.

89{
90 PopupMenu = true;
91}

◆ SetValidator()

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

Definition at line 83 of file CustomLineEdit.cpp.

84{
85 Validator = ValidatorSet;
86}

◆ StringValidated

void dbe::CustomLineEdit::StringValidated ( )
signal

◆ TryValidate

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

Definition at line 117 of file CustomLineEdit.cpp.

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

◆ ValidateText()

void dbe::CustomLineEdit::ValidateText ( )

Definition at line 72 of file CustomLineEdit.cpp.

73{
74 QString Dummy ( "Dummy" );
75 TryValidate ( Dummy );
76}

◆ ValueChanged

void dbe::CustomLineEdit::ValueChanged ( )
signal

Member Data Documentation

◆ CheckDefault

bool dbe::CustomLineEdit::CheckDefault
private

Definition at line 42 of file CustomLineEdit.hpp.

◆ ContextMenu

QMenu* dbe::CustomLineEdit::ContextMenu
private

Definition at line 45 of file CustomLineEdit.hpp.

◆ Dec

QAction* dbe::CustomLineEdit::Dec
private

Definition at line 46 of file CustomLineEdit.hpp.

◆ DefaultValue

QString dbe::CustomLineEdit::DefaultValue
private

Definition at line 50 of file CustomLineEdit.hpp.

◆ Hex

QAction* dbe::CustomLineEdit::Hex
private

Definition at line 48 of file CustomLineEdit.hpp.

◆ IsMultiValue

bool dbe::CustomLineEdit::IsMultiValue
private

Definition at line 44 of file CustomLineEdit.hpp.

◆ NullCheck

bool dbe::CustomLineEdit::NullCheck
private

Definition at line 41 of file CustomLineEdit.hpp.

◆ Oct

QAction* dbe::CustomLineEdit::Oct
private

Definition at line 47 of file CustomLineEdit.hpp.

◆ PopupMenu

bool dbe::CustomLineEdit::PopupMenu
private

Definition at line 43 of file CustomLineEdit.hpp.

◆ Valid

bool dbe::CustomLineEdit::Valid
private

Definition at line 40 of file CustomLineEdit.hpp.

◆ Validator

QValidator* dbe::CustomLineEdit::Validator
private

Definition at line 49 of file CustomLineEdit.hpp.


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