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
This commit is contained in:
Abdelrazak Younes 2008-05-14 11:27:33 +00:00
parent 42a70d2559
commit 074f1bee36

View File

@ -14,7 +14,9 @@
#include "GuiCharacter.h" #include "GuiCharacter.h"
#include "GuiApplication.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "Font.h" #include "Font.h"
#include "Buffer.h" #include "Buffer.h"
#include "BufferParams.h" #include "BufferParams.h"
@ -24,6 +26,9 @@
#include "Language.h" #include "Language.h"
#include "Paragraph.h" #include "Paragraph.h"
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
using namespace std; using namespace std;
@ -120,10 +125,18 @@ static QList<FamilyPair> familyData()
static QList<LanguagePair> languageData() static QList<LanguagePair> languageData()
{ {
QList<LanguagePair> list; QList<LanguagePair> list;
Languages::const_iterator it = languages.begin(); // FIXME (Abdel 14/05/2008): it would be nice if we could use this model
for (; it != languages.end(); ++it) { // directly in the language combo; but, as we need also the 'No Change' and
list << LanguagePair( // 'Reset' items, this is not possible right now. Separating those two
qt_(it->second.display()), toqstr(it->second.lang())); // 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; return list;
} }