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

Method insert_item

src/laybasic/laybasic/layAbstractMenu.cc:1607–1644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1605}
1606
1607void
1608AbstractMenu::insert_item (const std::string &p, const std::string &name, Action *action)
1609{
1610 bool primary = true;
1611
1612 tl::Extractor extr (p.c_str ());
1613 while (! extr.at_end ()) {
1614
1615 typedef std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator > > path_type;
1616 path_type path = find_item (extr);
1617 if (! path.empty ()) {
1618
1619 AbstractMenuItem *parent = path.back ().first;
1620 std::list<AbstractMenuItem>::iterator iter = path.back ().second;
1621
1622 // insert the new item
1623 parent->children.insert (iter, AbstractMenuItem (mp_dispatcher));
1624 --iter;
1625
1626 iter->setup_item (parent->name (), name, action, primary);
1627 primary = false;
1628
1629 // find any items with the same name and remove them
1630 for (std::list<AbstractMenuItem>::iterator existing = parent->children.begin (); existing != parent->children.end (); ) {
1631 std::list<AbstractMenuItem>::iterator existing_next = existing;
1632 ++existing_next;
1633 if (existing->name () == iter->name () && existing != iter) {
1634 parent->children.erase (existing);
1635 }
1636 existing = existing_next;
1637 }
1638
1639 }
1640
1641 }
1642
1643 emit_changed ();
1644}
1645
1646void
1647AbstractMenu::insert_separator (const std::string &p, const std::string &name)

Callers 15

test_1Method · 0.80
test_2Method · 0.80
test_4Method · 0.80
test_5Method · 0.80
test_8Method · 0.80
initializeMethod · 0.80
test_flatten.rbFile · 0.80
test_annot.rbFile · 0.80
test_sel.rbFile · 0.80
screenshots.rbFile · 0.80
browser.rbFile · 0.80

Calls 10

setup_itemMethod · 0.80
c_strMethod · 0.45
at_endMethod · 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 5

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