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 379 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 2110 of file BuildingBlockEditors.cpp.

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

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

◆ buildtooltip()

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

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

Definition at line 2275 of file BuildingBlockEditors.cpp.

2276{
2277 t_virtue const & Virtue = m_base_data_editor->get();
2278
2279 setToolTip (
2280 QString ( "Attribute Name: %1 \n" ).arg ( Virtue.p_name.c_str() ) + QString (
2281 " Type: %1 \n" ).arg (
2282 dunedaq::conffwk::attribute_t::type2str ( Virtue.p_type ) )
2283 + QString ( " Range: %1 \n" ).arg ( Virtue.p_range.c_str() )
2284 + QString ( " Format: %1 \n" ).arg (
2285 dunedaq::conffwk::attribute_t::format2str ( Virtue.p_int_format ) )
2286 + QString ( " Not Null: %1 \n" ).arg ( Virtue.p_is_not_null )
2287 + QString ( " Is Multi Value: %1 \n" ).arg ( Virtue.p_is_multi_value )
2288 + QString ( " Default Value: %1 \n" ).arg ( Virtue.p_default_value.c_str() )
2289 + QString ( " Description: %1 \n" ).arg ( Virtue.p_description.c_str() ) );
2290}
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 2292 of file BuildingBlockEditors.cpp.

2293{
2294 Q_UNUSED ( Event )
2295 emit signal_force_close();
2296}

◆ CustomContextMenuRequested

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

Definition at line 2464 of file BuildingBlockEditors.cpp.

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

◆ EndSignal

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

Definition at line 2443 of file BuildingBlockEditors.cpp.

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

◆ eventFilter()

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

Definition at line 2308 of file BuildingBlockEditors.cpp.

2309{
2310 ( void ) Target;
2311 ( void ) Event;
2312 return false;
2313}

◆ LineValueChanged [1/2]

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

Definition at line 2408 of file BuildingBlockEditors.cpp.

2409{
2410 QStringList Data = BaseWidget->getdata();
2411
2412 if ( (!Data.isEmpty()) && BaseWidget->dataeditor()->is_valid())
2413 {
2414 AddToDataList ( Data.at ( 0 ) );
2415 }
2416}

◆ LineValueChanged [2/2]

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

Definition at line 2418 of file BuildingBlockEditors.cpp.

2419{
2420 int r = ListWidget->row ( changed );
2421 QString newtext = changed->text();
2422 QString oldtext = this_data.at ( r );
2423 this_data.replace ( r, newtext );
2424 this_value_changed = true;
2425
2426 StatusBar->showMessage ( QString ( "Item %1 was modified." ).arg ( oldtext ) );
2427
2429}
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 2431 of file BuildingBlockEditors.cpp.

2432{
2433 Q_UNUSED ( IndexList )
2434
2435 this_data.clear();
2436
2437 for ( int i = 0; i < ListWidget->count(); ++i )
2438 {
2439 this_data.append ( ListWidget->item ( i )->text() );
2440 }
2441}

◆ RemoveFromDataList

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

Color management needs to be done

Definition at line 2332 of file BuildingBlockEditors.cpp.

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

◆ RemoveSlot

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

Definition at line 2480 of file BuildingBlockEditors.cpp.

◆ SetEditor()

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

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

Definition at line 2249 of file BuildingBlockEditors.cpp.

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

◆ SetStatusBar()

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

Color Management needs to be done

Uncomment if you want a status bar

Definition at line 2298 of file BuildingBlockEditors.cpp.

2299{
2300 StatusBar = new QStatusBar ( this );
2301 StatusBar->setSizeGripEnabled ( false );
2303 StatusBar->setAutoFillBackground ( true );
2305 StatusBar->setHidden ( true );
2306}

◆ UpdateActions

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

EditString validator string

Null Check validator string

Definition at line 2374 of file BuildingBlockEditors.cpp.

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

Member Data Documentation

◆ BaseWidget

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

Definition at line 403 of file BuildingBlockEditors.hpp.

◆ ContextMenu

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

Definition at line 404 of file BuildingBlockEditors.hpp.

◆ ListWidget

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

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

◆ OkButton

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

Definition at line 400 of file BuildingBlockEditors.hpp.

◆ RemoveAction

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

Definition at line 405 of file BuildingBlockEditors.hpp.

◆ RemoveButton

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

Definition at line 401 of file BuildingBlockEditors.hpp.

◆ StatusBar

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

Definition at line 399 of file BuildingBlockEditors.hpp.


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