]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Menubar_pimpl.C
Get rid of the static_casts.
[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
14 #include "Menubar_pimpl.h"
15 #include "MenuBackend.h"
16 #include "LyXAction.h"
17 #include "kbmap.h"
18 #include "buffer.h"
19 #include "lyxfunc.h"
20 #include "FloatList.h"
21 #include "support/lstrings.h"
22 #include "support/LAssert.h"
23 #include "qt_helpers.h"
24 #include "debug.h"
25
26 #include "QtView.h"
27 #include "QLPopupMenu.h"
28
29 #include <qmenubar.h>
30 #include <qcursor.h>
31
32 #include <algorithm>
33
34 using std::endl;
35 using std::vector;
36 using std::max;
37 using std::min;
38 using std::for_each;
39 using std::pair;
40
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         }
52 }
53
54
55 Menubar::Pimpl::~Pimpl()
56 {}
57
58
59 void Menubar::Pimpl::openByName(string const & name)
60 {
61         NameMap::const_iterator const cit = name_map_.find(name);
62         if (cit == name_map_.end())
63                 return;
64
65         // this will have to do I'm afraid.
66         cit->second->exec(QCursor::pos());
67 }
68
69
70 void Menubar::Pimpl::update()
71 {}
72
73
74 QtView * Menubar::Pimpl::view()
75 {
76         return owner_;
77 }
78
79
80 MenuBackend const & Menubar::Pimpl::backend()
81 {
82         return menubackend_;
83 }