MCPcopy Create free account
hub / github.com/SpartanJ/eepp / parent

Method parent

include/eepp/ui/models/stringmapmodel.hpp:72–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 }
71
72 virtual ModelIndex parent( const ModelIndex& index ) const {
73 if ( !index.isValid() )
74 return {};
75 Node* node = static_cast<Node*>( index.internalData() );
76 if ( node->parent == mRoot || node->parent == nullptr )
77 return {};
78 Node* grandParent = node->parent->parent;
79 if ( !grandParent )
80 return {};
81 // Find row of parent in grandparent's visible children
82 auto it = std::find( grandParent->visibleChildren.begin(),
83 grandParent->visibleChildren.end(), node->parent );
84 if ( it != grandParent->visibleChildren.end() ) {
85 int row = std::distance( grandParent->visibleChildren.begin(), it );
86 return createIndex( row, 0, node->parent );
87 }
88 return {};
89 }
90
91 virtual Variant data( const ModelIndex& index, ModelRole role = ModelRole::Display ) const override {
92 if ( !index.isValid() )

Callers

nothing calls this directly

Calls 6

findFunction · 0.85
distanceFunction · 0.85
internalDataMethod · 0.80
isValidMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected