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 <QHeaderView>
8#include <QMimeData>
9#include <QVBoxLayout>
10#include <qevent.h>
11
13#include "dbe/MainWindow.hpp"
14#include "dbe/TableTab.hpp"
15
16//------------------------------------------------------------------------------------------------------
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//------------------------------------------------------------------------------------------------------
50void
52{
53
54 if (this_model == nullptr) {
56 connect(this,
57 SIGNAL(sig_data_dropped(QMimeData const&, Qt::DropAction)),
59 SLOT(slot_data_dropped(QMimeData const&, Qt::DropAction)));
60 }
61
64}
65
66void
68{
69 this_model->ResetModel();
70 this_filter->ResetModel();
71}
72
73void
75{
76 if (this_model == nullptr) {
78 } else {
80 }
81
82 connect(this_model, SIGNAL(ResetTab()), this, SLOT(ResetTabView()));
83}
84//------------------------------------------------------------------------------------------------------
85
86//------------------------------------------------------------------------------------------------------
87void
89{
90 this_view->setModel(NULL);
91}
92
93void
95{
96 this_filter->setSourceModel(this_model);
97
98 this_view->setItemDelegate(this_delegate);
99 this_view->setModel(this_filter);
100 this_view->show();
101
103}
104
105void
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}
118
119void
121{
122 reset_models();
124 this_holder->setTabText(this_holder->indexOf(this), this_model->get_class_name());
125}
126//------------------------------------------------------------------------------------------------------
127
128//------------------------------------------------------------------------------------------------------
134void
135dbe::TableTab::dragEnterEvent(QDragEnterEvent* event)
136{
137
138 // If there is nothing created then create as needed
139 CreateModels();
140
141 // Check that all mimetypes are supported
142 for (auto const& mimetype : this_model->mimeTypes()) {
143 if (not event->mimeData()->hasFormat(mimetype.toStdString().c_str())) {
144 event->ignore();
145 return;
146 }
147 }
148
149 // Support only copy actions
150 if (event->proposedAction() != Qt::DropAction::CopyAction) {
151 return;
152 }
153
154 event->acceptProposedAction();
155
156 // connect signals
157 MainWindow* mainwin = MainWindow::findthis();
158 connect(
159 GetTableView(), SIGNAL(OpenEditor(tref)), mainwin, SLOT(slot_launch_object_editor(tref)), Qt::UniqueConnection);
160 connect(GetTableDelegate(),
161 SIGNAL(CreateObjectEditorSignal(tref)),
162 mainwin,
163 SLOT(slot_launch_object_editor(tref)),
164 Qt::UniqueConnection);
165}
166//------------------------------------------------------------------------------------------------------
167
168//------------------------------------------------------------------------------------------------------
176void
177dbe::TableTab::dropEvent(QDropEvent* event)
178{
179 emit sig_data_dropped(*event->mimeData(), event->proposedAction());
180}
181//------------------------------------------------------------------------------------------------------
182
183//------------------------------------------------------------------------------------------------------
186{
187 return this_model;
188}
189
192{
193 return this_filter;
194}
195
198{
199 return this_delegate;
200}
201
204{
205 return this_view;
206}
207//------------------------------------------------------------------------------------------------------
CustomDelegate(QObject *parent=0)
CustomTableView(QWidget *parent=0)
Including QT::include <QHeaderView>.
static MainWindow * findthis()
void ResetTableView()
Definition TableTab.cpp:94
void create_models()
Definition TableTab.cpp:51
CustomTableView * this_view
Definition TableTab.hpp:44
dbe::models::table * this_model
Definition TableTab.hpp:41
void sig_data_dropped(QMimeData const &data, Qt::DropAction)
void CreateModels()
Definition TableTab.cpp:74
QTabWidget * this_holder
Definition TableTab.hpp:45
void ResizeHeaders()
Definition TableTab.cpp:106
TableTab(QWidget *parent=0)
Including Qt.
Definition TableTab.cpp:24
void DisconnectView()
Definition TableTab.cpp:88
void ResetTabView()
Definition TableTab.cpp:120
CustomDelegate * this_delegate
Definition TableTab.hpp:43
dbe::models::table * GetTableModel() const
Definition TableTab.cpp:185
void reset_models()
Definition TableTab.cpp:67
dbe::models::tableselection * GetTableFilter() const
Definition TableTab.cpp:191
void dragEnterEvent(QDragEnterEvent *event) override
Definition TableTab.cpp:135
CustomTableView * GetTableView() const
Definition TableTab.cpp:203
void dropEvent(QDropEvent *event) override
Definition TableTab.cpp:177
CustomDelegate * GetTableDelegate() const
Definition TableTab.cpp:197
dbe::models::tableselection * this_filter
Definition TableTab.hpp:42
inner::configobject::tref tref
Definition tref.hpp:36