]> git.lyx.org Git - features.git/commitdiff
Fix bug 2738: Wrong sorting of languages in Document dialog
authorPavel Sanda <sanda@lyx.org>
Wed, 14 Nov 2007 02:01:50 +0000 (02:01 +0000)
committerPavel Sanda <sanda@lyx.org>
Wed, 14 Nov 2007 02:01:50 +0000 (02:01 +0000)
http://bugzilla.lyx.org/show_bug.cgi?id=2738

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

src/frontends/qt4/qt_helpers.cpp

index 7fe70acea35f00c4826bb9293cb04361fd63d57e..1fc4fbbdc6798934f4aff5476056432c73d6e765 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <algorithm>
 #include <fstream>
+#include <locale>
 
 using std::string;
 using std::vector;
@@ -162,11 +163,34 @@ QString const qt_(string const & str)
 
 namespace {
 
-struct Sorter
+class Sorter
 {
+public:
+#if !defined(USE_WCHAR_T) && defined(__GNUC__)
        bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const {
                return lhs.first < rhs.first;
        }
+#else
+       Sorter() : loc_ok(true)
+       {
+               try {
+                       loc_ = std::locale("");
+               } catch (...) {
+                       loc_ok = false;
+               }
+       };
+
+       bool operator()(LanguagePair const & lhs,
+                       LanguagePair const & rhs) const {
+               if (loc_ok)
+                       return loc_(lhs.first, rhs.first);
+               else
+                       return lhs.first < rhs.first;
+       }
+private:
+       std::locale loc_;
+       bool loc_ok;
+#endif
 };