/* 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 #include #include #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, 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); void updateDVDNo(const QList fileNos); virtual Qt::ItemFlags flags(const QModelIndex &index) const; QList availableQualities() { return mAvailableQualities; } QModelIndexList children(const QModelIndex &idx); public slots: void refresh(); private: void populate(); int mNumFields; QList 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