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 336 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 1881 of file BuildingBlockEditors.cpp.

1883 :
1884 base ( std::make_shared<t_build_block_editor> ( attr ), parent, owned ),
1885 m_base_data_editor ( std::static_pointer_cast<t_build_block_editor> ( p_data_editor ) )
1886{
1887 setupUi ( this );
1888 SetController();
1890 Combo->setFocusPolicy ( Qt::ClickFocus );
1891 Combo->installEventFilter ( this );
1892
1893 if ( Combo->lineEdit() != nullptr )
1894 {
1895 Combo->lineEdit()->installEventFilter ( this );
1896 }
1897
1898 t_virtue const & Virtue = m_base_data_editor->get();
1899
1900 if ( Virtue.p_type == dunedaq::conffwk::class_type )
1901 {
1902 Combo->setEditable ( true );
1903 }
1904}
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

Member Function Documentation

◆ buildtooltip()

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

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

Definition at line 2099 of file BuildingBlockEditors.cpp.

2100{}

◆ ChangeDetected

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

Definition at line 2067 of file BuildingBlockEditors.cpp.

2068{
2069 Q_UNUSED ( StringChange )
2070 this_value_changed = true;
2071 emit signal_value_change();
2072}

◆ CheckDefaults

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

Definition at line 2074 of file BuildingBlockEditors.cpp.

2075{
2076 Q_UNUSED ( DefaultIndex )
2077
2078 if ( !this_defaults.isEmpty() )
2079 {
2080 TryValidate ( Combo->currentText() );
2081 }
2082}

◆ CompareDefaults

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

Definition at line 2084 of file BuildingBlockEditors.cpp.

2085{
2086 if ( this_defaults.isEmpty() )
2087 {
2088 return false;
2089 }
2090
2091 if ( this_defaults == Combo->currentText() )
2092 {
2093 return true;
2094 }
2095
2096 return false;
2097}

◆ eventFilter()

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

Definition at line 1990 of file BuildingBlockEditors.cpp.

1991{
1992 if ( Target == Combo->lineEdit() && Event->type() == QEvent::MouseButtonRelease )
1993 {
1994 if ( !Combo->lineEdit()->hasSelectedText() )
1995 {
1996 Combo->lineEdit()->selectAll();
1997 return true;
1998 }
1999 }
2000
2001 if ( Event->type() == QEvent::Wheel )
2002 {
2003 return true;
2004 }
2005
2006 return false;
2007}

◆ getdata()

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

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

Definition at line 1951 of file BuildingBlockEditors.cpp.

1952{
1953 this_data.clear();
1954 this_data << Combo->currentText();
1955 return this_data;
1956}

◆ SetController()

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

Definition at line 2015 of file BuildingBlockEditors.cpp.

2016{
2017 connect ( Combo, SIGNAL ( editTextChanged ( const QString & ) ), this,
2018 SLOT ( TryValidate ( const QString & ) ), Qt::UniqueConnection );
2019 connect ( Combo, SIGNAL ( activated ( const QString & ) ), this,
2020 SLOT ( ChangeDetected ( const QString & ) ), Qt::UniqueConnection );
2021 connect ( Combo, SIGNAL ( currentIndexChanged ( int ) ), this,
2022 SLOT ( CheckDefaults ( int ) ),
2023 Qt::UniqueConnection );
2024}

◆ SetData()

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

Definition at line 1906 of file BuildingBlockEditors.cpp.

1907{
1908 if ( Data.isEmpty() )
1909 {
1910 return;
1911 }
1912
1913 int Index = Combo->findText ( Data.value ( 0 ) );
1914
1915 if ( Index != -1 )
1916 {
1917 Combo->setCurrentIndex ( Index );
1918 Combo->setEditText ( Data.value ( 0 ) );
1919 }
1920}
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 1985 of file BuildingBlockEditors.cpp.

1986{
1987 this_data = v;
1988}

◆ SetEditor()

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

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

Definition at line 1958 of file BuildingBlockEditors.cpp.

1959{
1960 t_virtue const & virt = m_base_data_editor->get();
1961
1962 if ( virt.p_type == dunedaq::conffwk::bool_type )
1963 {
1964 QStringList tmp
1965 { "true", "false" };
1966 SetValidatorData ( tmp );
1967 }
1968 else if ( virt.p_type == dunedaq::conffwk::enum_type )
1969 {
1970 QString rangename = virt.p_range.c_str();
1971 QStringList range = rangename.split ( "," );
1972 range.sort();
1973 SetValidatorData ( range );
1974 }
1975 else if ( virt.p_type == dunedaq::conffwk::class_type )
1976 {
1978 classes.sort();
1979 SetValidatorData ( classes );
1980 }
1981
1982 SetData ( this_data );
1983}
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 1922 of file BuildingBlockEditors.cpp.

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

◆ TryValidate

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

Definition at line 2026 of file BuildingBlockEditors.cpp.

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

◆ wheelEvent()

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

Definition at line 2009 of file BuildingBlockEditors.cpp.

2010{
2011 Q_UNUSED ( Event )
2012 return;
2013}

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 361 of file BuildingBlockEditors.hpp.


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