diff options
author | Arno <am@disconnect.de> | 2010-10-31 08:26:07 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-10-31 08:26:07 +0100 |
commit | 31bc791cb48e110db8f7b994931c1879974168a1 (patch) | |
tree | 1a7eabcb5e13fac78f62118fbbbc2a0c95d5582b /filesystemfileproxy.cpp | |
parent | 629841d403b13396e97d76591c3b67f156039b5c (diff) | |
download | SheMov-31bc791cb48e110db8f7b994931c1879974168a1.tar.gz SheMov-31bc791cb48e110db8f7b994931c1879974168a1.tar.bz2 SheMov-31bc791cb48e110db8f7b994931c1879974168a1.zip |
Added ".." entry to FileView
Show ".." entry in FileView and make it go to the parent directory. Had
to work around QT Bug 14760: NoDot doesn't work so the "." entry has to
be filtered in filterAcceptsRow()
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(); |