mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
Some more functor work.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8303 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9387970e7d
commit
4b1212acf2
@ -14,22 +14,6 @@
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace {
|
||||
|
||||
class BranchNamesEqual : public std::unary_function<Branch, bool> {
|
||||
public:
|
||||
BranchNamesEqual(string const & name)
|
||||
: name_(name) {}
|
||||
bool operator()(Branch const & branch) const
|
||||
{
|
||||
return branch.getBranch() == name_;
|
||||
}
|
||||
private:
|
||||
string name_;
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
string const & Branch::getBranch() const
|
||||
{
|
||||
|
@ -98,4 +98,17 @@ private:
|
||||
std::string separator_;
|
||||
};
|
||||
|
||||
|
||||
class BranchNamesEqual : public std::unary_function<Branch, bool> {
|
||||
public:
|
||||
BranchNamesEqual(std::string const & name)
|
||||
: name_(name) {}
|
||||
bool operator()(Branch const & branch) const
|
||||
{
|
||||
return branch.getBranch() == name_;
|
||||
}
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,8 @@
|
||||
2004-01-05 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* BranchList.h: move the BranchNamesEqual functor here from...
|
||||
* BranchList.C: ... to here
|
||||
|
||||
* BranchList.C: new BranchListEqual fuctor, use it. Remove
|
||||
SameName and match.
|
||||
(add): replace a finding loop with std::find_if.
|
||||
|
@ -1,3 +1,11 @@
|
||||
2004-01-05 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* insetbranch.C (isBranchSelected): use the BranchNamesEqual
|
||||
functor
|
||||
get rid of the SameName functor
|
||||
|
||||
* insettabular.C: improve the functor.
|
||||
|
||||
2003-12-29 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetexternal.C (setParams): update defaultTemplateName.
|
||||
|
@ -117,4 +117,4 @@ libinsets_la_SOURCES = \
|
||||
# insetsection.h \
|
||||
# insetsection.C \
|
||||
# insettheorem.C \
|
||||
# insettheorem.h \
|
||||
# insettheorem.h
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
|
||||
using std::string;
|
||||
using std::auto_ptr;
|
||||
using std::istringstream;
|
||||
@ -140,31 +139,19 @@ InsetBranch::priv_dispatch(FuncRequest const & cmd,
|
||||
return DispatchResult(true);
|
||||
}
|
||||
return InsetCollapsable::priv_dispatch(cmd, idx, pos);
|
||||
|
||||
|
||||
default:
|
||||
return InsetCollapsable::priv_dispatch(cmd, idx, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
struct SameBranch {
|
||||
SameBranch(string const & branch_name) : bn(branch_name) {}
|
||||
bool operator()(Branch const & branch) const
|
||||
{ return bn == branch.getBranch(); }
|
||||
private:
|
||||
string bn;
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
bool InsetBranch::isBranchSelected(BranchList const & branchlist) const
|
||||
{
|
||||
BranchList::const_iterator it = branchlist.begin();
|
||||
BranchList::const_iterator const end = branchlist.end();
|
||||
it = std::find_if(it, end, SameBranch(params_.branch));
|
||||
BranchList::const_iterator it =
|
||||
std::find_if(branchlist.begin(), end,
|
||||
BranchNamesEqual(params_.branch));
|
||||
if (it == end)
|
||||
return false;
|
||||
return it->getSelected();
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using lyx::graphics::PreviewLoader;
|
||||
@ -120,18 +121,15 @@ TabularFeature tabularFeature[] =
|
||||
{ LyXTabular::LAST_ACTION, "" }
|
||||
};
|
||||
|
||||
struct FindFeature {
|
||||
///
|
||||
FindFeature(LyXTabular::Feature feature)
|
||||
: feature_(feature)
|
||||
{}
|
||||
///
|
||||
bool operator()(TabularFeature & tf)
|
||||
{
|
||||
|
||||
class FeatureEqual : public std::unary_function<TabularFeature, bool> {
|
||||
public:
|
||||
FeatureEqual(LyXTabular::Feature feature)
|
||||
: feature_(feature) {}
|
||||
bool operator()(TabularFeature const & tf) const {
|
||||
return tf.action == feature_;
|
||||
}
|
||||
private:
|
||||
///
|
||||
LyXTabular::Feature feature_;
|
||||
};
|
||||
|
||||
@ -140,10 +138,10 @@ private:
|
||||
|
||||
string const featureAsString(LyXTabular::Feature feature)
|
||||
{
|
||||
TabularFeature * it = tabularFeature;
|
||||
TabularFeature * end = it +
|
||||
TabularFeature * end = tabularFeature +
|
||||
sizeof(tabularFeature) / sizeof(TabularFeature);
|
||||
it = std::find_if(it, end, FindFeature(feature));
|
||||
TabularFeature * it = std::find_if(tabularFeature, end,
|
||||
FeatureEqual(feature));
|
||||
return (it == end) ? string() : it->feature;
|
||||
}
|
||||
|
||||
@ -282,7 +280,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
continue;
|
||||
if (first_visible_cell < 0)
|
||||
first_visible_cell = cell;
|
||||
if (hasSelection())
|
||||
if (hasSelection())
|
||||
drawCellSelection(pi.pain, nx, y, i, j, cell);
|
||||
|
||||
int const cx = nx + tabular.getBeginningOfTextInCell(cell);
|
||||
@ -507,16 +505,16 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(cmd);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int cell = bv->cursor().data_.back().idx_;
|
||||
if (cell != -1) {
|
||||
|
||||
|
||||
if (cell != actcell) {
|
||||
lyxerr << "## ERROR ## InsetTabular::priv_dispatch: actcell: "
|
||||
lyxerr << "## ERROR ## InsetTabular::priv_dispatch: actcell: "
|
||||
<< actcell << " and cell " << cell << " should be the same "
|
||||
<< "here" << endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user