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

#include <string_attr_text_edit.hpp>

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

Public Slots

void TryValidate ()
void EmitDecSlot ()
void EmitOctSlot ()
void EmitHexSlot ()

Signals

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

Public Member Functions

 string_attr_text_edit (QWidget *parent=0, bool IsNull=true, bool IsMulti=false)
 Include Qt Headers.
 ~string_attr_text_edit ()
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 string_attr_text_edit.hpp.

Constructor & Destructor Documentation

◆ string_attr_text_edit()

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

Include Qt Headers.

Include DBE

Definition at line 15 of file string_attr_text_edit.cpp.

16 : QTextEdit ( 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 ( ) ), this,
29 SLOT ( TryValidate ( ) ) );
30 //this->setFixedHeight ( 30 );
31 //this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
32}

◆ ~string_attr_text_edit()

dbe::string_attr_text_edit::~string_attr_text_edit ( )

Definition at line 34 of file string_attr_text_edit.cpp.

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

Member Function Documentation

◆ contextMenuEvent()

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

Definition at line 194 of file string_attr_text_edit.cpp.

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

◆ CreateActions()

void dbe::string_attr_text_edit::CreateActions ( )

Definition at line 96 of file string_attr_text_edit.cpp.

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

◆ DecChange

void dbe::string_attr_text_edit::DecChange ( )
signal

◆ EmitDecSlot

void dbe::string_attr_text_edit::EmitDecSlot ( )
slot

Definition at line 170 of file string_attr_text_edit.cpp.

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

◆ EmitHexSlot

void dbe::string_attr_text_edit::EmitHexSlot ( )
slot

Definition at line 186 of file string_attr_text_edit.cpp.

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

◆ EmitOctSlot

void dbe::string_attr_text_edit::EmitOctSlot ( )
slot

Definition at line 178 of file string_attr_text_edit.cpp.

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

◆ HexChange

void dbe::string_attr_text_edit::HexChange ( )
signal

◆ IsNullCheck()

bool dbe::string_attr_text_edit::IsNullCheck ( )

Definition at line 57 of file string_attr_text_edit.cpp.

58{
59 return NullCheck;
60}

◆ IsValid()

bool dbe::string_attr_text_edit::IsValid ( )

Definition at line 62 of file string_attr_text_edit.cpp.

63{
64 return Valid;
65}

◆ OctChange

void dbe::string_attr_text_edit::OctChange ( )
signal

◆ SetCheckDefault()

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

Definition at line 67 of file string_attr_text_edit.cpp.

68{
69 CheckDefault = Default;
70}

◆ SetDefaultValue()

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

Definition at line 72 of file string_attr_text_edit.cpp.

73{
74 DefaultValue = ValueDefault;
75}

◆ SetLoadedDefaultFlag()

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

Definition at line 81 of file string_attr_text_edit.cpp.

82{
83 setProperty ( "loadedDefaults", Loaded );
84}

◆ SetMultiCheck()

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

Definition at line 52 of file string_attr_text_edit.cpp.

53{
54 IsMultiValue = IsMulti;
55}

◆ SetNullCheck()

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

Definition at line 42 of file string_attr_text_edit.cpp.

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

◆ SetPopupMenu()

void dbe::string_attr_text_edit::SetPopupMenu ( )

Definition at line 91 of file string_attr_text_edit.cpp.

92{
93 PopupMenu = true;
94}

◆ SetValidator()

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

Definition at line 86 of file string_attr_text_edit.cpp.

87{
88 Validator = ValidatorSet;
89}

◆ StringValidated

void dbe::string_attr_text_edit::StringValidated ( )
signal

◆ TryValidate

void dbe::string_attr_text_edit::TryValidate ( )
slot

Definition at line 120 of file string_attr_text_edit.cpp.

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

◆ ValidateText()

void dbe::string_attr_text_edit::ValidateText ( )

Definition at line 77 of file string_attr_text_edit.cpp.

78{
79}

◆ ValueChanged

void dbe::string_attr_text_edit::ValueChanged ( )
signal

Member Data Documentation

◆ CheckDefault

bool dbe::string_attr_text_edit::CheckDefault
private

Definition at line 47 of file string_attr_text_edit.hpp.

◆ ContextMenu

QMenu* dbe::string_attr_text_edit::ContextMenu
private

Definition at line 50 of file string_attr_text_edit.hpp.

◆ Dec

QAction* dbe::string_attr_text_edit::Dec
private

Definition at line 51 of file string_attr_text_edit.hpp.

◆ DefaultValue

QString dbe::string_attr_text_edit::DefaultValue
private

Definition at line 55 of file string_attr_text_edit.hpp.

◆ Hex

QAction* dbe::string_attr_text_edit::Hex
private

Definition at line 53 of file string_attr_text_edit.hpp.

◆ IsMultiValue

bool dbe::string_attr_text_edit::IsMultiValue
private

Definition at line 49 of file string_attr_text_edit.hpp.

◆ NullCheck

bool dbe::string_attr_text_edit::NullCheck
private

Definition at line 46 of file string_attr_text_edit.hpp.

◆ Oct

QAction* dbe::string_attr_text_edit::Oct
private

Definition at line 52 of file string_attr_text_edit.hpp.

◆ PopupMenu

bool dbe::string_attr_text_edit::PopupMenu
private

Definition at line 48 of file string_attr_text_edit.hpp.

◆ Valid

bool dbe::string_attr_text_edit::Valid
private

Definition at line 45 of file string_attr_text_edit.hpp.

◆ Validator

QValidator* dbe::string_attr_text_edit::Validator
private

Definition at line 54 of file string_attr_text_edit.hpp.


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