]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Menus.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / Menus.cpp
index c22f49a7613983524bf767557486434335972b79..1a91ca82a1c1abb2323166b661c122859be9cc7a 100644 (file)
@@ -45,6 +45,7 @@
 #include "TocBackend.h"
 #include "ToolbarBackend.h"
 
+#include "support/assert.h"
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/filetools.h"
@@ -57,6 +58,8 @@
 #include <QMenuBar>
 #include <QString>
 
+#include <boost/shared_ptr.hpp>
+
 #include <algorithm>
 #include <ostream>
 #include <vector>
@@ -139,7 +142,7 @@ public:
                 bool optional = false)
                : kind_(kind), label_(label), submenuname_(submenu), optional_(optional)
        {
-               BOOST_ASSERT(kind == Submenu);
+               LASSERT(kind == Submenu, /**/);
        }
 
        MenuItem(Kind kind,
@@ -199,7 +202,7 @@ public:
        /// 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]; }
@@ -408,8 +411,7 @@ void MenuDefinition::read(Lexer & lex)
        };
 
        lex.pushTable(menutags);
-       if (lyxerr.debugging(Debug::PARSER))
-               lex.printTable(lyxerr);
+       lex.setContext("MenuDefinition::read: ");
 
        bool quit = false;
        bool optional = false;
@@ -517,8 +519,7 @@ void MenuDefinition::read(Lexer & lex)
                        break;
 
                default:
-                       lex.printError("MenuDefinition::read: "
-                                      "Unknown menu tag: `$$Token'");
+                       lex.printError("Unknown menu tag");
                        break;
                }
        }
@@ -727,7 +728,7 @@ void MenuDefinition::expandFormats(MenuItem::Kind kind, Buffer const * buf)
                                continue;
                        break;
                default:
-                       BOOST_ASSERT(false);
+                       LASSERT(false, /**/);
                        break;
                }
                // FIXME: if we had proper support for translating the
@@ -913,9 +914,7 @@ void MenuDefinition::expandToc(Buffer const * buf)
                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");
@@ -1129,7 +1128,7 @@ void Menu::Impl::populate(QMenu & qMenu, MenuDefinition const & menu)
 /////////////////////////////////////////////////////////////////////
 
 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;
@@ -1188,7 +1187,7 @@ struct Menus::Impl {
        ///
        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_;
@@ -1377,7 +1376,7 @@ MenuDefinition const & Menus::Impl::getMenu(QString const & name) const
                MenuNamesEqual(name));
        if (cit == menulist_.end())
                lyxerr << "No submenu named " << fromqstr(name) << endl;
-       BOOST_ASSERT(cit != menulist_.end());
+       LASSERT(cit != menulist_.end(), /**/);
        return (*cit);
 }
 
@@ -1388,7 +1387,7 @@ MenuDefinition & Menus::Impl::getMenu(QString const & name)
                MenuNamesEqual(name));
        if (it == menulist_.end())
                lyxerr << "No submenu named " << fromqstr(name) << endl;
-       BOOST_ASSERT(it != menulist_.end());
+       LASSERT(it != menulist_.end(), /**/);
        return (*it);
 }
 
@@ -1401,6 +1400,10 @@ MenuDefinition & Menus::Impl::getMenu(QString const & name)
 
 Menus::Menus() : d(new Impl) {}
 
+Menus::~Menus()
+{
+  delete d;
+}
 
 void Menus::read(Lexer & lex)
 {
@@ -1416,15 +1419,12 @@ void Menus::read(Lexer & lex)
                { "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);
-       if (lyxerr.debugging(Debug::PARSER))
-               lex.printTable(lyxerr);
+       lex.setContext("Menus::read");
 
        bool quit = false;
 
@@ -1449,8 +1449,7 @@ void Menus::read(Lexer & lex)
                        quit = true;
                        break;
                default:
-                       lex.printError("menubackend::read: "
-                                      "Unknown menu tag: `$$Token'");
+                       lex.printError("Unknown menu tag");
                        break;
                }
        }
@@ -1486,10 +1485,7 @@ void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial)
                        << 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;