From bd569ada80c783b91fc94c9b1e5acccc32875b96 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 18 Jun 2008 11:35:24 +0000 Subject: [PATCH] Local aware sorting of the toc type. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25304 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/TocModel.cpp | 14 ++++++++++++++ src/frontends/qt4/TocModel.h | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/frontends/qt4/TocModel.cpp b/src/frontends/qt4/TocModel.cpp index 6b115c8390..e50ca368a5 100644 --- a/src/frontends/qt4/TocModel.cpp +++ b/src/frontends/qt4/TocModel.cpp @@ -25,6 +25,8 @@ #include "support/debug.h" #include "support/lassert.h" +#include + #include using namespace std; @@ -160,6 +162,12 @@ int TocModel::modelDepth() const TocModels::TocModels(): bv_(0) { names_ = new TocTypeModel(this); + names_sorted_ = new QSortFilterProxyModel(this); + names_sorted_->setSourceModel(names_); +#if QT_VERSION >= 0x040300 + names_sorted_->setSortLocaleAware(true); +#endif + names_sorted_->sort(0); } @@ -198,6 +206,12 @@ QStandardItemModel * TocModels::model(QString const & type) } +QAbstractItemModel * TocModels::nameModel() +{ + return names_sorted_; +} + + QModelIndex TocModels::currentIndex(QString const & type) const { const_iterator it = models_.find(type); diff --git a/src/frontends/qt4/TocModel.h b/src/frontends/qt4/TocModel.h index 4bdbbbad22..14ab2622e2 100644 --- a/src/frontends/qt4/TocModel.h +++ b/src/frontends/qt4/TocModel.h @@ -19,6 +19,9 @@ #include #include +class QAbstractItemModel; +class QSortFilterProxyModel; + namespace lyx { class Buffer; @@ -81,7 +84,7 @@ public: /// QStandardItemModel * model(QString const & type); /// - QStandardItemModel * nameModel() { return names_; } + QAbstractItemModel * nameModel(); /// QModelIndex currentIndex(QString const & type) const; /// @@ -106,6 +109,8 @@ private: QHash models_; /// TocTypeModel * names_; + /// + QSortFilterProxyModel * names_sorted_; }; } // namespace frontend