]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/Menubar_pimpl.C
Get rid of the static_casts.
[lyx.git] / src / frontends / qt2 / Menubar_pimpl.C
index 559a730d3ed44cfd86b49d07ddbd7a29d9a00579..517a4bdb516982dc9dea79f4d2cbeb5f4dd3a789 100644 (file)
@@ -1,93 +1,83 @@
 /**
- * \file Menubar_pimpl.C
- * Copyright 1999-2001 The LyX Team.
- * See the file COPYING.
+ * \file qt2/Menubar_pimpl.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author  Lars Gullik Bjønnes, larsbj@lyx.org
+ * \author  Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#include <algorithm>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "Menubar_pimpl.h"
 #include "MenuBackend.h"
 #include "LyXAction.h"
 #include "kbmap.h"
 #include "buffer.h"
-#include "Dialogs.h"
 #include "lyxfunc.h"
 #include "FloatList.h"
 #include "support/lstrings.h"
 #include "support/LAssert.h"
-#include "gettext.h"
+#include "qt_helpers.h"
 #include "debug.h"
 
 #include "QtView.h"
+#include "QLPopupMenu.h"
+
 #include <qmenubar.h>
-#include <qpopupmenu.h>
+#include <qcursor.h>
+
+#include <algorithm>
+
 using std::endl;
 using std::vector;
 using std::max;
 using std::min;
 using std::for_each;
-
-typedef vector<int>::size_type size_type;
-
-extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
-extern LyXAction lyxaction;
+using std::pair;
 
 
-Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe) 
+Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe)
        : owner_(static_cast<QtView*>(view)), menubackend_(mbe)
 {
        Menu::const_iterator m = mbe.getMenubar().begin();
        Menu::const_iterator end = mbe.getMenubar().end();
        for (; m != end; ++m) {
-               makeMenu(owner_->menuBar(), *m);
+               pair<int, QLPopupMenu *> menu =
+                       createMenu(owner_->menuBar(), &(*m), this, true);
+               name_map_[m->submenuname()] = menu.second;
        }
 }
 
 
-void Menubar::Pimpl::makeMenu(QMenuData * parent, MenuItem const & menu)
+Menubar::Pimpl::~Pimpl()
+{}
+
+
+void Menubar::Pimpl::openByName(string const & name)
+{
+       NameMap::const_iterator const cit = name_map_.find(name);
+       if (cit == name_map_.end())
+               return;
+
+       // this will have to do I'm afraid.
+       cit->second->exec(QCursor::pos());
+}
+
+
+void Menubar::Pimpl::update()
+{}
+
+
+QtView * Menubar::Pimpl::view()
 {
-       // FIXME: leak
-       QPopupMenu * pm = new QPopupMenu();
-       parent->insertItem(menu.label().c_str(), pm);
-       Menu md;
-       menubackend_.getMenu(menu.submenu()).expand(md, 0);
-       Menu::const_iterator m = md.begin();
-       Menu::const_iterator end = md.end();
-       for (; m != end; ++m) {
-               if (m->kind() == MenuItem::Separator) {
-                       pm->insertSeparator();
-               } else {
-                       pm->insertItem(m->label().c_str(), m->action());
-               } 
-       }
+       return owner_;
 }
 
-void Menubar::Pimpl::openByName(string const & name)
+
+MenuBackend const & Menubar::Pimpl::backend()
 {
-       lyxerr << "Menubar::Pimpl::openByName: menu " << name << endl;
-
-#if 0
-       if (menubackend_->getMenu(current_menu_name_).hasSubmenu(name)) {
-               for (ButtonList::const_iterator cit = buttonlist_.begin();
-                    cit != buttonlist_.end(); ++cit) {
-                       if ((*cit)->item_->submenu() == name) {
-                               MenuCallback((*cit)->obj_, 1);
-                               return;
-                       }
-               }
-       }
-#endif
+       return menubackend_;
 }