+2002-09-12 John Levon <levon@movementarian.org>
+
+ * Menubar_pimpl.C:
+ * Menubar_pimpl.h:
+ * QtView.C: implement openByName(). Move activated
+ signal to per-menu
+
2002-09-12 John Levon <levon@movementarian.org>
* QCommandBuffer.C: fix click
#include "QLPopupMenu.h"
#include <qmenubar.h>
-
+#include <qcursor.h>
using std::endl;
using std::vector;
using std::max;
using std::min;
using std::for_each;
+using std::pair;
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) {
- createMenu(owner_->menuBar(), &(*m), this, true);
+ pair<int, QLPopupMenu *> menu =
+ createMenu(owner_->menuBar(), &(*m), this, true);
+ name_map_[m->submenuname()] = menu.second;
+ QObject::connect(menu.second, SIGNAL(activated(int)),
+ owner_, SLOT(activated(int)));
}
}
-void Menubar::Pimpl::openByName(string const &)
+void Menubar::Pimpl::openByName(string const & name)
{
- // FIXME
+ 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());
}
#ifndef MENUBAR_PIMPL_H
#define MENUBAR_PIMPL_H
-#include <vector>
#include <map>
#include <config.h>
class LyXView;
class QtView;
class MenuBackend;
+class QLPopupMenu;
struct Menubar::Pimpl {
public:
/// menu controller
MenuBackend const & menubackend_;
+
+ typedef std::map<string, QLPopupMenu *> NameMap;
+
+ /// name to menu for openByName
+ NameMap name_map_;
};
#endif // MENUBAR_PIMPL_H
::current_view = bufferview_.get();
menubar_.reset(new Menubar(this, menubackend));
-
- connect(menuBar(), SIGNAL(activated(int)),
- this, SLOT(activated(int)));
-
toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
statusBar()->setSizeGripEnabled(false);