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"
15 #include "frontends/lyx_gui.h"
23 lyx_gui::getRGBColor(LColor::background, color_);
27 string const & Branch::getBranch() const
33 void Branch::setBranch(string const & s)
39 bool Branch::getSelected() const
45 bool Branch::setSelected(bool b)
54 lyx::RGBColor const & Branch::getColor() const
60 void Branch::setColor(lyx::RGBColor const & c)
66 void Branch::setColor(string const & c)
68 if (c.size() == 7 && c[0] == '#')
69 color_ = lyx::RGBColor(c);
71 // no color set or invalid color - use normal background
72 lyx_gui::getRGBColor(LColor::background, color_);
76 Branch * BranchList::find(std::string const & name)
79 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
80 return it == list.end() ? 0 : &*it;
84 Branch const * BranchList::find(std::string const & name) const
86 List::const_iterator it =
87 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
88 return it == list.end() ? 0 : &*it;
92 bool BranchList::add(string const & s)
95 string::size_type i = 0;
97 string::size_type const j = s.find_first_of(separator_, i);
99 if (j == string::npos)
102 name = s.substr(i, j - i);
103 // Is this name already in the list?
105 std::find_if(list.begin(), list.end(),
106 BranchNamesEqual(name)) != list.end();
111 br.setSelected(false);
114 if (j == string::npos)
122 bool BranchList::remove(string const & s)
124 List::size_type const size = list.size();
125 list.remove_if(BranchNamesEqual(s));
126 return size != list.size();