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