move languageData() out of qt_helpers.cpp

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24670 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-05-07 22:42:44 +00:00
parent dece756aff
commit fbb8c063ec
6 changed files with 31 additions and 76 deletions

View File

@ -116,10 +116,23 @@ static QList<FamilyPair> familyData()
return families; return families;
} }
static QList<LanguagePair> languageData()
{
QList<LanguagePair> list;
Languages::const_iterator it = languages.begin();
for (; it != languages.end(); ++it) {
list << LanguagePair(
qt_(it->second.display()), toqstr(it->second.lang()));
}
return list;
}
namespace { namespace {
template<typename T> template<typename T>
void fillCombo(QComboBox * combo, QList<T> list) void fillCombo(QComboBox * combo, QList<T> const & list)
{ {
typename QList<T>::const_iterator cit = list.begin(); typename QList<T>::const_iterator cit = list.begin();
for (; cit != list.end(); ++cit) for (; cit != list.end(); ++cit)

View File

@ -16,7 +16,6 @@
#include "GuiDialog.h" #include "GuiDialog.h"
#include "ui_CharacterUi.h" #include "ui_CharacterUi.h"
#include "qt_helpers.h" // for LanguagePair
#include "Font.h" #include "Font.h"
#include <utility> #include <utility>
@ -45,6 +44,7 @@ typedef std::pair<QString, FontShape> ShapePair;
typedef std::pair<QString, FontSize> SizePair; typedef std::pair<QString, FontSize> SizePair;
typedef std::pair<QString, FontState> BarPair; typedef std::pair<QString, FontState> BarPair;
typedef std::pair<QString, ColorCode> ColorPair; typedef std::pair<QString, ColorCode> ColorPair;
typedef std::pair<QString, QString> LanguagePair;
class GuiCharacter : public GuiDialog, public Ui::CharacterUi class GuiCharacter : public GuiDialog, public Ui::CharacterUi
{ {

View File

@ -510,10 +510,6 @@ GuiDocument::GuiDocument(GuiView & lv)
{ {
setupUi(this); setupUi(this);
QList<LanguagePair> langs = languageData();
for (int i = 0; i != langs.size(); ++i)
lang_.append(langs[i].second);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply())); connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@ -790,10 +786,12 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
// language & quotes // language & quotes
QList<LanguagePair>::const_iterator lit = langs.begin(); Languages::const_iterator lit = languages.begin();
QList<LanguagePair>::const_iterator lend = langs.end(); Languages::const_iterator lend = languages.end();
for (; lit != lend; ++lit) for (; lit != lend; ++lit) {
langModule->languageCO->addItem(lit->first); lang_.append(toqstr(lit->second.lang()));
langModule->languageCO->addItem(qt_(lit->second.display()));
}
// Always put the default encoding in the first position. // Always put the default encoding in the first position.
// It is special because the displayed text is translated. // It is special because the displayed text is translated.

View File

@ -13,19 +13,20 @@
#include "GuiPrefs.h" #include "GuiPrefs.h"
#include "qt_helpers.h" #include "FileDialog.h"
#include "GuiApplication.h" #include "GuiApplication.h"
#include "GuiFontExample.h"
#include "GuiFontLoader.h" #include "GuiFontLoader.h"
#include "GuiKeySymbol.h"
#include "qt_helpers.h"
#include "BufferList.h" #include "BufferList.h"
#include "Color.h" #include "Color.h"
#include "ConverterCache.h" #include "ConverterCache.h"
#include "FileDialog.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "GuiFontExample.h"
#include "GuiKeySymbol.h"
#include "KeyMap.h" #include "KeyMap.h"
#include "KeySequence.h" #include "KeySequence.h"
#include "Language.h"
#include "LyXAction.h" #include "LyXAction.h"
#include "PanelStack.h" #include "PanelStack.h"
#include "paper.h" #include "paper.h"
@ -1658,12 +1659,11 @@ PrefLanguage::PrefLanguage(QWidget * parent)
defaultLanguageCO->clear(); defaultLanguageCO->clear();
// store the lang identifiers for later Languages::const_iterator lit = languages.begin();
//foreach (LanguagePair const & lpair, languageData(false)) { Languages::const_iterator lend = languages.end();
QList<LanguagePair> l = languageData(); for (; lit != lend; ++lit) {
foreach (LanguagePair const & lpair, l) { lang_.append(toqstr(lit->second.lang()));
defaultLanguageCO->addItem(lpair.first); defaultLanguageCO->addItem(qt_(lit->second.display()));
lang_.append(lpair.second);
} }
} }

View File

@ -160,55 +160,6 @@ QString const qt_(string const & str)
return toqstr(_(str)); return toqstr(_(str));
} }
namespace {
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_ = locale("");
} catch (...) {
loc_ok = false;
}
}
bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const
{
// FIXME: would that be "QString::localeAwareCompare()"?
if (loc_ok)
return loc_(fromqstr(lhs.first), fromqstr(rhs.first));
else
return lhs.first < rhs.first;
}
private:
locale loc_;
bool loc_ok;
#endif
};
} // namespace anon
QList<LanguagePair> languageData()
{
QList<LanguagePair> list;
Languages::const_iterator it = languages.begin();
for (; it != languages.end(); ++it) {
list << LanguagePair(
qt_(it->second.display()), toqstr(it->second.lang()));
}
return list;
}
void rescanTexStyles() void rescanTexStyles()
{ {

View File

@ -19,8 +19,6 @@
#include <QString> #include <QString>
#include <utility>
class QComboBox; class QComboBox;
class QLineEdit; class QLineEdit;
class QCheckBox; class QCheckBox;
@ -70,11 +68,6 @@ void setValid(QWidget * widget, bool valid);
QString const qt_(std::string const & str); QString const qt_(std::string const & str);
/// ///
typedef std::pair<QString, QString> LanguagePair;
///
QList<LanguagePair> languageData();
support::FileName libFileSearch(QString const & dir, QString const & name, support::FileName libFileSearch(QString const & dir, QString const & name,
QString const & ext = QString()); QString const & ext = QString());