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