DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TreeModelInterface.hpp
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: yes (from dbe/TreeModelInterface.h to include/dbe/TreeModelInterface.hpp).
5
6#ifndef TREEMODELINTERFACE_H
7#define TREEMODELINTERFACE_H
8
9#include "dbe/treenode.hpp"
10#include "dbe/Exceptions.hpp"
11
14#include "conffwk/Schema.hpp"
15
16#include <QModelIndex>
17#include <vector>
18#include <algorithm>
19
20namespace dbe
21{
22
24{
25public:
26 virtual treenode * getnode ( const QModelIndex & index ) const = 0;
27
28 virtual ~TreeModelInterface() = default;
29};
30
31} // namespace dbe
32
33#define TREEMODEL_REMOVE_ROWS_DEF(classname) \
34bool classname::removeRows(int row, int count, QModelIndex const & parent) \
35{\
36 \
37 assert(count > 0);\
38 \
39 int const last = row + count - 1;\
40 emit beginRemoveRows(parent, row, last);\
41 for (int current = last; current != row - 1; --current)\
42 {\
43 QModelIndex src_index = this->mapToSource(index(current, parent.column(), parent));\
44 treenode * element = this->getnode(src_index);\
45 \
46 if (element != nullptr)\
47 {\
48 treenode * element_parent = element->GetParent();\
49 if (element_parent != nullptr)\
50 {\
51 element_parent->RemoveChild(element);\
52 }\
53 }\
54 else\
55 {\
56 return false;\
57 }\
58 }\
59 emit endRemoveRows();\
60 return true;\
61}\
62
63#endif // TREEMODELINTERFACE_H
virtual ~TreeModelInterface()=default
virtual treenode * getnode(const QModelIndex &index) const =0
conffwk entry point
Include QT Headers.