From 2e968d06610325ad5b69cee0e93f99b8435d5542 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 29 May 2008 17:57:57 +0000 Subject: [PATCH] next try git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25000 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Color.cpp | 11 ++--- src/LyXRC.cpp | 64 +++++++++++----------------- src/frontends/qt4/ColorCache.cpp | 10 +++++ src/frontends/qt4/ColorCache.h | 8 ++-- src/frontends/qt4/GuiApplication.cpp | 4 +- src/frontends/qt4/GuiViewSource.h | 2 - src/support/docstring.cpp | 9 ++-- 7 files changed, 50 insertions(+), 58 deletions(-) diff --git a/src/Color.cpp b/src/Color.cpp index 47e251d14b..f4e84aeee1 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -21,7 +21,6 @@ #include "support/debug.h" #include "support/gettext.h" #include "support/lstrings.h" - #include "support/lassert.h" #include @@ -237,16 +236,14 @@ bool ColorSet::setColor(ColorCode col, string const & x11name) { InfoTab::iterator it = infotab.find(col); if (it == infotab.end()) { - lyxerr << "Color " << col << " not found in database." - << endl; + LYXERR0("Color " << col << " not found in database."); return false; } // "inherit" is returned for colors not in the database // (and anyway should not be redefined) if (col == Color_none || col == Color_inherit || col == Color_ignore) { - lyxerr << "Color " << getLyXName(col) - << " may not be redefined" << endl; + LYXERR0("Color " << getLyXName(col) << " may not be redefined."); return false; } @@ -280,8 +277,8 @@ ColorCode ColorSet::getFromLyXName(string const & lyxname) const string const lcname = ascii_lowercase(lyxname); Transform::const_iterator it = lyxcolors.find(lcname); if (it == lyxcolors.end()) { - lyxerr << "ColorSet::getFromLyXName: Unknown color \"" - << lyxname << '"' << endl; + LYXERR0("ColorSet::getFromLyXName: Unknown color \"" + << lyxname << '"'); return Color_none; } diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 42caf22a3f..fa916ba242 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -663,7 +663,7 @@ int LyXRC::read(Lexer & lexrc) case RC_USETEMPDIR: if (lexrc.next()) - lyxerr << "Ignoring obsolete use_tempdir flag." << endl; + LYXERR0("Ignoring obsolete use_tempdir flag."); break; case RC_USELASTFILEPOS: @@ -757,23 +757,18 @@ int LyXRC::read(Lexer & lexrc) lexrc >> typewriter_font_foundry; break; - case RC_SET_COLOR: - { - string lyx_name, x11_name; - - if (lexrc.next()) { - lyx_name = lexrc.getString(); - } else { + case RC_SET_COLOR: { + if (!lexrc.next()) { lexrc.printError("Missing color tag."); break; } + string lyx_name = lexrc.getString(); - if (lexrc.next()) { - x11_name = lexrc.getString(); - } else { + if (!lexrc.next()) { lexrc.printError("Missing color name for color: `$$Token'"); break; } + string x11_name = lexrc.getString(); ColorCode const col = lcolor.getFromLyXName(lyx_name); @@ -782,13 +777,11 @@ int LyXRC::read(Lexer & lexrc) col == Color_ignore) break; - if (!lcolor.setColor(col, x11_name)) { - lyxerr << "Bad lyxrc set_color for " - << lyx_name << endl; - - } + if (!lcolor.setColor(col, x11_name)) + LYXERR0("Bad lyxrc set_color for " << lyx_name); break; } + case RC_AUTOREGIONDELETE: // Auto region delete defaults to true lexrc >> auto_region_delete; @@ -832,9 +825,8 @@ int LyXRC::read(Lexer & lexrc) lexrc >> use_spell_lib; break; case RC_SPELL_COMMAND: - if (lexrc.next(true)) { + if (lexrc.next(true)) isp_command = lexrc.getString(); - } break; case RC_ACCEPT_COMPOUND: lexrc >> isp_accept_compound; @@ -918,30 +910,24 @@ int LyXRC::read(Lexer & lexrc) case RC_COPIER: { string fmt, command; - if (lexrc.next()) { + if (lexrc.next()) fmt = lexrc.getString(); - } - if (lexrc.next(true)) { + if (lexrc.next(true)) command = lexrc.getString(); - } setMover(fmt, command); break; } case RC_CONVERTER: { string from, to, command, flags; - if (lexrc.next()) { + if (lexrc.next()) from = lexrc.getString(); - } - if (lexrc.next()) { + if (lexrc.next()) to = lexrc.getString(); - } - if (lexrc.next(true)) { + if (lexrc.next(true)) command = lexrc.getString(); - } - if (lexrc.next()) { + if (lexrc.next()) flags = lexrc.getString(); - } if (command.empty()) theConverters().erase(from, to); else @@ -987,13 +973,13 @@ int LyXRC::read(Lexer & lexrc) else if (flag == "vector") flgs |= Format::vector; else - lyxerr << "Ignoring unknown flag `" + LYXERR0("Ignoring unknown flag `" << flag << "' for format `" - << format << "'." << endl; + << format << "'."); } if (prettyname.empty()) { if (theConverters().formatIsUsed(format)) - LYXERR0( "Can't delete format " << format); + LYXERR0("Can't delete format " << format); else formats.erase(format); } else { @@ -1024,9 +1010,8 @@ int LyXRC::read(Lexer & lexrc) else { preview = PREVIEW_OFF; if (tmp != "false" && tmp != "off") - lyxerr << "Unrecognized " - "preview status \"" - << tmp << '\n' << endl; + LYXERR0("Unrecognized preview status \"" + << tmp << '\n'); } } break; @@ -1679,10 +1664,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c case RC_SET_COLOR: for (int i = 0; i < Color_ignore; ++i) { ColorCode lc = static_cast(i); - - string const col(lcolor.getX11Name(lc)); - if (ignore_system_lyxrc || - col != system_lcolor.getX11Name(lc)) { + string const col = lcolor.getX11Name(lc); + if (ignore_system_lyxrc + || col != system_lcolor.getX11Name(lc)) { os << "\\set_color \"" << lcolor.getLyXName(lc) << "\" \"" << col << "\"\n"; diff --git a/src/frontends/qt4/ColorCache.cpp b/src/frontends/qt4/ColorCache.cpp index 16c4497eab..4ae3d065bb 100644 --- a/src/frontends/qt4/ColorCache.cpp +++ b/src/frontends/qt4/ColorCache.cpp @@ -22,6 +22,16 @@ void ColorCache::init() { for (int col = 0; col <= Color_ignore; ++col) lcolors_[col] = QColor(lcolor.getX11Name(ColorCode(col)).c_str()); + initialized_ = true; +} + + +/// get the given color +QColor const & ColorCache::get(ColorCode color) const +{ + if (!initialized_) + const_cast(this)->init(); + return lcolors_[color]; } diff --git a/src/frontends/qt4/ColorCache.h b/src/frontends/qt4/ColorCache.h index 54768f6124..b667f91197 100644 --- a/src/frontends/qt4/ColorCache.h +++ b/src/frontends/qt4/ColorCache.h @@ -26,19 +26,21 @@ struct RGBColor; class ColorCache { public: - ColorCache() { init(); } + ColorCache() : initialized_(false) {} /// get the given color - QColor const & get(ColorCode color) const { return lcolors_[color]; } + QColor const & get(ColorCode color) const; /// clear all colors - void clear() { init(); } + void clear() { initialized_ = false; } private: /// void init(); /// QColor lcolors_[Color_ignore + 1]; + /// + bool initialized_; }; /// diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index d3c8439492..104f69a0b3 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -200,7 +200,9 @@ public: } bool canConvert(QString const & mime, QString flav) - { return mimeFor(flav) == mime; } + { + return mimeFor(flav) == mime; + } QVariant convertToMime(QString const & mime, QList data, QString flav) { diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 1b2add4ad9..9f460aa105 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -20,8 +20,6 @@ #include "GuiView.h" #include "qt_helpers.h" -#include "support/debug.h" - #include #include #include diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp index f3a9c01c6b..7f56557899 100644 --- a/src/support/docstring.cpp +++ b/src/support/docstring.cpp @@ -12,22 +12,21 @@ #include "support/docstring.h" +#include "support/lassert.h" #include "support/lstrings.h" #include "support/qstring_helpers.h" #include "support/unicode.h" +#include + #include #include #include -#include - -#include "support/lassert.h" - using namespace std; -namespace lyx { +namespace lyx { docstring const from_ascii(char const * ascii) { -- 2.39.5