From 24ab0d6c05a85008891d9979fb3b6b796e9e44cf Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 10 Dec 2003 14:49:51 +0000 Subject: [PATCH] Clean-up of the Note, Branch mailer interface. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8223 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 8 ++++++ src/frontends/controllers/ControlBranch.C | 2 +- src/frontends/controllers/ControlNote.C | 6 ++--- src/insets/ChangeLog | 4 +++ src/insets/insetbranch.C | 33 +++++++++++++---------- src/insets/insetbranch.h | 6 ++--- src/insets/insetnote.C | 27 +++++++++---------- src/insets/insetnote.h | 8 +++--- 8 files changed, 53 insertions(+), 41 deletions(-) diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 74a80e448a..edda46b6fd 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,11 @@ +2003-12-10 Angus Leeming + + * ControlBranch.C (dispatchParams): change to invocation of + InsetBranchMailer::params2string. + + * ControlNote.C (dispatchParams): change to invocation of + InsetNoteMailer::params2string. + 2003-12-05 Angus Leeming * ControlVCLog.[Ch]: removed. diff --git a/src/frontends/controllers/ControlBranch.C b/src/frontends/controllers/ControlBranch.C index 68eae58c0f..10f9811a36 100644 --- a/src/frontends/controllers/ControlBranch.C +++ b/src/frontends/controllers/ControlBranch.C @@ -41,6 +41,6 @@ void ControlBranch::clearParams() void ControlBranch::dispatchParams() { - string const lfun = InsetBranchMailer::params2string(string("branch"), params()); + string const lfun = InsetBranchMailer::params2string(params()); kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun)); } diff --git a/src/frontends/controllers/ControlNote.C b/src/frontends/controllers/ControlNote.C index ac49fd1038..6f22c819bc 100644 --- a/src/frontends/controllers/ControlNote.C +++ b/src/frontends/controllers/ControlNote.C @@ -27,12 +27,10 @@ ControlNote::ControlNote(Dialog & parent) bool ControlNote::initialiseParams(string const & data) { - InsetNoteParams params; + InsetNoteParams params; InsetNoteMailer::string2params(data, params); params_.reset(new InsetNoteParams(params)); - return true; - } @@ -44,7 +42,7 @@ void ControlNote::clearParams() void ControlNote::dispatchParams() { - string const lfun = InsetNoteMailer::params2string(string("note"), params()); + string const lfun = InsetNoteMailer::params2string(params()); kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun)); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 5db03efc2c..dba5e2eb63 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-12-10 Angus Leeming + + * insetbranch.[Ch]: changes to the InsetBranchMailer interface. + * insetnote.[Ch]: changes to the InsetNoteMailer interface. 2003-12-10 André Pönitz diff --git a/src/insets/insetbranch.C b/src/insets/insetbranch.C index 81a925afec..e08702b2c2 100644 --- a/src/insets/insetbranch.C +++ b/src/insets/insetbranch.C @@ -59,7 +59,7 @@ InsetBranch::InsetBranch(InsetBranch const & in) InsetBranch::~InsetBranch() { - InsetBranchMailer("branch", *this).hideDialog(); + InsetBranchMailer(*this).hideDialog(); } @@ -111,7 +111,7 @@ void InsetBranch::setButtonLabel() bool InsetBranch::showInsetDialog(BufferView * bv) const { - InsetBranchMailer("branch", const_cast(*this)).showDialog(bv); + InsetBranchMailer(const_cast(*this)).showDialog(bv); return true; } @@ -136,12 +136,12 @@ InsetBranch::priv_dispatch(FuncRequest const & cmd, return DispatchResult(false); case LFUN_INSET_DIALOG_UPDATE: - InsetBranchMailer("branch", *this).updateDialog(bv); + InsetBranchMailer(*this).updateDialog(bv); return DispatchResult(true); case LFUN_MOUSE_RELEASE: if (cmd.button() == mouse_button::button3 && hitButton(cmd)) { - InsetBranchMailer("branch", *this).showDialog(bv); + InsetBranchMailer(*this).showDialog(bv); return DispatchResult(true); } return InsetCollapsable::priv_dispatch(cmd, idx, pos); @@ -200,11 +200,11 @@ void InsetBranch::validate(LaTeXFeatures & features) const -InsetBranchMailer::InsetBranchMailer(string const & name, - InsetBranch & inset) - : name_(name), inset_(inset) -{ -} +string const InsetBranchMailer:: name_("branch"); + +InsetBranchMailer::InsetBranchMailer(InsetBranch & inset) + : inset_(inset) +{} string const InsetBranchMailer::inset2string(Buffer const & buf) const @@ -212,15 +212,14 @@ string const InsetBranchMailer::inset2string(Buffer const & buf) const InsetBranchParams params = inset_.params(); params.branchlist = buf.params().branchlist(); inset_.setParams(params); - return params2string(name_, params); + return params2string(params); } -string const InsetBranchMailer::params2string(string const & name, - InsetBranchParams const & params) +string const InsetBranchMailer::params2string(InsetBranchParams const & params) { ostringstream data; - data << name << ' '; + data << name_ << ' '; params.write(data); // Add all_branches parameter to data: data << params.branchlist.allBranches() << "\n"; @@ -229,7 +228,7 @@ string const InsetBranchMailer::params2string(string const & name, void InsetBranchMailer::string2params(string const & in, - InsetBranchParams & params) + InsetBranchParams & params) { params = InsetBranchParams(); @@ -239,6 +238,12 @@ void InsetBranchMailer::string2params(string const & in, istringstream data(in); LyXLex lex(0,0); lex.setStream(data); + + string name; + lex >> name; + if (name != name_) + return; + params.read(lex); // Process all_branches here: if (lex.isOK()) { diff --git a/src/insets/insetbranch.h b/src/insets/insetbranch.h index a1d710b3c8..6da8766643 100644 --- a/src/insets/insetbranch.h +++ b/src/insets/insetbranch.h @@ -90,7 +90,7 @@ private: class InsetBranchMailer : public MailInset { public: /// - InsetBranchMailer(std::string const & name, InsetBranch & inset); + InsetBranchMailer(InsetBranch & inset); /// virtual InsetBase & inset() const { return inset_; } /// @@ -98,13 +98,13 @@ public: /// virtual std::string const inset2string(Buffer const &) const; /// - static std::string const params2string(std::string const &, InsetBranchParams const &); + static std::string const params2string(InsetBranchParams const &); /// static void string2params(std::string const &, InsetBranchParams &); private: /// - std::string const name_; + static std::string const name_; /// InsetBranch & inset_; }; diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index 4e64471950..14f2ec49c6 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -58,7 +58,7 @@ InsetNote::InsetNote(InsetNote const & in) InsetNote::~InsetNote() { - InsetNoteMailer("note", *this).hideDialog(); + InsetNoteMailer(*this).hideDialog(); } @@ -113,7 +113,7 @@ void InsetNote::setButtonLabel() bool InsetNote::showInsetDialog(BufferView * bv) const { - InsetNoteMailer("note", const_cast(*this)).showDialog(bv); + InsetNoteMailer(const_cast(*this)).showDialog(bv); return true; } @@ -134,12 +134,12 @@ InsetNote::priv_dispatch(FuncRequest const & cmd, } case LFUN_INSET_DIALOG_UPDATE: - InsetNoteMailer("note", *this).updateDialog(bv); + InsetNoteMailer(*this).updateDialog(bv); return DispatchResult(true, true); case LFUN_MOUSE_RELEASE: if (cmd.button() == mouse_button::button3 && hitButton(cmd)) { - InsetNoteMailer("note", *this).showDialog(bv); + InsetNoteMailer(*this).showDialog(bv); return DispatchResult(true, true); } // fallthrough: @@ -244,31 +244,30 @@ void InsetNote::validate(LaTeXFeatures & features) const -InsetNoteMailer::InsetNoteMailer(string const & name, - InsetNote & inset) - : name_(name), inset_(inset) -{ -} +string const InsetNoteMailer:: name_("note"); + +InsetNoteMailer::InsetNoteMailer(InsetNote & inset) + : inset_(inset) +{} string const InsetNoteMailer::inset2string(Buffer const &) const { - return params2string(name_, inset_.params()); + return params2string(inset_.params()); } -string const InsetNoteMailer::params2string(string const & name, - InsetNoteParams const & params) +string const InsetNoteMailer::params2string(InsetNoteParams const & params) { ostringstream data; - data << name << ' '; + data << name_ << ' '; params.write(data); return data.str(); } void InsetNoteMailer::string2params(string const & in, - InsetNoteParams & params) + InsetNoteParams & params) { params = InsetNoteParams(); diff --git a/src/insets/insetnote.h b/src/insets/insetnote.h index 3a88423824..f2bd70d7ae 100644 --- a/src/insets/insetnote.h +++ b/src/insets/insetnote.h @@ -86,7 +86,7 @@ private: class InsetNoteMailer : public MailInset { public: /// - InsetNoteMailer(std::string const & name, InsetNote & inset); + InsetNoteMailer(InsetNote & inset); /// virtual InsetBase & inset() const { return inset_; } /// @@ -94,17 +94,15 @@ public: /// virtual std::string const inset2string(Buffer const &) const; /// - static std::string const params2string(std::string const &, InsetNoteParams const &); + static std::string const params2string(InsetNoteParams const &); /// static void string2params(std::string const &, InsetNoteParams &); private: /// - std::string const name_; + static std::string const name_; /// InsetNote & inset_; }; - - #endif -- 2.39.2