]> git.lyx.org Git - features.git/commitdiff
next try
authorAndré Pönitz <poenitz@gmx.net>
Thu, 29 May 2008 17:57:57 +0000 (17:57 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 29 May 2008 17:57:57 +0000 (17:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25000 a592a061-630c-0410-9148-cb99ea01b6c8

src/Color.cpp
src/LyXRC.cpp
src/frontends/qt4/ColorCache.cpp
src/frontends/qt4/ColorCache.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiViewSource.h
src/support/docstring.cpp

index 47e251d14b7ee2fa2e9c04c07713e054f900950d..f4e84aeee1c0087cf013ac279fc763f014e96396 100644 (file)
@@ -21,7 +21,6 @@
 #include "support/debug.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
-
 #include "support/lassert.h"
 
 #include <map>
@@ -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;
        }
 
index 42caf22a3f5687fcd683b71bf45503c2f7c92f9c..fa916ba24288c70052be154b52a91f6a0d8f34d8 100644 (file)
@@ -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<ColorCode>(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";
index 16c4497eab66ea07afa86bce84cb34be57b26724..4ae3d065bb7304a8a85a419f818df425861e4f47 100644 (file)
@@ -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<ColorCache *>(this)->init();
+       return lcolors_[color];
 }
 
 
index 54768f612443b21e98ece648f5b113a139088e16..b667f911971e0b14c43764627df808edf0198fb5 100644 (file)
@@ -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_;
 };
 
 ///
index d3c8439492ed610d046dcaafc2ac070c669592db..104f69a0b352a9f7f695e5b1f427a65b386b3121 100644 (file)
@@ -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<QByteArray> data, QString flav)
        {
index 1b2add4ad91de1dfcac4b57cdf563b9b5a436eab..9f460aa105443ddd38904b784e2602f7ccad4e3c 100644 (file)
@@ -20,8 +20,6 @@
 #include "GuiView.h"
 #include "qt_helpers.h"
 
-#include "support/debug.h"
-
 #include <QDockWidget>
 #include <QString>
 #include <QTextCharFormat>
index f3a9c01c6bc379ee364e4f8e2f8683a933796317..7f56557899fcc7043303ed780596a08d869e92f7 100644 (file)
 
 #include "support/docstring.h"
 
+#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/qstring_helpers.h"
 #include "support/unicode.h"
 
+#include <QFile>
+
 #include <locale>
 #include <iostream>
 #include <typeinfo>
 
-#include <QFile>
-
-#include "support/lassert.h"
-
 using namespace std;
 
-namespace lyx {
 
+namespace lyx {
 
 docstring const from_ascii(char const * ascii)
 {