LCOV - code coverage report
Current view: top level - dbe/src/structure - tableselection.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 109 0
Test Date: 2026-07-12 15:23:06 Functions: 0.0 % 20 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              : #include "dbe/tableselection.hpp"
       7              : 
       8              : #include "dbe/messenger.hpp"
       9              : 
      10            0 : dbe::models::tableselection::tableselection ( QObject * parent )
      11              :   : QSortFilterProxyModel ( parent ),
      12            0 :     Type ( ExactFilter )
      13              : {
      14            0 :   model_common_connections();
      15            0 : }
      16              : 
      17            0 : void dbe::models::tableselection::SetFilterType (
      18              :   dbe::models::tableselection::FilterType Filter )
      19              : {
      20            0 :   Type = Filter;
      21            0 : }
      22              : 
      23            0 : dbe::TableNode * dbe::models::tableselection::getnode ( const QModelIndex & index ) const
      24              : {
      25            0 :   if ( index.isValid() )
      26              :   {
      27            0 :     QModelIndex sourceParent = mapToSource ( index );
      28            0 :     dbe::models::table * my = dynamic_cast<dbe::models::table *> ( sourceModel() );
      29              : 
      30            0 :     if ( my != 0 )
      31              :     {
      32            0 :       return my->getnode ( sourceParent );
      33              :     }
      34              :     else
      35              :     {
      36              :       return nullptr;
      37              :     }
      38              :   }
      39              :   else
      40              :   {
      41              :     return nullptr;
      42              :   }
      43              : }
      44              : 
      45            0 : bool dbe::models::tableselection::setData ( const QModelIndex & index,
      46              :                                             const QVariant & value,
      47              :                                             int role )
      48              : {
      49            0 :   if ( index.isValid() )
      50              :   {
      51            0 :     QModelIndex sourceParent;
      52              : 
      53            0 :     int idx_row = index.row();
      54            0 :     int idx_col = index.column();
      55              : 
      56            0 :     try
      57              :     {
      58            0 :       QModelIndex idx_index = this->index ( idx_row, idx_col );
      59            0 :       sourceParent = mapToSource ( idx_index );
      60              :     }
      61            0 :     catch ( std::exception const & stderr )
      62              :     {
      63            0 :       WARN ( "Error setting data", stderr.what() );
      64            0 :       return true;
      65            0 :     }
      66              : 
      67            0 :     bool success = sourceModel()->setData ( sourceParent, value, role );
      68            0 :     QModelIndex idx_index = this->index ( idx_row, idx_col );
      69            0 :     emit dataChanged ( idx_index, idx_index );
      70              : 
      71            0 :     return success;
      72              :   }
      73              :   else
      74              :   {
      75              :     return true;
      76              :   }
      77              : }
      78              : 
      79            0 : void dbe::models::tableselection::ResetModel()
      80              : {
      81            0 :   beginResetModel();
      82            0 :   endResetModel();
      83            0 : }
      84              : 
      85            0 : bool dbe::models::tableselection::filterAcceptsRow ( int sourceRow,
      86              :                                                      const QModelIndex & sourceParent ) const
      87              : {
      88            0 :   QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
      89              : 
      90            0 :   if ( filterRegExp().isEmpty() )
      91              :   {
      92              :     return true;
      93              :   }
      94              : 
      95            0 :   switch ( Type )
      96              :   {
      97            0 :   case dbe::models::tableselection::RegExpFilter:
      98            0 :     if ( filterRegExp().indexIn ( sourceModel()->data ( index0 ).toString() ) != -1 )
      99              :     {
     100              :       return true;
     101              :     }
     102              :     else
     103              :     {
     104              :       return false;
     105              :     }
     106              : 
     107            0 :   case dbe::models::tableselection::ExactFilter:
     108            0 :     return ( filterRegExp().exactMatch ( sourceModel()->data ( index0 ).toString() ) );
     109              : 
     110              :   default:
     111              :     return true;
     112              :   }
     113              : }
     114              : 
     115            0 : bool dbe::models::tableselection::lessThan ( const QModelIndex & left,
     116              :                                              const QModelIndex & right ) const
     117              : {
     118            0 :   QVariant LeftData = sourceModel()->data ( left );
     119            0 :   QVariant RightData = sourceModel()->data ( right );
     120              : 
     121            0 :   switch ( LeftData.type() )
     122              :   {
     123            0 :   case QVariant::Bool:
     124            0 :   case QVariant::UInt:
     125            0 :     return ( LeftData.toUInt() < RightData.toUInt() );
     126              : 
     127            0 :   case QVariant::Int:
     128            0 :     return ( LeftData.toInt() < RightData.toInt() );
     129              : 
     130            0 :   case QVariant::String:
     131            0 :   {
     132            0 :     const QString& l = LeftData.toString();
     133            0 :     const QString& r = RightData.toString();
     134              : 
     135            0 :     bool ok;
     136            0 :     const double ld = l.toDouble(&ok);
     137            0 :     if(ok == true) {
     138            0 :         return ( ld < r.toDouble());
     139              :     }
     140              : 
     141            0 :     const qint64 lll = l.toLongLong(&ok);
     142            0 :     if(ok == true) {
     143            0 :         return (lll < r.toLongLong());
     144              :     }
     145              : 
     146            0 :     const quint64 lull = l.toULongLong(&ok);
     147            0 :     if(ok == true) {
     148            0 :         return (lull < r.toULongLong());
     149              :     }
     150              : 
     151            0 :     return ((l).compare(r) > 0);
     152            0 :   }
     153              : 
     154              :   default:
     155              :     return false;
     156              :   }
     157              : 
     158              :   return true;
     159            0 : }
     160              : 
     161            0 : dbe::tref dbe::models::tableselection::getobject ( QModelIndex const & index ) const
     162              : {
     163            0 :   if ( index.isValid() )
     164              :   {
     165            0 :     if ( models::table * src_model = dynamic_cast<dbe::models::table *>
     166            0 :                                      ( this->sourceModel() ) )
     167              :     {
     168            0 :       QModelIndex const src_index = this->mapToSource ( index );
     169              : 
     170            0 :       if ( src_index.isValid() )
     171              :       {
     172            0 :         return src_model->GetTableObject ( src_index.row() );
     173              :       }
     174              :     }
     175              :   }
     176              : 
     177            0 :   throw daq::dbe::cannot_handle_invalid_qmodelindex ( ERS_HERE );
     178              : }
     179              : 
     180            0 : dunedaq::conffwk::class_t dbe::models::tableselection::getclass ( QModelIndex const & index )
     181              : const
     182              : {
     183            0 :   if ( index.isValid() )
     184              :   {
     185            0 :     if ( dbe::models::table * src_model =
     186            0 :            dynamic_cast<dbe::models::table *> ( this->sourceModel() ) )
     187              :     {
     188            0 :       QModelIndex const src_index = this->mapToSource ( index );
     189              : 
     190            0 :       if ( src_index.isValid() )
     191              :       {
     192            0 :         return src_model->getclass ( src_index );
     193              :       }
     194              :     }
     195              :   }
     196              : 
     197            0 :   return dunedaq::conffwk::class_t();
     198              : }
     199              : 
     200            0 : QAbstractItemModel * dbe::models::tableselection::ReturnSourceModel() const
     201              : {
     202            0 :   return nullptr;
     203              : }
     204              : 
     205              : //-----------------------------------------------------------------------------------------------------
     206            0 : MODEL_COMMON_INTERFACE_CREATE_THAT_OBJ_IMPL ( dbe::models::tableselection )
     207              : {
     208            0 :   Q_UNUSED(index);
     209            0 :   Q_UNUSED(obj);
     210            0 : }
     211              : 
     212            0 : MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL ( dbe::models::tableselection )
     213              : {
     214            0 :   Q_UNUSED(index);
     215            0 : }
     216              : 
     217            0 : MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL ( dbe::models::tableselection )
     218              : {
     219            0 :   Q_UNUSED(index);
     220            0 :   Q_UNUSED(obj);
     221            0 : }
     222              : 
     223            0 : MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL ( dbe::models::tableselection )
     224              : {
     225            0 :   Q_UNUSED(index);
     226            0 :   Q_UNUSED(obj);
     227            0 : }
     228              : 
     229              : //-----------------------------------------------------------------------------------------------------
     230              : 
     231              : //-----------------------------------------------------------------------------------------------------
     232            0 : MODEL_COMMON_INTERFACE_LOOKUP_IMPL ( dbe::models::tableselection )
     233              : {
     234            0 :   Q_UNUSED(obj);
     235            0 :   return QModelIndex();
     236              : }
     237              : //-----------------------------------------------------------------------------------------------------
     238              : 
     239              : //-----------------------------------------------------------------------------------------------------
     240            0 : MODEL_REMOVE_ROWS_DEF ( dbe::models::tableselection )
     241              : {
     242            0 :   Q_UNUSED(row);
     243            0 :   Q_UNUSED(count);
     244            0 :   Q_UNUSED(parent);
     245            0 :   return true;
     246              : }
     247              : 
     248            0 : MODEL_COMMON_INTERFACE_SLOTS_DEF ( dbe::models::tableselection )
     249              : //------------------------------------------------------------------------------------------
        

Generated by: LCOV version 2.0-1