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

#include <BuildingBlockEditors.hpp>

Inheritance diagram for dbe::widgets::editors::stringattr:
[legend]
Collaboration diagram for dbe::widgets::editors::stringattr:
[legend]

Public Types

typedef dunedaq::conffwk::attribute_t t_virtue
 
typedef editor_data< t_virtuet_build_block_editor
 

Signals

void signal_data_input_complete ()
 
- Signals inherited from dbe::widgets::editors::base
void signal_force_close ()
 
void signal_edit_end ()
 
void signal_internal_value_change ()
 
void signal_value_change ()
 

Public Member Functions

 stringattr (t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
 
 ~stringattr ()
 
void SetEditor () override
 
QTextEdit * GetLineEdit () const
 
void SetNullCheck (bool Check)
 
void SetMultiCheck (bool Multi)
 
void SetCheckDefaults (bool Default)
 
void SetFocusOnLine ()
 
bool eventFilter (QObject *, QEvent *)
 
void ClearText ()
 
- Public Member Functions inherited from dbe::widgets::editors::base
template<typename T = editor_data_state>
std::shared_ptr< T > dataeditor ()
 
virtual void setdata (QStringList const &)
 
void setchanged (bool)
 
bool ischanged () const
 
virtual QStringList getdata ()
 
template<>
std::shared_ptr< editor_data_statedataeditor ()
 

Private Slots

void UpdateActions ()
 
void AddToDataList ()
 
void ShowDialog ()
 
void UpdateFromTextEdit ()
 
void ToogleTextEditOkButton ()
 

Private Member Functions

void buildtooltip () override
 
void closeEvent (QCloseEvent *)
 
void SetController ()
 
void setdefaults (const QString &)
 
void ShowPopupButton ()
 
void HidePopupButton ()
 

Private Attributes

std::shared_ptr< t_build_block_editorm_base_data_editor
 
QString DefaultValue
 
QPushButton * PopUpButton
 
QDialog * Dialog
 
QPushButton * OkButtonDialog
 
QPlainTextEdit * TextEditDialog
 

Additional Inherited Members

- Public Slots inherited from dbe::widgets::editors::base
virtual void slot_set_initial_loaded ()
 
- Protected Member Functions inherited from dbe::widgets::editors::base
 base (std::shared_ptr< editor_data_state > editordata, QWidget *parent=nullptr, bool owned=false)
 
- Protected Attributes inherited from dbe::widgets::editors::base
std::shared_ptr< editor_data_statep_data_editor
 
QString this_defaults
 
QStringList this_data
 
bool this_is_owned
 
bool this_value_changed
 
bool this_initial_load
 

Detailed Description

Definition at line 235 of file BuildingBlockEditors.hpp.

Member Typedef Documentation

◆ t_build_block_editor

◆ t_virtue

Constructor & Destructor Documentation

◆ stringattr()

dbe::widgets::editors::stringattr::stringattr ( t_virtue const & attr,
QWidget * parent = nullptr,
bool owned = false )

LAYOUT CHANGE

Definition at line 904 of file BuildingBlockEditors.cpp.

906 :
907 base ( std::make_shared<t_build_block_editor> ( attr ), parent, owned ),
908 m_base_data_editor ( std::static_pointer_cast<t_build_block_editor> ( p_data_editor ) ),
909 DefaultValue ( "" ),
910 PopUpButton ( nullptr ),
911 Dialog ( nullptr ),
912 OkButtonDialog ( nullptr ),
913 TextEditDialog ( nullptr )
914{
915 setupUi ( this );
916 t_virtue const & virtue = m_base_data_editor->get();
917
918 StringLineEdit->installEventFilter(this);
919 StringLineEdit->setTabChangesFocus(true);
920
921 setWindowTitle ( QString ( "Edit Attr : %1" ).arg ( virtue.p_name.c_str() ) );
922 AttributeNameLabel->setText ( QString ( virtue.p_name.c_str() ) + " : " );
924 AttributeNameLabel->setHidden ( true );
925
926 UpdateActions ( );
927
928 if ( m_base_data_editor->must_not_be_null() )
929 {
930 m_base_data_editor->set_valid ( true );
931 StringLineEdit->setPalette ( StyleUtility::WarningStatusBarPallete );
932 OkButton->setDisabled ( true );
933 SetNullCheck ( true );
934 }
935 else
936 {
937 SetNullCheck ( false );
938 }
939
940 if ( virtue.p_is_multi_value )
941 {
942 StringLineEdit->setPalette ( QApplication::palette ( this ) );
943 }
944
945 OkButton->setHidden ( true );
946
947 if ( this_is_owned )
948 {
949 connect ( StringLineEdit, SIGNAL ( StringValidated() ), this, SLOT ( AddToDataList() ),
950 Qt::UniqueConnection );
951 OkButton->setHidden ( true );
952 }
953
955
956 buildtooltip();
957 UpdateActions ( );
958
959 AttributeNameLabel->setFocus();
960}
static QPalette WarningStatusBarPallete
base(std::shared_ptr< editor_data_state > editordata, QWidget *parent=nullptr, bool owned=false)
std::shared_ptr< editor_data_state > p_data_editor
std::shared_ptr< t_build_block_editor > m_base_data_editor
dunedaq::conffwk::attribute_t t_virtue

◆ ~stringattr()

dbe::widgets::editors::stringattr::~stringattr ( )

Definition at line 962 of file BuildingBlockEditors.cpp.

963{
964 delete Dialog;
965 delete PopUpButton;
966}

Member Function Documentation

◆ AddToDataList

void dbe::widgets::editors::stringattr::AddToDataList ( )
privateslot

Definition at line 1122 of file BuildingBlockEditors.cpp.

1123{
1124 QString NewValue = StringLineEdit->toPlainText();
1125
1126 if ( !this_data.contains ( NewValue ) )
1127 {
1128 StringLineEdit->setToolTip ( QString ( "The set value is : %1" ).arg ( NewValue ) );
1129 this_data.clear();
1130 this_data.append ( NewValue );
1131
1132 UpdateActions ( );
1133 this_value_changed = true;
1134
1135 if ( !this_is_owned )
1136 {
1137 emit signal_value_change();
1138 emit signal_edit_end();
1139 }
1140 else
1141 {
1142 emit signal_value_change();
1143 }
1144 }
1145}

◆ buildtooltip()

void dbe::widgets::editors::stringattr::buildtooltip ( )
overrideprivatevirtual

Implements dbe::widgets::editors::base.

Definition at line 1046 of file BuildingBlockEditors.cpp.

1047{
1048 t_virtue const & Virtue = m_base_data_editor->get();
1049
1050 setToolTip (
1051 QString ( "Attribute Name: %1 \n" ).arg ( Virtue.p_name.c_str() ) + QString (
1052 " Type: %1 \n" ).arg (
1053 dunedaq::conffwk::attribute_t::type2str ( Virtue.p_type ) )
1054 + QString ( " Range: %1 \n" ).arg ( Virtue.p_range.c_str() )
1055 + QString ( " Format: %1 \n" ).arg (
1056 dunedaq::conffwk::attribute_t::format2str ( Virtue.p_int_format ) )
1057 + QString ( " Not Null: %1 \n" ).arg ( Virtue.p_is_not_null )
1058 + QString ( " Is Multi Value: %1 \n" ).arg ( Virtue.p_is_multi_value )
1059 + QString ( " Default Value: %1 \n" ).arg ( Virtue.p_default_value.c_str() )
1060 + QString ( " Description: %1 \n" ).arg ( Virtue.p_description.c_str() ) );
1061}
static const char * type2str(type_t type)
static const char * format2str(int_format_t format)

◆ ClearText()

void dbe::widgets::editors::stringattr::ClearText ( )

Definition at line 1041 of file BuildingBlockEditors.cpp.

1042{
1043 GetLineEdit()->clear();
1044}

◆ closeEvent()

void dbe::widgets::editors::stringattr::closeEvent ( QCloseEvent * Event)
privatevirtual

Reimplemented from dbe::widgets::editors::base.

Definition at line 1063 of file BuildingBlockEditors.cpp.

1064{
1065 Q_UNUSED ( Event )
1066 emit signal_force_close();
1067}

◆ eventFilter()

bool dbe::widgets::editors::stringattr::eventFilter ( QObject * target,
QEvent * evt )

Definition at line 1005 of file BuildingBlockEditors.cpp.

1006{
1007 if (target == StringLineEdit)
1008 {
1009 if (evt->type() == QEvent::FocusIn)
1010 {
1012 }
1013 else if (evt->type() == QEvent::KeyPress)
1014 {
1015 QKeyEvent *kevt = static_cast<QKeyEvent*>(evt);
1016 switch (kevt->key())
1017 {
1018 case Qt::Key_Enter:
1019 case Qt::Key_Return:
1020
1021 if ( kevt->modifiers() == Qt::AltModifier)
1022 {
1023 kevt->setModifiers(Qt::NoModifier);
1024 return false;
1025 }else
1026 {
1027 StringLineEdit->parentWidget()->setFocus(Qt::FocusReason::TabFocusReason);
1029 return true;
1030 }
1031
1032 break;
1033 default:
1034 break;
1035 }
1036 }
1037 }
1038 return false;
1039}

◆ GetLineEdit()

QTextEdit * dbe::widgets::editors::stringattr::GetLineEdit ( ) const

Definition at line 980 of file BuildingBlockEditors.cpp.

981{
982 return StringLineEdit;
983}

◆ HidePopupButton()

void dbe::widgets::editors::stringattr::HidePopupButton ( )
private

Definition at line 1097 of file BuildingBlockEditors.cpp.

1098{
1099 if ( PopUpButton != nullptr )
1100 {
1101 PopUpButton->hide();
1102 }
1103}

◆ SetCheckDefaults()

void dbe::widgets::editors::stringattr::SetCheckDefaults ( bool Default)

Definition at line 995 of file BuildingBlockEditors.cpp.

996{
997 StringLineEdit->SetCheckDefault ( Default );
998}

◆ SetController()

void dbe::widgets::editors::stringattr::SetController ( )
private

Definition at line 1069 of file BuildingBlockEditors.cpp.

1070{
1071 connect ( StringLineEdit, SIGNAL ( textChanged ( ) ), this, SLOT ( UpdateActions ( ) ), Qt::UniqueConnection );
1072 connect ( this, SIGNAL ( signal_data_input_complete() ), this, SLOT ( AddToDataList() ) );
1073 connect ( OkButton, SIGNAL ( clicked() ), this, SLOT ( AddToDataList() ), Qt::UniqueConnection );
1074}

◆ setdefaults()

void dbe::widgets::editors::stringattr::setdefaults ( const QString & ValueDefault)
privatevirtual

Reimplemented from dbe::widgets::editors::base.

Definition at line 1076 of file BuildingBlockEditors.cpp.

1077{
1078 this_defaults = ValueDefault;
1079 StringLineEdit->SetDefaultValue ( ValueDefault );
1080}

◆ SetEditor()

void dbe::widgets::editors::stringattr::SetEditor ( )
overridevirtual

Implements dbe::widgets::editors::base.

Definition at line 968 of file BuildingBlockEditors.cpp.

969{
970 if ( this_data.isEmpty() )
971 {
972 return;
973 }
974
975 StringLineEdit->setText ( this_data.value ( 0 ) );
976
978}

◆ SetFocusOnLine()

void dbe::widgets::editors::stringattr::SetFocusOnLine ( )

Definition at line 1000 of file BuildingBlockEditors.cpp.

1001{
1002 StringLineEdit->selectAll();
1003}

◆ SetMultiCheck()

void dbe::widgets::editors::stringattr::SetMultiCheck ( bool Multi)

Definition at line 990 of file BuildingBlockEditors.cpp.

991{
992 StringLineEdit->SetMultiCheck ( Multi );
993}

◆ SetNullCheck()

void dbe::widgets::editors::stringattr::SetNullCheck ( bool Check)

Definition at line 985 of file BuildingBlockEditors.cpp.

986{
987 StringLineEdit->SetNullCheck ( Check );
988}

◆ ShowDialog

void dbe::widgets::editors::stringattr::ShowDialog ( )
privateslot

Definition at line 1147 of file BuildingBlockEditors.cpp.

1148{
1149
1150 if ( Dialog == nullptr )
1151 {
1152 QVBoxLayout * Layout = new QVBoxLayout();
1153 Dialog = new QDialog();
1154 t_virtue const & Virtue = m_base_data_editor->get();
1155 Dialog->setWindowTitle ( QString ( "Edit Attr : %1" ).arg ( Virtue.p_name.c_str() ) );
1156 TextEditDialog = new QPlainTextEdit ( Dialog );
1157 OkButtonDialog = new QPushButton ( "OK", Dialog );
1158 Layout->addWidget ( TextEditDialog );
1159 Layout->addWidget ( OkButtonDialog );
1160 Dialog->setLayout ( Layout );
1161 Dialog->setModal ( true );
1162
1163 connect ( TextEditDialog, SIGNAL ( textChanged() ), this, SLOT ( ToogleTextEditOkButton() ),
1164 Qt::UniqueConnection );
1165 connect ( OkButtonDialog, SIGNAL ( clicked() ), this, SLOT ( UpdateFromTextEdit() ),
1166 Qt::UniqueConnection );
1167 }
1168
1169 TextEditDialog->clear();
1170 TextEditDialog->insertPlainText ( StringLineEdit->toPlainText() );
1171 Dialog->show();
1172}

◆ ShowPopupButton()

void dbe::widgets::editors::stringattr::ShowPopupButton ( )
private

Definition at line 1082 of file BuildingBlockEditors.cpp.

1083{
1084 if ( PopUpButton == nullptr )
1085 {
1086 PopUpButton = new QPushButton ( "..." );
1087 PopUpButton->setMaximumWidth (
1088 PopUpButton->fontMetrics().boundingRect ( "..." ).width() + 15 );
1089 connect ( PopUpButton, SIGNAL ( clicked() ), this, SLOT ( ShowDialog() ),
1090 Qt::UniqueConnection );
1091 horizontalLayout->addWidget ( PopUpButton );
1092 }
1093
1094 PopUpButton->show();
1095}

◆ signal_data_input_complete

void dbe::widgets::editors::stringattr::signal_data_input_complete ( )
signal

◆ ToogleTextEditOkButton

void dbe::widgets::editors::stringattr::ToogleTextEditOkButton ( )
privateslot

Definition at line 1182 of file BuildingBlockEditors.cpp.

1183{
1184 t_virtue const & Virtue = m_base_data_editor->get();
1185
1186 if ( TextEditDialog->toPlainText().isEmpty() && Virtue.p_is_not_null )
1188 ->setEnabled (
1189 false );
1190 else
1191 {
1192 OkButtonDialog->setEnabled ( true );
1193 }
1194}

◆ UpdateActions

void dbe::widgets::editors::stringattr::UpdateActions ( )
privateslot

Definition at line 1105 of file BuildingBlockEditors.cpp.

1106{
1107 t_virtue const & Virtue = m_base_data_editor->get();
1108
1109 if ( Virtue.p_is_not_null && ( this_data.size() == 0 ) )
1110 {
1111 OkButton->setEnabled ( true );
1112 m_base_data_editor->set_valid ( false );
1113 }
1114
1115 else
1116 {
1117 OkButton->setEnabled ( true );
1118 m_base_data_editor->set_valid ( true );
1119 }
1120}

◆ UpdateFromTextEdit

void dbe::widgets::editors::stringattr::UpdateFromTextEdit ( )
privateslot

Definition at line 1174 of file BuildingBlockEditors.cpp.

1175{
1176 StringLineEdit->clear();
1177 StringLineEdit->setText ( TextEditDialog->toPlainText() );
1178 AddToDataList();
1179 Dialog->close();
1180}

Member Data Documentation

◆ DefaultValue

QString dbe::widgets::editors::stringattr::DefaultValue
private

Definition at line 268 of file BuildingBlockEditors.hpp.

◆ Dialog

QDialog* dbe::widgets::editors::stringattr::Dialog
private

Definition at line 270 of file BuildingBlockEditors.hpp.

◆ m_base_data_editor

std::shared_ptr<t_build_block_editor> dbe::widgets::editors::stringattr::m_base_data_editor
private

Definition at line 266 of file BuildingBlockEditors.hpp.

◆ OkButtonDialog

QPushButton* dbe::widgets::editors::stringattr::OkButtonDialog
private

Definition at line 271 of file BuildingBlockEditors.hpp.

◆ PopUpButton

QPushButton* dbe::widgets::editors::stringattr::PopUpButton
private

Definition at line 269 of file BuildingBlockEditors.hpp.

◆ TextEditDialog

QPlainTextEdit* dbe::widgets::editors::stringattr::TextEditDialog
private

Definition at line 272 of file BuildingBlockEditors.hpp.


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