diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index f93b34438c..73cc798191 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2002-07-25 John Levon + + * Menubar_pimpl.C: split create/fill of menus into + two functions + 2002-07-25 John Levon * Menubar_pimpl.C: make it compile again diff --git a/src/frontends/qt2/Menubar_pimpl.C b/src/frontends/qt2/Menubar_pimpl.C index ef857d617b..ef8d4ac69d 100644 --- a/src/frontends/qt2/Menubar_pimpl.C +++ b/src/frontends/qt2/Menubar_pimpl.C @@ -75,36 +75,39 @@ Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe) Menu tomenu; Menu const frommenu = menubackend_.getMenu(m->submenuname()); menubackend_.expand(frommenu, tomenu, owner_->buffer()); - makeMenu(owner_->menuBar(), m, tomenu); + fillMenu(createMenu(owner_->menuBar(), m), tomenu); } } -void Menubar::Pimpl::makeMenu(QMenuData * parent, MenuItem const * item, Menu const & menu) +QPopupMenu * Menubar::Pimpl::createMenu(QMenuData * parent, MenuItem const * item) { // FIXME: does this leak or not ? QPopupMenu * pm = new QPopupMenu(); int const parentid = parent->insertItem(getLabel(*item).c_str(), pm); + + MenuItemInfo const info(parent, parentid, item); + items_[item->label()] = info; + return pm; +} + +void Menubar::Pimpl::fillMenu(QMenuData * qmenu, Menu const & menu) +{ Menu::const_iterator m = menu.begin(); Menu::const_iterator end = menu.end(); for (; m != end; ++m) { - // FIXME: handle the special stuff here if (m->kind() == MenuItem::Separator) { - pm->insertSeparator(); + qmenu->insertSeparator(); } else if (m->kind() == MenuItem::Submenu) { - makeMenu(pm, m, *m->submenu()); + fillMenu(createMenu(qmenu, m), *m->submenu()); } else { - pm->insertItem(getLabel(*m).c_str(), m->action()); - MenuItemInfo const info(pm, m->action(), m); + qmenu->insertItem(getLabel(*m).c_str(), m->action()); + MenuItemInfo const info(qmenu, m->action(), m); items_[m->label()] = info; updateItem(info); } } - - MenuItemInfo const info(parent, parentid, item); - items_[item->label()] = info; - updateSubmenu(info); } diff --git a/src/frontends/qt2/Menubar_pimpl.h b/src/frontends/qt2/Menubar_pimpl.h index c5581423ba..66e0e12f75 100644 --- a/src/frontends/qt2/Menubar_pimpl.h +++ b/src/frontends/qt2/Menubar_pimpl.h @@ -28,6 +28,7 @@ class LyXView; class QtView; class QMenuData; +class QPopupMenu; class Menu; class MenuItem; class MenuBackend; @@ -64,7 +65,10 @@ public: private: /// create a menu - void makeMenu(QMenuData * parent, MenuItem const * item, Menu const & menu); + QPopupMenu * createMenu(QMenuData * parent, MenuItem const * item); + + /// populate a menu (recursively) + void fillMenu(QMenuData * qmenu, Menu const & menu); /// special handling updating a submenu label void updateSubmenu(MenuItemInfo const & i);