LCOV - code coverage report
Current view: top level - dbe/src - TableTab.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 76 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 15 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
       7              : #include <QHeaderView>
       8              : #include <QMimeData>
       9              : #include <QVBoxLayout>
      10              : #include <qevent.h>
      11              : 
      12              : /// Including dbe
      13              : #include "dbe/MainWindow.hpp"
      14              : #include "dbe/TableTab.hpp"
      15              : 
      16              : //------------------------------------------------------------------------------------------------------
      17              : /**
      18              :  * Construct a Tabletab and let everything unitialized until first use
      19              :  *
      20              :  * Set the geometry and operational properties of the object
      21              :  *
      22              :  * @param parent a pointer to the parent widget
      23              :  */
      24            0 : dbe::TableTab::TableTab(QWidget* parent)
      25              :   : QWidget(parent)
      26            0 :   , this_model(nullptr)
      27            0 :   , this_filter(nullptr)
      28            0 :   , this_delegate(nullptr)
      29            0 :   , this_view(nullptr)
      30              : {
      31            0 :   this_view = new CustomTableView();
      32              :   /// Adjusting layout
      33            0 :   QVBoxLayout* TabLayout = new QVBoxLayout(this);
      34            0 :   TabLayout->addWidget(this_view);
      35            0 :   this_view->hide();
      36            0 :   setAcceptDrops(true);
      37            0 :   this_holder = dynamic_cast<QTabWidget*>(parent);
      38            0 : }
      39              : 
      40            0 : dbe::TableTab::~TableTab()
      41              : {
      42            0 :   delete this_model;
      43            0 :   delete this_filter;
      44            0 :   delete this_delegate;
      45            0 :   delete this_view;
      46            0 : }
      47              : //------------------------------------------------------------------------------------------------------
      48              : 
      49              : //------------------------------------------------------------------------------------------------------
      50              : void
      51            0 : dbe::TableTab::create_models()
      52              : {
      53              : 
      54            0 :   if (this_model == nullptr) {
      55            0 :     this_model = new dbe::models::table();
      56            0 :     connect(this,
      57              :             SIGNAL(sig_data_dropped(QMimeData const&, Qt::DropAction)),
      58              :             this_model,
      59              :             SLOT(slot_data_dropped(QMimeData const&, Qt::DropAction)));
      60              :   }
      61              : 
      62            0 :   this_delegate = this_delegate == nullptr ? new CustomDelegate() : this_delegate;
      63            0 :   this_filter = this_filter == nullptr ? new dbe::models::tableselection() : this_filter;
      64            0 : }
      65              : 
      66              : void
      67            0 : dbe::TableTab::reset_models()
      68              : {
      69            0 :   this_model->ResetModel();
      70            0 :   this_filter->ResetModel();
      71            0 : }
      72              : 
      73              : void
      74            0 : dbe::TableTab::CreateModels()
      75              : {
      76            0 :   if (this_model == nullptr) {
      77            0 :     create_models();
      78              :   } else {
      79            0 :     reset_models();
      80              :   }
      81              : 
      82            0 :   connect(this_model, SIGNAL(ResetTab()), this, SLOT(ResetTabView()));
      83            0 : }
      84              : //------------------------------------------------------------------------------------------------------
      85              : 
      86              : //------------------------------------------------------------------------------------------------------
      87              : void
      88            0 : dbe::TableTab::DisconnectView()
      89              : {
      90            0 :   this_view->setModel(NULL);
      91            0 : }
      92              : 
      93              : void
      94            0 : dbe::TableTab::ResetTableView()
      95              : {
      96            0 :   this_filter->setSourceModel(this_model);
      97              : 
      98            0 :   this_view->setItemDelegate(this_delegate);
      99            0 :   this_view->setModel(this_filter);
     100            0 :   this_view->show();
     101              : 
     102            0 :   ResizeHeaders();
     103            0 : }
     104              : 
     105              : void
     106            0 : dbe::TableTab::ResizeHeaders()
     107              : {
     108              :   // TODO: at the moment the resize of columns creates too large columns when several data are in a cell
     109              :   //       the resize of rows is a little bit expensive with large tables
     110              :   //       to be re-evaluated
     111              :   //
     112              :   //  if ( this_view->model() != nullptr )
     113              :   //  {
     114              :   //      this_view->resizeRowsToContents();
     115              :   //      this_view->resizeColumnsToContents();
     116              :   //  }
     117            0 : }
     118              : 
     119              : void
     120            0 : dbe::TableTab::ResetTabView()
     121              : {
     122            0 :   reset_models();
     123            0 :   ResetTableView();
     124            0 :   this_holder->setTabText(this_holder->indexOf(this), this_model->get_class_name());
     125            0 : }
     126              : //------------------------------------------------------------------------------------------------------
     127              : 
     128              : //------------------------------------------------------------------------------------------------------
     129              : /**
     130              :  * Capture event of the pointer entering the tabletab while dragging something
     131              :  *
     132              :  * @param event is a pointer to the associated qt event object
     133              :  */
     134              : void
     135            0 : dbe::TableTab::dragEnterEvent(QDragEnterEvent* event)
     136              : {
     137              : 
     138              :   // If there is nothing created then create as needed
     139            0 :   CreateModels();
     140              : 
     141              :   // Check that all mimetypes are supported
     142            0 :   for (auto const& mimetype : this_model->mimeTypes()) {
     143            0 :     if (not event->mimeData()->hasFormat(mimetype.toStdString().c_str())) {
     144            0 :       event->ignore();
     145            0 :       return;
     146              :     }
     147            0 :   }
     148              : 
     149              :   // Support only copy actions
     150            0 :   if (event->proposedAction() != Qt::DropAction::CopyAction) {
     151              :     return;
     152              :   }
     153              : 
     154            0 :   event->acceptProposedAction();
     155              : 
     156              :   // connect signals
     157            0 :   MainWindow* mainwin = MainWindow::findthis();
     158            0 :   connect(
     159            0 :     GetTableView(), SIGNAL(OpenEditor(tref)), mainwin, SLOT(slot_launch_object_editor(tref)), Qt::UniqueConnection);
     160            0 :   connect(GetTableDelegate(),
     161              :           SIGNAL(CreateObjectEditorSignal(tref)),
     162              :           mainwin,
     163              :           SLOT(slot_launch_object_editor(tref)),
     164              :           Qt::UniqueConnection);
     165              : }
     166              : //------------------------------------------------------------------------------------------------------
     167              : 
     168              : //------------------------------------------------------------------------------------------------------
     169              : /**
     170              :  * Capture a mouse release event of a dragged object
     171              :  *
     172              :  * Properly emits a signal to the associated tablemodel, i.e. this is a thread safe operation
     173              :  *
     174              :  * @param event is a pointer to the associated qt event object
     175              :  */
     176              : void
     177            0 : dbe::TableTab::dropEvent(QDropEvent* event)
     178              : {
     179            0 :   emit sig_data_dropped(*event->mimeData(), event->proposedAction());
     180            0 : }
     181              : //------------------------------------------------------------------------------------------------------
     182              : 
     183              : //------------------------------------------------------------------------------------------------------
     184              : dbe::models::table*
     185            0 : dbe::TableTab::GetTableModel() const
     186              : {
     187            0 :   return this_model;
     188              : }
     189              : 
     190              : dbe::models::tableselection*
     191            0 : dbe::TableTab::GetTableFilter() const
     192              : {
     193            0 :   return this_filter;
     194              : }
     195              : 
     196              : dbe::CustomDelegate*
     197            0 : dbe::TableTab::GetTableDelegate() const
     198              : {
     199            0 :   return this_delegate;
     200              : }
     201              : 
     202              : dbe::CustomTableView*
     203            0 : dbe::TableTab::GetTableView() const
     204              : {
     205            0 :   return this_view;
     206              : }
     207              : //------------------------------------------------------------------------------------------------------
        

Generated by: LCOV version 2.0-1