summaryrefslogtreecommitdiffstats
path: root/filestreemodel.h
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-08-12 19:40:33 +0200
committerArno <am@disconnect.de>2010-08-12 19:40:33 +0200
commit91cf2978ba97bc8ebda2da9df01d3dde22b99f14 (patch)
tree27dbafd0df752982535e12fc6eb847221649a83d /filestreemodel.h
parent3af9f3f8b900b9dd5e09300e74d6ce49018be98e (diff)
downloadSheMov-91cf2978ba97bc8ebda2da9df01d3dde22b99f14.tar.gz
SheMov-91cf2978ba97bc8ebda2da9df01d3dde22b99f14.tar.bz2
SheMov-91cf2978ba97bc8ebda2da9df01d3dde22b99f14.zip
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.
Diffstat (limited to 'filestreemodel.h')
-rw-r--r--filestreemodel.h16
1 files changed, 12 insertions, 4 deletions
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<int, QString> 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<QString, QString> filesBySeriesPartId(int seriesPartId) const;
- QList<QMap<QString, QString> > streamInfo(const QModelIndex &idx);
- QMap<QString, QString> pictureInfo(const QModelIndex &idx);
+ QList<QMap<QString, QString> > streamInfo(const QModelIndex &idx) const;
+ QList<QMap<QString, QString> > streamInfo(const QString &path) const;
+ QMap<QString, QString> pictureInfo(const QString &path) const;
+ QMap<QString, QString> pictureInfo(const QModelIndex &idx) const;
QMap<QString, QString> 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<int, QString> mFileTypes;
QHash<int, QString> mCoverTypes;
QHash<int, QString> mModeNames;
+ QHash<QString, QString> mPicsDurationCache;
SeriesTreeModel *mSeriesModel;
int mMode;
+ const int mMagic;
};
#endif // FILESTREEMODEL_H