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 240 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 909 of file BuildingBlockEditors.cpp.

911 :
912 base ( std::make_shared<t_build_block_editor> ( attr ), parent, owned ),
913 m_base_data_editor ( std::static_pointer_cast<t_build_block_editor> ( p_data_editor ) ),
914 DefaultValue ( "" ),
915 PopUpButton ( nullptr ),
916 Dialog ( nullptr ),
917 OkButtonDialog ( nullptr ),
918 TextEditDialog ( nullptr )
919{
920 setupUi ( this );
921 t_virtue const & virtue = m_base_data_editor->get();
922
923 StringLineEdit->installEventFilter(this);
924 StringLineEdit->setTabChangesFocus(true);
925
926 setWindowTitle ( QString ( "Edit Attr : %1" ).arg ( virtue.p_name.c_str() ) );
927 AttributeNameLabel->setText ( QString ( virtue.p_name.c_str() ) + " : " );
929 AttributeNameLabel->setHidden ( true );
930
931 UpdateActions ( );
932
933 if ( m_base_data_editor->must_not_be_null() )
934 {
935 m_base_data_editor->set_valid ( true );
936 StringLineEdit->setPalette ( StyleUtility::WarningStatusBarPallete );
937 OkButton->setDisabled ( true );
938 SetNullCheck ( true );
939 }
940 else
941 {
942 SetNullCheck ( false );
943 }
944
945 if ( virtue.p_is_multi_value )
946 {
947 StringLineEdit->setPalette ( QApplication::palette ( this ) );
948 }
949
950 OkButton->setHidden ( true );
951
952 if ( this_is_owned )
953 {
954 connect ( StringLineEdit, SIGNAL ( StringValidated() ), this, SLOT ( AddToDataList() ),
955 Qt::UniqueConnection );
956 OkButton->setHidden ( true );
957 }
958
960
961 buildtooltip();
962 UpdateActions ( );
963
964 AttributeNameLabel->setFocus();
965}
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 967 of file BuildingBlockEditors.cpp.

968{
969 delete Dialog;
970 delete PopUpButton;
971}

Member Function Documentation

◆ AddToDataList

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

Definition at line 1127 of file BuildingBlockEditors.cpp.

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

◆ buildtooltip()

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

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

Definition at line 1051 of file BuildingBlockEditors.cpp.

1052{
1053 t_virtue const & Virtue = m_base_data_editor->get();
1054
1055 setToolTip (
1056 QString ( "Attribute Name: %1 \n" ).arg ( Virtue.p_name.c_str() ) + QString (
1057 " Type: %1 \n" ).arg (
1058 dunedaq::conffwk::attribute_t::type2str ( Virtue.p_type ) )
1059 + QString ( " Range: %1 \n" ).arg ( Virtue.p_range.c_str() )
1060 + QString ( " Format: %1 \n" ).arg (
1061 dunedaq::conffwk::attribute_t::format2str ( Virtue.p_int_format ) )
1062 + QString ( " Not Null: %1 \n" ).arg ( Virtue.p_is_not_null )
1063 + QString ( " Is Multi Value: %1 \n" ).arg ( Virtue.p_is_multi_value )
1064 + QString ( " Default Value: %1 \n" ).arg ( Virtue.p_default_value.c_str() )
1065 + QString ( " Description: %1 \n" ).arg ( Virtue.p_description.c_str() ) );
1066}
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 1046 of file BuildingBlockEditors.cpp.

1047{
1048 GetLineEdit()->clear();
1049}

◆ closeEvent()

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

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

Definition at line 1068 of file BuildingBlockEditors.cpp.

1069{
1070 Q_UNUSED ( Event )
1071 emit signal_force_close();
1072}

◆ eventFilter()

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

Definition at line 1010 of file BuildingBlockEditors.cpp.

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

◆ GetLineEdit()

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

Definition at line 985 of file BuildingBlockEditors.cpp.

986{
987 return StringLineEdit;
988}

◆ HidePopupButton()

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

Definition at line 1102 of file BuildingBlockEditors.cpp.

1103{
1104 if ( PopUpButton != nullptr )
1105 {
1106 PopUpButton->hide();
1107 }
1108}

◆ SetCheckDefaults()

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

Definition at line 1000 of file BuildingBlockEditors.cpp.

1001{
1002 StringLineEdit->SetCheckDefault ( Default );
1003}

◆ SetController()

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

Definition at line 1074 of file BuildingBlockEditors.cpp.

1075{
1076 connect ( StringLineEdit, SIGNAL ( textChanged ( ) ), this, SLOT ( UpdateActions ( ) ), Qt::UniqueConnection );
1077 connect ( this, SIGNAL ( signal_data_input_complete() ), this, SLOT ( AddToDataList() ) );
1078 connect ( OkButton, SIGNAL ( clicked() ), this, SLOT ( AddToDataList() ), Qt::UniqueConnection );
1079}

◆ setdefaults()

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

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

Definition at line 1081 of file BuildingBlockEditors.cpp.

1082{
1083 this_defaults = ValueDefault;
1084 StringLineEdit->SetDefaultValue ( ValueDefault );
1085}

◆ SetEditor()

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

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

Definition at line 973 of file BuildingBlockEditors.cpp.

974{
975 if ( this_data.isEmpty() )
976 {
977 return;
978 }
979
980 StringLineEdit->setText ( this_data.value ( 0 ) );
981
983}

◆ SetFocusOnLine()

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

Definition at line 1005 of file BuildingBlockEditors.cpp.

1006{
1007 StringLineEdit->selectAll();
1008}

◆ SetMultiCheck()

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

Definition at line 995 of file BuildingBlockEditors.cpp.

996{
997 StringLineEdit->SetMultiCheck ( Multi );
998}

◆ SetNullCheck()

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

Definition at line 990 of file BuildingBlockEditors.cpp.

991{
992 StringLineEdit->SetNullCheck ( Check );
993}

◆ ShowDialog

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

Definition at line 1152 of file BuildingBlockEditors.cpp.

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

◆ ShowPopupButton()

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

Definition at line 1087 of file BuildingBlockEditors.cpp.

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

◆ 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 1187 of file BuildingBlockEditors.cpp.

1188{
1189 t_virtue const & Virtue = m_base_data_editor->get();
1190
1191 if ( TextEditDialog->toPlainText().isEmpty() && Virtue.p_is_not_null )
1193 ->setEnabled (
1194 false );
1195 else
1196 {
1197 OkButtonDialog->setEnabled ( true );
1198 }
1199}

◆ UpdateActions

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

Definition at line 1110 of file BuildingBlockEditors.cpp.

1111{
1112 t_virtue const & Virtue = m_base_data_editor->get();
1113
1114 if ( Virtue.p_is_not_null && ( this_data.size() == 0 ) )
1115 {
1116 OkButton->setEnabled ( true );
1117 m_base_data_editor->set_valid ( false );
1118 }
1119
1120 else
1121 {
1122 OkButton->setEnabled ( true );
1123 m_base_data_editor->set_valid ( true );
1124 }
1125}

◆ UpdateFromTextEdit

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

Definition at line 1179 of file BuildingBlockEditors.cpp.

1180{
1181 StringLineEdit->clear();
1182 StringLineEdit->setText ( TextEditDialog->toPlainText() );
1183 AddToDataList();
1184 Dialog->close();
1185}

Member Data Documentation

◆ DefaultValue

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

Definition at line 273 of file BuildingBlockEditors.hpp.

◆ Dialog

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

Definition at line 275 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 271 of file BuildingBlockEditors.hpp.

◆ OkButtonDialog

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

Definition at line 276 of file BuildingBlockEditors.hpp.

◆ PopUpButton

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

Definition at line 274 of file BuildingBlockEditors.hpp.

◆ TextEditDialog

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

Definition at line 277 of file BuildingBlockEditors.hpp.


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