]> git.lyx.org Git - features.git/commitdiff
* src/frontends/controllers/frontend_helpers.{cpp,h}:
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 30 Jul 2007 13:48:46 +0000 (13:48 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 30 Jul 2007 13:48:46 +0000 (13:48 +0000)
- new function getSortedColors
* src/frontends/qt4/QPrefs.cpp:
- use that to sort the colors (bug 2571)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19236 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/frontend_helpers.cpp
src/frontends/controllers/frontend_helpers.h
src/frontends/qt4/QPrefs.cpp

index 22d1048a80197cfa98255a59b8fc587a2fcd6793..25c1434641dfdca00f8c7db0d8e28c8a1a007a13 100644 (file)
@@ -1113,6 +1113,16 @@ public:
        }
 };
 
+
+class ColorSorter
+{
+public:
+       bool operator()(Color::color const & lhs,
+                       Color::color const & rhs) const {
+               return lcolor.getGUIName(lhs) < lcolor.getGUIName(rhs);
+       }
+};
+
 } // namespace anon
 
 
@@ -1147,6 +1157,14 @@ vector<LanguagePair> const getLanguageData(bool character_dlg)
        return langs;
 }
 
+
+vector<Color_color> const getSortedColors(vector<Color_color> colors)
+{
+       // sort the colors
+       std::sort(colors.begin(), colors.end(), ColorSorter());
+       return colors;
+}
+
 } // namespace frontend
 
 using support::addName;
index ae3ce48de993bf50dc4772d777b14cba1d3af624..2d71a2668bf6da54b5b56b10a9e31b01a119804b 100644 (file)
@@ -229,6 +229,8 @@ typedef std::pair<docstring, std::string> LanguagePair;
  *  to the vector.
  */
 std::vector<LanguagePair> const getLanguageData(bool character_dlg);
+/// sort colors for the gui
+std::vector<Color_color> const getSortedColors(std::vector<Color_color> colors);
 
 } // namespace frontend
 
index 3840f7e249ff3602dc622b0e71f2e528b6a98565..b7b446b1cb580d4085b5fed4a57ec4371c0a720e 100644 (file)
@@ -534,9 +534,15 @@ PrefColors::PrefColors(QPrefs * form, QWidget * parent)
                        || lc == Color::ignore) continue;
 
                lcolors_.push_back(lc);
+       }
+       lcolors_ = frontend::getSortedColors(lcolors_);
+       vector<Color_color>::const_iterator cit = lcolors_.begin();
+       vector<Color_color>::const_iterator const end = lcolors_.end();
+       for (; cit != end; ++cit)
+       {
                // This is not a memory leak:
                /*QListWidgetItem * newItem =*/ new QListWidgetItem(QIcon(icon),
-                       toqstr(lcolor.getGUIName(lc)), lyxObjectsLW);
+                       toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW);
        }
        curcolors_.resize(lcolors_.size());
        newcolors_.resize(lcolors_.size());