LCOV - code coverage report
Current view: top level - dbe/src/widgets - BatchChangeWidget.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 350 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 17 0

            Line data    Source code
       1              : #include "dbe/BatchChangeWidget.hpp"
       2              : 
       3              : #include "ui_BatchChangeWidget.h"
       4              : 
       5              : #include "dbe/MainWindow.hpp"
       6              : #include "dbe/config_api.hpp"
       7              : #include "dbe/config_api_set.hpp"
       8              : #include "dbe/config_api_get.hpp"
       9              : #include "dbe/config_api_graph.hpp"
      10              : #include "dbe/messenger.hpp"
      11              : 
      12              : #include <QApplication>
      13              : #include <boost/scope_exit.hpp>
      14              : 
      15              : namespace dbegraph = dbe::config::api::graph;
      16              : 
      17            0 : dbe::BatchChangeWidget::~BatchChangeWidget() = default;
      18              : 
      19            0 : dbe::BatchChangeWidget::BatchChangeWidget ( QWidget * parent )
      20              :   :
      21              :   QWidget ( parent ),
      22            0 :   ui ( new Ui::BatchChangeWidget ),
      23            0 :   UseTable ( false ),
      24            0 :   ClassChanged ( true ),
      25            0 :   TableClass ( "" ),
      26            0 :   m_filter_table ( nullptr )
      27              : {
      28            0 :   ui->setupUi ( this );
      29            0 :   ui->TitleLabel->setStyleSheet (
      30              :     "QLabel { background-color:green; color:beige; font:bold14px; border-style:outset; border-width:2px;"
      31              :     "border-radius:10px; border-color:beige; font:bold14px; min-width:10em; padding:6px}" );
      32            0 :   ui->FirstStepLabel->setStyleSheet ( "QLabel { color:#DB5816; font: bold 14px;}" );
      33            0 :   ui->SecondStepLabel->setStyleSheet ( "QLabel { color:#DE8A14; font: bold 14px;}" );
      34            0 :   ui->ThirdStepLabel->setStyleSheet ( "QLabel { color:#8DAA2E; font: bold 14px;}" );
      35            0 :   setWindowTitle ( "Batch Change" );
      36              : 
      37            0 :   QStringList ListOfClasses ( dbe::config::api::info::onclass::allnames<QStringList>() );
      38            0 :   ui->ClassCombo->addItems ( ListOfClasses );
      39            0 :   ui->ClassCombo->setEditable ( true );
      40            0 :   ui->ClassCombo->setEditText ( "Type/Select Classes" );
      41              : 
      42            0 :   ui->AttributeBox->setEnabled ( false );
      43            0 :   ui->RelationshipBox->setEnabled ( false );
      44            0 :   ui->NewAttributeGroupBox->setEnabled ( false );
      45            0 :   ui->NewRelationshipGroupBox->setEnabled ( false );
      46            0 :   ui->MatchButton->setEnabled ( false );
      47            0 :   ui->FilterUid->setText ( "*" );
      48            0 :   ui->AttributeValueFilter->setText ( "*" );
      49              : 
      50            0 :   SetController();
      51            0 : }
      52              : 
      53            0 : dbe::BatchChangeWidget::BatchChangeWidget ( bool ObjectsFromTable, QString ClassName,
      54            0 :                                             std::vector<dref> & Objects, QWidget * parent )
      55              :   :
      56            0 :   BatchChangeWidget ( parent )
      57              : {
      58            0 :   ClassChanged = false;
      59              : 
      60            0 :   TableObjects = Objects;
      61            0 :   UseTable = ObjectsFromTable;
      62            0 :   TableClass = ClassName;
      63              : 
      64            0 :   ui->ClassCombo->setCurrentIndex ( ui->ClassCombo->findText ( TableClass ) );
      65            0 :   ui->SubclassesCheckBox->setEnabled ( false );
      66            0 :   FillInfo ( TableClass );
      67              : 
      68            0 :   if ( UseTable )
      69              :   {
      70            0 :     setWindowTitle ( "Batch change - Table" );
      71            0 :     ui->FilterGroupBox->hide();
      72            0 :     ui->Label1->hide();
      73            0 :     ui->Label2->hide();
      74            0 :     ui->FirstStepLabel->hide();
      75            0 :     ui->SecondStepLabel->hide();
      76            0 :     ui->ThirdStepLabel->hide();
      77            0 :     ui->Line1->hide();
      78            0 :     ui->Line2->hide();
      79            0 :     ui->TitleLabel->setText ( "Batch Change of multiple objects - Table" );
      80            0 :     resize ( 540, 280 );
      81              :   }
      82            0 : }
      83              : 
      84            0 : void dbe::BatchChangeWidget::SetController()
      85              : {
      86            0 :   connect ( ui->ClassCombo, SIGNAL ( activated ( QString ) ), this,
      87              :             SLOT ( FillInfo ( const QString & ) ) );
      88              : 
      89            0 :   connect ( ui->ChangeButton, SIGNAL ( clicked() ), this, SLOT ( MakeChanges() ) );
      90              : 
      91            0 :   connect ( ui->MatchButton, SIGNAL ( clicked() ), this, SLOT ( FindMatching() ) );
      92              : 
      93            0 :   connect ( ui->NewRelationshipComboBox, SIGNAL ( activated ( QString ) ), this,
      94              :             SLOT ( EnableCheckBox ( QString ) ) );
      95            0 :   connect ( ui->CancelButton, SIGNAL ( clicked() ), this, SLOT ( close() ) );
      96              : 
      97            0 :   connect ( ui->RelationshipComboBox, SIGNAL ( activated ( int ) ), this,
      98              :             SLOT ( UpdateRelationshipFilter ( int ) ) );
      99              : 
     100            0 :   connect ( ui->NewRelationshipComboBox, SIGNAL ( activated ( int ) ), this,
     101              :             SLOT ( UpdateRelationshipNewValues ( int ) ) );
     102              : 
     103            0 :   MainWindow * mainwin = MainWindow::findthis();
     104              : 
     105            0 :   if ( mainwin != nullptr )
     106              :   {
     107            0 :     connect ( this, SIGNAL ( sig_batch_change_start() ), mainwin,
     108              :               SLOT ( slot_batch_change_start() ), Qt::UniqueConnection );
     109            0 :     connect ( this, SIGNAL ( sig_batch_change_stop(const QList<QPair<QString, QString>>&) ), mainwin,
     110              :               SLOT ( slot_batch_change_stop(const QList<QPair<QString, QString>>&) ),
     111              :               Qt::UniqueConnection );
     112              :   }
     113            0 : }
     114              : 
     115            0 : void dbe::BatchChangeWidget::keyPressEvent(QKeyEvent* event) {
     116            0 :   if (event->key() == Qt::Key_Escape) {
     117            0 :     close();
     118              :   }
     119            0 :   QWidget::keyPressEvent(event);
     120            0 : }
     121              : 
     122            0 : void dbe::BatchChangeWidget::filter ( std::vector<dref> & objs, const QString & cname )
     123              : {
     124              : 
     125            0 :   dunedaq::conffwk::class_t const & cinfo = dbe::config::api::info::onclass::definition (
     126            0 :                                          cname.toStdString(), false );
     127            0 :   std::vector<dunedaq::conffwk::attribute_t> const & attributes = cinfo.p_attributes;
     128            0 :   std::vector<dunedaq::conffwk::relationship_t> const & relations = cinfo.p_relationships;
     129              : 
     130              :   // Filtering UID
     131            0 :   std::vector<dref> filtered;
     132              : 
     133            0 :   if ( !ui->FilterUid->text().isEmpty() )
     134              :   {
     135            0 :     QRegExp uidfilter ( ui->FilterUid->text() );
     136            0 :     uidfilter.setPatternSyntax ( QRegExp::Wildcard );
     137              : 
     138            0 :     for ( dbe::dref const & it : objs )
     139              :     {
     140              : 
     141            0 :       if ( uidfilter.exactMatch ( QString::fromStdString ( it.ref().UID() ) ) )
     142              :       {
     143            0 :         filtered.push_back ( it );
     144              :       }
     145              :     }
     146              : 
     147            0 :     objs = filtered;
     148            0 :     filtered.clear();
     149            0 :   }
     150              : 
     151              : /// Filtering Attributes
     152            0 :   QRegExp attribute_filter ( ui->AttributeValueFilter->text() );
     153            0 :   attribute_filter.setPatternSyntax ( QRegExp::Wildcard );
     154              : 
     155            0 :   std::string selected_attribute_name = ui->AttributeComboBox->currentText().toStdString();
     156              : 
     157            0 :   std::vector<dunedaq::conffwk::attribute_t>::const_iterator attrdef = std::find_if (
     158              :                                                                     std::begin ( attributes ), std::end ( attributes ),
     159            0 :                                                                     [&selected_attribute_name] ( dunedaq::conffwk::attribute_t const & attr )
     160              :   {
     161            0 :     return attr.p_name == selected_attribute_name;
     162              :   } );
     163              : 
     164            0 :   if ( attrdef != std::end ( attributes ) )
     165              :   {
     166            0 :     for ( dbe::dref const & it : objs )
     167              :     {
     168            0 :       QStringList values
     169            0 :       { dbe::config::api::get::attribute::list<QStringList> ( it.ref(), *attrdef ) };
     170              : 
     171            0 :       for ( QString & v : values )
     172            0 :         if ( attribute_filter.exactMatch ( v ) )
     173              :         {
     174            0 :           filtered.push_back ( it );
     175              :           break;
     176              :         }
     177            0 :     }
     178              : 
     179              :   }
     180              : 
     181            0 :   objs = filtered;
     182            0 :   filtered.clear();
     183              : 
     184              :   // Filter on Relationship
     185              : 
     186            0 :   std::string selected_relation_name =
     187            0 :     ui->RelationshipComboBox->currentText().toStdString();
     188              : 
     189            0 :   std::vector<dunedaq::conffwk::relationship_t>::const_iterator relationdef = std::find_if (
     190              :                                                                            std::begin ( relations ), std::end ( relations ),
     191            0 :                                                                            [&selected_relation_name] ( dunedaq::conffwk::relationship_t const & rel )
     192              :   {
     193            0 :     return rel.p_name == selected_relation_name;
     194              :   } );
     195              : 
     196            0 :   if ( relationdef != std::end ( relations ) )
     197              :   {
     198            0 :     QRegExp relation_filter ( ui->RelationshipValueFilter->currentText() );
     199            0 :     relation_filter.setPatternSyntax ( QRegExp::Wildcard );
     200              : 
     201            0 :     for ( dbe::dref const & it : objs )
     202              :     {
     203            0 :       QStringList ValueList
     204              :       {
     205              :         dbegraph::linked::through::relation<QStringList> (
     206            0 :           it.ref(), *relationdef ) };
     207              : 
     208            0 :       if ( ValueList.isEmpty() and ( ui->RelationshipValueFilter->currentText() == "*"
     209            0 :                                      or ui->RelationshipValueFilter->currentText() == "" ) )
     210              :       {
     211            0 :         filtered.push_back ( it );
     212              :       }
     213              :       else
     214              :       {
     215            0 :         for ( QString const & v : ValueList )
     216            0 :           if ( relation_filter.exactMatch ( v ) )
     217              :           {
     218            0 :             filtered.push_back ( it );
     219              :             break;
     220              :           }
     221              :       }
     222            0 :     }
     223              : 
     224            0 :   }
     225              : 
     226            0 :   objs = filtered;
     227            0 :   filtered.clear();
     228            0 : }
     229              : 
     230            0 : void dbe::BatchChangeWidget::FillInfo ( const QString & Name )
     231              : {
     232            0 :   ui->AttributeBox->setEnabled ( false );
     233            0 :   ui->RelationshipBox->setEnabled ( false );
     234            0 :   ui->NewAttributeGroupBox->setEnabled ( false );
     235            0 :   ui->NewRelationshipGroupBox->setEnabled ( false );
     236              : 
     237            0 :   const dunedaq::conffwk::class_t & ClassInfo = dbe::config::api::info::onclass::definition (
     238            0 :                                              Name.toStdString(),
     239            0 :                                              false );
     240            0 :   const std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.p_attributes;
     241            0 :   const std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo
     242            0 :                                                                     .p_relationships;
     243              : 
     244            0 :   QStringList ValueList;
     245              : 
     246            0 :   for ( dunedaq::conffwk::attribute_t Attribute : AttributeList )
     247              :   {
     248            0 :     ValueList.append ( QString ( Attribute.p_name.c_str() ) );
     249            0 :   }
     250              : 
     251            0 :   ui->AttributeComboBox->clear();
     252            0 :   ui->NewAttributeComboBox->clear();
     253            0 :   ui->AttributeComboBox->addItems ( ValueList );
     254            0 :   ui->NewAttributeComboBox->addItems ( ValueList );
     255              : 
     256            0 :   if ( !AttributeList.empty() && !UseTable )
     257              :   {
     258            0 :     ui->AttributeBox->setEnabled ( true );
     259            0 :     ui->NewAttributeGroupBox->setEnabled ( true );
     260            0 :     ui->MatchButton->setEnabled ( true );
     261              :   }
     262              : 
     263            0 :   if ( !AttributeList.empty() && UseTable )
     264              :   {
     265            0 :     ui->NewAttributeGroupBox->setEnabled ( true );
     266              :   }
     267              : 
     268            0 :   ValueList.clear();
     269              : 
     270            0 :   for ( dunedaq::conffwk::relationship_t Relationship : RelationshipList )
     271              :   {
     272            0 :     ValueList.append ( QString ( Relationship.p_name.c_str() ) );
     273            0 :   }
     274              : 
     275            0 :   ui->RelationshipComboBox->clear();
     276            0 :   ui->NewRelationshipComboBox->clear();
     277            0 :   ui->RelationshipComboBox->addItems ( ValueList );
     278            0 :   ui->NewRelationshipComboBox->addItems ( ValueList );
     279              : 
     280            0 :   if ( !RelationshipList.empty() && !UseTable )
     281              :   {
     282            0 :     ui->RelationshipBox->setEnabled ( true );
     283            0 :     ui->NewRelationshipGroupBox->setEnabled ( true );
     284            0 :     ui->MatchButton->setEnabled ( true );
     285              :   }
     286              : 
     287            0 :   if ( !RelationshipList.empty() && UseTable )
     288              :   {
     289            0 :     ui->NewRelationshipGroupBox->setEnabled ( true );
     290              :   }
     291              : 
     292            0 :   if ( !UseTable )
     293              :   {
     294            0 :     UpdateRelationshipFilter ( 0 );
     295            0 :     UpdateRelationshipNewValues ( 0 );
     296            0 :     ui->RelationshipValueFilter->setCurrentIndex ( 0 );
     297            0 :     ui->RelationshipEdit->setCurrentIndex ( -1 );
     298              :   }
     299              :   else
     300              :   {
     301            0 :     UpdateRelationshipNewValues ( 0 );
     302            0 :     ui->RelationshipEdit->setCurrentIndex ( -1 );
     303              :   }
     304              : 
     305            0 :   if ( ClassChanged )
     306              :   {
     307            0 :     UseTable = false;
     308              :   }
     309              : 
     310            0 :   ClassChanged = true;
     311            0 : }
     312              : 
     313            0 : void dbe::BatchChangeWidget::MakeChanges()
     314              : {
     315            0 :   std::vector<dref> Objects;
     316              : 
     317            0 :   BOOST_SCOPE_EXIT(&Objects, this_)
     318              :   {
     319            0 :       QList<QPair<QString, QString>> objs;
     320            0 :       for(const auto& o : Objects) {
     321            0 :           objs.append(QPair<QString, QString>(QString::fromStdString(o.class_name()),
     322            0 :                                               QString::fromStdString(o.UID())));
     323              :       }
     324              : 
     325            0 :       this_->emit sig_batch_change_stop(objs);
     326              : 
     327              : 
     328            0 :       QApplication::restoreOverrideCursor();
     329            0 :       this_->ui->ChangeButton->setEnabled(true);
     330            0 :       confaccessor::ref().blockSignals(false);
     331            0 :   }
     332            0 :   BOOST_SCOPE_EXIT_END
     333              : 
     334            0 :   ui->ChangeButton->setEnabled(false);
     335            0 :   QApplication::setOverrideCursor(Qt::WaitCursor);
     336            0 :   confaccessor::ref().blockSignals(true);
     337              : 
     338            0 :   bool SubClasses = ui->SubclassesCheckBox->isChecked();
     339            0 :   QString ClassName = ui->ClassCombo->currentText();
     340              : 
     341            0 :   std::unique_ptr<dbe::interface::messenger::batch_guard> batchmode (
     342            0 :     interface::messenger::qt::batchmode() );
     343              : 
     344            0 :   emit sig_batch_change_start();
     345              : 
     346            0 :   if ( not UseTable )
     347              :   {
     348            0 :     std::vector<tref> const & tmprefs = dbe::config::api::info::onclass::objects (
     349            0 :                                           ClassName.toStdString(), SubClasses );
     350              : 
     351            0 :     std::copy ( tmprefs.begin(), tmprefs.end(), std::back_inserter ( Objects ) );
     352              : 
     353            0 :     if ( not Objects.empty() )
     354              :     {
     355            0 :       filter ( Objects, ClassName );
     356              :     }
     357            0 :   }
     358              :   else
     359              :   {
     360            0 :     Objects = TableObjects;
     361              :   }
     362              : 
     363            0 :   if ( Objects.empty() ) QMessageBox::information ( this, tr ( "Message" ),
     364            0 :                                                       tr ( "No objects match filter!" ) );
     365              :   else
     366              :   {
     367            0 :     const dunedaq::conffwk::class_t & ClassInfo = dbe::config::api::info::onclass::definition (
     368            0 :                                                ClassName.toStdString(), false );
     369            0 :     const std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.p_attributes;
     370            0 :     const std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo
     371            0 :                                                                       .p_relationships;
     372            0 :     dunedaq::conffwk::attribute_t AttributeChange;
     373            0 :     dunedaq::conffwk::relationship_t RelationshipChange;
     374              : 
     375            0 :     for ( dunedaq::conffwk::attribute_t i : AttributeList )
     376            0 :       if ( i.p_name == ui->NewAttributeComboBox->currentText().toStdString() )
     377              :       {
     378            0 :         AttributeChange = i;
     379            0 :         break;
     380            0 :       }
     381              : 
     382            0 :     for ( dunedaq::conffwk::relationship_t i : RelationshipList )
     383            0 :       if ( i.p_name == ui->NewRelationshipComboBox->currentText().toStdString() )
     384              :       {
     385            0 :         RelationshipChange = i;
     386            0 :         break;
     387            0 :       }
     388              : 
     389            0 :     QStringList AttributeChangeList;
     390              : 
     391            0 :     if ( !ui->AttributeEdit->text().isEmpty() ) AttributeChangeList
     392            0 :           << ui->AttributeEdit->text();
     393              : 
     394            0 :     for ( auto objects_iter = Objects.begin(); objects_iter != Objects.end(); ++objects_iter )
     395              :     {
     396            0 :       tref Object = objects_iter->ref();
     397              : 
     398            0 :       QStringList RelationshipChangeList;
     399              : 
     400            0 :       if ( ui->ChangeAtrributeCheckBox->isChecked() )
     401              :       {
     402            0 :         if ( !AttributeChangeList.isEmpty() )
     403              :         {
     404            0 :           dbe::config::api::set::attribute ( Object, AttributeChange, AttributeChangeList );
     405              :         }
     406              :       }
     407              : 
     408            0 :       if ( ui->ChangeRelationshipCheckBox->isChecked() )
     409              :       {
     410            0 :         if ( ui->AddCheckBox->isChecked() )
     411              :         {
     412            0 :           RelationshipChangeList =
     413            0 :             dbegraph::linked::through::relation<QStringList> (
     414            0 :               Object, RelationshipChange );
     415              :         }
     416              : 
     417            0 :         RelationshipChangeList << ui->RelationshipEdit->currentText();
     418            0 :         dbe::config::api::set::relation ( Object, RelationshipChange, RelationshipChangeList );
     419              :       }
     420            0 :     }
     421            0 :   }
     422            0 : }
     423              : 
     424            0 : void dbe::BatchChangeWidget::FindMatching()
     425              : {
     426            0 :   QString ClassName = ui->ClassCombo->currentText();
     427            0 :   bool SubClasses = ui->SubclassesCheckBox->isChecked();
     428              : 
     429            0 :   std::vector<tref> const & tmprefs = dbe::config::api::info::onclass::objects (
     430            0 :                                         ClassName.toStdString(), SubClasses );
     431              : 
     432            0 :   std::vector<dref> candidates;
     433            0 :   std::copy ( tmprefs.begin(), tmprefs.end(), std::back_inserter ( candidates ) );
     434              : 
     435            0 :   if ( !candidates.empty() )
     436              :   {
     437            0 :     filter ( candidates, ClassName );
     438              :   }
     439              : 
     440            0 :   if ( candidates.empty() )
     441              :   {
     442            0 :     QMessageBox::information ( this, tr ( "Message" ), tr ( "No objects match filter!" ) );
     443              :   }
     444              :   else
     445              :   {
     446            0 :     int NumberOfColumns = 1;
     447            0 :     bool AttributeEnabled = false;
     448            0 :     bool RelationshipEnabled = false;
     449              : 
     450            0 :     if ( ui->AttributeComboBox->isEnabled() )
     451              :     {
     452            0 :       AttributeEnabled = true;
     453            0 :       NumberOfColumns++;
     454              :     }
     455              : 
     456            0 :     if ( ui->RelationshipComboBox->isEnabled() )
     457              :     {
     458            0 :       RelationshipEnabled = true;
     459            0 :       NumberOfColumns++;
     460              :     }
     461              : 
     462            0 :     m_filter_table = std::unique_ptr<QTableWidget> ( new QTableWidget() );
     463            0 :     m_filter_table->setWindowTitle ( tr ( "Objects matching filter" ) );
     464            0 :     m_filter_table->setColumnCount ( NumberOfColumns );
     465            0 :     m_filter_table->setRowCount ( candidates.size() );
     466              : 
     467            0 :     for ( size_t i = 0; i < candidates.size(); i++ )
     468              :     {
     469            0 :       QTableWidgetItem * AttributeValue;
     470            0 :       QTableWidgetItem * RelationshipValue;
     471              : 
     472            0 :       QTableWidgetItem * ObjectUid = new QTableWidgetItem (
     473            0 :         tr ( "%1@%2" ).arg ( candidates.at ( i ).UID().c_str() ).arg (
     474            0 :           candidates.at ( i ).class_name().c_str() ) );
     475            0 :       m_filter_table->setItem ( i, 0, ObjectUid );
     476              : 
     477            0 :       if ( AttributeEnabled )
     478              :       {
     479            0 :         dunedaq::conffwk::attribute_t Attribute = dbe::config::api::info::attributematch (
     480            0 :                                                ui->AttributeComboBox->currentText(), ClassName );
     481              : 
     482            0 :         QStringList AttributeValueList
     483              :         {
     484            0 :           dbe::config::api::get::attribute::list<QStringList> ( candidates.at ( i ).ref(),
     485            0 :           Attribute ) };
     486              : 
     487            0 :         AttributeValue = new QTableWidgetItem ( AttributeValueList.join ( " " ) );
     488            0 :         m_filter_table->setItem ( i, 1, AttributeValue );
     489            0 :       }
     490              : 
     491            0 :       if ( RelationshipEnabled )
     492              :       {
     493            0 :         dunedaq::conffwk::relationship_t Relationship = config::api::info::relation::match (
     494            0 :                                                      ui->RelationshipComboBox->currentText(), ClassName );
     495              : 
     496            0 :         QStringList RelationshipList
     497              :         {
     498              :           dbegraph::linked::through::relation<QStringList> (
     499            0 :             candidates.at ( i ).ref(), Relationship ) };
     500              : 
     501            0 :         RelationshipValue = new QTableWidgetItem ( RelationshipList.join ( " " ) );
     502            0 :         m_filter_table->setItem ( i, 2, RelationshipValue );
     503            0 :       }
     504              :     }
     505              : 
     506            0 :     QStringList Headers;
     507            0 :     Headers << "Object Id";
     508              : 
     509            0 :     if ( AttributeEnabled )
     510              :     {
     511            0 :       Headers << ui->AttributeComboBox->currentText();
     512              :     }
     513              : 
     514            0 :     if ( RelationshipEnabled )
     515              :     {
     516            0 :       Headers << ui->RelationshipComboBox->currentText();
     517              :     }
     518              : 
     519            0 :     m_filter_table->setHorizontalHeaderLabels ( Headers );
     520              : 
     521            0 :     QHeaderView * HeaderView = m_filter_table->horizontalHeader();
     522            0 :     HeaderView->setStretchLastSection ( true );
     523            0 :     m_filter_table->resize ( 500, 300 );
     524            0 :     m_filter_table->show();
     525            0 :   }
     526            0 : }
     527              : 
     528            0 : void dbe::BatchChangeWidget::EnableCheckBox ( QString RelationshipName )
     529              : {
     530            0 :   QString ClassName = ui->ClassCombo->currentText();
     531            0 :   const dunedaq::conffwk::class_t & ClassInfo = dbe::config::api::info::onclass::definition (
     532            0 :                                              ClassName.toStdString(), false );
     533            0 :   std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.p_relationships;
     534              : 
     535            0 :   for ( dunedaq::conffwk::relationship_t & i : RelationshipList )
     536              :   {
     537            0 :     if ( i.p_name == RelationshipName.toStdString() )
     538              :     {
     539            0 :       if ( ( i.p_cardinality == dunedaq::conffwk::zero_or_many ) || ( i.p_cardinality
     540              :                                                                  == dunedaq::conffwk::one_or_many ) )
     541              :       {
     542            0 :         ui->AddCheckBox->setEnabled ( true );
     543              :       }
     544              :       else
     545              :       {
     546            0 :         ui->AddCheckBox->setEnabled ( false );
     547              :       }
     548              : 
     549              :       break;
     550              :     }
     551              :   }
     552            0 : }
     553              : 
     554            0 : void dbe::BatchChangeWidget::UpdateRelationshipFilter ( int )
     555              : {
     556            0 :   ui->RelationshipValueFilter->clear();
     557            0 :   ui->RelationshipValueFilter->addItem ( "*" );
     558              : 
     559            0 :   QString ClassName = ui->ClassCombo->currentText();
     560            0 :   QString RelationshipName = ui->RelationshipComboBox->currentText();
     561              : 
     562            0 :   const dunedaq::conffwk::class_t & ClassInfo = dbe::config::api::info::onclass::definition (
     563            0 :                                              ClassName.toStdString(), false );
     564            0 :   std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.p_relationships;
     565              : 
     566            0 :   if ( RelationshipList.size() != 0 )
     567              :   {
     568            0 :     dunedaq::conffwk::relationship_t ChosenRelationship;
     569              : 
     570            0 :     for ( dunedaq::conffwk::relationship_t & i : RelationshipList )
     571              :     {
     572            0 :       if ( i.p_name == RelationshipName.toStdString() )
     573              :       {
     574            0 :         ChosenRelationship = i;
     575              :         break;
     576              :       }
     577              :     }
     578              : 
     579            0 :     std::vector<tref> const & Objects = dbe::config::api::info::onclass::objects (
     580            0 :                                           ChosenRelationship.p_type );
     581              : 
     582            0 :     QStringList ObjectsUid;
     583              : 
     584            0 :     for ( tref const & Object : Objects )
     585              :     {
     586            0 :       ObjectsUid.append ( Object.UID().c_str() );
     587              :     }
     588              : 
     589            0 :     ui->RelationshipValueFilter->addItems ( ObjectsUid );
     590            0 :   }
     591            0 : }
     592              : 
     593            0 : void dbe::BatchChangeWidget::UpdateRelationshipNewValues ( int )
     594              : {
     595            0 :   ui->RelationshipEdit->clear();
     596              : 
     597            0 :   QString ClassName = ui->ClassCombo->currentText();
     598            0 :   QString RelationshipName = ui->NewRelationshipComboBox->currentText();
     599              : 
     600            0 :   const dunedaq::conffwk::class_t & ClassInfo = dbe::config::api::info::onclass::definition (
     601            0 :                                              ClassName.toStdString(), false );
     602            0 :   std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.p_relationships;
     603              : 
     604            0 :   if ( RelationshipList.size() != 0 )
     605              :   {
     606            0 :     dunedaq::conffwk::relationship_t ChosenRelationship;
     607              : 
     608            0 :     for ( dunedaq::conffwk::relationship_t & i : RelationshipList )
     609              :     {
     610            0 :       if ( i.p_name == RelationshipName.toStdString() )
     611              :       {
     612            0 :         ChosenRelationship = i;
     613              :         break;
     614              :       }
     615              :     }
     616              : 
     617            0 :     std::vector<tref> const & Objects = dbe::config::api::info::onclass::objects (
     618            0 :                                           ChosenRelationship.p_type );
     619              : 
     620            0 :     QStringList ObjectsUid;
     621              : 
     622            0 :     for ( tref const & Object : Objects )
     623              :     {
     624            0 :       ObjectsUid.append ( Object.UID().c_str() );
     625              :     }
     626              : 
     627            0 :     ui->RelationshipEdit->addItems ( ObjectsUid );
     628            0 :   }
     629            0 : }
        

Generated by: LCOV version 2.0-1