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 <QApplication>
25 void updateIds(std::map<int, T*> const & stdmap, std::vector<int> & ids)
28 typename std::map<int, T*>::const_iterator it;
29 for (it = stdmap.begin(); it != stdmap.end(); ++it)
30 ids.push_back(it->first);
39 GuiImplementation::GuiImplementation()
45 LyXView& GuiImplementation::createRegisteredView()
47 updateIds(views_, view_ids_);
49 while (views_.find(id) != views_.end())
51 views_.insert(std::pair<int, GuiView *>(id, new GuiView(id)));
52 updateIds(views_, view_ids_);
57 bool GuiImplementation::unregisterView(int id)
59 updateIds(views_, view_ids_);
60 BOOST_ASSERT(views_.find(id) != views_.end());
61 BOOST_ASSERT(views_[id]);
63 std::map<int, GuiView *>::iterator it;
64 for (it = views_.begin(); it != views_.end(); ++it) {
65 if (it->first == id) {
70 updateIds(views_, view_ids_);
75 bool GuiImplementation::closeAllViews()
77 updateIds(views_, view_ids_);
80 // quit in CloseEvent will not be triggert
85 std::map<int, GuiView*> const cmap = views_;
86 std::map<int, GuiView*>::const_iterator it;
87 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 } // namespace frontend
112 #include "GuiImplementation_moc.cpp"