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