@@ -210,9 +210,9 @@ class LayoutParser
210210 void startSimpleEntry (LayoutDocEntry::Kind k,const std::string &id,const XMLHandlers::Attributes &attrib)
211211 {
212212 bool isVisible = m_visible && elemIsVisible (attrib);
213- if (m_part!=LayoutDocManager::Undefined && isVisible )
213+ if (m_part!=LayoutDocManager::Undefined)
214214 {
215- auto elem = std::make_unique<LayoutDocEntrySimple>(k,id);
215+ auto elem = std::make_unique<LayoutDocEntrySimple>(k,id,isVisible );
216216 // printf("startSimpleEntry(%s) isVisible=%d visible=%d\n",qPrint(elem->entryToString()),isVisible,elem->visible());
217217 m_layoutDocManager.addEntry (m_part,std::move (elem));
218218 }
@@ -228,9 +228,9 @@ class LayoutParser
228228 // printf("startSectionEntry: title='%s' userTitle='%s'\n",
229229 // qPrint(title),qPrint(userTitle));
230230 if (userTitle.isEmpty ()) userTitle = title;
231- if (m_part!=LayoutDocManager::Undefined && isVisible )
231+ if (m_part!=LayoutDocManager::Undefined)
232232 {
233- m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySection>(k,id,userTitle));
233+ m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySection>(k,id,userTitle,isVisible ));
234234 }
235235 }
236236
@@ -243,9 +243,9 @@ class LayoutParser
243243 if (userTitle.isEmpty ()) userTitle = title;
244244 if (userSubscript.isEmpty ()) userSubscript = subscript;
245245 bool isVisible = m_visible && elemIsVisible (attrib);
246- if (m_part!=LayoutDocManager::Undefined && isVisible )
246+ if (m_part!=LayoutDocManager::Undefined)
247247 {
248- m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntryMemberDecl>(type,id,userTitle,userSubscript));
248+ m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntryMemberDecl>(type,id,userTitle,userSubscript,isVisible ));
249249 }
250250 }
251251
@@ -256,9 +256,9 @@ class LayoutParser
256256 if (userTitle.isEmpty ()) userTitle = title;
257257 // printf("memberdef: %s\n",qPrint(userTitle));
258258 bool isVisible = m_visible && elemIsVisible (attrib);
259- if (m_part!=LayoutDocManager::Undefined && isVisible )
259+ if (m_part!=LayoutDocManager::Undefined)
260260 {
261- m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntryMemberDef>(type,id,userTitle));
261+ m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntryMemberDef>(type,id,userTitle,isVisible ));
262262 }
263263 }
264264
@@ -628,9 +628,9 @@ class LayoutParser
628628 {
629629 m_scope+=" memberdef/" ;
630630 bool isVisible = m_visible && elemIsVisible (attrib);
631- if (m_part!=LayoutDocManager::Undefined && isVisible )
631+ if (m_part!=LayoutDocManager::Undefined)
632632 {
633- m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDefStart,id));
633+ m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDefStart,id,isVisible ));
634634 }
635635 }
636636
@@ -641,18 +641,18 @@ class LayoutParser
641641 if (i!=-1 )
642642 {
643643 m_scope=m_scope.left (i);
644- bool isVisible = false ;
644+ bool isVisible = true ;
645645 for (const auto &lde : m_layoutDocManager.docEntries (m_part))
646646 {
647647 if (lde->kind () == LayoutDocEntry::MemberDefStart)
648648 {
649- isVisible = true ;
649+ isVisible = static_cast < const LayoutDocEntrySimple*>(lde. get ())-> visible () ;
650650 break ;
651651 }
652652 }
653- if (m_part!=LayoutDocManager::Undefined && isVisible )
653+ if (m_part!=LayoutDocManager::Undefined)
654654 {
655- m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDefEnd,id));
655+ m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDefEnd,id,isVisible ));
656656 }
657657 }
658658 }
@@ -661,9 +661,9 @@ class LayoutParser
661661 {
662662 m_scope+=" memberdecl/" ;
663663 bool isVisible = m_visible && elemIsVisible (attrib);
664- if (m_part!=LayoutDocManager::Undefined && isVisible )
664+ if (m_part!=LayoutDocManager::Undefined)
665665 {
666- m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDeclStart,id));
666+ m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDeclStart,id,isVisible ));
667667 }
668668 }
669669
@@ -673,18 +673,18 @@ class LayoutParser
673673 if (i!=-1 )
674674 {
675675 m_scope=m_scope.left (i);
676- bool isVisible = false ;
676+ bool isVisible = true ;
677677 for (const auto &lde : m_layoutDocManager.docEntries (m_part))
678678 {
679679 if (lde->kind () == LayoutDocEntry::MemberDeclStart)
680680 {
681- isVisible = true ;
681+ isVisible = static_cast < const LayoutDocEntrySimple*>(lde. get ())-> visible () ;
682682 break ;
683683 }
684684 }
685- if (m_part!=LayoutDocManager::Undefined && isVisible )
685+ if (m_part!=LayoutDocManager::Undefined)
686686 {
687- m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDeclEnd,id));
687+ m_layoutDocManager.addEntry (m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDeclEnd,id,isVisible ));
688688 }
689689 }
690690 }
@@ -1369,7 +1369,7 @@ void LayoutParser::endElement( const std::string &name )
13691369 }
13701370 if (it!=g_elementHandlers.end ())
13711371 {
1372- it->second .endCb (*this ,it->first );
1372+ it->second .endCb (*this ,it->first + " end " ); // added end to id to make it unique
13731373 }
13741374}
13751375
@@ -1409,6 +1409,7 @@ void LayoutDocManager::init()
14091409 [&]() { DebugLex::print (Debug::Lex_xml," Entering" ," libxml/xml.l" ,layoutFile); },
14101410 [&]() { DebugLex::print (Debug::Lex_xml," Finished" , " libxml/xml.l" ,layoutFile); }
14111411 );
1412+ removeInvisibleDocEntries ();
14121413}
14131414
14141415LayoutDocManager & LayoutDocManager::instance ()
@@ -1469,11 +1470,33 @@ void LayoutDocManager::parse(const QCString &fileName, const char *data)
14691470 // mergeNavEntries(layoutDocManager);
14701471 mergeDocEntries (layoutDocManager);
14711472
1473+ layoutDocManager.removeInvisibleDocEntries ();
1474+
14721475 // replace default layout with merged layout
14731476 d->docEntries .swap (layoutDocManager.d ->docEntries );
14741477 d->rootNav .swap (layoutDocManager.d ->rootNav );
14751478}
14761479
1480+ void LayoutDocManager::removeInvisibleDocEntries ()
1481+ {
1482+ // remove invisible entries
1483+ for (auto &list : d->docEntries )
1484+ {
1485+ auto it = list.begin ();
1486+ while (it!=list.end ())
1487+ {
1488+ if (*it==nullptr || !(*it)->visible ())
1489+ {
1490+ it = list.erase (it);
1491+ }
1492+ else
1493+ {
1494+ ++it;
1495+ }
1496+ }
1497+ }
1498+ }
1499+
14771500// search for candidate node in tree with root target. Returns the match target node if found, or nullptr otherwise.
14781501static LayoutNavEntry *findNavEntryRec (LayoutNavEntry *root, const std::string &id)
14791502{
@@ -1579,10 +1602,12 @@ static void mergeDocEntryLists(LayoutDocEntryList &targetList,LayoutDocEntryList
15791602 using IdMap = std::unordered_map<std::string,size_t >;
15801603
15811604 auto prepareSet = [](const LayoutDocEntryList &list, IdSet &set) {
1605+ // size_t idx=0;
15821606 for (const auto &e : list)
15831607 {
1584- // printf("set(%s)\n",qPrint(e->id()));
1608+ // printf("idx=%zu set(%s)\n",idx ,qPrint(e->id()));
15851609 set.insert (e->id ());
1610+ // idx++;
15861611 }
15871612 };
15881613
@@ -1593,6 +1618,7 @@ static void mergeDocEntryLists(LayoutDocEntryList &targetList,LayoutDocEntryList
15931618 auto it = set.find (id);
15941619 if (it != set.end ())
15951620 {
1621+ // printf("map %s->%zu\n",qPrint(id),i);
15961622 map[id]=i;
15971623 }
15981624 }
@@ -1605,7 +1631,9 @@ static void mergeDocEntryLists(LayoutDocEntryList &targetList,LayoutDocEntryList
16051631 prepareSet (targetList,targetSet);
16061632
16071633 IdMap sourceMap, targetMap;
1634+ // printf("---- targetMap\n");
16081635 prepareMap (targetList,sourceSet,targetMap);
1636+ // printf("---- sourceMap\n");
16091637 prepareMap (sourceList,targetSet,sourceMap);
16101638
16111639 // calculate list of insertion positions in the target list for each id in the source list
@@ -1622,12 +1650,14 @@ static void mergeDocEntryLists(LayoutDocEntryList &targetList,LayoutDocEntryList
16221650 if (i < kv.second ) // i appears before this shared id
16231651 {
16241652 size_t idx = targetMap[kv.first ]; // get the corresponding index in the target list
1653+ // printf(" evaluating %s->%zu min=%zu\n",qPrint(kv.first),idx,minIdx);
16251654 if (idx<minIdx) // update minimum
16261655 {
16271656 minIdx=idx;
16281657 }
16291658 }
16301659 }
1660+ // printf("insertion %s->%zu\n",qPrint(id),minIdx);
16311661 insertionList.push_back (minIdx);
16321662 }
16331663
@@ -1637,12 +1667,12 @@ static void mergeDocEntryLists(LayoutDocEntryList &targetList,LayoutDocEntryList
16371667 for (auto it=insertionList.rbegin (); it!=insertionList.rend (); ++it, idx--)
16381668 {
16391669 std::string id = sourceList[idx]->id ();
1640- // printf("entry %s\n",qPrint(id));
1670+ // printf("idx=%zu entry %s\n",idx ,qPrint(id));
16411671 if (targetSet.find (id)==targetSet.end ()) // need to add id
16421672 {
16431673 // for efficiency we move the elements from the source list to the target list, thus modifying the source list!
1674+ // printf("--> insert at %zu before %s\n",*it,qPrint(*it<targetList.size()?targetList[*it]->id():"none"));
16441675 targetList.insert (targetList.begin ()+*it, std::move (sourceList[idx]));
1645- // printf("--> insert\n");
16461676 }
16471677 }
16481678
0 commit comments