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"
28 theApp->getRgbColor(LColor::background, color_);
32 string const & Branch::getBranch() const
38 void Branch::setBranch(string const & s)
44 bool Branch::getSelected() const
50 bool Branch::setSelected(bool b)
59 RGBColor const & Branch::getColor() const
65 void Branch::setColor(RGBColor const & c)
71 void Branch::setColor(string const & c)
73 if (c.size() == 7 && c[0] == '#')
76 // no color set or invalid color - use normal background
77 theApp->getRgbColor(LColor::background, color_);
81 Branch * BranchList::find(std::string const & name)
84 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
85 return it == list.end() ? 0 : &*it;
89 Branch const * BranchList::find(std::string const & name) const
91 List::const_iterator it =
92 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
93 return it == list.end() ? 0 : &*it;
97 bool BranchList::add(string const & s)
100 string::size_type i = 0;
102 string::size_type const j = s.find_first_of(separator_, i);
104 if (j == string::npos)
107 name = s.substr(i, j - i);
108 // Is this name already in the list?
110 std::find_if(list.begin(), list.end(),
111 BranchNamesEqual(name)) != list.end();
116 br.setSelected(false);
119 if (j == string::npos)
127 bool BranchList::remove(string const & s)
129 size_t const size = list.size();
130 list.remove_if(BranchNamesEqual(s));
131 return size != list.size();