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