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, bool readonly=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
bool m_readonly
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 ()
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 388 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,
bool readonly = false )

Frame

Frame

Definition at line 2127 of file BuildingBlockEditors.cpp.

2129 :
2130 base ( std::make_shared<t_build_block_editor> ( attr ), parent, owned ),
2131 m_base_data_editor ( std::static_pointer_cast<t_build_block_editor> ( p_data_editor ) ),
2132 m_readonly(readonly),
2133 StatusBar ( nullptr ),
2134 OkButton ( nullptr ),
2135 RemoveButton ( nullptr ),
2136 ListWidget ( nullptr ),
2137 ContextMenu ( nullptr ),
2138 RemoveAction ( nullptr )
2139{
2140 t_virtue const & Virtue = m_base_data_editor->get();
2141
2142 setWindowTitle ( QString ( "Edit Attribute : %1" ).arg ( Virtue.p_name.c_str() ) );
2143 QVBoxLayout * MainLayout = new QVBoxLayout ( this );
2144 MainLayout->setSpacing ( 0 );
2145 MainLayout->setMargin ( 0 );
2146 MainLayout->setContentsMargins ( 0, 0, 0, 0 );
2147 QHBoxLayout * ButtonLayout = new QHBoxLayout();
2148 ListWidget = new QListWidget ( this );
2149 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
2150 MainLayout->addWidget ( ListWidget );
2151
2152 switch ( Virtue.p_type )
2153 {
2154 // Bool and enums have the same widget
2155
2159 {
2160 combo * Combo = new combo ( attr, this );
2161 MainLayout->addWidget ( Combo );
2162 connect ( Combo->Combo, SIGNAL ( activated ( const QString & ) ), this,
2163 SLOT ( AddToDataList ( const QString & ) ), Qt::UniqueConnection );
2164 BaseWidget = Combo;
2165 Combo->setStyleSheet ( "QLineEdit { background: #c0c0c0;} "
2166 "QLineEdit:focus {background: white;}" );
2167 break;
2168 }
2169
2170 // All numeric types are treated as uint64
2171
2182 {
2183 numericattr * Numeric = new numericattr ( Virtue, this );
2184 MainLayout->addWidget ( Numeric );
2185 connect ( Numeric, SIGNAL ( signal_value_change() ), this, SLOT ( LineValueChanged() ),
2186 Qt::UniqueConnection );
2187 connect ( Numeric, SIGNAL ( signal_value_duplicated() ), this, SLOT ( LineValueChanged() ),
2188 Qt::UniqueConnection );
2189 BaseWidget = Numeric;
2191 Numeric->GetLineEdit()->setFrame ( false );
2192 Numeric->GetLineEdit()->setReadOnly(m_readonly);
2193 Numeric->GetLineEdit()->setPlaceholderText (c_input_placeholder);
2194 Numeric->setStyleSheet (
2195 "QLineEdit { background: #c0c0c0;} QLineEdit:focus {background: white;}" );
2196 Numeric->GetLineEdit()->setFixedHeight ( 24 );
2197 ListWidget->setFrameStyle ( QFrame::NoFrame );
2198 break;
2199 }
2200
2201 // Types below are all treated as string types
2205 {
2206 stringattr * String = new stringattr ( Virtue, this );
2207 String->SetMultiCheck ( true );
2208 MainLayout->addWidget ( String );
2209 connect ( String, SIGNAL ( signal_value_change() ), this, SLOT ( LineValueChanged() ),
2210 Qt::UniqueConnection );
2213 String->GetLineEdit()->setReadOnly(m_readonly);
2214 String->GetLineEdit()->setFrameStyle(QFrame::NoFrame);
2215 String->GetLineEdit()->setPlaceholderText ( c_input_placeholder );
2216 String->setStyleSheet ( "QLineEdit { background: #c0c0c0;} "
2217 "QLineEdit:focus {background: white;}" );
2218// String->GetLineEdit()->setFixedHeight ( 24 );
2219
2220 ListWidget->setFrameStyle ( QFrame::NoFrame );
2221 break;
2222 }
2223
2224 default:
2225 break;
2226 }
2227
2228 OkButton = new QPushButton ( tr ( "Apply" ) );
2229 //RemoveButton = new QPushButton(tr("Remove"));
2230 ButtonLayout->addWidget ( OkButton );
2231 //ButtonLayout->addWidget(RemoveButton);
2232 connect ( OkButton, SIGNAL ( clicked() ), this, SLOT ( EndSignal() ) );
2233 //connect(RemoveButton,SIGNAL(clicked()),this,SLOT(RemoveFromDataList()));
2234 connect ( this, SIGNAL ( signal_internal_value_change() ), this, SLOT ( UpdateActions() ) );
2235 connect ( ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
2236 SLOT ( CustomContextMenuRequested ( QPoint ) ) );
2237
2238 MainLayout->addLayout ( ButtonLayout );
2239 SetStatusBar();
2240 MainLayout->addWidget ( StatusBar );
2241
2242 setLayout ( MainLayout );
2243
2244 if ( Virtue.p_is_not_null )
2245 {
2246 m_base_data_editor->set_valid ( false );
2247 OkButton->setDisabled ( true );
2248 }
2249
2250 if ( this_is_owned )
2251 {
2252 OkButton->setHidden ( true );
2253 }
2254
2255 else
2256 {
2257 QFont Font;
2258 QFontMetrics FontMetrics ( Font );
2259 setMinimumWidth (
2260 2 * FontMetrics.horizontalAdvance ( QString ( "Edit Relationship: %1" ).arg ( Virtue.p_name.c_str() ) )
2261 - 15 );
2262 setMinimumHeight ( 100 );
2263 }
2264
2265 buildtooltip();
2266 UpdateActions();
2267}
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)
std::shared_ptr< t_build_block_editor > m_base_data_editor
dunedaq::conffwk::attribute_t t_virtue

Member Function Documentation

◆ AddToDataList

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

Definition at line 2334 of file BuildingBlockEditors.cpp.

2335{
2336 if ( Data.isEmpty() )
2337 {
2338 return;
2339 }
2340
2341 this_data.append ( Data );
2342
2343 ListWidget->clear();
2344 ListWidget->addItems ( this_data );
2345 StatusBar->showMessage ( QString ( "Item %1 was added." ).arg ( Data ) );
2346
2347 this_value_changed = true;
2349}
nlohmann::json Data
Definition Structs.hpp:24

◆ buildtooltip()

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

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

Definition at line 2294 of file BuildingBlockEditors.cpp.

2295{
2296 t_virtue const & Virtue = m_base_data_editor->get();
2297
2298 setToolTip (
2299 QString ( "Attribute Name: %1 \n" ).arg ( Virtue.p_name.c_str() ) + QString (
2300 " Type: %1 \n" ).arg (
2301 dunedaq::conffwk::attribute_t::type2str ( Virtue.p_type ) )
2302 + QString ( " Range: %1 \n" ).arg ( Virtue.p_range.c_str() )
2303 + QString ( " Format: %1 \n" ).arg (
2304 dunedaq::conffwk::attribute_t::format2str ( Virtue.p_int_format ) )
2305 + QString ( " Not Null: %1 \n" ).arg ( Virtue.p_is_not_null )
2306 + QString ( " Is Multi Value: %1 \n" ).arg ( Virtue.p_is_multi_value )
2307 + QString ( " Default Value: %1 \n" ).arg ( Virtue.p_default_value.c_str() )
2308 + QString ( " Description: %1 \n" ).arg ( Virtue.p_description.c_str() ) );
2309}
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 2311 of file BuildingBlockEditors.cpp.

2312{
2313 Q_UNUSED ( Event )
2314 emit signal_force_close();
2315}

◆ CustomContextMenuRequested

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

Definition at line 2483 of file BuildingBlockEditors.cpp.

2484{
2485 if ( ContextMenu == nullptr )
2486 {
2487 ContextMenu = new QMenu ( ListWidget );
2488
2489 RemoveAction = new QAction ( tr ( "Remove" ), this );
2490 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
2491 connect ( RemoveAction, SIGNAL ( triggered() ), this, SLOT ( RemoveSlot() ),
2492 Qt::UniqueConnection );
2493 ContextMenu->addAction ( RemoveAction );
2494 }
2495
2496 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
2497}

◆ EndSignal

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

Definition at line 2462 of file BuildingBlockEditors.cpp.

2463{
2464 this_data.clear();
2465
2466 for ( int i = 0; i < ListWidget->count(); ++i )
2467 {
2468 this_data.append ( ListWidget->item ( i )->text() );
2469 }
2470
2471 if ( !this_is_owned )
2472 {
2473 m_base_data_editor->set_valid ( true );
2474 emit signal_edit_end();
2475 }
2476
2477 else
2478 {
2479 emit signal_value_change();
2480 }
2481}

◆ eventFilter()

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

Definition at line 2327 of file BuildingBlockEditors.cpp.

2328{
2329 ( void ) Target;
2330 ( void ) Event;
2331 return false;
2332}

◆ LineValueChanged [1/2]

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

Definition at line 2427 of file BuildingBlockEditors.cpp.

2428{
2429 QStringList Data = BaseWidget->getdata();
2430
2431 if ( (!Data.isEmpty()) && BaseWidget->dataeditor()->is_valid())
2432 {
2433 AddToDataList ( Data.at ( 0 ) );
2434 }
2435}

◆ LineValueChanged [2/2]

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

Definition at line 2437 of file BuildingBlockEditors.cpp.

2438{
2439 int r = ListWidget->row ( changed );
2440 QString newtext = changed->text();
2441 QString oldtext = this_data.at ( r );
2442 this_data.replace ( r, newtext );
2443 this_value_changed = true;
2444
2445 StatusBar->showMessage ( QString ( "Item %1 was modified." ).arg ( oldtext ) );
2446
2448}
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 2450 of file BuildingBlockEditors.cpp.

2451{
2452 Q_UNUSED ( IndexList )
2453
2454 this_data.clear();
2455
2456 for ( int i = 0; i < ListWidget->count(); ++i )
2457 {
2458 this_data.append ( ListWidget->item ( i )->text() );
2459 }
2460}

◆ RemoveFromDataList

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

Color management needs to be done

Definition at line 2351 of file BuildingBlockEditors.cpp.

2352{
2353 QList<QListWidgetItem *> widgets = ListWidget->selectedItems();
2354 this_value_changed = true;
2355
2356 for ( QListWidgetItem * widget : widgets )
2357 {
2358 int index = this_data.indexOf ( widget->text() );
2359
2360 if ( index != -1 )
2361 {
2362 this_data.takeAt ( index );
2363 }
2364
2365 int r = ListWidget->row ( widget );
2366
2367 if ( QListWidgetItem * w = ListWidget->takeItem ( r ) )
2368 {
2369 delete w;
2370 }
2371
2372 }
2373
2374 if ( this_is_owned )
2375 {
2376 StatusBar->showMessage ( "The selected items were removed." );
2377 }
2378
2379 if ( dynamic_cast<stringattr *> ( BaseWidget ) )
2380 {
2382 stringattr * StringWidget = dynamic_cast<stringattr *> ( BaseWidget );
2383 StringWidget->GetLineEdit()->selectAll();
2384 StringWidget->GetLineEdit()->clear();
2385 StringWidget->SetCheckDefaults ( false );
2386 StringWidget->SetNullCheck ( true );
2387 }
2388
2390 emit signal_value_change();
2391}

◆ RemoveSlot

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

Definition at line 2499 of file BuildingBlockEditors.cpp.

◆ SetEditor()

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

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

Definition at line 2269 of file BuildingBlockEditors.cpp.

2270{
2271 BaseWidget->SetEditor();
2272
2273 ListWidget->clear();
2274 ListWidget->addItems ( this_data );
2275 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
2276 ListWidget->setDragEnabled ( true );
2277 ListWidget->setAcceptDrops ( true );
2278 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
2279 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
2280
2281 for ( int i = 0; i < ListWidget->count(); ++i )
2282 {
2283 QListWidgetItem * widget = ListWidget->item ( i );
2284 widget->setFlags (
2285 Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled
2286 | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled );
2287 }
2288
2289 connect ( ListWidget, SIGNAL ( itemChanged ( QListWidgetItem * ) ), this,
2290 SLOT ( LineValueChanged ( QListWidgetItem * ) ) );
2292}

◆ SetStatusBar()

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

Color Management needs to be done

Uncomment if you want a status bar

Definition at line 2317 of file BuildingBlockEditors.cpp.

2318{
2319 StatusBar = new QStatusBar ( this );
2320 StatusBar->setSizeGripEnabled ( false );
2322 StatusBar->setAutoFillBackground ( true );
2324 StatusBar->setHidden ( true );
2325}

◆ UpdateActions

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

EditString validator string

Null Check validator string

Definition at line 2393 of file BuildingBlockEditors.cpp.

2394{
2395 t_virtue const & Virtue = m_base_data_editor->get();
2396
2397 if ( Virtue.p_is_not_null and this_data.size() == 0 )
2398 {
2399 OkButton->setDisabled ( true );
2400 StatusBar->showMessage ( "Attribute can not be null." );
2401 m_base_data_editor->set_valid ( false );
2404 }
2405
2406 else if ( Virtue.p_is_not_null and this_data.size() > 0 )
2407 {
2409
2410 StatusBar->showMessage ( "Attribute is set." );
2411 ListWidget->setPalette ( QApplication::palette ( this ) );
2412 OkButton->setEnabled ( true );
2413 m_base_data_editor->set_valid ( true );
2414
2415 if ( this_is_owned )
2416 {
2417 EndSignal();
2418 }
2419 }
2420 else if ( not Virtue.p_is_not_null and this_is_owned )
2421 {
2422 m_base_data_editor->set_valid ( true );
2423 EndSignal();
2424 }
2425}
static QPalette WarningStatusBarPallete

Member Data Documentation

◆ BaseWidget

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

Definition at line 414 of file BuildingBlockEditors.hpp.

◆ ContextMenu

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

Definition at line 415 of file BuildingBlockEditors.hpp.

◆ ListWidget

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

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

◆ m_readonly

bool dbe::widgets::editors::multiattr::m_readonly
private

Definition at line 409 of file BuildingBlockEditors.hpp.

◆ OkButton

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

Definition at line 411 of file BuildingBlockEditors.hpp.

◆ RemoveAction

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

Definition at line 416 of file BuildingBlockEditors.hpp.

◆ RemoveButton

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

Definition at line 412 of file BuildingBlockEditors.hpp.

◆ StatusBar

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

Definition at line 410 of file BuildingBlockEditors.hpp.


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