DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TableTab.cpp
Go to the documentation of this file.
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
7#include <QVBoxLayout>
8#include <QHeaderView>
9#include <QMimeData>
10#include <qevent.h>
11
13#include "dbe/TableTab.hpp"
14#include "dbe/MainWindow.hpp"
15
16//------------------------------------------------------------------------------------------------------
24dbe::TableTab::TableTab ( QWidget * parent )
25 : QWidget ( parent ),
26 this_model ( nullptr ),
27 this_filter ( nullptr ),
28 this_delegate ( nullptr ),
29 this_view ( nullptr )
30{
33 QVBoxLayout * TabLayout = new QVBoxLayout ( this );
34 TabLayout->addWidget ( this_view );
35 this_view->hide();
36 setAcceptDrops ( true );
37 this_holder = dynamic_cast<QTabWidget *> ( parent );
38}
39
41{
42 delete this_model;
43 delete this_filter;
44 delete this_delegate;
45 delete this_view;
46}
47//------------------------------------------------------------------------------------------------------
48
49//------------------------------------------------------------------------------------------------------
51{
52
53 if ( this_model == nullptr )
54 {
56 connect ( this, SIGNAL ( sig_data_dropped ( QMimeData const &, Qt::DropAction ) ),
58 SLOT ( slot_data_dropped ( QMimeData const &, Qt::DropAction ) ) );
59 }
60
63}
64
66{
67 this_model->ResetModel();
68 this_filter->ResetModel();
69}
70
72{
73 if ( this_model == nullptr )
74 {
76 }
77 else
78 {
80 }
81
82 connect ( this_model, SIGNAL ( ResetTab() ), this, SLOT ( ResetTabView() ) );
83}
84//------------------------------------------------------------------------------------------------------
85
86//------------------------------------------------------------------------------------------------------
88{
89 this_view->setModel ( NULL );
90}
91
93{
94 this_filter->setSourceModel ( this_model );
95
96 this_view->setItemDelegate ( this_delegate );
97 this_view->setModel ( this_filter );
98 this_view->show();
99
101}
102
104{
105 // TODO: at the moment the resize of columns creates too large columns when several data are in a cell
106 // the resize of rows is a little bit expensive with large tables
107 // to be re-evaluated
108 //
109 // if ( this_view->model() != nullptr )
110 // {
111 // this_view->resizeRowsToContents();
112 // this_view->resizeColumnsToContents();
113 // }
114}
115
117{
118 reset_models();
120 this_holder->setTabText ( this_holder->indexOf ( this ), this_model->get_class_name() );
121}
122//------------------------------------------------------------------------------------------------------
123
124//------------------------------------------------------------------------------------------------------
130void dbe::TableTab::dragEnterEvent ( QDragEnterEvent * event )
131{
132
133 // If there is nothing created then create as needed
134 CreateModels();
135
136 // Check that all mimetypes are supported
137 for ( auto const & mimetype : this_model->mimeTypes() )
138 {
139 if ( not event->mimeData()->hasFormat( mimetype.toStdString().c_str() ) )
140 {
141 event->ignore();
142 return;
143 }
144 }
145
146 // Support only copy actions
147 if ( event->proposedAction() != Qt::DropAction::CopyAction )
148 {
149 return;
150 }
151
152 event->acceptProposedAction();
153
154 // connect signals
155 MainWindow * mainwin = MainWindow::findthis();
156 connect ( GetTableView(), SIGNAL ( OpenEditor ( tref ) ), mainwin,
157 SLOT ( slot_launch_object_editor ( tref ) ), Qt::UniqueConnection );
158 connect ( GetTableDelegate(), SIGNAL ( CreateObjectEditorSignal ( tref ) ), mainwin,
159 SLOT ( slot_launch_object_editor ( tref ) ), Qt::UniqueConnection );
160}
161//------------------------------------------------------------------------------------------------------
162
163//------------------------------------------------------------------------------------------------------
171void dbe::TableTab::dropEvent ( QDropEvent * event )
172{
173 emit sig_data_dropped ( *event->mimeData(), event->proposedAction() );
174}
175//------------------------------------------------------------------------------------------------------
176
177//------------------------------------------------------------------------------------------------------
182
187
192
197//------------------------------------------------------------------------------------------------------
static MainWindow * findthis()
void ResetTableView()
Definition TableTab.cpp:92
void create_models()
Definition TableTab.cpp:50
CustomTableView * this_view
Definition TableTab.hpp:45
dbe::models::table * this_model
Definition TableTab.hpp:42
void sig_data_dropped(QMimeData const &data, Qt::DropAction)
void CreateModels()
Definition TableTab.cpp:71
QTabWidget * this_holder
Definition TableTab.hpp:46
void ResizeHeaders()
Definition TableTab.cpp:103
TableTab(QWidget *parent=0)
Including Qt.
Definition TableTab.cpp:24
void DisconnectView()
Definition TableTab.cpp:87
void ResetTabView()
Definition TableTab.cpp:116
CustomDelegate * this_delegate
Definition TableTab.hpp:44
dbe::models::table * GetTableModel() const
Definition TableTab.cpp:178
void reset_models()
Definition TableTab.cpp:65
dbe::models::tableselection * GetTableFilter() const
Definition TableTab.cpp:183
void dragEnterEvent(QDragEnterEvent *event) override
Definition TableTab.cpp:130
CustomTableView * GetTableView() const
Definition TableTab.cpp:193
void dropEvent(QDropEvent *event) override
Definition TableTab.cpp:171
CustomDelegate * GetTableDelegate() const
Definition TableTab.cpp:188
dbe::models::tableselection * this_filter
Definition TableTab.hpp:43
inner::configobject::tref tref
Definition tref.hpp:35