From 074f1bee3608dbab59d3e7d9c25e0a8c844c79ec Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 14 May 2008 11:27:33 +0000 Subject: [PATCH] Fix locale aware language sorting in character (text style) dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24761 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiCharacter.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/frontends/qt4/GuiCharacter.cpp b/src/frontends/qt4/GuiCharacter.cpp index 1c4acf0763..2d3770e06a 100644 --- a/src/frontends/qt4/GuiCharacter.cpp +++ b/src/frontends/qt4/GuiCharacter.cpp @@ -14,7 +14,9 @@ #include "GuiCharacter.h" +#include "GuiApplication.h" #include "qt_helpers.h" + #include "Font.h" #include "Buffer.h" #include "BufferParams.h" @@ -24,6 +26,9 @@ #include "Language.h" #include "Paragraph.h" +#include +#include +#include using namespace std; @@ -120,10 +125,18 @@ static QList familyData() static QList languageData() { QList list; - Languages::const_iterator it = languages.begin(); - for (; it != languages.end(); ++it) { - list << LanguagePair( - qt_(it->second.display()), toqstr(it->second.lang())); + // FIXME (Abdel 14/05/2008): it would be nice if we could use this model + // directly in the language combo; but, as we need also the 'No Change' and + // 'Reset' items, this is not possible right now. Separating those two + // entries in radio buttons would be a better GUI IMHO. + QAbstractItemModel * language_model = guiApp->languageModel(); + // Make sure the items are sorted. + language_model->sort(0); + + for (int i = 0; i != language_model->rowCount(); ++i) { + QModelIndex index = language_model->index(i, 0); + list << LanguagePair(index.data(Qt::DisplayRole).toString(), + index.data(Qt::UserRole).toString()); } return list; }