diff options
Diffstat (limited to 'filesystemfileproxy.cpp')
-rw-r--r-- | filesystemfileproxy.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/filesystemfileproxy.cpp b/filesystemfileproxy.cpp index 06ad939..7c49258 100644 --- a/filesystemfileproxy.cpp +++ b/filesystemfileproxy.cpp @@ -42,8 +42,28 @@ QVariant FilesystemFileProxy::data(const QModelIndex &index, int role) const{ return QSortFilterProxyModel::data(index, role); } +bool FilesystemFileProxy::filterAcceptsRow(int sourcerow, const QModelIndex &sourceparent) const{ + QFileSystemModel *m = static_cast<QFileSystemModel*>(sourceModel()); + QModelIndex idx = m->index(sourcerow, 0, sourceparent); + if(!idx.isValid()){ + return false; + } + QString fName = idx.data().toString(); + if(fName == "." ){ + return false; + } + return QSortFilterProxyModel::filterAcceptsRow(sourcerow, sourceparent); +} + bool FilesystemFileProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const { if(left.model()->headerData(left.column(), Qt::Horizontal).toString() == tr("Name")){ + if(left.data().toString() == ".."){ + if(sortOrder() == Qt::AscendingOrder){ + return true; + }else{ + return false; + } + } QFileSystemModel *source = static_cast<QFileSystemModel*>(sourceModel()); if(source->isDir(left) && source->isDir(right)){ return left.data().toString().toLower() < right.data().toString().toLower(); |