summaryrefslogtreecommitdiffstats
path: root/archivebrowsermodel.h
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2014-02-07 06:39:49 +0100
committerArno <am@disconnect.de>2014-02-07 06:39:49 +0100
commit9c85c8e441b5bc6bd9e6441a828599c137ea36be (patch)
treed1e3eaab343aa2d85e9ea05ce49f73ceed8be97d /archivebrowsermodel.h
parent3ac6968ebaf087aeb4bb3deeb1ded2bbbd54dfa5 (diff)
downloadSheMov-9c85c8e441b5bc6bd9e6441a828599c137ea36be.tar.gz
SheMov-9c85c8e441b5bc6bd9e6441a828599c137ea36be.tar.bz2
SheMov-9c85c8e441b5bc6bd9e6441a828599c137ea36be.zip
Implement ArchiveBrowser filtering
Filter ArchiveBrowser by Quality and/or size: * Quality: only show series with a quality less or equal * Size: only show series still fitting onto the DVD * Both: only show series with a quality less or equal _and_ still fitting on the DVD Use QItemSelection instead of going through the selected items in the tree. Seems to work somehow...
Diffstat (limited to 'archivebrowsermodel.h')
-rw-r--r--archivebrowsermodel.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/archivebrowsermodel.h b/archivebrowsermodel.h
index 3b7fc14..46a8102 100644
--- a/archivebrowsermodel.h
+++ b/archivebrowsermodel.h
@@ -9,23 +9,47 @@
#define ARCHIVEBROWSERMODEL_H
#include <QSqlDatabase>
+#include <QSortFilterProxyModel>
+#include <QList>
#include "smtreemodel.h"
class ArchiveBrowserModel : public SmTreeModel {
Q_OBJECT
public:
- enum CustomRoles { NameRole = Qt::UserRole + 1, GenericIdRole = Qt::UserRole + 2, NodeTypeRole = Qt::UserRole + 3, TotalSizeRole = Qt::UserRole + 4, QualityRole = 5, FileTypeRole = Qt::UserRole + 6, FullPathRole = Qt::UserRole + 7 };
- enum Fields { Name = 0, GenericId = 1, NodeType = 2, TotalSize = 3, Quality = 4, FileType = 5, FullPath = 6 };
+ enum CustomRoles { NameRole = Qt::UserRole + 1, GenericIdRole = Qt::UserRole + 2, NodeTypeRole = Qt::UserRole + 3, TotalSizeRole = Qt::UserRole + 4, QualityRole = 5, FileTypeRole = Qt::UserRole + 6, FullPathRole = Qt::UserRole + 7, SelectedRole = Qt::UserRole + 8 };
+ enum Fields { Name = 0, GenericId = 1, NodeType = 2, TotalSize = 3, Quality = 4, FileType = 5, FullPath = 6, Selected = 7 };
enum NodeTypes { SeriesPartNode = 1, FileNode = 2 };
explicit ArchiveBrowserModel(const QStringList &headers, QObject *parent = 0);
virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+ QList<int> availableQualities() { return mAvailableQualities; }
private:
void populate();
int mNumFields;
+ QList<int> mAvailableQualities;
QSqlDatabase mDb;
};
+class ArchiveBrowserModelProxy : public QSortFilterProxyModel {
+ Q_OBJECT
+ public:
+ explicit ArchiveBrowserModelProxy(QObject *parent = 0);
+
+ public slots:
+ void setQualityFilter(QString quality);
+ void setSizeFilter(int activate);
+ void setBytesRemaining(qint64 bytes);
+
+ protected:
+ virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+
+ private:
+ int mQuality;
+ bool mSizeFilter;
+ qint64 mBytesRemaining;
+};
+
#endif // ARCHIVEBROWSERMODEL_H