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

◆ ~string_attr_text_edit()

dbe::string_attr_text_edit::~string_attr_text_edit ( )

Definition at line 33 of file string_attr_text_edit.cpp.

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

Member Function Documentation

◆ contextMenuEvent()

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

Definition at line 195 of file string_attr_text_edit.cpp.

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

◆ CreateActions()

void dbe::string_attr_text_edit::CreateActions ( )

Definition at line 104 of file string_attr_text_edit.cpp.

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

◆ DecChange

void dbe::string_attr_text_edit::DecChange ( )
signal

◆ EmitDecSlot

void dbe::string_attr_text_edit::EmitDecSlot ( )
slot

Definition at line 168 of file string_attr_text_edit.cpp.

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

◆ 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 177 of file string_attr_text_edit.cpp.

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

◆ 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 63 of file string_attr_text_edit.cpp.

64{
65 return Valid;
66}

◆ OctChange

void dbe::string_attr_text_edit::OctChange ( )
signal

◆ SetCheckDefault()

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

Definition at line 69 of file string_attr_text_edit.cpp.

70{
71 CheckDefault = Default;
72}

◆ SetDefaultValue()

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

Definition at line 75 of file string_attr_text_edit.cpp.

76{
77 DefaultValue = ValueDefault;
78}

◆ SetLoadedDefaultFlag()

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

Definition at line 86 of file string_attr_text_edit.cpp.

87{
88 setProperty("loadedDefaults", Loaded);
89}

◆ SetMultiCheck()

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

Definition at line 51 of file string_attr_text_edit.cpp.

52{
53 IsMultiValue = IsMulti;
54}

◆ SetNullCheck()

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

Definition at line 41 of file string_attr_text_edit.cpp.

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

◆ SetPopupMenu()

void dbe::string_attr_text_edit::SetPopupMenu ( )

Definition at line 98 of file string_attr_text_edit.cpp.

99{
100 PopupMenu = true;
101}

◆ SetValidator()

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

Definition at line 92 of file string_attr_text_edit.cpp.

93{
94 Validator = ValidatorSet;
95}

◆ StringValidated

void dbe::string_attr_text_edit::StringValidated ( )
signal

◆ TryValidate

void dbe::string_attr_text_edit::TryValidate ( )
slot

Definition at line 129 of file string_attr_text_edit.cpp.

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

◆ ValidateText()

void dbe::string_attr_text_edit::ValidateText ( )

Definition at line 81 of file string_attr_text_edit.cpp.

82{
83}

◆ ValueChanged

void dbe::string_attr_text_edit::ValueChanged ( )
signal

Member Data Documentation

◆ CheckDefault

bool dbe::string_attr_text_edit::CheckDefault
private

Definition at line 48 of file string_attr_text_edit.hpp.

◆ ContextMenu

QMenu* dbe::string_attr_text_edit::ContextMenu
private

Definition at line 51 of file string_attr_text_edit.hpp.

◆ Dec

QAction* dbe::string_attr_text_edit::Dec
private

Definition at line 52 of file string_attr_text_edit.hpp.

◆ DefaultValue

QString dbe::string_attr_text_edit::DefaultValue
private

Definition at line 56 of file string_attr_text_edit.hpp.

◆ Hex

QAction* dbe::string_attr_text_edit::Hex
private

Definition at line 54 of file string_attr_text_edit.hpp.

◆ IsMultiValue

bool dbe::string_attr_text_edit::IsMultiValue
private

Definition at line 50 of file string_attr_text_edit.hpp.

◆ NullCheck

bool dbe::string_attr_text_edit::NullCheck
private

Definition at line 47 of file string_attr_text_edit.hpp.

◆ Oct

QAction* dbe::string_attr_text_edit::Oct
private

Definition at line 53 of file string_attr_text_edit.hpp.

◆ PopupMenu

bool dbe::string_attr_text_edit::PopupMenu
private

Definition at line 49 of file string_attr_text_edit.hpp.

◆ Valid

bool dbe::string_attr_text_edit::Valid
private

Definition at line 46 of file string_attr_text_edit.hpp.

◆ Validator

QValidator* dbe::string_attr_text_edit::Validator
private

Definition at line 55 of file string_attr_text_edit.hpp.


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