3 * \file GuiImplementation.cpp
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
15 #include "GuiImplementation.h"
19 #include <boost/assert.hpp>
21 #include <QApplication>
32 static void updateIds(map<int, GuiView *> const & stdmap, vector<int> & ids)
35 map<int, GuiView *>::const_iterator it;
36 for (it = stdmap.begin(); it != stdmap.end(); ++it)
37 ids.push_back(it->first);
41 GuiImplementation::GuiImplementation()
47 int GuiImplementation::createRegisteredView()
49 updateIds(views_, view_ids_);
51 while (views_.find(id) != views_.end())
53 views_[id] = new GuiView(id);
54 updateIds(views_, view_ids_);
59 bool GuiImplementation::unregisterView(int id)
61 updateIds(views_, view_ids_);
62 BOOST_ASSERT(views_.find(id) != views_.end());
63 BOOST_ASSERT(views_[id]);
65 map<int, GuiView *>::iterator it;
66 for (it = views_.begin(); it != views_.end(); ++it) {
67 if (it->first == id) {
72 updateIds(views_, view_ids_);
77 bool GuiImplementation::closeAllViews()
79 updateIds(views_, view_ids_);
81 // quit in CloseEvent will not be triggert
86 map<int, GuiView*> const cmap = views_;
87 map<int, GuiView*>::const_iterator it;
88 for (it = cmap.begin(); it != cmap.end(); ++it) {
89 // TODO: return false when close event was ignored
90 // e.g. quitWriteAll()->'Cancel'
91 // maybe we need something like 'bool closeView()'
93 // unregisterd by the CloseEvent
102 LyXView & GuiImplementation::view(int id) const
104 BOOST_ASSERT(views_.find(id) != views_.end());
105 return *views_.find(id)->second;
109 void GuiImplementation::hideDialogs(string const & name, Inset * inset) const
111 vector<int>::const_iterator it = view_ids_.begin();
112 vector<int>::const_iterator const end = view_ids_.end();
113 for (; it != end; ++it)
114 view(*it).getDialogs().hide(name, inset);
118 Buffer const * GuiImplementation::updateInset(Inset const * inset) const
120 Buffer const * buffer_ptr = 0;
121 vector<int>::const_iterator it = view_ids_.begin();
122 vector<int>::const_iterator const end = view_ids_.end();
123 for (; it != end; ++it) {
124 Buffer const * ptr = view(*it).updateInset(inset);
132 } // namespace frontend
135 #include "GuiImplementation_moc.cpp"