#include "TocBackend.h"
#include "ToolbarBackend.h"
+#include "support/assert.h"
#include "support/convert.h"
#include "support/debug.h"
#include "support/filetools.h"
#include <QMenuBar>
#include <QString>
+#include <boost/shared_ptr.hpp>
+
#include <algorithm>
#include <ostream>
#include <vector>
bool optional = false)
: kind_(kind), label_(label), submenuname_(submenu), optional_(optional)
{
- BOOST_ASSERT(kind == Submenu);
+ LASSERT(kind == Submenu, /**/);
}
MenuItem(Kind kind,
/// set the description of the submenu
void submenuname(QString const & name) { submenuname_ = name; }
///
- bool hasSubmenu() const { return submenu_.isEmpty(); }
+ bool hasSubmenu() const { return !submenu_.isEmpty(); }
///
MenuDefinition const & submenu() const { return submenu_.at(0); }
MenuDefinition & submenu() { return submenu_[0]; }
void MenuDefinition::read(Lexer & lex)
{
- enum Menutags {
+ enum {
md_item = 1,
md_branches,
md_documents,
md_floatlistinsert,
md_floatinsert,
md_pasterecent,
- md_toolbars,
- md_last
+ md_toolbars
};
- struct keyword_item menutags[md_last - 1] = {
+ LexerKeyword menutags[] = {
{ "bookmarks", md_bookmarks },
{ "branches", md_branches },
{ "charstyles", md_charstyles },
{ "viewformats", md_viewformats }
};
- lex.pushTable(menutags, md_last - 1);
- if (lyxerr.debugging(Debug::PARSER))
- lex.printTable(lyxerr);
+ lex.pushTable(menutags);
+ lex.setContext("MenuDefinition::read: ");
bool quit = false;
bool optional = false;
break;
default:
- lex.printError("MenuDefinition::read: "
- "Unknown menu tag: `$$Token'");
+ lex.printError("Unknown menu tag");
break;
}
}
continue;
break;
default:
- BOOST_ASSERT(false);
+ LASSERT(false, /**/);
break;
}
// FIXME: if we had proper support for translating the
else if (cit->first == "child") {
label = qt_("Child Documents");
in_other_list = false;
- } else if (cit->first == "embedded")
- label = qt_("Embedded Files");
- else if (cit->first == "graphics")
+ } else if (cit->first == "graphics")
label = qt_("List of Graphics");
else if (cit->first == "equation")
label = qt_("List of Equations");
else if (cit->first == "index")
label = qt_("List of Indexes");
- else if (cit->first == "listing")
- label = qt_("List of Listings");
+ else if (cit->first == "listing") {
+ // FIXME: the listing navigate menu causes a crash for unknown
+ // reason. See http://bugzilla.lyx.org/show_bug.cgi?id=4613
+ // This is a temporary fix:
+ //label = qt_("List of Listings");
+ continue;
+ }
else if (cit->first == "marginalnote")
label = qt_("List of Marginal notes");
else if (cit->first == "note")
/////////////////////////////////////////////////////////////////////
Menu::Menu(GuiView * gv, QString const & name, bool top_level)
-: d(new Menu::Impl)
+: QMenu(gv), d(new Menu::Impl)
{
d->top_level_menu = top_level? new MenuDefinition : 0;
d->view = gv;
///
MenuDefinition menubar_;
- typedef QMap<GuiView *, QHash<QString, Menu *> > NameMap;
+ typedef QMap<GuiView *, QHash<QString, Menu*> > NameMap;
/// name to menu for \c menu() method.
NameMap name_map_;
}
-void Menus::Impl::expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
- Buffer const * buf) const
+void Menus::Impl::expand(MenuDefinition const & frommenu,
+ MenuDefinition & tomenu, Buffer const * buf) const
{
if (!tomenu.empty())
tomenu.clear();
MenuNamesEqual(name));
if (cit == menulist_.end())
lyxerr << "No submenu named " << fromqstr(name) << endl;
- BOOST_ASSERT(cit != menulist_.end());
+ LASSERT(cit != menulist_.end(), /**/);
return (*cit);
}
MenuNamesEqual(name));
if (it == menulist_.end())
lyxerr << "No submenu named " << fromqstr(name) << endl;
- BOOST_ASSERT(it != menulist_.end());
+ LASSERT(it != menulist_.end(), /**/);
return (*it);
}
+
/////////////////////////////////////////////////////////////////////
-// Menus implementation
+//
+// Menus
+//
/////////////////////////////////////////////////////////////////////
-Menus::Menus(): d(new Impl) {}
+Menus::Menus() : d(new Impl) {}
+Menus::~Menus()
+{
+ delete d;
+}
void Menus::read(Lexer & lex)
{
- enum Menutags {
- md_menu = 1,
+ enum {
+ md_menu,
md_menubar,
md_endmenuset,
- md_last
};
- struct keyword_item menutags[md_last - 1] = {
+ LexerKeyword menutags[] = {
{ "end", md_endmenuset },
{ "menu", md_menu },
{ "menubar", md_menubar }
};
- //consistency check
- if (compare_ascii_no_case(lex.getString(), "menuset")) {
- lyxerr << "Menubackend::read: ERROR wrong token:`"
- << lex.getString() << '\'' << endl;
- }
+ // consistency check
+ if (compare_ascii_no_case(lex.getString(), "menuset"))
+ LYXERR0("Menus::read: ERROR wrong token: `" << lex.getString() << '\'');
- lex.pushTable(menutags, md_last - 1);
- if (lyxerr.debugging(Debug::PARSER))
- lex.printTable(lyxerr);
+ lex.pushTable(menutags);
+ lex.setContext("Menus::read");
bool quit = false;
quit = true;
break;
default:
- lex.printError("menubackend::read: "
- "Unknown menu tag: `$$Token'");
+ lex.printError("Unknown menu tag");
break;
}
}
<< fromqstr(d->menubar_.name()));
return;
}
- else {
- LYXERR(Debug::GUI, "menu bar entries "
- << d->menubar_.size());
- }
+ LYXERR(Debug::GUI, "menu bar entries " << d->menubar_.size());
MenuDefinition menu;
Buffer * buf = 0;