From 72e3177e3d74f26198dd3e4342381997854e78d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 15 Nov 2007 22:30:16 +0000 Subject: [PATCH] shuffle some code around git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21636 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyX.cpp | 22 ++-------------------- src/LyXFunc.cpp | 4 +++- src/frontends/Application.h | 1 + src/frontends/Gui.h | 12 ++++++++++++ src/frontends/qt4/GuiApplication.h | 1 + src/frontends/qt4/GuiImplementation.cpp | 25 +++++++++++++++++++++++++ src/frontends/qt4/GuiImplementation.h | 5 ++++- 7 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/LyX.cpp b/src/LyX.cpp index 1089fe9532..efb1237950 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -48,7 +48,6 @@ #include "frontends/alert.h" #include "frontends/Application.h" -#include "frontends/Dialogs.h" #include "frontends/Gui.h" #include "frontends/LyXView.h" @@ -380,18 +379,7 @@ Buffer const * LyX::updateInset(Inset const * inset) const { if (quitting || !inset) return 0; - - Buffer const * buffer_ptr = 0; - vector const & view_ids = pimpl_->application_->gui().viewIds(); - vector::const_iterator it = view_ids.begin(); - vector::const_iterator const end = view_ids.end(); - for (; it != end; ++it) { - Buffer const * ptr = - pimpl_->application_->gui().view(*it).updateInset(inset); - if (ptr) - buffer_ptr = ptr; - } - return buffer_ptr; + return application().gui().updateInset(inset); } @@ -399,13 +387,7 @@ void LyX::hideDialogs(std::string const & name, Inset * inset) const { if (quitting || !use_gui) return; - - vector const & view_ids = pimpl_->application_->gui().viewIds(); - vector::const_iterator it = view_ids.begin(); - vector::const_iterator const end = view_ids.end(); - for (; it != end; ++it) - pimpl_->application_->gui().view(*it).getDialogs(). - hide(name, inset); + application().gui().hideDialogs(name, inset); } diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 6b65f01241..557e7148e6 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -137,6 +137,7 @@ using support::prefixIs; namespace Alert = frontend::Alert; extern bool quitting; +extern bool use_gui; namespace { @@ -1560,9 +1561,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } - case LFUN_DIALOG_HIDE: + case LFUN_DIALOG_HIDE: { LyX::cref().hideDialogs(argument, 0); break; + } case LFUN_DIALOG_TOGGLE: { BOOST_ASSERT(lyx_view_); diff --git a/src/frontends/Application.h b/src/frontends/Application.h index 8ca6ace8a3..8fbdc47989 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -150,6 +150,7 @@ public: /// virtual Gui & gui() = 0; + virtual Gui const & gui() const = 0; /// Start the main event loop. /// The batch command is programmed to be execute once diff --git a/src/frontends/Gui.h b/src/frontends/Gui.h index 6dd9c8316a..f0372f6d14 100644 --- a/src/frontends/Gui.h +++ b/src/frontends/Gui.h @@ -14,9 +14,16 @@ #ifndef BASE_GUI_H #define BASE_GUI_H +#include "support/strfwd.h" + #include + namespace lyx { + +class Buffer; +class Inset; + namespace frontend { class LyXView; @@ -42,6 +49,11 @@ public: /// std::vector const & viewIds() { return view_ids_; } + /// + virtual void hideDialogs(std::string const & name, Inset * inset) const = 0; + /// + virtual Buffer const * updateInset(Inset const * inset) const = 0; + protected: /// std::vector view_ids_; diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 2d5a547f6c..22b55beaf7 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -59,6 +59,7 @@ public: virtual FontLoader & fontLoader() { return font_loader_; } virtual int exec(); virtual Gui & gui() { return gui_; } + virtual Gui const & gui() const { return gui_; } virtual void exit(int status); virtual bool event(QEvent * e); void syncEvents(); diff --git a/src/frontends/qt4/GuiImplementation.cpp b/src/frontends/qt4/GuiImplementation.cpp index 52f4da4fe6..d370ffb9e0 100644 --- a/src/frontends/qt4/GuiImplementation.cpp +++ b/src/frontends/qt4/GuiImplementation.cpp @@ -14,6 +14,7 @@ #include "GuiImplementation.h" #include "GuiView.h" +#include "Dialogs.h" #include @@ -21,6 +22,7 @@ using std::map; using std::vector; +using std::string; namespace lyx { @@ -104,6 +106,29 @@ LyXView & GuiImplementation::view(int id) const } +void GuiImplementation::hideDialogs(string const & name, Inset * inset) const +{ + vector::const_iterator it = view_ids_.begin(); + vector::const_iterator const end = view_ids_.end(); + for (; it != end; ++it) + view(*it).getDialogs().hide(name, inset); +} + + +Buffer const * GuiImplementation::updateInset(Inset const * inset) const +{ + Buffer const * buffer_ptr = 0; + vector::const_iterator it = view_ids_.begin(); + vector::const_iterator const end = view_ids_.end(); + for (; it != end; ++it) { + Buffer const * ptr = view(*it).updateInset(inset); + if (ptr) + buffer_ptr = ptr; + } + return buffer_ptr; +} + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiImplementation.h b/src/frontends/qt4/GuiImplementation.h index 38a51e5aa6..4474949172 100644 --- a/src/frontends/qt4/GuiImplementation.h +++ b/src/frontends/qt4/GuiImplementation.h @@ -41,9 +41,12 @@ public: virtual bool unregisterView(int id); virtual LyXView& view(int id) const; + /// + virtual void hideDialogs(std::string const & name, Inset * inset) const; + /// + virtual Buffer const * updateInset(Inset const * inset) const; private: - /// Multiple views container. /** * Warning: This must not be a smart pointer as the destruction of the -- 2.39.2