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 begin() const { return items_.begin(); }
/// ///
const_iterator end() const { return items_.end(); } const_iterator end() const { return items_.end(); }
///
void cat(MenuDefinition const & other);
// search for func in this menu iteratively, and put menu // search for func in this menu iteratively, and put menu
// names in a stack. // 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 void MenuDefinition::checkShortcuts() const
{ {
// This is a quadratic algorithm, but we do not care because // 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()) if (qmenu->d->name.isEmpty())
return; return;
if (!d->hasMenu(qmenu->d->name)) { docstring identifier = qstring_to_ucs4(qmenu->d->name);
qmenu->addAction(qt_("No Action Defined!")); 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: " LYXERR(Debug::GUI, "\tWARNING: non existing menu: "
<< qmenu->d->name); << menu_name);
continue;
}
fromLyxMenu.cat(d->getMenu(toqstr(menu_name)));
fromLyxMenu.add(MenuItem(MenuItem::Separator));
}
if (fromLyxMenu.empty()) {
qmenu->addAction(qt_("No Action Defined!"));
return; return;
} }
MenuDefinition const & fromLyxMenu = d->getMenu(qmenu->d->name);
BufferView * bv = 0; BufferView * bv = 0;
if (qmenu->d->view) if (qmenu->d->view)
bv = qmenu->d->view->currentBufferView(); bv = qmenu->d->view->currentBufferView();