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

#include <BuildingBlockEditors.hpp>

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

Public Types

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

Public Member Functions

 combo (t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
void SetEditor () override
void SetData (QStringList const &)
void SetValidatorData (QStringList const &Data, bool AcceptNoMatch=false)
void setdata (QStringList const &)
QStringList getdata () override
Public Member Functions inherited from dbe::widgets::editors::base
template<typename T = editor_data_state>
std::shared_ptr< T > dataeditor ()
virtual void setdefaults (QString const &)
void setchanged (bool)
bool ischanged () const
template<>
std::shared_ptr< editor_data_statedataeditor ()

Private Slots

void TryValidate (QString)
void ChangeDetected (QString const &)
void CheckDefaults (int)
bool CompareDefaults ()

Private Member Functions

void buildtooltip () override
bool eventFilter (QObject *, QEvent *)
void wheelEvent (QWheelEvent *)
void SetController ()

Private Attributes

std::shared_ptr< t_build_block_editorm_base_data_editor

Additional Inherited Members

Public Slots inherited from dbe::widgets::editors::base
virtual void slot_set_initial_loaded ()
Signals inherited from dbe::widgets::editors::base
void signal_force_close ()
void signal_edit_end ()
void signal_internal_value_change ()
void signal_value_change ()
Protected Member Functions inherited from dbe::widgets::editors::base
 base (std::shared_ptr< editor_data_state > editordata, QWidget *parent=nullptr, bool owned=false)
virtual void closeEvent (QCloseEvent *Event)
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 341 of file BuildingBlockEditors.hpp.

Member Typedef Documentation

◆ t_build_block_editor

◆ t_virtue

Constructor & Destructor Documentation

◆ combo()

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

Configuration of combo box

Definition at line 1886 of file BuildingBlockEditors.cpp.

1888 :
1889 base ( std::make_shared<t_build_block_editor> ( attr ), parent, owned ),
1890 m_base_data_editor ( std::static_pointer_cast<t_build_block_editor> ( p_data_editor ) )
1891{
1892 setupUi ( this );
1893 SetController();
1895 Combo->setFocusPolicy ( Qt::ClickFocus );
1896 Combo->installEventFilter ( this );
1897
1898 if ( Combo->lineEdit() != nullptr )
1899 {
1900 Combo->lineEdit()->installEventFilter ( this );
1901 }
1902
1903 t_virtue const & Virtue = m_base_data_editor->get();
1904
1905 if ( Virtue.p_type == dunedaq::conffwk::class_type )
1906 {
1907 Combo->setEditable ( true );
1908 }
1909}
base(std::shared_ptr< editor_data_state > editordata, QWidget *parent=nullptr, bool owned=false)
std::shared_ptr< editor_data_state > p_data_editor
dunedaq::conffwk::attribute_t t_virtue
std::shared_ptr< t_build_block_editor > m_base_data_editor

Member Function Documentation

◆ buildtooltip()

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

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

Definition at line 2104 of file BuildingBlockEditors.cpp.

2105{}

◆ ChangeDetected

void dbe::widgets::editors::combo::ChangeDetected ( QString const & StringChange)
privateslot

Definition at line 2072 of file BuildingBlockEditors.cpp.

2073{
2074 Q_UNUSED ( StringChange )
2075 this_value_changed = true;
2076 emit signal_value_change();
2077}

◆ CheckDefaults

void dbe::widgets::editors::combo::CheckDefaults ( int DefaultIndex)
privateslot

Definition at line 2079 of file BuildingBlockEditors.cpp.

2080{
2081 Q_UNUSED ( DefaultIndex )
2082
2083 if ( !this_defaults.isEmpty() )
2084 {
2085 TryValidate ( Combo->currentText() );
2086 }
2087}

◆ CompareDefaults

bool dbe::widgets::editors::combo::CompareDefaults ( )
privateslot

Definition at line 2089 of file BuildingBlockEditors.cpp.

2090{
2091 if ( this_defaults.isEmpty() )
2092 {
2093 return false;
2094 }
2095
2096 if ( this_defaults == Combo->currentText() )
2097 {
2098 return true;
2099 }
2100
2101 return false;
2102}

◆ eventFilter()

bool dbe::widgets::editors::combo::eventFilter ( QObject * Target,
QEvent * Event )
private

Definition at line 1995 of file BuildingBlockEditors.cpp.

1996{
1997 if ( Target == Combo->lineEdit() && Event->type() == QEvent::MouseButtonRelease )
1998 {
1999 if ( !Combo->lineEdit()->hasSelectedText() )
2000 {
2001 Combo->lineEdit()->selectAll();
2002 return true;
2003 }
2004 }
2005
2006 if ( Event->type() == QEvent::Wheel )
2007 {
2008 return true;
2009 }
2010
2011 return false;
2012}

◆ getdata()

QStringList dbe::widgets::editors::combo::getdata ( )
overridevirtual

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

Definition at line 1956 of file BuildingBlockEditors.cpp.

1957{
1958 this_data.clear();
1959 this_data << Combo->currentText();
1960 return this_data;
1961}

◆ SetController()

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

Definition at line 2020 of file BuildingBlockEditors.cpp.

2021{
2022 connect ( Combo, SIGNAL ( editTextChanged ( const QString & ) ), this,
2023 SLOT ( TryValidate ( const QString & ) ), Qt::UniqueConnection );
2024 connect ( Combo, SIGNAL ( activated ( const QString & ) ), this,
2025 SLOT ( ChangeDetected ( const QString & ) ), Qt::UniqueConnection );
2026 connect ( Combo, SIGNAL ( currentIndexChanged ( int ) ), this,
2027 SLOT ( CheckDefaults ( int ) ),
2028 Qt::UniqueConnection );
2029}

◆ SetData()

void dbe::widgets::editors::combo::SetData ( QStringList const & Data)

Definition at line 1911 of file BuildingBlockEditors.cpp.

1912{
1913 if ( Data.isEmpty() )
1914 {
1915 return;
1916 }
1917
1918 int Index = Combo->findText ( Data.value ( 0 ) );
1919
1920 if ( Index != -1 )
1921 {
1922 Combo->setCurrentIndex ( Index );
1923 Combo->setEditText ( Data.value ( 0 ) );
1924 }
1925}
nlohmann::json Data
Definition Structs.hpp:24

◆ setdata()

void dbe::widgets::editors::combo::setdata ( QStringList const & v)
virtual

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

Definition at line 1990 of file BuildingBlockEditors.cpp.

1991{
1992 this_data = v;
1993}
default char v[0]

◆ SetEditor()

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

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

Definition at line 1963 of file BuildingBlockEditors.cpp.

1964{
1965 t_virtue const & virt = m_base_data_editor->get();
1966
1967 if ( virt.p_type == dunedaq::conffwk::bool_type )
1968 {
1969 QStringList tmp
1970 { "true", "false" };
1971 SetValidatorData ( tmp );
1972 }
1973 else if ( virt.p_type == dunedaq::conffwk::enum_type )
1974 {
1975 QString rangename = virt.p_range.c_str();
1976 QStringList range = rangename.split ( "," );
1977 range.sort();
1978 SetValidatorData ( range );
1979 }
1980 else if ( virt.p_type == dunedaq::conffwk::class_type )
1981 {
1983 classes.sort();
1984 SetValidatorData ( classes );
1985 }
1986
1987 SetData ( this_data );
1988}
void SetValidatorData(QStringList const &Data, bool AcceptNoMatch=false)
void SetData(QStringList const &)
DAC value out of range
Message.
Definition DACNode.hpp:32

◆ SetValidatorData()

void dbe::widgets::editors::combo::SetValidatorData ( QStringList const & Data,
bool AcceptNoMatch = false )

Definition at line 1927 of file BuildingBlockEditors.cpp.

1928{
1929 Combo->clear();
1930 Combo->addItems ( Data );
1931
1932 QCompleter * Completer = new QCompleter ( Combo->model(), Combo );
1933 Completer->setCaseSensitivity ( Qt::CaseInsensitive );
1934 Completer->setCompletionMode ( QCompleter::PopupCompletion );
1935 Completer->setFilterMode(Qt::MatchContains);
1936
1937 Combo->setCompleter ( Completer );
1938
1939 m_base_data_editor->set_obligatory ( false );
1940
1941 QVariant VarFromList ( Data );
1942
1943 if ( AcceptNoMatch )
1944 {
1945 ValidatorAcceptNoMatch * TmpValidator = new ValidatorAcceptNoMatch ( VarFromList, this );
1946 Combo->setValidator ( TmpValidator );
1947 }
1948
1949 else
1950 {
1951 ValidatorAcceptMatch * TmpValidator = new ValidatorAcceptMatch ( VarFromList, this );
1952 Combo->setValidator ( TmpValidator );
1953 }
1954}

◆ TryValidate

void dbe::widgets::editors::combo::TryValidate ( QString tmp)
privateslot

Definition at line 2031 of file BuildingBlockEditors.cpp.

2032{
2033 int index = 0;
2034
2035 if ( Combo->validator() != nullptr )
2036 {
2037 if ( Combo->validator()->validate ( tmp, index ) == QValidator::Acceptable )
2038 {
2039 m_base_data_editor->set_valid ( true );
2040
2041 if ( CompareDefaults() )
2042 {
2043 Combo->setPalette ( StyleUtility::LoadedDefault );
2044 }
2045
2046 else
2047 {
2048 Combo->setPalette ( QApplication::palette ( this ) );
2049 }
2050 }
2051
2052 else if ( Combo->validator()->validate ( tmp, index ) == QValidator::Intermediate )
2053 {
2054 m_base_data_editor->set_not_null ( false );
2055 Combo->setPalette ( StyleUtility::WarningStatusBarPallete );
2056 }
2057 }
2058
2059 else
2060 {
2061 if ( CompareDefaults() )
2062 {
2063 Combo->setPalette ( StyleUtility::LoadedDefault );
2064 }
2065 else
2066 {
2067 Combo->setPalette ( QApplication::palette ( this ) );
2068 }
2069 }
2070}
static QPalette LoadedDefault
static QPalette WarningStatusBarPallete

◆ wheelEvent()

void dbe::widgets::editors::combo::wheelEvent ( QWheelEvent * Event)
private

Definition at line 2014 of file BuildingBlockEditors.cpp.

2015{
2016 Q_UNUSED ( Event )
2017 return;
2018}

Member Data Documentation

◆ m_base_data_editor

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

Definition at line 366 of file BuildingBlockEditors.hpp.


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