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_datumgetnode (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::trefGetQueryObjects ()
 
void ResetQueryObjects ()
 
void ResetModel ()
 
- Public Member Functions inherited from dbe::TreeModelInterface
virtual treenodegetnode (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< trefQueryObjects
 

Detailed Description

Definition at line 19 of file treeselection.hpp.

Member Typedef Documentation

◆ type_datum

Member Enumeration Documentation

◆ FilterType

Enumerator
RegExpFilterType 
ObjectFilterType 

Definition at line 33 of file treeselection.hpp.

Constructor & Destructor Documentation

◆ ~treeselection()

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

Definition at line 15 of file treeselection.cpp.

16{
17}

◆ treeselection()

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

Including DBE.

Definition at line 6 of file treeselection.cpp.

Member Function Documentation

◆ AcceptItem()

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

Definition at line 198 of file treeselection.cpp.

200{
201 if ( sourceModel()->canFetchMore ( SourceIndex ) )
202 {
203 sourceModel()->fetchMore ( SourceIndex );
204 }
205
206 if ( sourceModel()->data ( SourceIndex ).toString().contains ( filterRegExp() ) )
207 {
208 return true;
209 }
210
211 if ( LevelRestriction <= 1 )
212 {
213 return false;
214 }
215
216 for ( int i = 0; i < sourceModel()->rowCount ( SourceIndex ); ++i )
217 {
218 if ( AcceptItem ( SourceIndex.child ( i, 0 ), --LevelRestriction ) )
219 {
220 return true;
221 }
222 }
223
224 return false;
225}
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 275 of file treeselection.cpp.

276{
277 int Depth = 1;
278 QModelIndex CurrentIndex = SourceParent;
279
280 while ( CurrentIndex.isValid() )
281 {
282 CurrentIndex = CurrentIndex.parent();
283 Depth++;
284 }
285
286 return Depth;
287}

◆ canFetchMore()

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

Definition at line 32 of file treeselection.cpp.

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

◆ 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 132 of file treeselection.cpp.

134{
135 treenode * NodeObject = getnode ( sourceModel()->index ( source_row, 0, source_parent ) );
136
137 if ( dynamic_cast<AttributeNode *> ( NodeObject ) )
138 {
139 return false;
140 }
141
142 if ( Hide )
143 {
144 if ( !source_parent.isValid() )
145 {
146 QModelIndex Index_1 = sourceModel()->index ( source_row, 1, source_parent );
147
148 if ( sourceModel()->data ( Index_1 ).toUInt() == 0 )
149 {
150 return false;
151 }
152 }
153 }
154
155 switch ( Type )
156 {
157 case RegExpFilterType:
158 return RegexpFilter ( source_row, source_parent );
159
160 case ObjectFilterType:
161 return ObjectFilter ( source_row, source_parent );
162
163 default:
164 return true;
165 }
166}
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 72 of file treeselection.cpp.

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

◆ GetQueryObjects()

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

Definition at line 67 of file treeselection.cpp.

68{
69 return QueryObjects;
70}
std::vector< tref > QueryObjects

◆ hasChildren()

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

Definition at line 19 of file treeselection.cpp.

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

◆ lessThan()

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

Definition at line 168 of file treeselection.cpp.

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

◆ ObjectFilter()

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

Definition at line 239 of file treeselection.cpp.

241{
242 QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
243 QString id = sourceModel()->data ( index0 ).toString();
244
245 if ( ( filterRegExp() ).isEmpty() )
246 {
247 return true;
248 }
249
250 if ( AtDepth ( sourceParent ) > 2 )
251 {
252 return true;
253 }
254
255 if ( !sourceParent.isValid() )
256 {
257 for ( size_t i = 0; i < QueryObjects.size(); ++i )
258 if ( QString ( QueryObjects.at ( i ).class_name().c_str() ).compare ( id ) == 0 )
259 {
260 return true;
261 }
262 }
263 else
264 {
265 for ( size_t i = 0; i < QueryObjects.size(); ++i )
266 if ( id.compare ( QString ( QueryObjects.at ( i ).UID().c_str() ) ) == 0 )
267 {
268 return true;
269 }
270 }
271
272 return false;
273}
int AtDepth(const QModelIndex &SourceParent) const

◆ RegexpFilter()

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

Definition at line 227 of file treeselection.cpp.

229{
230 if ( AtDepth ( sourceParent ) <= LevelRestriction )
231 {
232 QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
233 return AcceptItem ( index0, LevelRestriction );
234 }
235
236 return true;
237}

◆ ResetModel()

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

Definition at line 126 of file treeselection.cpp.

127{
128 beginResetModel();
129 endResetModel();
130}

◆ ResetQueryObjects()

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

Definition at line 121 of file treeselection.cpp.

122{
123 QueryObjects.clear();
124}

◆ SetFilterRestrictionLevel()

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

Definition at line 51 of file treeselection.cpp.

52{
53 LevelRestriction = Levels;
54}

◆ SetFilterType()

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

Definition at line 56 of file treeselection.cpp.

58{
59 Type = Filter;
60}

◆ SetQueryObjects()

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

Definition at line 62 of file treeselection.cpp.

63{
64 QueryObjects = Objects;
65}

◆ 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 289 of file treeselection.cpp.

290{
291 Hide = HideLocal;
292 ResetModel();
293}

Member Data Documentation

◆ Hide

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

Definition at line 80 of file treeselection.hpp.

◆ LevelRestriction

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

Definition at line 78 of file treeselection.hpp.

◆ QueryObjects

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

Definition at line 82 of file treeselection.hpp.

◆ Type

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

Definition at line 77 of file treeselection.hpp.


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