1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
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.
*/
#ifndef ARCHIVEBROWSERMODEL_H
#define ARCHIVEBROWSERMODEL_H
#include <QSqlDatabase>
#include <QSortFilterProxyModel>
#include <QList>
#include "smtreemodel.h"
class ArchiveBrowserModel : public SmTreeModel {
Q_OBJECT
public:
enum CustomRoles { ExpansionRole = Qt::UserRole + 1, NameRole = Qt::UserRole + 2, GenericIdRole = Qt::UserRole + 3, NodeTypeRole = Qt::UserRole + 4, TotalSizeRole = Qt::UserRole + 5, QualityRole = 6, FileTypeRole = Qt::UserRole + 7, FullPathRole = Qt::UserRole + 8, SelectedRole = Qt::UserRole + 9 };
enum Fields { Expansion = 0, Name = 1, GenericId = 2, NodeType = 3, TotalSize = 4, Quality = 5, FileType = 6, FullPath = 7, Selected = 8 };
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);
void updateDVDNo(const QList<int> fileNos);
int nextDVDNo() const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
QList<int> availableQualities() { return mAvailableQualities; }
QModelIndexList children(const QModelIndex &idx);
public slots:
void refresh();
signals:
void populated();
private:
void populate();
void readConfig();
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
|