mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Hopefully fix locale aware language sorting in document and prefs dialogs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24758 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
aa7d21d98b
commit
09a3be216e
@ -57,6 +57,7 @@
|
|||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QSessionManager>
|
#include <QSessionManager>
|
||||||
#include <QSocketNotifier>
|
#include <QSocketNotifier>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -156,7 +157,8 @@ GuiApplication * guiApp;
|
|||||||
|
|
||||||
|
|
||||||
GuiApplication::GuiApplication(int & argc, char ** argv)
|
GuiApplication::GuiApplication(int & argc, char ** argv)
|
||||||
: QApplication(argc, argv), Application(), current_view_(0), global_menubar_(0)
|
: QApplication(argc, argv), Application(), current_view_(0),
|
||||||
|
global_menubar_(0), language_model_(0)
|
||||||
{
|
{
|
||||||
QString app_name = "LyX";
|
QString app_name = "LyX";
|
||||||
QCoreApplication::setOrganizationName(app_name);
|
QCoreApplication::setOrganizationName(app_name);
|
||||||
@ -250,10 +252,6 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GuiApplication::~GuiApplication()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
FuncStatus GuiApplication::getStatus(FuncRequest const & cmd)
|
FuncStatus GuiApplication::getStatus(FuncRequest const & cmd)
|
||||||
{
|
{
|
||||||
FuncStatus flag;
|
FuncStatus flag;
|
||||||
@ -457,20 +455,29 @@ void GuiApplication::exit(int status)
|
|||||||
void GuiApplication::execBatchCommands()
|
void GuiApplication::execBatchCommands()
|
||||||
{
|
{
|
||||||
LyX::ref().execBatchCommands();
|
LyX::ref().execBatchCommands();
|
||||||
|
}
|
||||||
|
|
||||||
language_model_ = new QStandardItemModel(this);
|
QAbstractItemModel * GuiApplication::languageModel()
|
||||||
language_model_->insertColumns(0, 1);
|
{
|
||||||
|
if (language_model_)
|
||||||
|
return language_model_;
|
||||||
|
|
||||||
|
QStandardItemModel * lang_model = new QStandardItemModel(this);
|
||||||
|
lang_model->insertColumns(0, 1);
|
||||||
int current_row;
|
int current_row;
|
||||||
Languages::const_iterator it = languages.begin();
|
Languages::const_iterator it = languages.begin();
|
||||||
Languages::const_iterator end = languages.end();
|
Languages::const_iterator end = languages.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
current_row = language_model_->rowCount();
|
current_row = lang_model->rowCount();
|
||||||
language_model_->insertRows(current_row, 1);
|
lang_model->insertRows(current_row, 1);
|
||||||
QModelIndex item = language_model_->index(current_row, 0);
|
QModelIndex item = lang_model->index(current_row, 0);
|
||||||
language_model_->setData(item, qt_(it->second.display()), Qt::DisplayRole);
|
lang_model->setData(item, qt_(it->second.display()), Qt::DisplayRole);
|
||||||
language_model_->setData(item, toqstr(it->second.lang()), Qt::UserRole);
|
lang_model->setData(item, toqstr(it->second.lang()), Qt::UserRole);
|
||||||
}
|
}
|
||||||
language_model_->sort(0);
|
language_model_ = new QSortFilterProxyModel(this);
|
||||||
|
language_model_->setSourceModel(lang_model);
|
||||||
|
language_model_->setSortLocaleAware(true);
|
||||||
|
return language_model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class QSessionManager;
|
class QSessionManager;
|
||||||
class QStandardItemModel;
|
class QAbstractItemModel;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
@ -55,8 +55,6 @@ class GuiApplication : public QApplication, public Application
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
GuiApplication(int & argc, char ** argv);
|
GuiApplication(int & argc, char ** argv);
|
||||||
///
|
|
||||||
virtual ~GuiApplication();
|
|
||||||
|
|
||||||
/// Method inherited from \c Application class
|
/// Method inherited from \c Application class
|
||||||
//@{
|
//@{
|
||||||
@ -106,7 +104,7 @@ public:
|
|||||||
///
|
///
|
||||||
ColorCache & colorCache() { return color_cache_; }
|
ColorCache & colorCache() { return color_cache_; }
|
||||||
|
|
||||||
QStandardItemModel * languageModel() { return language_model_; }
|
QAbstractItemModel * languageModel();
|
||||||
|
|
||||||
/// return a suitable serif font name.
|
/// return a suitable serif font name.
|
||||||
virtual QString const romanFontName();
|
virtual QString const romanFontName();
|
||||||
@ -147,7 +145,7 @@ private:
|
|||||||
///
|
///
|
||||||
ColorCache color_cache_;
|
ColorCache color_cache_;
|
||||||
///
|
///
|
||||||
QStandardItemModel * language_model_;
|
QSortFilterProxyModel * language_model_;
|
||||||
///
|
///
|
||||||
QTranslator qt_trans_;
|
QTranslator qt_trans_;
|
||||||
///
|
///
|
||||||
|
@ -50,9 +50,9 @@
|
|||||||
|
|
||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -788,7 +788,10 @@ GuiDocument::GuiDocument(GuiView & lv)
|
|||||||
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
|
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
// language & quotes
|
// language & quotes
|
||||||
langModule->languageCO->setModel(guiApp->languageModel());
|
QAbstractItemModel * language_model = guiApp->languageModel();
|
||||||
|
// FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
|
||||||
|
language_model->sort(0);
|
||||||
|
langModule->languageCO->setModel(language_model);
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
#include "frontends/Application.h"
|
#include "frontends/Application.h"
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
@ -54,7 +55,6 @@
|
|||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
@ -1651,7 +1651,10 @@ PrefLanguage::PrefLanguage(QWidget * parent)
|
|||||||
|
|
||||||
defaultLanguageCO->clear();
|
defaultLanguageCO->clear();
|
||||||
|
|
||||||
defaultLanguageCO->setModel(guiApp->languageModel());
|
QAbstractItemModel * language_model = guiApp->languageModel();
|
||||||
|
// FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
|
||||||
|
language_model->sort(0);
|
||||||
|
defaultLanguageCO->setModel(language_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user