LCOV - code coverage report
Current view: top level - dbe/src/structure - treenode.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 186 0
Test Date: 2026-07-12 15:23:06 Functions: 0.0 % 38 0

            Line data    Source code
       1              : // DUNE DAQ modification notice:
       2              : // This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
       3              : // Fork baseline commit: dbe-02-12-17 (2022-05-12).
       4              : // Renamed since fork: no.
       5              : 
       6              : /// Including QT Headers
       7              : #include "dbe/confaccessor.hpp"
       8              : #include "dbe/treenode.hpp"
       9              : #include "dbe/ui_constants.hpp"
      10              : #include "dbe/config_api_get.hpp"
      11              : #include "dbe/config_api_graph.hpp"
      12              : #include "dbe/dbcontroller.hpp"
      13              : #include "dbe/StyleUtility.hpp"
      14              : 
      15              : #include <QGraphicsPixmapItem>
      16              : #include <QGraphicsScene>
      17              : #include <QPainter>
      18              : #include <QBitmap>
      19              : #include <QDrag>
      20              : #include <QGraphicsSceneMouseEvent>
      21              : #include <QMimeData>
      22              : #include <QApplication>
      23              : #include <QMessageBox>
      24              : #include <QComboBox>
      25              : #include <QHBoxLayout>
      26              : #include <QPushButton>
      27              : #include <QLabel>
      28              : 
      29            0 : dbe::treenode::treenode ( treenode * ParentNode )
      30              :   :
      31            0 :   Parent ( ParentNode ),
      32            0 :   HasStructure ( false ),
      33            0 :   WasFetched ( false )
      34              : {
      35            0 :   if ( Parent != nullptr )
      36              :   {
      37            0 :     Parent->AddChild ( this );
      38              :   }
      39            0 : }
      40              : 
      41            0 : dbe::treenode::treenode ( const QString & Datum, treenode * ParentNode )
      42              :   :
      43            0 :   treenode ( ParentNode )
      44              : {
      45            0 :   Data.append ( Datum );
      46            0 : }
      47              : 
      48            0 : dbe::treenode::treenode ( const QStringList & DataList, treenode * ParentNode )
      49              :   :
      50            0 :   treenode ( ParentNode )
      51              : {
      52              : 
      53            0 :   for ( auto & i : DataList )
      54              :   {
      55            0 :     Data.append ( i );
      56              :   }
      57            0 : }
      58              : 
      59            0 : dbe::treenode::~treenode()
      60              : {
      61            0 :   qDeleteAll ( Children );
      62            0 : }
      63              : 
      64            0 : QVariant dbe::treenode::GetData ( const int Column, int role ) const
      65              : {
      66            0 :   if ( role == Qt::DisplayRole )
      67              :   {
      68            0 :     return Data.value ( Column );
      69              :   }
      70              :   else
      71              :   {
      72            0 :     return QVariant();
      73              :   }
      74              : }
      75              : 
      76            0 : void dbe::treenode::rename ( QString const & name )
      77              : {
      78            0 :   Data[0] = QVariant ( name );
      79            0 : }
      80              : 
      81            0 : dbe::tref dbe::treenode::GetObject() const
      82              : {
      83            0 :   throw daq::dbe::cannot_handle_invalid_qmodelindex ( ERS_HERE );
      84              : }
      85              : 
      86            0 : int dbe::treenode::GetRow() const
      87              : {
      88            0 :   if ( Parent )
      89              :   {
      90            0 :     return Parent->Children.indexOf ( const_cast<treenode *> ( this ) );
      91              :   }
      92              : 
      93              :   return 0;
      94              : }
      95              : 
      96            0 : void dbe::treenode::AddChild ( treenode * Child )
      97              : {
      98            0 :   Children.append ( Child );
      99            0 : }
     100              : 
     101            0 : void dbe::treenode::RemoveChild ( treenode * Child )
     102              : {
     103            0 :   Children.removeOne ( Child );
     104            0 : }
     105              : 
     106            0 : dbe::treenode * dbe::treenode::GetChild ( const int Row ) const
     107              : {
     108            0 :   return Children.at ( Row );
     109              : }
     110              : 
     111            0 : QList<dbe::treenode *> dbe::treenode::GetChildren() const
     112              : {
     113            0 :   return Children;
     114              : }
     115              : 
     116            0 : dbe::treenode * dbe::treenode::GetParent() const
     117              : {
     118            0 :   return Parent;
     119              : }
     120              : 
     121            0 : int dbe::treenode::ChildCount() const
     122              : {
     123            0 :   return Children.size();
     124              : }
     125              : 
     126            0 : int dbe::treenode::ColumnCount() const
     127              : {
     128            0 :   return Data.size();
     129              : }
     130              : 
     131            0 : void dbe::treenode::SetHasStructure ( bool Structure )
     132              : {
     133            0 :   HasStructure = Structure;
     134            0 : }
     135              : 
     136            0 : bool dbe::treenode::GetHasStructure() const
     137              : {
     138            0 :   return HasStructure;
     139              : }
     140              : 
     141            0 : void dbe::treenode::SetWasFetched ( bool Fetched )
     142              : {
     143            0 :   WasFetched = Fetched;
     144            0 : }
     145              : 
     146            0 : bool dbe::treenode::GetWasFetched() const
     147              : {
     148            0 :   return WasFetched;
     149              : }
     150              : 
     151            0 : dbe::ClassNode::ClassNode ( const dunedaq::conffwk::class_t & Info, treenode * ParentNode )
     152              :   :
     153              :   treenode ( ParentNode ),
     154            0 :   ClassInfo ( Info ),
     155            0 :   numObjects( 0 )
     156              : {
     157            0 :     Data.append ( QVariant ( QString::fromStdString ( ClassInfo.p_name ) ) );
     158            0 :     Data.append ( QVariant ( numObjects ) );
     159            0 :     m_tooltip = QVariant ( QString::fromStdString ( ClassInfo.p_description ) );
     160            0 : }
     161              : 
     162            0 : dbe::ClassNode::~ClassNode()
     163              : {
     164            0 : }
     165              : 
     166            0 : void dbe::ClassNode::updateData(bool addition) {
     167            0 :     addition ? ++numObjects : --numObjects;
     168              : 
     169            0 :     Data[1] =  QVariant ( numObjects );
     170              : 
     171            0 :     confaccessor::increase_total_objects ( addition == true ? 1 : -1 );
     172              : 
     173            0 :     if ( numObjects == 0 )
     174              :     {
     175            0 :       SetWasFetched ( true );
     176              :     }
     177              :     else
     178              :     {
     179            0 :       SetHasStructure ( true );
     180              :     }
     181            0 : }
     182              : 
     183            0 : void dbe::ClassNode::AddChild ( treenode * Child )
     184              : {
     185            0 :     dbe::treenode::AddChild(Child);
     186            0 :     updateData(true);
     187            0 : }
     188              : 
     189            0 : void dbe::ClassNode::RemoveChild ( treenode * Child )
     190              : {
     191            0 :     dbe::treenode::RemoveChild(Child);
     192            0 :     updateData(false);
     193            0 : }
     194              : 
     195            0 : QVariant dbe::ClassNode::GetData ( const int Column, int role ) const
     196              : {
     197            0 :   switch ( role )
     198              :   {
     199              : 
     200            0 :   case Qt::DisplayRole:
     201            0 :     return Data.value ( Column );
     202              : 
     203            0 :   case Qt::ToolTipRole:
     204              : 
     205            0 :     return m_tooltip;
     206              : 
     207            0 :     break;
     208            0 :   case Qt::DecorationRole:
     209              : 
     210            0 :     if ( Column == 0 )
     211              :     {
     212            0 :       return QIcon ( ":/Images/Folder.png" );
     213              :     }
     214              :   }
     215              : 
     216            0 :   return QVariant();
     217              : }
     218              : 
     219            0 : dunedaq::conffwk::class_t dbe::ClassNode::GetClassInfo() const
     220              : {
     221            0 :   return ClassInfo;
     222              : }
     223              : 
     224            0 : dbe::ObjectNode::ObjectNode ( dref obj, bool acopy, treenode * ParentNode )
     225              :   :
     226              :   treenode ( ParentNode ),
     227            0 :   configdata ( obj )
     228              : {
     229            0 :   Data.append ( QVariant ( QString::fromStdString ( configdata.UID() ) ) );
     230            0 :   if ( not acopy )
     231              :   {
     232            0 :     dunedaq::conffwk::class_t ClassInfo = dbe::config::api::info::onclass::definition (
     233            0 :                                        configdata.class_name(),
     234            0 :                                        false );
     235            0 :     std::vector<dunedaq::conffwk::attribute_t> Attributes = ClassInfo.p_attributes;
     236            0 :     std::vector<dunedaq::conffwk::relationship_t> Relationships = ClassInfo.p_relationships;
     237              : 
     238            0 :     if ( ( Relationships.size() > 0 ) )
     239              :     {
     240            0 :       SetHasStructure ( true );
     241              :     }
     242              : 
     243            0 :     for ( dunedaq::conffwk::attribute_t & Attribute : Attributes )
     244              :     {
     245            0 :       new AttributeNode ( Attribute, static_cast<treenode *> ( this ) );
     246              :     }
     247              : 
     248            0 :     for ( dunedaq::conffwk::relationship_t & Relationship : Relationships )
     249              :     {
     250            0 :       new RelationshipNode ( Relationship, static_cast<treenode *> ( this ) );
     251              :     }
     252            0 :   }
     253              : 
     254            0 :   SetWasFetched ( true );
     255            0 : }
     256              : 
     257            0 : dbe::ObjectNode::~ObjectNode() = default;
     258              : 
     259            0 : QVariant dbe::ObjectNode::GetData ( const int Column, int role ) const
     260              : {
     261            0 :   switch ( role )
     262              :   {
     263              : 
     264            0 :   case Qt::DisplayRole:
     265            0 :     return Data.value ( Column );
     266              : 
     267            0 :   case Qt::DecorationRole:
     268              : 
     269            0 :     if ( Column == 0 )
     270              :     {
     271            0 :       return QIcon ( ":/Images/TextGeneric.png" );
     272              :     }
     273              :     break;
     274              :   }
     275              : 
     276            0 :   return QVariant();
     277              : }
     278              : 
     279            0 : dbe::tref dbe::ObjectNode::GetObject() const
     280              : {
     281            0 :   return configdata.ref();
     282              : }
     283              : 
     284            0 : dbe::AttributeNode::AttributeNode ( const dunedaq::conffwk::attribute_t & AttributeData,
     285            0 :                                     treenode * ParentNode )
     286              :   :
     287              :   treenode ( ParentNode ),
     288            0 :   attribute_t_definition ( AttributeData )
     289              : {
     290            0 :   Data.append ( QVariant ( QString::fromStdString ( AttributeData.p_name ) ) );
     291              : 
     292            0 :   tref ObjectParent = GetParent()->GetObject();
     293              : 
     294            0 :   QStringList DataList
     295            0 :   { dbe::config::api::get::attribute::list<QStringList> ( ObjectParent, AttributeData ) };
     296              : 
     297            0 :   for ( QString & ObjectData : DataList )
     298              :   {
     299            0 :     if ( !ObjectData.isEmpty() )
     300              :     {
     301            0 :       treenode * ChildNode = new treenode ( ObjectData, static_cast<treenode *> ( this ) );
     302            0 :       ChildNode->SetWasFetched ( true );
     303              :     }
     304              :   }
     305              : 
     306            0 :   if ( DataList.size() > 0 && !DataList.at ( 0 ).isNull() )
     307              :   {
     308            0 :     SetHasStructure ( true );
     309              :   }
     310              : 
     311            0 :   SetWasFetched ( true );
     312            0 : }
     313              : 
     314            0 : dbe::AttributeNode::~AttributeNode() = default;
     315              : 
     316            0 : QVariant dbe::AttributeNode::GetData ( const int Column, int role ) const
     317              : {
     318            0 :   switch ( role )
     319              :   {
     320              : 
     321            0 :   case Qt::DisplayRole:
     322            0 :     return Data.value ( Column );
     323              : 
     324            0 :   case Qt::DecorationRole:
     325              : 
     326            0 :     if ( Column == 0 )
     327              :     {
     328            0 :       return QIcon ( ":/Images/SLink.png" );
     329              :     }
     330              :   }
     331              : 
     332            0 :   return QVariant();
     333              : }
     334              : 
     335            0 : dunedaq::conffwk::attribute_t dbe::AttributeNode::attribute_t() const
     336              : {
     337            0 :   return attribute_t_definition;
     338              : }
     339              : 
     340            0 : dbe::RelationshipNode::RelationshipNode ( const dunedaq::conffwk::relationship_t & relation,
     341            0 :                                           treenode * ParentNode )
     342              :   :
     343              :   treenode ( ParentNode ),
     344            0 :   relation_t_definition ( relation )
     345              : {
     346            0 :   Data.append ( QVariant ( QString::fromStdString ( relation.p_name ) ) );
     347              : 
     348            0 :   std::vector<tref> DataList;
     349            0 :   tref ObjectParent = GetParent()->GetObject();
     350              : 
     351            0 :   if ( ( relation_t_definition.p_cardinality == dunedaq::conffwk::only_one )
     352            0 :        || ( relation_t_definition
     353              :             .p_cardinality
     354              :             == dunedaq::conffwk::zero_or_one ) )
     355              :   {
     356            0 :     try
     357              :     {
     358            0 :       tref Data =
     359            0 :         dbe::config::api::graph::linked::through::relation<tref> (
     360              :           ObjectParent,
     361            0 :           relation );
     362            0 :       DataList.push_back ( Data );
     363            0 :     }
     364            0 :     catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
     365              :     {
     366              :       //nothing needs be done to handle the case that a relationship is not set
     367            0 :     }
     368              :   }
     369              :   else
     370              :   {
     371            0 :     DataList =
     372            0 :       config::api::graph::linked::through::relation<std::vector<tref>> (
     373              :         ObjectParent,
     374            0 :         relation );
     375              :   }
     376              : 
     377            0 :   for ( tref const & Object : DataList )
     378              :   {
     379            0 :     new ObjectNode ( Object, true, static_cast<treenode *> ( this ) );
     380              :   }
     381              : 
     382            0 :   if ( DataList.size() > 0 )
     383              :   {
     384            0 :     SetHasStructure ( true );
     385              :   }
     386              : 
     387            0 :   SetWasFetched ( true );
     388            0 : }
     389              : 
     390            0 : dbe::RelationshipNode::~RelationshipNode() = default;
     391              : 
     392            0 : QVariant dbe::RelationshipNode::GetData ( const int Column, int role ) const
     393              : {
     394            0 :   switch ( role )
     395              :   {
     396              : 
     397            0 :   case Qt::DisplayRole:
     398            0 :     return Data.value ( Column );
     399              : 
     400            0 :   case Qt::DecorationRole:
     401              : 
     402            0 :     if ( Column == 0 )
     403              :     {
     404            0 :       return QIcon ( ":/Images/SLink.png" );
     405              :     }
     406              :   }
     407              : 
     408            0 :   return QVariant();
     409              : }
     410              : 
     411            0 : dunedaq::conffwk::relationship_t dbe::RelationshipNode::relation_t() const
     412              : {
     413            0 :   return relation_t_definition;
     414              : }
        

Generated by: LCOV version 2.0-1