]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Menubar_pimpl.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / Menubar_pimpl.C
1 /**
2  * \file qt2/Menubar_pimpl.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author  Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
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 #include <algorithm>
36
37 using std::endl;
38 using std::vector;
39 using std::max;
40 using std::min;
41 using std::for_each;
42 using std::pair;
43
44
45 Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe)
46         : owner_(static_cast<QtView*>(view)), menubackend_(mbe)
47 {
48         Menu::const_iterator m = mbe.getMenubar().begin();
49         Menu::const_iterator end = mbe.getMenubar().end();
50         for (; m != end; ++m) {
51                 pair<int, QLPopupMenu *> menu =
52                         createMenu(owner_->menuBar(), &(*m), this, true);
53                 name_map_[m->submenuname()] = menu.second;
54         }
55 }
56
57
58 void Menubar::Pimpl::openByName(string const & name)
59 {
60         NameMap::const_iterator const cit = name_map_.find(name);
61         if (cit == name_map_.end())
62                 return;
63
64         // this will have to do I'm afraid.
65         cit->second->exec(QCursor::pos());
66 }