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