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 theApp->getRgbColor(LColor::background, color_);
29 string const & Branch::getBranch() const
35 void Branch::setBranch(string const & s)
41 bool Branch::getSelected() const
47 bool Branch::setSelected(bool b)
56 lyx::RGBColor const & Branch::getColor() const
62 void Branch::setColor(lyx::RGBColor const & c)
68 void Branch::setColor(string const & c)
70 if (c.size() == 7 && c[0] == '#')
71 color_ = lyx::RGBColor(c);
73 // no color set or invalid color - use normal background
74 theApp->getRgbColor(LColor::background, color_);
78 Branch * BranchList::find(std::string const & name)
81 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
82 return it == list.end() ? 0 : &*it;
86 Branch const * BranchList::find(std::string const & name) const
88 List::const_iterator it =
89 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
90 return it == list.end() ? 0 : &*it;
94 bool BranchList::add(string const & s)
97 string::size_type i = 0;
99 string::size_type const j = s.find_first_of(separator_, i);
101 if (j == string::npos)
104 name = s.substr(i, j - i);
105 // Is this name already in the list?
107 std::find_if(list.begin(), list.end(),
108 BranchNamesEqual(name)) != list.end();
113 br.setSelected(false);
116 if (j == string::npos)
124 bool BranchList::remove(string const & s)
126 List::size_type const size = list.size();
127 list.remove_if(BranchNamesEqual(s));
128 return size != list.size();