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

Generated by: LCOV version 2.0-1