implement openByName

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5280 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-09-12 02:10:19 +00:00
parent bcffabeb84
commit af5a63bc3e
5 changed files with 27 additions and 17 deletions

View File

@ -1,3 +1,10 @@
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

View File

@ -30,13 +30,14 @@
#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)
@ -44,12 +45,21 @@ Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & 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());
}

View File

@ -12,7 +12,6 @@
#ifndef MENUBAR_PIMPL_H
#define MENUBAR_PIMPL_H
#include <vector>
#include <map>
#include <config.h>
@ -27,6 +26,7 @@
class LyXView;
class QtView;
class MenuBackend;
class QLPopupMenu;
struct Menubar::Pimpl {
public:
@ -49,6 +49,11 @@ private:
/// menu controller
MenuBackend const & menubackend_;
typedef std::map<string, QLPopupMenu *> NameMap;
/// name to menu for openByName
NameMap name_map_;
};
#endif // MENUBAR_PIMPL_H

View File

@ -61,10 +61,6 @@ QtView::QtView(unsigned int width, unsigned int height)
::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);

View File

@ -9,14 +9,6 @@ lyx_gui (qt)
- move out lyxserver
- do dpi (cannot easily fix)
Menubar_pimpl
- implement openByName
QAbout
- give good default size
QDocument
- implement me. Need MVC (Edwin is on this)