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

Generated by: LCOV version 2.0-1