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, bool readonly=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
bool m_readonly
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 ()
Public Attributes inherited from dbe::widgets::editors::base
const QString c_input_placeholder {"Add a new value"}
const QString c_no_object_placeholder {"No Object currently set"}
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 244 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,
bool readonly = false )

LAYOUT CHANGE

Definition at line 888 of file BuildingBlockEditors.cpp.

890 :
891 base ( std::make_shared<t_build_block_editor> ( attr ), parent, owned ),
892 m_base_data_editor ( std::static_pointer_cast<t_build_block_editor> ( p_data_editor ) ),
893 m_readonly(readonly),
894 DefaultValue ( "" ),
895 PopUpButton ( nullptr ),
896 Dialog ( nullptr ),
897 OkButtonDialog ( nullptr ),
898 TextEditDialog ( nullptr )
899{
900 setupUi ( this );
901 t_virtue const & virtue = m_base_data_editor->get();
902
903 if (m_readonly) {
904 StringLineEdit->setReadOnly(true);
905 }
906 else {
907 StringLineEdit->installEventFilter(this);
908 }
909 StringLineEdit->setTabChangesFocus(true);
910
911 setWindowTitle ( QString ( "Edit Attr : %1" ).arg ( virtue.p_name.c_str() ) );
912 AttributeNameLabel->setText ( QString ( virtue.p_name.c_str() ) + " : " );
914 AttributeNameLabel->setHidden ( true );
915
916 UpdateActions ( );
917
918 if ( m_base_data_editor->must_not_be_null() )
919 {
920 m_base_data_editor->set_valid ( true );
921 StringLineEdit->setPalette ( StyleUtility::WarningStatusBarPallete );
922 OkButton->setDisabled ( true );
923 SetNullCheck ( true );
924 }
925 else
926 {
927 SetNullCheck ( false );
928 }
929
930 if ( virtue.p_is_multi_value )
931 {
932 StringLineEdit->setPalette ( QApplication::palette ( this ) );
933 }
934
935 OkButton->setHidden ( true );
936
937 if ( this_is_owned )
938 {
939 connect ( StringLineEdit, SIGNAL ( StringValidated() ), this, SLOT ( AddToDataList() ),
940 Qt::UniqueConnection );
941 OkButton->setHidden ( true );
942 }
943
945
946 buildtooltip();
947 UpdateActions ( );
948
949 AttributeNameLabel->setFocus();
950}
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 952 of file BuildingBlockEditors.cpp.

953{
954 delete Dialog;
955 delete PopUpButton;
956}

Member Function Documentation

◆ AddToDataList

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

Definition at line 1114 of file BuildingBlockEditors.cpp.

1115{
1116 QString NewValue = StringLineEdit->toPlainText();
1117
1118 if ( !this_data.contains ( NewValue ) )
1119 {
1120 StringLineEdit->setToolTip ( QString ( "The set value is : %1" ).arg ( NewValue ) );
1121 this_data.clear();
1122 this_data.append ( NewValue );
1123
1124 UpdateActions ( );
1125 this_value_changed = true;
1126
1127 if ( !this_is_owned )
1128 {
1129 emit signal_value_change();
1130 emit signal_edit_end();
1131 }
1132 else
1133 {
1134 emit signal_value_change();
1135 }
1136 }
1137}

◆ buildtooltip()

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

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

Definition at line 1036 of file BuildingBlockEditors.cpp.

1037{
1038 t_virtue const & Virtue = m_base_data_editor->get();
1039
1040 setToolTip (
1041 QString ( "Attribute Name: %1 \n" ).arg ( Virtue.p_name.c_str() ) + QString (
1042 " Type: %1 \n" ).arg (
1043 dunedaq::conffwk::attribute_t::type2str ( Virtue.p_type ) )
1044 + QString ( " Range: %1 \n" ).arg ( Virtue.p_range.c_str() )
1045 + QString ( " Format: %1 \n" ).arg (
1046 dunedaq::conffwk::attribute_t::format2str ( Virtue.p_int_format ) )
1047 + QString ( " Not Null: %1 \n" ).arg ( Virtue.p_is_not_null )
1048 + QString ( " Is Multi Value: %1 \n" ).arg ( Virtue.p_is_multi_value )
1049 + QString ( " Default Value: %1 \n" ).arg ( Virtue.p_default_value.c_str() )
1050 + QString ( " Description: %1 \n" ).arg ( Virtue.p_description.c_str() ) );
1051}
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 1031 of file BuildingBlockEditors.cpp.

1032{
1033 GetLineEdit()->clear();
1034}

◆ closeEvent()

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

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

Definition at line 1053 of file BuildingBlockEditors.cpp.

1054{
1055 Q_UNUSED ( Event )
1056 emit signal_force_close();
1057}

◆ eventFilter()

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

Definition at line 995 of file BuildingBlockEditors.cpp.

996{
997 if (target == StringLineEdit)
998 {
999 if (evt->type() == QEvent::FocusIn)
1000 {
1002 }
1003 else if (evt->type() == QEvent::KeyPress)
1004 {
1005 QKeyEvent *kevt = static_cast<QKeyEvent*>(evt);
1006 switch (kevt->key())
1007 {
1008 case Qt::Key_Enter:
1009 case Qt::Key_Return:
1010
1011 if ( kevt->modifiers() == Qt::AltModifier)
1012 {
1013 kevt->setModifiers(Qt::NoModifier);
1014 return false;
1015 }else
1016 {
1017 StringLineEdit->parentWidget()->setFocus(Qt::FocusReason::TabFocusReason);
1019 return true;
1020 }
1021
1022 break;
1023 default:
1024 break;
1025 }
1026 }
1027 }
1028 return false;
1029}

◆ GetLineEdit()

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

Definition at line 970 of file BuildingBlockEditors.cpp.

971{
972 return StringLineEdit;
973}

◆ HidePopupButton()

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

Definition at line 1089 of file BuildingBlockEditors.cpp.

1090{
1091 if ( PopUpButton != nullptr )
1092 {
1093 PopUpButton->hide();
1094 }
1095}

◆ SetCheckDefaults()

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

Definition at line 985 of file BuildingBlockEditors.cpp.

986{
987 StringLineEdit->SetCheckDefault ( Default );
988}

◆ SetController()

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

Definition at line 1059 of file BuildingBlockEditors.cpp.

1060{
1061 if (!m_readonly) {
1062 connect ( StringLineEdit, SIGNAL ( textChanged ( ) ), this, SLOT ( UpdateActions ( ) ), Qt::UniqueConnection );
1063 connect ( this, SIGNAL ( signal_data_input_complete() ), this, SLOT ( AddToDataList() ) );
1064 connect ( OkButton, SIGNAL ( clicked() ), this, SLOT ( AddToDataList() ), Qt::UniqueConnection );
1065 }
1066}

◆ setdefaults()

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

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

Definition at line 1068 of file BuildingBlockEditors.cpp.

1069{
1070 this_defaults = ValueDefault;
1071 StringLineEdit->SetDefaultValue ( ValueDefault );
1072}

◆ SetEditor()

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

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

Definition at line 958 of file BuildingBlockEditors.cpp.

959{
960 if ( this_data.isEmpty() )
961 {
962 return;
963 }
964
965 StringLineEdit->setText ( this_data.value ( 0 ) );
966
968}

◆ SetFocusOnLine()

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

Definition at line 990 of file BuildingBlockEditors.cpp.

991{
992 StringLineEdit->selectAll();
993}

◆ SetMultiCheck()

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

Definition at line 980 of file BuildingBlockEditors.cpp.

981{
982 StringLineEdit->SetMultiCheck ( Multi );
983}

◆ SetNullCheck()

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

Definition at line 975 of file BuildingBlockEditors.cpp.

976{
977 StringLineEdit->SetNullCheck ( Check );
978}

◆ ShowDialog

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

Definition at line 1139 of file BuildingBlockEditors.cpp.

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

◆ ShowPopupButton()

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

Definition at line 1074 of file BuildingBlockEditors.cpp.

1075{
1076 if ( PopUpButton == nullptr )
1077 {
1078 PopUpButton = new QPushButton ( "..." );
1079 PopUpButton->setMaximumWidth (
1080 PopUpButton->fontMetrics().boundingRect ( "..." ).width() + 15 );
1081 connect ( PopUpButton, SIGNAL ( clicked() ), this, SLOT ( ShowDialog() ),
1082 Qt::UniqueConnection );
1083 horizontalLayout->addWidget ( PopUpButton );
1084 }
1085
1086 PopUpButton->show();
1087}

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

1175{
1176 t_virtue const & Virtue = m_base_data_editor->get();
1177
1178 if ( TextEditDialog->toPlainText().isEmpty() && Virtue.p_is_not_null )
1180 ->setEnabled (
1181 false );
1182 else
1183 {
1184 OkButtonDialog->setEnabled ( true );
1185 }
1186}

◆ UpdateActions

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

Definition at line 1097 of file BuildingBlockEditors.cpp.

1098{
1099 t_virtue const & Virtue = m_base_data_editor->get();
1100
1101 if ( Virtue.p_is_not_null && ( this_data.size() == 0 ) )
1102 {
1103 OkButton->setEnabled ( true );
1104 m_base_data_editor->set_valid ( false );
1105 }
1106
1107 else
1108 {
1109 OkButton->setEnabled ( true );
1110 m_base_data_editor->set_valid ( true );
1111 }
1112}

◆ UpdateFromTextEdit

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

Definition at line 1166 of file BuildingBlockEditors.cpp.

1167{
1168 StringLineEdit->clear();
1169 StringLineEdit->setText ( TextEditDialog->toPlainText() );
1170 AddToDataList();
1171 Dialog->close();
1172}

Member Data Documentation

◆ DefaultValue

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

Definition at line 279 of file BuildingBlockEditors.hpp.

◆ Dialog

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

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

◆ m_readonly

bool dbe::widgets::editors::stringattr::m_readonly
private

Definition at line 278 of file BuildingBlockEditors.hpp.

◆ OkButtonDialog

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

Definition at line 282 of file BuildingBlockEditors.hpp.

◆ PopUpButton

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

Definition at line 280 of file BuildingBlockEditors.hpp.

◆ TextEditDialog

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

Definition at line 283 of file BuildingBlockEditors.hpp.


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