From 91cf2978ba97bc8ebda2da9df01d3dde22b99f14 Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 12 Aug 2010 19:40:33 +0200 Subject: Show picture size or duration in FilesTreeView Finally managed to view size of pictures or duration for movies in the file view. That values are not held in the database, they're created on the fly. For this to perform I created a disk based cache. I also had to create some convenience functions: FilesTreeModel::streamInfo(const QString &) FilesTreeModel::pictureInfo(const QString &) The cache is a QDataStream and will be deleted if the magic doesn't fit. --- filestreemodel.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'filestreemodel.h') diff --git a/filestreemodel.h b/filestreemodel.h index 405878b..2a9519f 100644 --- a/filestreemodel.h +++ b/filestreemodel.h @@ -21,9 +21,9 @@ class SeriesTreeModel; class FilesTreeModel : public SmTreeModel { Q_OBJECT public: - enum CustomRoles { FileNameRole = Qt::UserRole + 1, FullPathRole = Qt::UserRole + 2, SizeRole = Qt::UserRole + 3, DvdNoRole = Qt::UserRole + 4, SizeDisplayRole = Qt::UserRole + 5, FileTypeRole = Qt::UserRole + 6, Md5SumRole = Qt::UserRole + 7, PartNoRole = Qt::UserRole + 8, SeriesPartIdRole = Qt::UserRole + 9, QualityRole = Qt::UserRole + 10, FilesIdRole = Qt::UserRole + 11, SeriesPartRole = Qt::UserRole + 12, DisplayNameRole = Qt::UserRole + 13 }; + enum CustomRoles { FileNameRole = Qt::UserRole + 1, FullPathRole = Qt::UserRole + 2, SizeRole = Qt::UserRole + 3, DvdNoRole = Qt::UserRole + 4, SizeDisplayRole = Qt::UserRole + 5, FileTypeRole = Qt::UserRole + 6, Md5SumRole = Qt::UserRole + 7, PartNoRole = Qt::UserRole + 8, SeriesPartIdRole = Qt::UserRole + 9, QualityRole = Qt::UserRole + 10, FilesIdRole = Qt::UserRole + 11, SeriesPartRole = Qt::UserRole + 12, DisplayNameRole = Qt::UserRole + 13, SizeDurationRole = Qt::UserRole + 14 }; enum FileTypes { Movie = 1, FrontCover = 2, BackCover = 3, GeneralCover = 4 }; - enum Fields { FileName = 0, PartNo = 1, SizeDisplay = 2, Quality = 3, DvdNo = 4, FullPath = 5, Size = 6, FileType = 7, Md5Sum = 8, SeriesPartId = 9, FilesId = 10, SeriesPart = 11, DisplayName = 12 }; + enum Fields { FileName = 0, PartNo = 1, SizeDisplay = 2, Quality = 3, DvdNo = 4, FullPath = 5, Size = 6, FileType = 7, Md5Sum = 8, SeriesPartId = 9, FilesId = 10, SeriesPart = 11, DisplayName = 12, SizeDuration = 13 }; enum Mode { Normal = 0, Archived = 1, Local = 2 }; explicit FilesTreeModel(QStringList &headers, QObject *parent = 0); const QHash fileTypes() const { return mFileTypes; } @@ -39,8 +39,10 @@ class FilesTreeModel : public SmTreeModel { bool setData(const QModelIndex &index, const QVariant &value, int role); Qt::ItemFlags flags(const QModelIndex &index) const; QHash filesBySeriesPartId(int seriesPartId) const; - QList > streamInfo(const QModelIndex &idx); - QMap pictureInfo(const QModelIndex &idx); + QList > streamInfo(const QModelIndex &idx) const; + QList > streamInfo(const QString &path) const; + QMap pictureInfo(const QString &path) const; + QMap pictureInfo(const QModelIndex &idx) const; QMap pictureMetaInfo(const QModelIndex &idx); //file manipulation @@ -48,6 +50,10 @@ class FilesTreeModel : public SmTreeModel { bool deleteFile(const QModelIndex &file); bool deleteFiles(const QModelIndexList &files); + //misc + void readCache(); + void writeCache(); + private: //functions void populate(QSqlQuery &filesQuery); @@ -64,8 +70,10 @@ class FilesTreeModel : public SmTreeModel { QHash mFileTypes; QHash mCoverTypes; QHash mModeNames; + QHash mPicsDurationCache; SeriesTreeModel *mSeriesModel; int mMode; + const int mMagic; }; #endif // FILESTREEMODEL_H -- cgit v1.2.3-70-g09d2