X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBranchList.C;h=9cec82928edfc11763b0efd08fb944f850946958;hb=27a777ccc624b19c5d1961a6279c0db97594c0fb;hp=1900d956c3fd4becd2daaf7ccebba049bc81e4ce;hpb=4b1212acf2da860c58f1d579f74fae86e7e45a47;p=lyx.git diff --git a/src/BranchList.C b/src/BranchList.C index 1900d956c3..9cec82928e 100644 --- a/src/BranchList.C +++ b/src/BranchList.C @@ -11,17 +11,31 @@ #include #include "BranchList.h" +#include "LColor.h" + +#include "frontends/Application.h" + +#include + + +namespace lyx { using std::string; -string const & Branch::getBranch() const +Branch::Branch() +{ + theApp()->getRgbColor(LColor::background, color_); +} + + +docstring const & Branch::getBranch() const { return branch_; } -void Branch::setBranch(string const & s) +void Branch::setBranch(docstring const & s) { branch_ = s; } @@ -42,19 +56,29 @@ bool Branch::setSelected(bool b) } -string const & Branch::getColor() const +RGBColor const & Branch::getColor() const { return color_; } -void Branch::setColor(string const & c) +void Branch::setColor(RGBColor const & c) { color_ = c; } -Branch * BranchList::find(std::string const & name) +void Branch::setColor(string const & c) +{ + if (c.size() == 7 && c[0] == '#') + color_ = RGBColor(c); + else + // no color set or invalid color - use normal background + theApp()->getRgbColor(LColor::background, color_); +} + + +Branch * BranchList::find(docstring const & name) { List::iterator it = std::find_if(list.begin(), list.end(), BranchNamesEqual(name)); @@ -62,7 +86,7 @@ Branch * BranchList::find(std::string const & name) } -Branch const * BranchList::find(std::string const & name) const +Branch const * BranchList::find(docstring const & name) const { List::const_iterator it = std::find_if(list.begin(), list.end(), BranchNamesEqual(name)); @@ -70,14 +94,14 @@ Branch const * BranchList::find(std::string const & name) const } -bool BranchList::add(string const & s) +bool BranchList::add(docstring const & s) { bool added = false; - string::size_type i = 0; + docstring::size_type i = 0; while (true) { - string::size_type const j = s.find_first_of(separator_, i); - string name; - if (j == string::npos) + docstring::size_type const j = s.find_first_of(separator_, i); + docstring name; + if (j == docstring::npos) name = s.substr(i); else name = s.substr(i, j - i); @@ -90,10 +114,9 @@ bool BranchList::add(string const & s) Branch br; br.setBranch(name); br.setSelected(false); - br.setColor("none"); list.push_back(br); } - if (j == string::npos) + if (j == docstring::npos) break; i = j + 1; } @@ -101,9 +124,12 @@ bool BranchList::add(string const & s) } -bool BranchList::remove(string const & s) +bool BranchList::remove(docstring const & s) { - List::size_type const size = list.size(); + size_t const size = list.size(); list.remove_if(BranchNamesEqual(s)); return size != list.size(); } + + +} // namespace lyx