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"
27 theApp()->getRgbColor(Color::background, color_);
31 docstring const & Branch::getBranch() const
37 void Branch::setBranch(docstring const & s)
43 bool Branch::getSelected() const
49 bool Branch::setSelected(bool b)
58 RGBColor const & Branch::getColor() const
64 void Branch::setColor(RGBColor const & c)
70 void Branch::setColor(string const & c)
72 if (c.size() == 7 && c[0] == '#')
75 // no color set or invalid color - use normal background
76 theApp()->getRgbColor(Color::background, color_);
80 Branch * BranchList::find(docstring const & name)
83 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
84 return it == list.end() ? 0 : &*it;
88 Branch const * BranchList::find(docstring const & name) const
90 List::const_iterator it =
91 std::find_if(list.begin(), list.end(), BranchNamesEqual(name));
92 return it == list.end() ? 0 : &*it;
96 bool BranchList::add(docstring const & s)
99 docstring::size_type i = 0;
101 docstring::size_type const j = s.find_first_of(separator_, i);
103 if (j == docstring::npos)
106 name = s.substr(i, j - i);
107 // Is this name already in the list?
109 std::find_if(list.begin(), list.end(),
110 BranchNamesEqual(name)) != list.end();
115 br.setSelected(false);
118 if (j == docstring::npos)
126 bool BranchList::remove(docstring const & s)
128 size_t const size = list.size();
129 list.remove_if(BranchNamesEqual(s));
130 return size != list.size();