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
This commit is contained in:
Angus Leeming 2003-12-10 14:49:51 +00:00
parent ea03d868c4
commit 24ab0d6c05
8 changed files with 53 additions and 41 deletions

View File

@ -1,3 +1,11 @@
2003-12-10 Angus Leeming <leeming@lyx.org>
* ControlBranch.C (dispatchParams): change to invocation of
InsetBranchMailer::params2string.
* ControlNote.C (dispatchParams): change to invocation of
InsetNoteMailer::params2string.
2003-12-05 Angus Leeming <leeming@lyx.org>
* ControlVCLog.[Ch]: removed.

View File

@ -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));
}

View File

@ -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));
}

View File

@ -1,3 +1,7 @@
2003-12-10 Angus Leeming <leeming@lyx.org>
* insetbranch.[Ch]: changes to the InsetBranchMailer interface.
* insetnote.[Ch]: changes to the InsetNoteMailer interface.
2003-12-10 André Pönitz <poenitz@gmx.net>

View File

@ -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<InsetBranch &>(*this)).showDialog(bv);
InsetBranchMailer(const_cast<InsetBranch &>(*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()) {

View File

@ -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_;
};

View File

@ -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<InsetNote &>(*this)).showDialog(bv);
InsetNoteMailer(const_cast<InsetNote &>(*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();

View File

@ -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