Implement the possibility of concatenating (context) menus.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36605 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-11-29 23:15:31 +00:00
parent e7f2bbe1ee
commit c9da62fb08

View File

@ -298,6 +298,8 @@ public:
const_iterator begin() const { return items_.begin(); }
///
const_iterator end() const { return items_.end(); }
///
void cat(MenuDefinition const & other);
// search for func in this menu iteratively, and put menu
// names in a stack.
@ -641,6 +643,14 @@ bool MenuDefinition::hasFunc(FuncRequest const & func) const
}
void MenuDefinition::cat(MenuDefinition const & other)
{
const_iterator et = other.end();
for (const_iterator it = other.begin(); it != et; ++it)
add(*it);
}
void MenuDefinition::checkShortcuts() const
{
// This is a quadratic algorithm, but we do not care because
@ -1976,14 +1986,27 @@ void Menus::updateMenu(Menu * qmenu)
if (qmenu->d->name.isEmpty())
return;
if (!d->hasMenu(qmenu->d->name)) {
docstring identifier = qstring_to_ucs4(qmenu->d->name);
MenuDefinition fromLyxMenu(qmenu->d->name);
while (!identifier.empty()) {
docstring menu_name;
identifier = split(identifier, menu_name, ';');
if (!d->hasMenu(toqstr(menu_name))) {
LYXERR(Debug::GUI, "\tWARNING: non existing menu: "
<< menu_name);
continue;
}
fromLyxMenu.cat(d->getMenu(toqstr(menu_name)));
fromLyxMenu.add(MenuItem(MenuItem::Separator));
}
if (fromLyxMenu.empty()) {
qmenu->addAction(qt_("No Action Defined!"));
LYXERR(Debug::GUI, "\tWARNING: non existing menu: "
<< qmenu->d->name);
return;
}
MenuDefinition const & fromLyxMenu = d->getMenu(qmenu->d->name);
BufferView * bv = 0;
if (qmenu->d->view)
bv = qmenu->d->view->currentBufferView();