LCOV - code coverage report
Current view: top level - dbe/src/structure - subtreeproxy.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 129 0
Test Date: 2026-07-12 15:23:06 Functions: 0.0 % 24 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 DBE
       7              : #include "dbe/config_ui_info.hpp"
       8              : #include "dbe/subtreeproxy.hpp"
       9              : #include "dbe/tree.hpp"
      10              : #include "dbe/treenode.hpp"
      11              : #include "dbe/confaccessor.hpp"
      12              : #include "dbe/messenger.hpp"
      13              : 
      14            0 : dbe::models::subtree_proxy::subtree_proxy ( const QString & Name,
      15              :                                             const QStringList & Default,
      16            0 :                                             QObject * parent )
      17              :   : QSortFilterProxyModel ( parent ),
      18            0 :     this_gui_windowname ( Name ),
      19            0 :     this_default_filter ( Default ),
      20            0 :     this_apply_default_filter ( false )
      21              : {
      22            0 :   check_view_type();
      23            0 :   model_common_connections();
      24            0 : }
      25              : 
      26            0 : dbe::models::subtree_proxy::~subtree_proxy()
      27              : {
      28            0 : }
      29              : 
      30            0 : void dbe::models::subtree_proxy::ResetModel()
      31              : {
      32            0 :   beginResetModel();
      33            0 :   endResetModel();
      34            0 : }
      35              : 
      36            0 : bool dbe::models::subtree_proxy::filterAcceptsRow ( int source_row,
      37              :                                                     const QModelIndex & source_parent ) const
      38              : {
      39            0 :   if ( this_apply_default_filter )
      40              :   {
      41            0 :     return ApplyDefaultFilter ( source_row, source_parent );
      42              :   }
      43              :   else
      44              :   {
      45            0 :     return ApplyUserFilter ( source_row, source_parent );
      46              :   }
      47              : }
      48              : 
      49            0 : bool dbe::models::subtree_proxy::lessThan ( const QModelIndex & left,
      50              :                                             const QModelIndex & right ) const
      51              : {
      52            0 :   if ( left.parent() == QModelIndex() || left.parent().parent() == QModelIndex() )
      53              :   {
      54            0 :     QVariant LeftData = sourceModel()->data ( left );
      55            0 :     QVariant RightData = sourceModel()->data ( right );
      56              : 
      57            0 :     switch ( LeftData.type() )
      58              :     {
      59            0 :     case QVariant::Bool:
      60            0 :     case QVariant::UInt:
      61            0 :       return ( LeftData.toUInt() < RightData.toUInt() );
      62              : 
      63            0 :     case QVariant::Int:
      64            0 :       return ( LeftData.toInt() < RightData.toInt() );
      65              : 
      66            0 :     case QVariant::String:
      67            0 :       return ( ( LeftData.toString() ).compare ( RightData.toString() ) > 0 );
      68              : 
      69              :     default:
      70              :       return false;
      71              :     }
      72              : 
      73              :     return true;
      74            0 :   }
      75              : 
      76              :   return false;
      77              : }
      78              : 
      79            0 : void dbe::models::subtree_proxy::check_view_type()
      80              : {
      81            0 :   this_window_config = confaccessor::guiconfig()->window (
      82            0 :                          this_gui_windowname.toStdString() );
      83              : 
      84            0 :   if ( this_window_config.Title.isEmpty() )
      85              :   {
      86            0 :     this_apply_default_filter = true;
      87              :   }
      88            0 : }
      89              : 
      90            0 : void dbe::models::subtree_proxy::LoadClasses()
      91              : {
      92            0 :   if ( this_apply_default_filter == false )
      93              :   {
      94            0 :     for ( QString const & i : this_window_config.GraphicalClassesList )
      95              :     {
      96            0 :       GraphicalClass Class = confaccessor::guiconfig()->graphical ( i.toStdString() );
      97            0 :       QStringList ClassList = Class.DerivedClasses;
      98            0 :       ClassList.append ( Class.DatabaseClassName );
      99              : 
     100            0 :       for ( QString & ClassName : ClassList )
     101              :       {
     102            0 :         treenode * ClassNode = confaccessor::gethandler()->getnode ( ClassName );
     103              : 
     104            0 :         if ( ClassNode )
     105              :         {
     106            0 :           dbe::models::tree * UnderlyingModel =
     107            0 :             static_cast<dbe::models::tree *> ( sourceModel() );
     108            0 :           QModelIndex ParentIndex = UnderlyingModel->getindex ( ClassNode );
     109              : 
     110            0 :           if ( sourceModel()->canFetchMore ( ParentIndex ) ) sourceModel()->fetchMore (
     111              :               ParentIndex );
     112              :         }
     113              :       }
     114            0 :     }
     115              :   }
     116            0 : }
     117              : 
     118            0 : dbe::tref dbe::models::subtree_proxy::getobject ( const QModelIndex & index ) const
     119              : {
     120            0 :   if ( index.isValid() )
     121              :   {
     122            0 :     QModelIndex sourceParent = mapToSource ( index );
     123            0 :     dbe::models::tree * my = dynamic_cast<dbe::models::tree *> ( sourceModel() );
     124              : 
     125            0 :     if ( my )
     126              :     {
     127            0 :       return my->getobject ( sourceParent );
     128              :     }
     129              :   }
     130              : 
     131            0 :   throw daq::dbe::cannot_handle_invalid_qmodelindex ( ERS_HERE );
     132              : }
     133              : 
     134            0 : dbe::treenode * dbe::models::subtree_proxy::getnode ( const QModelIndex & index ) const
     135              : {
     136            0 :   QModelIndex sourceParent = mapToSource ( index );
     137            0 :   dbe::models::tree * my = dynamic_cast<dbe::models::tree *> ( sourceModel() );
     138              : 
     139            0 :   if ( my )
     140              :   {
     141            0 :     return my->getnode ( sourceParent );
     142              :   }
     143              : 
     144              :   return nullptr;
     145              : }
     146              : 
     147            0 : dunedaq::conffwk::class_t dbe::models::subtree_proxy::getclass ( const QModelIndex & index )
     148              : const
     149              : {
     150            0 :   QModelIndex sourceParent = mapToSource ( index );
     151            0 :   dbe::models::tree * my = dynamic_cast<dbe::models::tree *> ( sourceModel() );
     152              : 
     153            0 :   if ( my )
     154              :   {
     155            0 :     return my->getclass ( sourceParent );
     156              :   }
     157              : 
     158            0 :   return dunedaq::conffwk::class_t();
     159              : }
     160              : 
     161            0 : QAbstractItemModel * dbe::models::subtree_proxy::ReturnSourceModel() const
     162              : {
     163            0 :   return sourceModel();
     164              : }
     165              : 
     166            0 : bool dbe::models::subtree_proxy::ApplyDefaultFilter ( int source_row,
     167              :                                                       const QModelIndex & source_parent ) const
     168              : {
     169            0 :   Q_UNUSED ( source_row )
     170            0 :   Q_UNUSED ( source_parent )
     171              : 
     172            0 :   return true;
     173              : }
     174              : 
     175            0 : bool dbe::models::subtree_proxy::ApplyUserFilter ( int source_row,
     176              :                                                    const QModelIndex & source_parent ) const
     177              : {
     178            0 :   dbe::models::tree * srcmodel = static_cast<tree *> ( sourceModel() );
     179              : 
     180            0 :   QModelIndex const & nodeindex = srcmodel->index ( source_row, 0, source_parent );
     181            0 :   treenode * tofilter = srcmodel->getnode ( nodeindex );
     182            0 :   QString const nodename = srcmodel->data ( nodeindex ).toString();
     183              : 
     184            0 :   if ( not source_parent.isValid() )
     185              :   {
     186              :     /// Process classes
     187              : 
     188            0 :     for ( QString const & admissible : this_window_config.GraphicalClassesList )
     189              :     {
     190            0 :       GraphicalClass candidate = confaccessor::guiconfig()->graphical (
     191            0 :                                    admissible.toStdString() );
     192              : 
     193            0 :       if ( candidate.DatabaseClassName == nodename
     194            0 :            or candidate.DerivedClasses.contains ( nodename ) )
     195              :       {
     196            0 :         return true;
     197              :       }
     198            0 :     }
     199              :   }
     200            0 :   else if ( dynamic_cast<ObjectNode *> ( tofilter ) )
     201              :   {
     202              :     return true;
     203              :   }
     204            0 :   else if ( dynamic_cast<RelationshipNode *> ( tofilter ) )
     205              :   {
     206              :     /// Process objects
     207            0 :     QString const related = sourceModel()->data ( nodeindex.parent().parent() ).toString();
     208              : 
     209            0 :     for ( QString const & admissible : this_window_config.GraphicalClassesList )
     210              :     {
     211            0 :       GraphicalClass candidate = confaccessor::guiconfig()->graphical (
     212            0 :                                    admissible.toStdString() );
     213              : 
     214            0 :       if ( candidate.DatabaseClassName == related or candidate.DerivedClasses.contains (
     215              :              related ) )
     216              :       {
     217            0 :         return candidate.ShowAllRelationships or candidate.Relationships.contains ( nodename );
     218              :       }
     219              : 
     220            0 :     }
     221            0 :   }
     222              : 
     223              :   return false;
     224            0 : }
     225              : //----------------------------------------------------------------------------------------------------
     226              : 
     227              : //----------------------------------------------------------------------------------------------------
     228            0 : MODEL_COMMON_INTERFACE_LOOKUP_IMPL ( dbe::models::subtree_proxy )
     229              : {
     230            0 :   if ( treenode * classnode = confaccessor::gethandler()->getnode (
     231            0 :                                 QString::fromStdString ( obj.class_name() ) ) )
     232              :   {
     233              : 
     234            0 :     auto found = [&obj, classnode] ( int i )
     235              :     {
     236            0 :       return obj.UID() == classnode->GetChild ( i )->GetData ( 0 ).toString().toStdString();
     237            0 :     };
     238              : 
     239            0 :     int i = 0;
     240            0 :     int const childs = classnode->ChildCount();
     241              : 
     242            0 :     for ( ; i < childs and not found ( i ); ++i )
     243              :       ;
     244              : 
     245            0 :     return i == childs ? QModelIndex() : index ( i, 0, QModelIndex() );
     246              :   }
     247              : 
     248            0 :   return QModelIndex();
     249              : }
     250              : 
     251            0 : MODEL_COMMON_INTERFACE_CREATE_THAT_OBJ_IMPL ( dbe::models::subtree_proxy )
     252              : {
     253              : // TODO implement create object from signal for Subtreeproxymodel
     254            0 :   Q_UNUSED(index);
     255            0 :   Q_UNUSED(obj);
     256            0 : }
     257              : 
     258            0 : MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL ( dbe::models::subtree_proxy )
     259              : {
     260            0 :   if ( index.isValid() )
     261              :   {
     262            0 :     this->removeRows ( index.row(), 1, index.parent() );
     263              :   }
     264            0 : }
     265              : 
     266            0 : MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL ( dbe::models::subtree_proxy )
     267              : {
     268              :   //TODO implement rename object
     269            0 :   Q_UNUSED(index);
     270            0 :   Q_UNUSED(obj);
     271            0 : }
     272              : 
     273            0 : MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL ( dbe::models::subtree_proxy )
     274              : {
     275              : // TODO implement update object from signal for Subtreeproxymodel
     276            0 :   Q_UNUSED(index);
     277            0 :   Q_UNUSED(obj);
     278            0 : }
     279              : 
     280            0 : TREEMODEL_REMOVE_ROWS_DEF ( dbe::models::subtree_proxy )
     281            0 : MODEL_COMMON_INTERFACE_SLOTS_DEF ( dbe::models::subtree_proxy )
     282              : //----------------------------------------------------------------------------------------------------
     283              : 
        

Generated by: LCOV version 2.0-1