| 1666 | } |
| 1667 | |
| 1668 | void |
| 1669 | AbstractMenu::insert_menu (const std::string &p, const std::string &name, Action *action) |
| 1670 | { |
| 1671 | typedef std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator > > path_type; |
| 1672 | tl::Extractor extr (p.c_str ()); |
| 1673 | path_type path = find_item (extr); |
| 1674 | if (! path.empty ()) { |
| 1675 | |
| 1676 | AbstractMenuItem *parent = path.back ().first; |
| 1677 | std::list<AbstractMenuItem>::iterator iter = path.back ().second; |
| 1678 | |
| 1679 | parent->children.insert (iter, AbstractMenuItem (mp_dispatcher)); |
| 1680 | --iter; |
| 1681 | iter->setup_item (parent->name (), name, action, true); |
| 1682 | iter->set_has_submenu (); |
| 1683 | |
| 1684 | // find any items with the same name and remove them |
| 1685 | for (std::list<AbstractMenuItem>::iterator existing = parent->children.begin (); existing != parent->children.end (); ) { |
| 1686 | std::list<AbstractMenuItem>::iterator existing_next = existing; |
| 1687 | ++existing_next; |
| 1688 | if (existing->name () == iter->name () && existing != iter) { |
| 1689 | parent->children.erase (existing); |
| 1690 | } |
| 1691 | existing = existing_next; |
| 1692 | } |
| 1693 | |
| 1694 | } |
| 1695 | |
| 1696 | emit_changed (); |
| 1697 | } |
| 1698 | |
| 1699 | void |
| 1700 | AbstractMenu::insert_menu (const std::string &path, const std::string &name, const std::string &title) |