fix my color cache "improvements"

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25029 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-05-31 22:39:52 +00:00
parent a694de895e
commit 7f678a39cd
3 changed files with 14 additions and 13 deletions

View File

@ -16,6 +16,7 @@
#include <string>
namespace lyx {
void ColorCache::init()
@ -27,11 +28,14 @@ void ColorCache::init()
/// get the given color
QColor const & ColorCache::get(ColorCode color) const
QColor ColorCache::get(ColorCode color) const
{
if (!initialized_)
const_cast<ColorCache *>(this)->init();
if (color <= Color_ignore)
return lcolors_[color];
// used by branches
return QColor(lcolor.getX11Name(color).c_str());
}

View File

@ -29,7 +29,7 @@ public:
ColorCache() : initialized_(false) {}
/// get the given color
QColor const & get(ColorCode color) const;
QColor get(ColorCode color) const;
/// clear all colors
void clear() { initialized_ = false; }

View File

@ -82,10 +82,9 @@ void InsetBranch::setButtonLabel()
if (!params_.branch.empty()) {
// FIXME UNICODE
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
if (c == Color_none) {
if (c == Color_none)
s = _("Undef: ") + s;
}
}
if (decoration() == InsetLayout::Classic)
setLabel(isOpen() ? s : getNewLabel(s) );
else
@ -95,15 +94,13 @@ void InsetBranch::setButtonLabel()
ColorCode InsetBranch::backgroundColor() const
{
if (!params_.branch.empty()) {
if (params_.branch.empty())
return Inset::backgroundColor();
// FIXME UNICODE
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
if (c == Color_none) {
if (c == Color_none)
c = Color_error;
}
return c;
} else
return Inset::backgroundColor();
}