Local aware sorting of the toc type.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25304 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-06-18 11:35:24 +00:00
parent 7917f03145
commit bd569ada80
2 changed files with 20 additions and 1 deletions

View 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);

View 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