DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
treenode.cpp
Go to the documentation of this file.
1
3#include "dbe/treenode.hpp"
8
9#include <QGraphicsPixmapItem>
10#include <QGraphicsScene>
11#include <QPainter>
12#include <QBitmap>
13#include <QDrag>
14#include <QGraphicsSceneMouseEvent>
15#include <QMimeData>
16#include <QApplication>
17#include <QMessageBox>
18#include <QComboBox>
19#include <QHBoxLayout>
20#include <QPushButton>
21#include <QLabel>
22
24 :
25 Parent ( ParentNode ),
26 HasStructure ( false ),
27 WasFetched ( false )
28{
29 if ( Parent != nullptr )
30 {
31 Parent->AddChild ( this );
32 }
33}
34
35dbe::treenode::treenode ( const QString & Datum, treenode * ParentNode )
36 :
37 treenode ( ParentNode )
38{
39 Data.append ( Datum );
40}
41
42dbe::treenode::treenode ( const QStringList & DataList, treenode * ParentNode )
43 :
44 treenode ( ParentNode )
45{
46
47 for ( auto & i : DataList )
48 {
49 Data.append ( i );
50 }
51}
52
54{
55 qDeleteAll ( Children );
56}
57
58QVariant dbe::treenode::GetData ( const int Column, int role ) const
59{
60 if ( role == Qt::DisplayRole )
61 {
62 return Data.value ( Column );
63 }
64 else
65 {
66 return QVariant();
67 }
68}
69
70void dbe::treenode::rename ( QString const & name )
71{
72 Data[0] = QVariant ( name );
73}
74
76{
77 throw daq::dbe::cannot_handle_invalid_qmodelindex ( ERS_HERE );
78}
79
81{
82 if ( Parent )
83 {
84 return Parent->Children.indexOf ( const_cast<treenode *> ( this ) );
85 }
86
87 return 0;
88}
89
91{
92 Children.append ( Child );
93}
94
96{
97 Children.removeOne ( Child );
98}
99
100dbe::treenode * dbe::treenode::GetChild ( const int Row ) const
101{
102 return Children.at ( Row );
103}
104
105QList<dbe::treenode *> dbe::treenode::GetChildren() const
106{
107 return Children;
108}
109
111{
112 return Parent;
113}
114
116{
117 return Children.size();
118}
119
121{
122 return Data.size();
123}
124
125void dbe::treenode::SetHasStructure ( bool Structure )
126{
127 HasStructure = Structure;
128}
129
131{
132 return HasStructure;
133}
134
135void dbe::treenode::SetWasFetched ( bool Fetched )
136{
137 WasFetched = Fetched;
138}
139
141{
142 return WasFetched;
143}
144
146 :
147 treenode ( ParentNode ),
148 ClassInfo ( Info ),
149 numObjects( 0 )
150{
151 Data.append ( QVariant ( QString::fromStdString ( ClassInfo.p_name ) ) );
152 Data.append ( QVariant ( numObjects ) );
153}
154
158
159void dbe::ClassNode::updateData(bool addition) {
160 addition ? ++numObjects : --numObjects;
161
162 Data[1] = QVariant ( numObjects );
163
164 confaccessor::increase_total_objects ( addition == true ? 1 : -1 );
165
166 if ( numObjects == 0 )
167 {
168 SetWasFetched ( true );
169 }
170 else
171 {
172 SetHasStructure ( true );
173 }
174}
175
177{
179 updateData(true);
180}
181
183{
185 updateData(false);
186}
187
188QVariant dbe::ClassNode::GetData ( const int Column, int role ) const
189{
190 switch ( role )
191 {
192
193 case Qt::DisplayRole:
194 return Data.value ( Column );
195
196 case Qt::DecorationRole:
197
198 if ( Column == 0 )
199 {
200 return QIcon ( ":/Images/Folder.png" );
201 }
202 }
203
204 return QVariant();
205}
206
208{
209 return ClassInfo;
210}
211
212dbe::ObjectNode::ObjectNode ( dref obj, bool acopy, treenode * ParentNode )
213 :
214 treenode ( ParentNode ),
215 configdata ( obj )
216{
217 Data.append ( QVariant ( QString::fromStdString ( configdata.UID() ) ) );
218
219 if ( not acopy )
220 {
223 false );
224 std::vector<dunedaq::conffwk::attribute_t> Attributes = ClassInfo.p_attributes;
225 std::vector<dunedaq::conffwk::relationship_t> Relationships = ClassInfo.p_relationships;
226
227 if ( ( Relationships.size() > 0 ) )
228 {
229 SetHasStructure ( true );
230 }
231
232 for ( dunedaq::conffwk::attribute_t & Attribute : Attributes )
233 {
234 new AttributeNode ( Attribute, static_cast<treenode *> ( this ) );
235 }
236
237 for ( dunedaq::conffwk::relationship_t & Relationship : Relationships )
238 {
239 new RelationshipNode ( Relationship, static_cast<treenode *> ( this ) );
240 }
241 }
242
243 SetWasFetched ( true );
244}
245
247
248QVariant dbe::ObjectNode::GetData ( const int Column, int role ) const
249{
250 switch ( role )
251 {
252
253 case Qt::DisplayRole:
254 return Data.value ( Column );
255
256 case Qt::DecorationRole:
257
258 if ( Column == 0 )
259 {
260 return QIcon ( ":/Images/TextGeneric.png" );
261 }
262 }
263
264 return QVariant();
265}
266
268{
269 return configdata.ref();
270}
271
273 treenode * ParentNode )
274 :
275 treenode ( ParentNode ),
276 attribute_t_definition ( AttributeData )
277{
278 Data.append ( QVariant ( QString::fromStdString ( AttributeData.p_name ) ) );
279
280 tref ObjectParent = GetParent()->GetObject();
281
282 QStringList DataList
283 { dbe::config::api::get::attribute::list<QStringList> ( ObjectParent, AttributeData ) };
284
285 for ( QString & ObjectData : DataList )
286 {
287 if ( !ObjectData.isEmpty() )
288 {
289 treenode * ChildNode = new treenode ( ObjectData, static_cast<treenode *> ( this ) );
290 ChildNode->SetWasFetched ( true );
291 }
292 }
293
294 if ( DataList.size() > 0 && !DataList.at ( 0 ).isNull() )
295 {
296 SetHasStructure ( true );
297 }
298
299 SetWasFetched ( true );
300}
301
303
304QVariant dbe::AttributeNode::GetData ( const int Column, int role ) const
305{
306 switch ( role )
307 {
308
309 case Qt::DisplayRole:
310 return Data.value ( Column );
311
312 case Qt::DecorationRole:
313
314 if ( Column == 0 )
315 {
316 return QIcon ( ":/Images/SLink.png" );
317 }
318 }
319
320 return QVariant();
321}
322
324{
325 return attribute_t_definition;
326}
327
329 treenode * ParentNode )
330 :
331 treenode ( ParentNode ),
332 relation_t_definition ( relation )
333{
334 Data.append ( QVariant ( QString::fromStdString ( relation.p_name ) ) );
335
336 std::vector<tref> DataList;
337 tref ObjectParent = GetParent()->GetObject();
338
343 {
344 try
345 {
346 tref Data =
347 dbe::config::api::graph::linked::through::relation<tref> (
348 ObjectParent,
349 relation );
350 DataList.push_back ( Data );
351 }
352 catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
353 {
354 //nothing needs be done to handle the case that a relationship is not set
355 }
356 }
357 else
358 {
359 DataList =
361 ObjectParent,
362 relation );
363 }
364
365 for ( tref const & Object : DataList )
366 {
367 new ObjectNode ( Object, true, static_cast<treenode *> ( this ) );
368 }
369
370 if ( DataList.size() > 0 )
371 {
372 SetHasStructure ( true );
373 }
374
375 SetWasFetched ( true );
376}
377
379
380QVariant dbe::RelationshipNode::GetData ( const int Column, int role ) const
381{
382 switch ( role )
383 {
384
385 case Qt::DisplayRole:
386 return Data.value ( Column );
387
388 case Qt::DecorationRole:
389
390 if ( Column == 0 )
391 {
392 return QIcon ( ":/Images/SLink.png" );
393 }
394 }
395
396 return QVariant();
397}
398
400{
401 return relation_t_definition;
402}
#define ERS_HERE
virtual QVariant GetData(const int Column, int role=Qt::DisplayRole) const
Definition treenode.cpp:304
dunedaq::conffwk::attribute_t attribute_t() const
Definition treenode.cpp:323
AttributeNode(const dunedaq::conffwk::attribute_t &AttributeData, treenode *ParentNode)
Definition treenode.cpp:272
void AddChild(treenode *Child) override
Definition treenode.cpp:176
unsigned int numObjects
Definition treenode.hpp:72
dunedaq::conffwk::class_t GetClassInfo() const
Definition treenode.cpp:207
void updateData(bool addition)
Definition treenode.cpp:159
virtual QVariant GetData(const int Column, int role=Qt::DisplayRole) const
Definition treenode.cpp:188
void RemoveChild(treenode *Child) override
Definition treenode.cpp:182
dunedaq::conffwk::class_t ClassInfo
Definition treenode.hpp:71
ClassNode(const dunedaq::conffwk::class_t &Info, treenode *ParentNode)
Definition treenode.cpp:145
ObjectNode(dref ObjectData, bool IsCopy, treenode *ParentNode)
Definition treenode.cpp:212
tref GetObject() const
Definition treenode.cpp:267
virtual QVariant GetData(const int Column, int role=Qt::DisplayRole) const
Definition treenode.cpp:248
virtual QVariant GetData(const int Column, int role=Qt::DisplayRole) const
Definition treenode.cpp:380
dunedaq::conffwk::relationship_t relation_t_definition
Definition treenode.hpp:106
dunedaq::conffwk::relationship_t relation_t() const
Definition treenode.cpp:399
RelationshipNode(const dunedaq::conffwk::relationship_t &RelationshipData, treenode *ParentNode)
Definition treenode.cpp:328
static void increase_total_objects(int const i)
static T list(dbe::inner::configobject::tref obj, dunedaq::conffwk::attribute_t const &attr)
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
dunedaq::conffwk::ConfigObject & ref(bool check_null=true) const
int ColumnCount() const
Definition treenode.cpp:120
virtual ~treenode()
Definition treenode.cpp:53
treenode * GetParent() const
Definition treenode.cpp:110
virtual void RemoveChild(treenode *Child)
Definition treenode.cpp:95
void rename(QString const &)
Definition treenode.cpp:70
void SetHasStructure(bool Structure)
Definition treenode.cpp:125
bool GetHasStructure() const
Definition treenode.cpp:130
virtual tref GetObject() const
Definition treenode.cpp:75
treenode(treenode *ParentNode=nullptr)
Including QT Headers.
Definition treenode.cpp:23
QList< treenode * > GetChildren() const
Definition treenode.cpp:105
treenode * GetChild(const int Row) const
Definition treenode.cpp:100
int ChildCount() const
Definition treenode.cpp:115
virtual void AddChild(treenode *Child)
Definition treenode.cpp:90
treenode * Parent
Definition treenode.hpp:50
bool GetWasFetched() const
Definition treenode.cpp:140
virtual QVariant GetData(const int Column, int role=Qt::DisplayRole) const
Definition treenode.cpp:58
void SetWasFetched(bool Fetched)
Definition treenode.cpp:135
int GetRow() const
Definition treenode.cpp:80
QList< QVariant > Data
Definition treenode.hpp:52
T relation(tref item, dunedaq::conffwk::relationship_t const &relation)
inner::configobject::tref tref
Definition tref.hpp:30
const std::vector< attribute_t > p_attributes
Definition Schema.hpp:163
const std::vector< relationship_t > p_relationships
Definition Schema.hpp:164