MCPcopy Create free account
hub / github.com/KLayout/klayout / insert_menu

Method insert_menu

src/laybasic/laybasic/layAbstractMenu.cc:1668–1697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1666}
1667
1668void
1669AbstractMenu::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
1699void
1700AbstractMenu::insert_menu (const std::string &path, const std::string &name, const std::string &title)

Callers 7

test_1Method · 0.80
test_4Method · 0.80
test_5Method · 0.80
test_8Method · 0.80
update_menuMethod · 0.80
init_menuMethod · 0.80

Calls 10

setup_itemMethod · 0.80
set_has_submenuMethod · 0.80
c_strMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
insertMethod · 0.45
nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by 4

test_1Method · 0.64
test_4Method · 0.64
test_5Method · 0.64
test_8Method · 0.64