]> git.lyx.org Git - features.git/commitdiff
Local aware sorting of the toc type.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 18 Jun 2008 11:35:24 +0000 (11:35 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 18 Jun 2008 11:35:24 +0000 (11:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25304 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/TocModel.cpp
src/frontends/qt4/TocModel.h

index 6b115c8390bd92b0ee84427bbe00be0cbf20dc74..e50ca368a5a6222851a6a84633da43484e787378 100644 (file)
@@ -25,6 +25,8 @@
 #include "support/debug.h"
 #include "support/lassert.h"
 
+#include <QSortFilterProxyModel>
+
 #include <climits>
 
 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);
index 4bdbbbad2229c2f5e29f98d21412f0065731ac9d..14ab2622e27dad6af3eac8fc99a9600b128415c4 100644 (file)
@@ -19,6 +19,9 @@
 #include <QStandardItemModel>
 #include <QStringList>
 
+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<QString, TocModel *> models_;
        ///
        TocTypeModel * names_;
+       ///
+       QSortFilterProxyModel * names_sorted_;
 };
 
 } // namespace frontend