diff options
Diffstat (limited to 'filesystemfileproxy.cpp')
-rw-r--r-- | filesystemfileproxy.cpp | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/filesystemfileproxy.cpp b/filesystemfileproxy.cpp deleted file mode 100644 index f68b3d2..0000000 --- a/filesystemfileproxy.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version - 2 of the License, or (at your option) any later version. -*/ - -#include <QDateTime> - -#include "filesystemfileproxy.h" -#include "smdirmodel.h" -#include "helper.h" - -FilesystemFileProxy::FilesystemFileProxy(QObject *parent) : QSortFilterProxyModel(parent) {} - -QVariant FilesystemFileProxy::data(const QModelIndex &index, int role) const{ - if(!index.isValid()){ - return QVariant(); - } - SmDirModel *source = qobject_cast<SmDirModel*>(sourceModel()); - if(role == Qt::DisplayRole){ - QModelIndex real = mapToSource(index); - QLocale l; - if(index.column() == SmDirModel::Created){ - return real.data().toDateTime().toString("MM-dd-yyyy hh:mm"); - } - if(index.column() == SmDirModel::Size){ - if(source->isDir(real)){ - return QVariant(); - } - return l.toString(real.data().toLongLong()); - } - if(index.column() == SmDirModel::Type){ - if(source->isDir(real)){ - return QVariant(); - } - } - } - if(role == Qt::TextAlignmentRole){ - if(index.column() == SmDirModel::Size || index.column() == SmDirModel::DurSize || index.column() == SmDirModel::Bitrate){ - int retval = Qt::AlignRight | Qt::AlignVCenter; - return retval; - } - } - if(role == Qt::FontRole){ - if(index.column() == SmDirModel::Md5sum || index.column() == SmDirModel::DurSize || index.column() == SmDirModel::Bitrate){ - - return QFont("Monospace"); - } - } - return QSortFilterProxyModel::data(index, role); -} - -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; - } - } - SmDirModel *source = qobject_cast<SmDirModel*>(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")){ - SmDirModel *source = qobject_cast<SmDirModel*>(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); -} - |