diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index b0b38480ef..ba130abe88 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2002-09-12 John Levon + + * Menubar_pimpl.C: + * Menubar_pimpl.h: + * QtView.C: implement openByName(). Move activated + signal to per-menu + 2002-09-12 John Levon * QCommandBuffer.C: fix click diff --git a/src/frontends/qt2/Menubar_pimpl.C b/src/frontends/qt2/Menubar_pimpl.C index 16c0ddcd5e..3a0c64348f 100644 --- a/src/frontends/qt2/Menubar_pimpl.C +++ b/src/frontends/qt2/Menubar_pimpl.C @@ -30,13 +30,14 @@ #include "QLPopupMenu.h" #include - +#include 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(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 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()); } diff --git a/src/frontends/qt2/Menubar_pimpl.h b/src/frontends/qt2/Menubar_pimpl.h index 1dc44a423b..37755e7615 100644 --- a/src/frontends/qt2/Menubar_pimpl.h +++ b/src/frontends/qt2/Menubar_pimpl.h @@ -12,7 +12,6 @@ #ifndef MENUBAR_PIMPL_H #define MENUBAR_PIMPL_H -#include #include #include @@ -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 NameMap; + + /// name to menu for openByName + NameMap name_map_; }; #endif // MENUBAR_PIMPL_H diff --git a/src/frontends/qt2/QtView.C b/src/frontends/qt2/QtView.C index 8bb706409b..e825c76b9b 100644 --- a/src/frontends/qt2/QtView.C +++ b/src/frontends/qt2/QtView.C @@ -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); diff --git a/src/frontends/qt2/TODO b/src/frontends/qt2/TODO index 1d7ea780fa..c235a7514a 100644 --- a/src/frontends/qt2/TODO +++ b/src/frontends/qt2/TODO @@ -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)