DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::models::treeselection Class Reference

#include <treeselection.hpp>

Inheritance diagram for dbe::models::treeselection:
[legend]
Collaboration diagram for dbe::models::treeselection:
[legend]

Public Types

enum  FilterType { RegExpFilterType = 1 , ObjectFilterType = 2 }
typedef treenode type_datum

Public Member Functions

 ~treeselection ()
 treeselection (QObject *parent=0)
 Including DBE.
type_datum * getnode (type_index const &index) const override
void fetchMore (type_index const &index)
bool hasChildren (type_index const &index) const
bool canFetchMore (type_index const &index) const
void SetFilterType (FilterType Filter)
void SetFilterRestrictionLevel (int Levels)
void SetQueryObjects (std::vector< tref > Objects)
std::vector< dbe::tref > GetQueryObjects ()
void ResetQueryObjects ()
void ResetModel ()
Public Member Functions inherited from dbe::TreeModelInterface
virtual treenode * getnode (const QModelIndex &index) const =0
virtual ~TreeModelInterface ()=default
Public Member Functions inherited from dbe::model_common_impl< treeselection >
bool delete_objects (type_indices::iterator, type_indices::iterator) override
bool update_objects (type_indices::iterator, type_indices::iterator) override
bool create_objects (type_indices::iterator, type_indices::iterator) override
Public Member Functions inherited from dbe::model_common_interface
virtual ~model_common_interface ()=default
Public Member Functions inherited from dbe::model_initiate_actions_interface
virtual ~model_initiate_actions_interface ()=default
Public Member Functions inherited from dbe::model_common_data_access_interface
virtual type_object_ref getobject (type_index const &index) const =0
virtual type_class_info getclass (type_index const &index) const =0
virtual QAbstractItemModel * ReturnSourceModel () const =0
virtual ~model_common_data_access_interface ()=default
Public Member Functions inherited from dbe::model_common_async_operations< treeselection >
MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS model_common_async_operations ()
void model_common_connections ()

Protected Member Functions

bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const
bool lessThan (const QModelIndex &left, const QModelIndex &right) const
Protected Member Functions inherited from dbe::model_common_interface
virtual void remove_deleted_object (type_index const &index)=0
virtual void rename_contained_object (type_index const &index, type_object_info const &obj)=0
virtual void update_contained_object (type_index const &index, type_object_info const &obj)=0
virtual void create_contained_object (type_index const &index, type_object_info const &obj)=0
virtual type_index lookup (type_object_info const &)=0
QUuid getuuid () const
Protected Member Functions inherited from dbe::model_common_async_operations< treeselection >
void remove_object (type_object_info const &)
void create_object (type_object_info const &)
void rename_object (type_object_info const &)
void update_object (type_object_info const &)
void update_multiple_objects (std::vector< type_object_info > const &)

Private Slots

void ToggleEmptyClasses (bool HideLocal)
void slot_create_object (QString const &src, dref const &obj)
void slot_remove_object (QString const &src, dref const &obj)
void slot_update_object (QString const &src, dref const &obj)
void slot_rename_object (QString const &src, dref const &obj)

Private Member Functions

bool AcceptItem (const QModelIndex &SourceIndex, int LevelRestriction) const
bool RegexpFilter (int sourceRow, const QModelIndex &sourceParent) const
bool ObjectFilter (int sourceRow, const QModelIndex &sourceParent) const
int AtDepth (const QModelIndex &SourceParent) const

Private Attributes

FilterType Type
int LevelRestriction
bool Hide
std::vector< tref > QueryObjects

Detailed Description

Definition at line 22 of file treeselection.hpp.

Member Typedef Documentation

◆ type_datum

Member Enumeration Documentation

◆ FilterType

Enumerator
RegExpFilterType 
ObjectFilterType 

Definition at line 35 of file treeselection.hpp.

Constructor & Destructor Documentation

◆ ~treeselection()

dbe::models::treeselection::~treeselection ( )

Definition at line 20 of file treeselection.cpp.

20{}

◆ treeselection()

dbe::models::treeselection::treeselection ( QObject * parent = 0)
explicit

Including DBE.

Definition at line 11 of file treeselection.cpp.

Member Function Documentation

◆ AcceptItem()

bool dbe::models::treeselection::AcceptItem ( const QModelIndex & SourceIndex,
int LevelRestriction ) const
private

Definition at line 196 of file treeselection.cpp.

197{
198 if (sourceModel()->canFetchMore(SourceIndex)) {
199 sourceModel()->fetchMore(SourceIndex);
200 }
201
202 if (sourceModel()->data(SourceIndex).toString().contains(filterRegExp())) {
203 return true;
204 }
205
206 if (LevelRestriction <= 1) {
207 return false;
208 }
209
210 for (int i = 0; i < sourceModel()->rowCount(SourceIndex); ++i) {
211 if (AcceptItem(sourceModel()->index(i, 0), --LevelRestriction)) {
212 return true;
213 }
214 }
215
216 return false;
217}
bool canFetchMore(type_index const &index) const
bool AcceptItem(const QModelIndex &SourceIndex, int LevelRestriction) const

◆ AtDepth()

int dbe::models::treeselection::AtDepth ( const QModelIndex & SourceParent) const
private

Definition at line 260 of file treeselection.cpp.

261{
262 int Depth = 1;
263 QModelIndex CurrentIndex = SourceParent;
264
265 while (CurrentIndex.isValid()) {
266 CurrentIndex = CurrentIndex.parent();
267 Depth++;
268 }
269
270 return Depth;
271}

◆ canFetchMore()

bool dbe::models::treeselection::canFetchMore ( type_index const & index) const

Definition at line 34 of file treeselection.cpp.

35{
36 if (index.isValid()) {
37 QModelIndex sourceParent = mapToSource(index);
38 return sourceModel()->canFetchMore(sourceParent);
39 } else {
40 return false;
41 }
42}

◆ fetchMore()

void dbe::models::treeselection::fetchMore ( type_index const & index)

Definition at line 45 of file treeselection.cpp.

46{
47 QModelIndex sourceParent = mapToSource(index);
48 sourceModel()->fetchMore(sourceParent);
49}

◆ filterAcceptsRow()

bool dbe::models::treeselection::filterAcceptsRow ( int source_row,
const QModelIndex & source_parent ) const
protected

Definition at line 137 of file treeselection.cpp.

138{
139 treenode* NodeObject = getnode(sourceModel()->index(source_row, 0, source_parent));
140
141 if (dynamic_cast<AttributeNode*>(NodeObject)) {
142 return false;
143 }
144
145 if (Hide) {
146 if (!source_parent.isValid()) {
147 QModelIndex Index_1 = sourceModel()->index(source_row, 1, source_parent);
148
149 if (sourceModel()->data(Index_1).toUInt() == 0) {
150 return false;
151 }
152 }
153 }
154
155 switch (Type) {
156 case RegExpFilterType:
157 return RegexpFilter(source_row, source_parent);
158
159 case ObjectFilterType:
160 return ObjectFilter(source_row, source_parent);
161
162 default:
163 return true;
164 }
165}
bool RegexpFilter(int sourceRow, const QModelIndex &sourceParent) const
type_datum * getnode(type_index const &index) const override
bool ObjectFilter(int sourceRow, const QModelIndex &sourceParent) const

◆ getnode()

dbe::treenode * dbe::models::treeselection::getnode ( type_index const & index) const
override

Definition at line 76 of file treeselection.cpp.

77{
78 if (index.isValid()) {
79 dbe::models::tree* UnderlyingModel = dynamic_cast<dbe::models::tree*>(sourceModel());
80
81 if (UnderlyingModel) {
82 return UnderlyingModel->getnode(index);
83 }
84 }
85
86 return nullptr;
87}
type_datum * getnode(const type_index &index) const override
Definition tree.cpp:306

◆ GetQueryObjects()

std::vector< dbe::tref > dbe::models::treeselection::GetQueryObjects ( )

Definition at line 70 of file treeselection.cpp.

71{
72 return QueryObjects;
73}
std::vector< tref > QueryObjects

◆ hasChildren()

bool dbe::models::treeselection::hasChildren ( type_index const & index) const

Definition at line 23 of file treeselection.cpp.

24{
25 if (index.isValid()) {
26 QModelIndex sourceParent = mapToSource(index);
27 return sourceModel()->hasChildren(sourceParent);
28 } else {
29 return true;
30 }
31}

◆ lessThan()

bool dbe::models::treeselection::lessThan ( const QModelIndex & left,
const QModelIndex & right ) const
protected

Definition at line 168 of file treeselection.cpp.

169{
170 if (left.parent() == QModelIndex() || left.parent().parent() == QModelIndex()) {
171 QVariant LeftData = sourceModel()->data(left);
172 QVariant RightData = sourceModel()->data(right);
173
174 switch (LeftData.type()) {
175 case QVariant::Bool:
176 case QVariant::UInt:
177 return (LeftData.toUInt() < RightData.toUInt());
178
179 case QVariant::Int:
180 return (LeftData.toInt() < RightData.toInt());
181
182 case QVariant::String:
183 return ((LeftData.toString()).compare(RightData.toString()) > 0);
184
185 default:
186 return false;
187 }
188
189 return true;
190 }
191
192 return false;
193}

◆ ObjectFilter()

bool dbe::models::treeselection::ObjectFilter ( int sourceRow,
const QModelIndex & sourceParent ) const
private

Definition at line 231 of file treeselection.cpp.

232{
233 QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
234 QString id = sourceModel()->data(index0).toString();
235
236 if ((filterRegExp()).isEmpty()) {
237 return true;
238 }
239
240 if (AtDepth(sourceParent) > 2) {
241 return true;
242 }
243
244 if (!sourceParent.isValid()) {
245 for (size_t i = 0; i < QueryObjects.size(); ++i)
246 if (QString(QueryObjects.at(i).class_name().c_str()).compare(id) == 0) {
247 return true;
248 }
249 } else {
250 for (size_t i = 0; i < QueryObjects.size(); ++i)
251 if (id.compare(QString(QueryObjects.at(i).UID().c_str())) == 0) {
252 return true;
253 }
254 }
255
256 return false;
257}
int AtDepth(const QModelIndex &SourceParent) const

◆ RegexpFilter()

bool dbe::models::treeselection::RegexpFilter ( int sourceRow,
const QModelIndex & sourceParent ) const
private

Definition at line 220 of file treeselection.cpp.

221{
222 if (AtDepth(sourceParent) <= LevelRestriction) {
223 QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
224 return AcceptItem(index0, LevelRestriction);
225 }
226
227 return true;
228}

◆ ResetModel()

void dbe::models::treeselection::ResetModel ( )

Definition at line 130 of file treeselection.cpp.

131{
132 beginResetModel();
133 endResetModel();
134}

◆ ResetQueryObjects()

void dbe::models::treeselection::ResetQueryObjects ( )

Definition at line 124 of file treeselection.cpp.

125{
126 QueryObjects.clear();
127}

◆ SetFilterRestrictionLevel()

void dbe::models::treeselection::SetFilterRestrictionLevel ( int Levels)

Definition at line 52 of file treeselection.cpp.

53{
54 LevelRestriction = Levels;
55}

◆ SetFilterType()

void dbe::models::treeselection::SetFilterType ( FilterType Filter)

Definition at line 58 of file treeselection.cpp.

59{
60 Type = Filter;
61}

◆ SetQueryObjects()

void dbe::models::treeselection::SetQueryObjects ( std::vector< tref > Objects)

Definition at line 64 of file treeselection.cpp.

65{
66 QueryObjects = Objects;
67}

◆ slot_create_object

void dbe::models::treeselection::slot_create_object ( QString const & src,
dref const & obj )
privateslot

◆ slot_remove_object

void dbe::models::treeselection::slot_remove_object ( QString const & src,
dref const & obj )
privateslot

◆ slot_rename_object

void dbe::models::treeselection::slot_rename_object ( QString const & src,
dref const & obj )
privateslot

◆ slot_update_object

void dbe::models::treeselection::slot_update_object ( QString const & src,
dref const & obj )
privateslot

◆ ToggleEmptyClasses

void dbe::models::treeselection::ToggleEmptyClasses ( bool HideLocal)
privateslot

Definition at line 274 of file treeselection.cpp.

275{
276 Hide = HideLocal;
277 ResetModel();
278}

Member Data Documentation

◆ Hide

bool dbe::models::treeselection::Hide
private

Definition at line 82 of file treeselection.hpp.

◆ LevelRestriction

int dbe::models::treeselection::LevelRestriction
private

Definition at line 80 of file treeselection.hpp.

◆ QueryObjects

std::vector<tref> dbe::models::treeselection::QueryObjects
private

Definition at line 84 of file treeselection.hpp.

◆ Type

FilterType dbe::models::treeselection::Type
private

Definition at line 79 of file treeselection.hpp.


The documentation for this class was generated from the following files: