3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Martin Vermeer
8 * Full author contact details are available in file CREDITS.
13 #include "BranchList.h"
16 #include "frontends/Application.h"
25 Branch::Branch() : selected_(false)
27 // no theApp() with command line export
29 theApp()->getRgbColor(Color_background
, color_
);
33 docstring
const & Branch::getBranch() const
39 void Branch::setBranch(docstring
const & s
)
45 bool Branch::getSelected() const
51 bool Branch::setSelected(bool b
)
60 RGBColor
const & Branch::getColor() const
66 void Branch::setColor(RGBColor
const & c
)
72 void Branch::setColor(string
const & str
)
74 if (str
.size() == 7 && str
[0] == '#')
75 color_
= rgbFromHexName(str
);
77 // no color set or invalid color - use normal background
78 theApp()->getRgbColor(Color_background
, color_
);
82 Branch
* BranchList::find(docstring
const & name
)
85 find_if(list
.begin(), list
.end(), BranchNamesEqual(name
));
86 return it
== list
.end() ? 0 : &*it
;
90 Branch
const * BranchList::find(docstring
const & name
) const
92 List::const_iterator it
=
93 find_if(list
.begin(), list
.end(), BranchNamesEqual(name
));
94 return it
== list
.end() ? 0 : &*it
;
98 bool BranchList::add(docstring
const & s
)
101 docstring::size_type i
= 0;
103 docstring::size_type
const j
= s
.find_first_of(separator_
, i
);
105 if (j
== docstring::npos
)
108 name
= s
.substr(i
, j
- i
);
109 // Is this name already in the list?
111 find_if(list
.begin(), list
.end(),
112 BranchNamesEqual(name
)) != list
.end();
117 br
.setSelected(false);
120 if (j
== docstring::npos
)
128 bool BranchList::remove(docstring
const & s
)
130 size_t const size
= list
.size();
131 list
.remove_if(BranchNamesEqual(s
));
132 return size
!= list
.size();