From 5a28629d4e37964697f643817f90d96a1e97de41 Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 1 Feb 2011 15:04:48 +0100 Subject: [PATCH] add some file --- src/plugins/xdxf/DictsProxyListModel.h | 55 ++++++++++++++++++++++++++++++++ src/plugins/xdxf/scrollbar.png | Bin 0 -> 161 bytes 2 files changed, 55 insertions(+) create mode 100644 src/plugins/xdxf/DictsProxyListModel.h create mode 100644 src/plugins/xdxf/scrollbar.png diff --git a/src/plugins/xdxf/DictsProxyListModel.h b/src/plugins/xdxf/DictsProxyListModel.h new file mode 100644 index 0000000..7ecfdf8 --- /dev/null +++ b/src/plugins/xdxf/DictsProxyListModel.h @@ -0,0 +1,55 @@ +#ifndef DICTSPROXYLISTMODEL_H +#define DICTSPROXYLISTMODEL_H + +#include +#include + +class DictsProxyListModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + enum DictTypeRoles { + NumberRole=Qt::UserRole + 1, + FromRole, + ToRole, + NameRole, + SizeRole, + LinkRole }; + + DictsProxyListModel(QObject *parent = 0): QSortFilterProxyModel(parent){ } + QString from() { return _from;} + QString to() {return _to;} + void setFrom(QString from) { _from = from; invalidateFilter(); } + void setTo(QString to) {_to = to; invalidateFilter();} + +protected: + bool filterAcceptsRow(int source_row, const QModelIndex&) const { + QString sourceFrom = sourceModel()->data(sourceModel()->index(source_row, 0),FromRole).toString(); + QString sourceTo = sourceModel()->data(sourceModel()->index(source_row, 0),ToRole).toString(); + return ((_from.isEmpty() || sourceFrom == _from) && + (_to.isEmpty() || sourceTo == _to)); + } + + bool lessThan(const QModelIndex &left, const QModelIndex &right) const { + QString l = left.model()->data(left,sortRole()).toString(); + QString r = right.model()->data(right,sortRole()).toString(); + if(sortRole() == SizeRole){ + l.remove(" MB"); + r.remove(" MB"); + float lNumber = l.toFloat(); + float rNumber = r.toFloat(); + return (lNumber < rNumber); + } + else if(sortRole()>Qt::UserRole) + return (l < r); + else + QSortFilterProxyModel::lessThan(left, right); + } + +private: + QString _from; + QString _to; + +}; + +#endif // DICTPROXYLISTMODEL_H diff --git a/src/plugins/xdxf/scrollbar.png b/src/plugins/xdxf/scrollbar.png new file mode 100644 index 0000000000000000000000000000000000000000..0228dcf9ebb52f89ef1ee1ba502649abd78e23d9 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=7>k44ofy`glX(f`uqAoByDx`7I;J!Gca%qgD@k*tT_@uLG}_)Usv{