MCPcopy Create free account
hub / github.com/baldurk/renderdoc / parent

Method parent

qrenderdoc/Code/QRDUtils.cpp:3784–3863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3782}
3783
3784QModelIndex StructuredDataItemModel::parent(const QModelIndex &index) const
3785{
3786 if(index.internalPointer() == NULL)
3787 return QModelIndex();
3788
3789 Index decodedIndex = decodeIndex(index);
3790
3791 SDObject *obj = NULL;
3792
3793 // array members have parents that are page nodes
3794 if(decodedIndex.tag == ArrayMember)
3795 {
3796 int pageRow = decodedIndex.indexInArray / ArrayPageSize;
3797 return createIndex(decodedIndex.indexInArray / ArrayPageSize, 0,
3798 encodeIndex({PageNode, decodedIndex.obj, pageRow * ArrayPageSize}));
3799 }
3800 else if(decodedIndex.tag == PageNode)
3801 {
3802 obj = decodedIndex.obj;
3803 }
3804 else
3805 {
3806 obj = decodedIndex.obj->GetParent();
3807 }
3808
3809 // need to figure out the index for obj, it could be an array member itself in theory, or it might
3810 // be direct, or it could be a root object
3811 if(obj)
3812 {
3813 SDObject *parent = obj->GetParent();
3814
3815 if(parent == NULL)
3816 {
3817 int row = m_Objects.indexOf(obj);
3818 if(row >= 0)
3819 return createIndex(row, 0, obj);
3820
3821 qCritical() << "Encountered object with no parent that is not a root";
3822
3823 return QModelIndex();
3824 }
3825
3826 // if the parent is a large array
3827 if(isLargeArray(parent))
3828 {
3829 // we expect to have set up our member index before this lookup was ever needed
3830 auto it = m_ArrayMembers.find(obj);
3831 if(it == m_ArrayMembers.end())
3832 {
3833 qCritical() << "Expected member index to be set up, but it is not";
3834
3835 return QModelIndex();
3836 }
3837
3838 // return the index for this item, with the child index we looked up
3839 return createIndex(it.value(), 0, encodeIndex({ArrayMember, parent, it.value()}));
3840 }
3841

Callers 4

startFunction · 0.45
jquery-3.6.0.jsFile · 0.45
jquery.jsFile · 0.45
theme.jsFile · 0.45

Calls 8

createIndexFunction · 0.85
QModelIndexClass · 0.50
GetParentMethod · 0.45
indexOfMethod · 0.45
findMethod · 0.45
endMethod · 0.45
valueMethod · 0.45
GetChildMethod · 0.45

Tested by

no test coverage detected