add some file
authorjakub <jakub.jaszczynski@comarch.com>
Tue, 1 Feb 2011 14:04:48 +0000 (15:04 +0100)
committerjakub <jakub.jaszczynski@comarch.com>
Tue, 1 Feb 2011 14:04:48 +0000 (15:04 +0100)
src/plugins/xdxf/DictsProxyListModel.h [new file with mode: 0644]
src/plugins/xdxf/scrollbar.png [new file with mode: 0644]

diff --git a/src/plugins/xdxf/DictsProxyListModel.h b/src/plugins/xdxf/DictsProxyListModel.h
new file mode 100644 (file)
index 0000000..7ecfdf8
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef DICTSPROXYLISTMODEL_H
+#define DICTSPROXYLISTMODEL_H
+
+#include <QSortFilterProxyModel>
+#include <QDebug>
+
+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 (file)
index 0000000..0228dcf
Binary files /dev/null and b/src/plugins/xdxf/scrollbar.png differ