]> git.lyx.org Git - lyx.git/commitdiff
implement openByName
authorJohn Levon <levon@movementarian.org>
Thu, 12 Sep 2002 02:10:19 +0000 (02:10 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 12 Sep 2002 02:10:19 +0000 (02:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5280 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/Menubar_pimpl.C
src/frontends/qt2/Menubar_pimpl.h
src/frontends/qt2/QtView.C
src/frontends/qt2/TODO

index b0b38480ef70a08f5778187bd783b6ae5d044300..ba130abe885ef1568749576682fede3092d039bf 100644 (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
index 16c0ddcd5ef3d2307e46b5341212b3c5ab9bc8e5..3a0c64348ff516bd39c653f1c78e744acd2651d3 100644 (file)
 #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());
 }
index 1dc44a423bf253fb6a9993bbe04552f5c0e21829..37755e761525062fe9d17057960608329c62a667 100644 (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
index 8bb706409bf9d8b7459ab88601b73d5ca3834ecb..e825c76b9b83d8210b63ef08d473f2fca1eca7de 100644 (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);
index 1d7ea780fae8a4d5710ba29229af57400937f999..c235a7514a84bc7d639cc5adf0a931d87dba3140 100644 (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)