From 6af9b265b0e9e3bc88d9e0bb61701aac64b2f8f1 Mon Sep 17 00:00:00 2001 From: am Date: Mon, 6 Jul 2009 15:51:54 +0000 Subject: -implemented sorting in fileview -implemented location bar git-svn-id: file:///var/svn/repos2/shemov/trunk@378 f440f766-f032-0410-8965-dc7d17de2ca0 --- filesystemfileproxy.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'filesystemfileproxy.cpp') diff --git a/filesystemfileproxy.cpp b/filesystemfileproxy.cpp index 22f8868..2379226 100644 --- a/filesystemfileproxy.cpp +++ b/filesystemfileproxy.cpp @@ -7,8 +7,40 @@ #include #include +#include +#include +#include #include "filesystemfileproxy.h" FilesystemFileProxy::FilesystemFileProxy(QObject *parent) : QSortFilterProxyModel(parent) {} +bool FilesystemFileProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const { + if(left.model()->headerData(left.column(), Qt::Horizontal).toString() == tr("Name")){ + QDirModel *source = static_cast(sourceModel()); + if(source->isDir(left) && source->isDir(right)){ + return left.data().toString().toLower() < right.data().toString().toLower(); + } + if(source->isDir(left)){ + return true; + } + if(source->isDir(right)){ + return false; + } + return left.data().toString().toLower() < right.data().toString().toLower(); + } + if(left.model()->headerData(left.column(), Qt::Horizontal).toString() == tr("Size")){ + QDirModel *source = static_cast(sourceModel()); + QFileInfo lInfo = source->fileInfo(left); + QFileInfo rInfo = source->fileInfo(right); + if(lInfo.isDir() && rInfo.isDir()){ + return lInfo.fileName().toLower() < rInfo.fileName().toLower(); + } + if(lInfo.isDir() && !rInfo.isDir()){ + return true; + } + return lInfo.size() < rInfo.size(); + } + return QSortFilterProxyModel::lessThan(left, right); +} + -- cgit v1.2.3-70-g09d2