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

#include <BuildingBlockEditors.hpp>

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

Public Types

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

Public Member Functions

 multiattr (t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
 
void SetEditor () override
 
- 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 &)
 
virtual void setdefaults (QString const &)
 
void setchanged (bool)
 
bool ischanged () const
 
virtual QStringList getdata ()
 
template<>
std::shared_ptr< editor_data_statedataeditor ()
 

Private Slots

void AddToDataList (const QString &Data)
 
void RemoveFromDataList ()
 
void UpdateActions ()
 
void LineValueChanged ()
 
void LineValueChanged (QListWidgetItem *p)
 
void ListOrderChange (const QModelIndexList &IndexList)
 
void EndSignal ()
 
void CustomContextMenuRequested (const QPoint &pos)
 
void RemoveSlot ()
 

Private Member Functions

void buildtooltip ()
 
void closeEvent (QCloseEvent *Event)
 
void SetStatusBar ()
 
bool eventFilter (QObject *Target, QEvent *Event)
 

Private Attributes

std::shared_ptr< t_build_block_editorm_base_data_editor
 
QStatusBar * StatusBar
 
QPushButton * OkButton
 
QPushButton * RemoveButton
 
QListWidget * ListWidget
 
baseBaseWidget
 
QMenu * ContextMenu
 
QAction * RemoveAction
 

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

Member Typedef Documentation

◆ t_build_block_editor

◆ t_virtue

Constructor & Destructor Documentation

◆ multiattr()

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

Frame

Frame

Definition at line 2105 of file BuildingBlockEditors.cpp.

2107 :
2108 base ( std::make_shared<t_build_block_editor> ( attr ), parent, owned ),
2109 m_base_data_editor ( std::static_pointer_cast<t_build_block_editor> ( p_data_editor ) ),
2110 StatusBar ( nullptr ),
2111 OkButton ( nullptr ),
2112 RemoveButton ( nullptr ),
2113 ListWidget ( nullptr ),
2114 ContextMenu ( nullptr ),
2115 RemoveAction ( nullptr )
2116{
2117 t_virtue const & Virtue = m_base_data_editor->get();
2118
2119 setWindowTitle ( QString ( "Edit Attribute : %1" ).arg ( Virtue.p_name.c_str() ) );
2120 QVBoxLayout * MainLayout = new QVBoxLayout ( this );
2121 MainLayout->setSpacing ( 0 );
2122 MainLayout->setMargin ( 0 );
2123 MainLayout->setContentsMargins ( 0, 0, 0, 0 );
2124 QHBoxLayout * ButtonLayout = new QHBoxLayout();
2125 ListWidget = new QListWidget ( this );
2126 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
2127
2128 switch ( Virtue.p_type )
2129 {
2130 // Bool and enums have the same widget
2131
2135 {
2136 combo * Combo = new combo ( attr, this );
2137 MainLayout->addWidget ( Combo );
2138 connect ( Combo->Combo, SIGNAL ( activated ( const QString & ) ), this,
2139 SLOT ( AddToDataList ( const QString & ) ), Qt::UniqueConnection );
2140 BaseWidget = Combo;
2141
2142 break;
2143 }
2144
2145 // All numeric types are treated as uint64
2146
2157 {
2158 numericattr * Numeric = new numericattr ( Virtue, this );
2159 MainLayout->addWidget ( Numeric );
2160 connect ( Numeric, SIGNAL ( signal_value_change() ), this, SLOT ( LineValueChanged() ),
2161 Qt::UniqueConnection );
2162 connect ( Numeric, SIGNAL ( signal_value_duplicated() ), this, SLOT ( LineValueChanged() ),
2163 Qt::UniqueConnection );
2164 BaseWidget = Numeric;
2166 Numeric->GetLineEdit()->setFrame ( false );
2167 Numeric->GetLineEdit()->setPlaceholderText ( "Type Here" );
2168 Numeric->setStyleSheet (
2169 "QLineEdit { background: #c0c0c0;} QLineEdit:focus {background: white;}" );
2170 Numeric->GetLineEdit()->setFixedHeight ( 24 );
2171 ListWidget->setFrameStyle ( QFrame::NoFrame );
2172 break;
2173 }
2174
2175 // Types below are all treated as string types
2176
2180 {
2181 stringattr * String = new stringattr ( Virtue, this );
2182 String->SetMultiCheck ( true );
2183 MainLayout->addWidget ( String );
2184 connect ( String, SIGNAL ( signal_value_change() ), this, SLOT ( LineValueChanged() ),
2185 Qt::UniqueConnection );
2188 String->GetLineEdit()->setFrameStyle(QFrame::NoFrame);
2189// String->GetLineEdit()->setPlaceholderText ( "Type here" );
2190 String->setStyleSheet ( "QLineEdit { background: #c0c0c0;} "
2191 "QLineEdit:focus {background: white;}" );
2192// String->GetLineEdit()->setFixedHeight ( 24 );
2193
2194 ListWidget->setFrameStyle ( QFrame::NoFrame );
2195 break;
2196 }
2197
2198 default:
2199 break;
2200 }
2201
2202 OkButton = new QPushButton ( tr ( "Apply" ) );
2203 //RemoveButton = new QPushButton(tr("Remove"));
2204 ButtonLayout->addWidget ( OkButton );
2205 //ButtonLayout->addWidget(RemoveButton);
2206 connect ( OkButton, SIGNAL ( clicked() ), this, SLOT ( EndSignal() ) );
2207 //connect(RemoveButton,SIGNAL(clicked()),this,SLOT(RemoveFromDataList()));
2208 connect ( this, SIGNAL ( signal_internal_value_change() ), this, SLOT ( UpdateActions() ) );
2209 connect ( ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
2210 SLOT ( CustomContextMenuRequested ( QPoint ) ) );
2211
2212 MainLayout->addWidget ( ListWidget );
2213 MainLayout->addLayout ( ButtonLayout );
2214 SetStatusBar();
2215 MainLayout->addWidget ( StatusBar );
2216
2217 setLayout ( MainLayout );
2218
2219 if ( Virtue.p_is_not_null )
2220 {
2221 m_base_data_editor->set_valid ( false );
2222 OkButton->setDisabled ( true );
2223 }
2224
2225 if ( this_is_owned )
2226 {
2227 OkButton->setHidden ( true );
2228 }
2229
2230 else
2231 {
2232 QFont Font;
2233 QFontMetrics FontMetrics ( Font );
2234 setMinimumWidth (
2235 2 * FontMetrics.width ( QString ( "Edit Relationship: %1" ).arg ( Virtue.p_name.c_str() ) )
2236 - 15 );
2237 setMinimumHeight ( 100 );
2238 }
2239
2240 buildtooltip();
2241 UpdateActions();
2242}
base(std::shared_ptr< editor_data_state > editordata, QWidget *parent=nullptr, bool owned=false)
std::shared_ptr< editor_data_state > p_data_editor
void CustomContextMenuRequested(const QPoint &pos)
dunedaq::conffwk::attribute_t t_virtue
std::shared_ptr< t_build_block_editor > m_base_data_editor

Member Function Documentation

◆ AddToDataList

void dbe::widgets::editors::multiattr::AddToDataList ( const QString & Data)
privateslot

Definition at line 2310 of file BuildingBlockEditors.cpp.

2311{
2312 if ( Data.isEmpty() )
2313 {
2314 return;
2315 }
2316
2317 this_data.append ( Data );
2318
2319 ListWidget->clear();
2320 ListWidget->addItems ( this_data );
2321 StatusBar->showMessage ( QString ( "Item %1 was added." ).arg ( Data ) );
2322
2323 this_value_changed = true;
2325}
nlohmann::json Data
Definition Structs.hpp:24

◆ buildtooltip()

void dbe::widgets::editors::multiattr::buildtooltip ( )
privatevirtual

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

Definition at line 2270 of file BuildingBlockEditors.cpp.

2271{
2272 t_virtue const & Virtue = m_base_data_editor->get();
2273
2274 setToolTip (
2275 QString ( "Attribute Name: %1 \n" ).arg ( Virtue.p_name.c_str() ) + QString (
2276 " Type: %1 \n" ).arg (
2277 dunedaq::conffwk::attribute_t::type2str ( Virtue.p_type ) )
2278 + QString ( " Range: %1 \n" ).arg ( Virtue.p_range.c_str() )
2279 + QString ( " Format: %1 \n" ).arg (
2280 dunedaq::conffwk::attribute_t::format2str ( Virtue.p_int_format ) )
2281 + QString ( " Not Null: %1 \n" ).arg ( Virtue.p_is_not_null )
2282 + QString ( " Is Multi Value: %1 \n" ).arg ( Virtue.p_is_multi_value )
2283 + QString ( " Default Value: %1 \n" ).arg ( Virtue.p_default_value.c_str() )
2284 + QString ( " Description: %1 \n" ).arg ( Virtue.p_description.c_str() ) );
2285}
static const char * type2str(type_t type)
static const char * format2str(int_format_t format)

◆ closeEvent()

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

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

Definition at line 2287 of file BuildingBlockEditors.cpp.

2288{
2289 Q_UNUSED ( Event )
2290 emit signal_force_close();
2291}

◆ CustomContextMenuRequested

void dbe::widgets::editors::multiattr::CustomContextMenuRequested ( const QPoint & pos)
privateslot

Definition at line 2459 of file BuildingBlockEditors.cpp.

2460{
2461 if ( ContextMenu == nullptr )
2462 {
2463 ContextMenu = new QMenu ( ListWidget );
2464
2465 RemoveAction = new QAction ( tr ( "Remove" ), this );
2466 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
2467 connect ( RemoveAction, SIGNAL ( triggered() ), this, SLOT ( RemoveSlot() ),
2468 Qt::UniqueConnection );
2469 ContextMenu->addAction ( RemoveAction );
2470 }
2471
2472 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
2473}

◆ EndSignal

void dbe::widgets::editors::multiattr::EndSignal ( )
privateslot

Definition at line 2438 of file BuildingBlockEditors.cpp.

2439{
2440 this_data.clear();
2441
2442 for ( int i = 0; i < ListWidget->count(); ++i )
2443 {
2444 this_data.append ( ListWidget->item ( i )->text() );
2445 }
2446
2447 if ( !this_is_owned )
2448 {
2449 m_base_data_editor->set_valid ( true );
2450 emit signal_edit_end();
2451 }
2452
2453 else
2454 {
2455 emit signal_value_change();
2456 }
2457}

◆ eventFilter()

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

Definition at line 2303 of file BuildingBlockEditors.cpp.

2304{
2305 ( void ) Target;
2306 ( void ) Event;
2307 return false;
2308}

◆ LineValueChanged [1/2]

void dbe::widgets::editors::multiattr::LineValueChanged ( )
privateslot

Definition at line 2403 of file BuildingBlockEditors.cpp.

2404{
2405 QStringList Data = BaseWidget->getdata();
2406
2407 if ( (!Data.isEmpty()) && BaseWidget->dataeditor()->is_valid())
2408 {
2409 AddToDataList ( Data.at ( 0 ) );
2410 }
2411}

◆ LineValueChanged [2/2]

void dbe::widgets::editors::multiattr::LineValueChanged ( QListWidgetItem * p)
privateslot

Definition at line 2413 of file BuildingBlockEditors.cpp.

2414{
2415 int r = ListWidget->row ( changed );
2416 QString newtext = changed->text();
2417 QString oldtext = this_data.at ( r );
2418 this_data.replace ( r, newtext );
2419 this_value_changed = true;
2420
2421 StatusBar->showMessage ( QString ( "Item %1 was modified." ).arg ( oldtext ) );
2422
2424}
Only Configuration DB opened by rdbconfig or oksconflibs plug in can be changed

◆ ListOrderChange

void dbe::widgets::editors::multiattr::ListOrderChange ( const QModelIndexList & IndexList)
privateslot

Definition at line 2426 of file BuildingBlockEditors.cpp.

2427{
2428 Q_UNUSED ( IndexList )
2429
2430 this_data.clear();
2431
2432 for ( int i = 0; i < ListWidget->count(); ++i )
2433 {
2434 this_data.append ( ListWidget->item ( i )->text() );
2435 }
2436}

◆ RemoveFromDataList

void dbe::widgets::editors::multiattr::RemoveFromDataList ( )
privateslot

Color management needs to be done

Definition at line 2327 of file BuildingBlockEditors.cpp.

2328{
2329 QList<QListWidgetItem *> widgets = ListWidget->selectedItems();
2330 this_value_changed = true;
2331
2332 for ( QListWidgetItem * widget : widgets )
2333 {
2334 int index = this_data.indexOf ( widget->text() );
2335
2336 if ( index != -1 )
2337 {
2338 this_data.takeAt ( index );
2339 }
2340
2341 int r = ListWidget->row ( widget );
2342
2343 if ( QListWidgetItem * w = ListWidget->takeItem ( r ) )
2344 {
2345 delete w;
2346 }
2347
2348 }
2349
2350 if ( this_is_owned )
2351 {
2352 StatusBar->showMessage ( "The selected items were removed." );
2353 }
2354
2355 if ( dynamic_cast<stringattr *> ( BaseWidget ) )
2356 {
2358 stringattr * StringWidget = dynamic_cast<stringattr *> ( BaseWidget );
2359 StringWidget->GetLineEdit()->selectAll();
2360 StringWidget->GetLineEdit()->clear();
2361 StringWidget->SetCheckDefaults ( false );
2362 StringWidget->SetNullCheck ( true );
2363 }
2364
2366 emit signal_value_change();
2367}

◆ RemoveSlot

void dbe::widgets::editors::multiattr::RemoveSlot ( )
privateslot

Definition at line 2475 of file BuildingBlockEditors.cpp.

◆ SetEditor()

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

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

Definition at line 2244 of file BuildingBlockEditors.cpp.

2245{
2247
2248 ListWidget->clear();
2249 ListWidget->addItems ( this_data );
2250 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
2251 ListWidget->setDragEnabled ( true );
2252 ListWidget->setAcceptDrops ( true );
2253 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
2254 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
2255
2256 for ( int i = 0; i < ListWidget->count(); ++i )
2257 {
2258 QListWidgetItem * widget = ListWidget->item ( i );
2259 widget->setFlags (
2260 Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled
2261 | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled );
2262
2263 }
2264
2265 connect ( ListWidget, SIGNAL ( itemChanged ( QListWidgetItem * ) ), this,
2266 SLOT ( LineValueChanged ( QListWidgetItem * ) ) );
2268}
virtual void SetEditor()=0

◆ SetStatusBar()

void dbe::widgets::editors::multiattr::SetStatusBar ( )
private

Color Management needs to be done

Uncomment if you want a status bar

Definition at line 2293 of file BuildingBlockEditors.cpp.

2294{
2295 StatusBar = new QStatusBar ( this );
2296 StatusBar->setSizeGripEnabled ( false );
2298 StatusBar->setAutoFillBackground ( true );
2300 StatusBar->setHidden ( true );
2301}

◆ UpdateActions

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

EditString validator string

Null Check validator string

Definition at line 2369 of file BuildingBlockEditors.cpp.

2370{
2371 t_virtue const & Virtue = m_base_data_editor->get();
2372
2373 if ( Virtue.p_is_not_null and this_data.size() == 0 )
2374 {
2375 OkButton->setDisabled ( true );
2376 StatusBar->showMessage ( "Attribute can not be null." );
2377 m_base_data_editor->set_valid ( false );
2380 }
2381
2382 else if ( Virtue.p_is_not_null and this_data.size() > 0 )
2383 {
2385
2386 StatusBar->showMessage ( "Attribute is set." );
2387 ListWidget->setPalette ( QApplication::palette ( this ) );
2388 OkButton->setEnabled ( true );
2389 m_base_data_editor->set_valid ( true );
2390
2391 if ( this_is_owned )
2392 {
2393 EndSignal();
2394 }
2395 }
2396 else if ( not Virtue.p_is_not_null and this_is_owned )
2397 {
2398 m_base_data_editor->set_valid ( true );
2399 EndSignal();
2400 }
2401}
static QPalette WarningStatusBarPallete

Member Data Documentation

◆ BaseWidget

base* dbe::widgets::editors::multiattr::BaseWidget
private

Definition at line 398 of file BuildingBlockEditors.hpp.

◆ ContextMenu

QMenu* dbe::widgets::editors::multiattr::ContextMenu
private

Definition at line 399 of file BuildingBlockEditors.hpp.

◆ ListWidget

QListWidget* dbe::widgets::editors::multiattr::ListWidget
private

Definition at line 397 of file BuildingBlockEditors.hpp.

◆ m_base_data_editor

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

Definition at line 392 of file BuildingBlockEditors.hpp.

◆ OkButton

QPushButton* dbe::widgets::editors::multiattr::OkButton
private

Definition at line 395 of file BuildingBlockEditors.hpp.

◆ RemoveAction

QAction* dbe::widgets::editors::multiattr::RemoveAction
private

Definition at line 400 of file BuildingBlockEditors.hpp.

◆ RemoveButton

QPushButton* dbe::widgets::editors::multiattr::RemoveButton
private

Definition at line 396 of file BuildingBlockEditors.hpp.

◆ StatusBar

QStatusBar* dbe::widgets::editors::multiattr::StatusBar
private

Definition at line 394 of file BuildingBlockEditors.hpp.


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