void KHelpMain::fillBookmarkMenu(KBookmark *parent, QPopupMenu *menu, int &id) { KBookmark *bm; for ( bm = parent->getChildren().first(); bm != NULL; bm = parent->getChildren().next() ) { if ( bm->getType() == KBookmark::URL ) { menu->insertItem( bm->getText(), id ); id++; } else { QPopupMenu *subMenu = new QPopupMenu; menu->insertItem( bm->getText(), subMenu ); fillBookmarkMenu( bm, subMenu, id ); } } }
// write the contents of a folder (recursive) // void KBookmarkManager::writeFolder( QTextStream &stream, KBookmark *parent ) { KBookmark *bm; for ( bm = parent->getChildren().first(); bm != NULL; bm = parent->getChildren().next() ) { if ( bm->getType() == KBookmark::URL ) { stream << "<DT><A HREF=\"" << bm->getURL() << "\">" << bm->getText() << "</A>" << endl; } else { stream << "<DT><H3>" << bm->getText() << "</H3>" << endl; stream << "<DL><P>" << endl; writeFolder( stream, bm ); stream << "</DL><P>" << endl; } } }
KBookmark *KBookmarkManager::findBookmark( KBookmark *parent, int id, int &currId ) { KBookmark *bm; for ( bm = parent->getChildren().first(); bm != NULL; bm = parent->getChildren().next() ) { if ( bm->getType() == KBookmark::URL ) { if ( currId == id ) return bm; currId++; } else { KBookmark *retbm; if ( ( retbm = findBookmark( bm, id, currId ) ) != NULL ) return retbm; } } return NULL; }