From: André Pönitz Date: Thu, 27 Mar 2008 00:07:54 +0000 (+0000) Subject: remove InsetWrapMailer class X-Git-Tag: 1.6.10~5399 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=209b04eaa9b2e6820a40a81699f7e640eb67686b;p=features.git remove InsetWrapMailer class git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23991 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index de958700e1..95ff1536ae 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1248,7 +1248,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } case WRAP_CODE: { InsetWrapParams p; - data = InsetWrapMailer::params2string(p); + data = InsetWrap::params2string(p); break; } default: diff --git a/src/frontends/Application.h b/src/frontends/Application.h index ab08ace618..28a64a48d6 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -245,6 +245,7 @@ public: frontend::Application * theApp(); frontend::Application * createApplication(int & argc, char * argv[]); +void hideDialogs(std::string const & name, Inset * inset); } // namespace lyx diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index b1ee77e2cf..c3079de9bd 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -756,8 +756,11 @@ void GuiApplication::onLastWindowClosed() global_menubar_->grabKeyboard(); } + //////////////////////////////////////////////////////////////////////// +// // X11 specific stuff goes here... + #ifdef Q_WS_X11 bool GuiApplication::x11EventFilter(XEvent * xev) { @@ -794,6 +797,13 @@ bool GuiApplication::x11EventFilter(XEvent * xev) } // namespace frontend +void hideDialogs(std::string const & name, Inset * inset) +{ + if (theApp()) + theApp()->hideDialogs(name, inset); +} + + //////////////////////////////////////////////////////////////////// // // Font stuff @@ -820,6 +830,12 @@ frontend::FontMetrics const & theFontMetrics(FontInfo const & f) } +//////////////////////////////////////////////////////////////////// +// +// Misc stuff +// +//////////////////////////////////////////////////////////////////// + frontend::Clipboard & theClipboard() { BOOST_ASSERT(frontend::guiApp); diff --git a/src/frontends/qt4/GuiWrap.cpp b/src/frontends/qt4/GuiWrap.cpp index 743235f39e..6cc8b54f09 100644 --- a/src/frontends/qt4/GuiWrap.cpp +++ b/src/frontends/qt4/GuiWrap.cpp @@ -189,7 +189,7 @@ void GuiWrap::updateContents() bool GuiWrap::initialiseParams(string const & data) { - InsetWrapMailer::string2params(data, params_); + InsetWrap::string2params(data, params_); return true; } @@ -202,7 +202,7 @@ void GuiWrap::clearParams() void GuiWrap::dispatchParams() { - string const lfun = InsetWrapMailer::params2string(params_); + string const lfun = InsetWrap::params2string(params_); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index 0653c02399..e4f4d4188e 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -50,8 +50,7 @@ InsetERT::InsetERT(Buffer const & buf, CollapseStatus status) InsetERT::~InsetERT() { - if (theApp()) - theApp()->hideDialogs("ert", this); + hideDialogs("ert", this); } diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index 244467ac86..31e58670a4 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -34,6 +34,8 @@ #include "support/debug.h" #include "support/gettext.h" +#include "frontends/Application.h" + using namespace std; namespace lyx { @@ -53,7 +55,7 @@ InsetWrap::InsetWrap(Buffer const & buf, string const & type) InsetWrap::~InsetWrap() { - InsetWrapMailer(*this).hideDialog(); + hideDialogs("ert", this); } @@ -62,7 +64,7 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_INSET_MODIFY: { InsetWrapParams params; - InsetWrapMailer::string2params(to_utf8(cmd.argument()), params); + InsetWrap::string2params(to_utf8(cmd.argument()), params); params_.lines = params.lines; params_.placement = params.placement; params_.overhang = params.overhang; @@ -71,7 +73,7 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: - InsetWrapMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("wrap", params2string(params())); break; default: @@ -252,25 +254,13 @@ bool InsetWrap::insetAllowed(InsetCode code) const bool InsetWrap::showInsetDialog(BufferView * bv) const { if (!InsetText::showInsetDialog(bv)) - InsetWrapMailer(const_cast(*this)).showDialog(bv); + bv->showDialog("wrap", params2string(params()), + const_cast(this)); return true; } -string const InsetWrapMailer::name_("wrap"); - -InsetWrapMailer::InsetWrapMailer(InsetWrap & inset) - : inset_(inset) -{} - - -string const InsetWrapMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -void InsetWrapMailer::string2params(string const & in, InsetWrapParams & params) +void InsetWrap::string2params(string const & in, InsetWrapParams & params) { params = InsetWrapParams(); if (in.empty()) @@ -282,15 +272,21 @@ void InsetWrapMailer::string2params(string const & in, InsetWrapParams & params) string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetWrapMailer", in, 1, name_); + if (!lex || name != "wrap") { + LYXERR0("InsetWrap::string2params(" << in << ")\n" + "Expected arg 1 to be \"wrap\"\n"); + return; + } // This is part of the inset proper that is usually swallowed // by Text::readInset string id; lex >> id; - if (!lex || id != "Wrap") - return print_mailer_error("InsetBoxMailer", in, 2, "Wrap"); + if (!lex || id != "Wrap") { + LYXERR0("InsetWrap::string2params(" << in << ")\n" + "Expected arg 1 to be \"Wrap\"\n"); + return; + } // We have to read the type here! lex >> params.type; @@ -298,10 +294,10 @@ void InsetWrapMailer::string2params(string const & in, InsetWrapParams & params) } -string const InsetWrapMailer::params2string(InsetWrapParams const & params) +string InsetWrap::params2string(InsetWrapParams const & params) { ostringstream data; - data << name_ << ' '; + data << "wrap" << ' '; params.write(data); return data.str(); } diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index 4bdafb6555..6078e53ec6 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -14,7 +14,6 @@ #include "InsetCollapsable.h" #include "Length.h" -#include "MailInset.h" namespace lyx { @@ -50,6 +49,10 @@ public: ~InsetWrap(); /// InsetWrapParams const & params() const { return params_; } + /// + static void string2params(std::string const &, InsetWrapParams &); + /// + static std::string params2string(InsetWrapParams const &); private: /// void write(std::ostream & os) const; @@ -88,29 +91,6 @@ private: docstring name_; }; - -class InsetWrapMailer : public MailInset { -public: - /// - InsetWrapMailer(InsetWrap & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, InsetWrapParams &); - /// - static std::string const params2string(InsetWrapParams const &); -private: - /// - static std::string const name_; - /// - InsetWrap & inset_; -}; - - } // namespace lyx #endif