From bd6a6a7c42dabe2d0d86e309a6dc6b04de7c0a10 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 6 Jul 2013 08:06:52 +0200 Subject: Basic ArchiveFilesModel and ArchiveController Implement a new file model for the archive. It's quite basic at this stage, but finally something happens when clicking the archive tree. Also, implement the interaction (signal -> slot) between the views and models in an explicit controller to prevent the mess from the old archive. --- archivemodel.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'archivemodel.h') diff --git a/archivemodel.h b/archivemodel.h index 4ef39fa..a9994d0 100644 --- a/archivemodel.h +++ b/archivemodel.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "smtreemodel.h" @@ -35,6 +36,7 @@ class ArchiveModel : public SmTreeModel { virtual bool removeNode(const QModelIndex &idx); QStringList indexToPath(const QModelIndex &idx) const; QModelIndexList pathToIndex(const QStringList &path) const; + QSet seriesPartIds(const QModelIndex &idx) const; signals: void needRefresh(); @@ -64,6 +66,24 @@ class ArchiveModel : public SmTreeModel { int mOrder; }; +class ArchiveFilesModel : public SmTreeModel { + Q_OBJECT + public: + enum CustomRoles { SeriesPartIdRole = Qt::UserRole + 1, FilenameRole = Qt::UserRole + 2, Md5SumRole = Qt::UserRole + 3, SizeRole = Qt::UserRole + 4, DvdNoRole = Qt::UserRole + 5, FileTypeRole = Qt::UserRole + 6, FileNumberRole = Qt::UserRole + 7, QualityRole = Qt::UserRole + 8, FileIdRole = Qt::UserRole + 9, PicSizeRole = Qt::UserRole + 10, DurationRole = Qt::UserRole + 11, FullPathRole = Qt::UserRole + 12 }; + enum Fields { SeriesPartId = 0, Filename = 1, Md5Sum = 2, Size = 3, DvdNo = 4, FileType = 5, FileNumber = 6, Quality = 7, FileId = 8, PicSize = 9, Duration = 10, FullPath = 11 }; + enum FileType { Movie = 1, FrontCover = 2, BackCover = 3, GeneralCover = 4 }; + enum { NumFields = 12 }; + explicit ArchiveFilesModel(const QStringList &headers, QObject *parent = 0); + virtual QVariant data(const QModelIndex &index, int role) const; + virtual bool setData(const QModelIndex &idx, const QVariant &value, int role); + void populate(const QSet &seriesPartIds); + + private: + QList mSeriesPartIds; + QHash mRoleDbColumnMap; + QSqlDatabase mDb; +}; + class ArchiveCollector : public QThread { Q_OBJECT public: -- cgit v1.2.3-70-g09d2