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

#include <subtreeproxy.hpp>

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

Public Member Functions

 subtree_proxy (const QString &Name, const QStringList &Default, QObject *parent=nullptr)
 Including DBE.
 
 ~subtree_proxy ()
 
void ResetModel ()
 
void check_view_type ()
 
void LoadClasses ()
 
treenodegetnode (const QModelIndex &index) const
 
- Public Member Functions inherited from dbe::TreeModelInterface
virtual ~TreeModelInterface ()=default
 
- Public Member Functions inherited from dbe::model_common_impl< subtree_proxy >
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< subtree_proxy >
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< subtree_proxy >
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 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 ApplyDefaultFilter (int source_row, const QModelIndex &source_parent) const
 
bool ApplyUserFilter (int source_row, const QModelIndex &source_parent) const
 

Private Attributes

QString this_gui_windowname
 
QStringList this_default_filter
 
Window this_window_config
 
bool this_apply_default_filter
 

Detailed Description

Definition at line 21 of file subtreeproxy.hpp.

Constructor & Destructor Documentation

◆ subtree_proxy()

dbe::models::subtree_proxy::subtree_proxy ( const QString & Name,
const QStringList & Default,
QObject * parent = nullptr )
explicit

Including DBE.

Definition at line 9 of file subtreeproxy.cpp.

◆ ~subtree_proxy()

dbe::models::subtree_proxy::~subtree_proxy ( )

Definition at line 21 of file subtreeproxy.cpp.

22{
23}

Member Function Documentation

◆ ApplyDefaultFilter()

bool dbe::models::subtree_proxy::ApplyDefaultFilter ( int source_row,
const QModelIndex & source_parent ) const
private

Definition at line 161 of file subtreeproxy.cpp.

163{
164 Q_UNUSED ( source_row )
165 Q_UNUSED ( source_parent )
166
167 return true;
168}

◆ ApplyUserFilter()

bool dbe::models::subtree_proxy::ApplyUserFilter ( int source_row,
const QModelIndex & source_parent ) const
private

Process classes

Process objects

Definition at line 170 of file subtreeproxy.cpp.

172{
173 dbe::models::tree * srcmodel = static_cast<tree *> ( sourceModel() );
174
175 QModelIndex const & nodeindex = srcmodel->index ( source_row, 0, source_parent );
176 treenode * tofilter = srcmodel->getnode ( nodeindex );
177 QString const nodename = srcmodel->data ( nodeindex ).toString();
178
179 if ( not source_parent.isValid() )
180 {
182
183 for ( QString const & admissible : this_window_config.GraphicalClassesList )
184 {
185 GraphicalClass candidate = confaccessor::guiconfig()->graphical (
186 admissible.toStdString() );
187
188 if ( candidate.DatabaseClassName == nodename
189 or candidate.DerivedClasses.contains ( nodename ) )
190 {
191 return true;
192 }
193 }
194 }
195 else if ( dynamic_cast<ObjectNode *> ( tofilter ) )
196 {
197 return true;
198 }
199 else if ( dynamic_cast<RelationshipNode *> ( tofilter ) )
200 {
202 QString const related = sourceModel()->data ( nodeindex.parent().parent() ).toString();
203
204 for ( QString const & admissible : this_window_config.GraphicalClassesList )
205 {
206 GraphicalClass candidate = confaccessor::guiconfig()->graphical (
207 admissible.toStdString() );
208
209 if ( candidate.DatabaseClassName == related or candidate.DerivedClasses.contains (
210 related ) )
211 {
212 return candidate.ShowAllRelationships or candidate.Relationships.contains ( nodename );
213 }
214
215 }
216 }
217
218 return false;
219}
static cptr< ui::config::info > guiconfig()
QVariant data(const type_index &index, int role=Qt::DisplayRole) const override
Definition tree.cpp:116
type_datum * getnode(const type_index &index) const override
Definition tree.cpp:309
type_index index(int row, int column, const type_index &parent) const override
Definition tree.cpp:32
QStringList GraphicalClassesList

◆ check_view_type()

void dbe::models::subtree_proxy::check_view_type ( )

Definition at line 74 of file subtreeproxy.cpp.

75{
77 this_gui_windowname.toStdString() );
78
79 if ( this_window_config.Title.isEmpty() )
80 {
82 }
83}

◆ filterAcceptsRow()

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

Definition at line 31 of file subtreeproxy.cpp.

33{
35 {
36 return ApplyDefaultFilter ( source_row, source_parent );
37 }
38 else
39 {
40 return ApplyUserFilter ( source_row, source_parent );
41 }
42}
bool ApplyDefaultFilter(int source_row, const QModelIndex &source_parent) const
bool ApplyUserFilter(int source_row, const QModelIndex &source_parent) const

◆ getnode()

dbe::treenode * dbe::models::subtree_proxy::getnode ( const QModelIndex & index) const
virtual

Implements dbe::TreeModelInterface.

Definition at line 129 of file subtreeproxy.cpp.

130{
131 QModelIndex sourceParent = mapToSource ( index );
132 dbe::models::tree * my = dynamic_cast<dbe::models::tree *> ( sourceModel() );
133
134 if ( my )
135 {
136 return my->getnode ( sourceParent );
137 }
138
139 return nullptr;
140}

◆ lessThan()

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

Definition at line 44 of file subtreeproxy.cpp.

46{
47 if ( left.parent() == QModelIndex() || left.parent().parent() == QModelIndex() )
48 {
49 QVariant LeftData = sourceModel()->data ( left );
50 QVariant RightData = sourceModel()->data ( right );
51
52 switch ( LeftData.type() )
53 {
54 case QVariant::Bool:
55 case QVariant::UInt:
56 return ( LeftData.toUInt() < RightData.toUInt() );
57
58 case QVariant::Int:
59 return ( LeftData.toInt() < RightData.toInt() );
60
61 case QVariant::String:
62 return ( ( LeftData.toString() ).compare ( RightData.toString() ) > 0 );
63
64 default:
65 return false;
66 }
67
68 return true;
69 }
70
71 return false;
72}

◆ LoadClasses()

void dbe::models::subtree_proxy::LoadClasses ( )

Definition at line 85 of file subtreeproxy.cpp.

86{
87 if ( this_apply_default_filter == false )
88 {
89 for ( QString const & i : this_window_config.GraphicalClassesList )
90 {
91 GraphicalClass Class = confaccessor::guiconfig()->graphical ( i.toStdString() );
92 QStringList ClassList = Class.DerivedClasses;
93 ClassList.append ( Class.DatabaseClassName );
94
95 for ( QString & ClassName : ClassList )
96 {
97 treenode * ClassNode = confaccessor::gethandler()->getnode ( ClassName );
98
99 if ( ClassNode )
100 {
101 dbe::models::tree * UnderlyingModel =
102 static_cast<dbe::models::tree *> ( sourceModel() );
103 QModelIndex ParentIndex = UnderlyingModel->getindex ( ClassNode );
104
105 if ( sourceModel()->canFetchMore ( ParentIndex ) ) sourceModel()->fetchMore (
106 ParentIndex );
107 }
108 }
109 }
110 }
111}
static cptr< datahandler > gethandler()
type_index getindex(treenode *NodeItem, type_index const &RootIndex=QModelIndex()) const
Definition tree.cpp:279

◆ ResetModel()

void dbe::models::subtree_proxy::ResetModel ( )

Definition at line 25 of file subtreeproxy.cpp.

26{
27 beginResetModel();
28 endResetModel();
29}

◆ slot_create_object

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

◆ slot_remove_object

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

◆ slot_rename_object

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

◆ slot_update_object

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

Member Data Documentation

◆ this_apply_default_filter

bool dbe::models::subtree_proxy::this_apply_default_filter
private

Definition at line 62 of file subtreeproxy.hpp.

◆ this_default_filter

QStringList dbe::models::subtree_proxy::this_default_filter
private

Definition at line 59 of file subtreeproxy.hpp.

◆ this_gui_windowname

QString dbe::models::subtree_proxy::this_gui_windowname
private

Definition at line 58 of file subtreeproxy.hpp.

◆ this_window_config

Window dbe::models::subtree_proxy::this_window_config
private

Definition at line 60 of file subtreeproxy.hpp.


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