]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Menubar_pimpl.C
implement openByName
[lyx.git] / src / frontends / qt2 / Menubar_pimpl.C
1 /**
2  * \file Menubar_pimpl.C
3  * Copyright 1999-2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author  Lars Gullik Bjønnes, larsbj@lyx.org
7  */
8
9 #include <config.h>
10
11 #include <algorithm>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "Menubar_pimpl.h"
18 #include "MenuBackend.h"
19 #include "LyXAction.h"
20 #include "kbmap.h"
21 #include "buffer.h"
22 #include "lyxfunc.h"
23 #include "FloatList.h"
24 #include "support/lstrings.h"
25 #include "support/LAssert.h"
26 #include "gettext.h"
27 #include "debug.h"
28
29 #include "QtView.h"
30 #include "QLPopupMenu.h"
31  
32 #include <qmenubar.h>
33 #include <qcursor.h>
34  
35 using std::endl;
36 using std::vector;
37 using std::max;
38 using std::min;
39 using std::for_each;
40 using std::pair;
41
42 Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe) 
43         : owner_(static_cast<QtView*>(view)), menubackend_(mbe)
44 {
45         Menu::const_iterator m = mbe.getMenubar().begin();
46         Menu::const_iterator end = mbe.getMenubar().end();
47         for (; m != end; ++m) {
48                 pair<int, QLPopupMenu *> menu =
49                         createMenu(owner_->menuBar(), &(*m), this, true);
50                 name_map_[m->submenuname()] = menu.second;
51                 QObject::connect(menu.second, SIGNAL(activated(int)),
52                         owner_, SLOT(activated(int)));
53         }
54 }
55
56
57 void Menubar::Pimpl::openByName(string const & name)
58 {
59         NameMap::const_iterator const cit = name_map_.find(name); 
60         if (cit == name_map_.end()) 
61                 return;
62
63         // this will have to do I'm afraid.
64         cit->second->exec(QCursor::pos());
65 }