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 24 of file treeselection.hpp.

Member Typedef Documentation

◆ type_datum

Member Enumeration Documentation

◆ FilterType

Enumerator
RegExpFilterType 
ObjectFilterType 

Definition at line 38 of file treeselection.hpp.

Constructor & Destructor Documentation

◆ ~treeselection()

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

Definition at line 20 of file treeselection.cpp.

21{
22}

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

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

281{
282 int Depth = 1;
283 QModelIndex CurrentIndex = SourceParent;
284
285 while ( CurrentIndex.isValid() )
286 {
287 CurrentIndex = CurrentIndex.parent();
288 Depth++;
289 }
290
291 return Depth;
292}

◆ canFetchMore()

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

Definition at line 37 of file treeselection.cpp.

38{
39 if ( index.isValid() )
40 {
41 QModelIndex sourceParent = mapToSource ( index );
42 return sourceModel()->canFetchMore ( sourceParent );
43 }
44 else
45 {
46 return false;
47 }
48}

◆ fetchMore()

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

Definition at line 50 of file treeselection.cpp.

51{
52 QModelIndex sourceParent = mapToSource ( index );
53 sourceModel()->fetchMore ( sourceParent );
54}

◆ filterAcceptsRow()

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

Definition at line 137 of file treeselection.cpp.

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

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

◆ GetQueryObjects()

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

Definition at line 72 of file treeselection.cpp.

73{
74 return QueryObjects;
75}
std::vector< tref > QueryObjects

◆ hasChildren()

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

Definition at line 24 of file treeselection.cpp.

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

◆ lessThan()

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

Definition at line 173 of file treeselection.cpp.

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

◆ ObjectFilter()

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

Definition at line 244 of file treeselection.cpp.

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

◆ RegexpFilter()

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

Definition at line 232 of file treeselection.cpp.

234{
235 if ( AtDepth ( sourceParent ) <= LevelRestriction )
236 {
237 QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
238 return AcceptItem ( index0, LevelRestriction );
239 }
240
241 return true;
242}

◆ ResetModel()

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

Definition at line 131 of file treeselection.cpp.

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

◆ ResetQueryObjects()

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

Definition at line 126 of file treeselection.cpp.

127{
128 QueryObjects.clear();
129}

◆ SetFilterRestrictionLevel()

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

Definition at line 56 of file treeselection.cpp.

57{
58 LevelRestriction = Levels;
59}

◆ SetFilterType()

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

Definition at line 61 of file treeselection.cpp.

63{
64 Type = Filter;
65}

◆ SetQueryObjects()

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

Definition at line 67 of file treeselection.cpp.

68{
69 QueryObjects = Objects;
70}

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

295{
296 Hide = HideLocal;
297 ResetModel();
298}

Member Data Documentation

◆ Hide

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

Definition at line 85 of file treeselection.hpp.

◆ LevelRestriction

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

Definition at line 83 of file treeselection.hpp.

◆ QueryObjects

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

Definition at line 87 of file treeselection.hpp.

◆ Type

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

Definition at line 82 of file treeselection.hpp.


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