From 69bdaf5d1cdf2cb6a5da8371658e1c3995a71cfb Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 16 Dec 2010 19:46:34 +0100 Subject: Cache for frame grabbing Implemetented a cache for hovering over movies, saving the pictures from ffmpeg. For that SmGlobals got a new member *frameCache, handling all the dirty file access. I first tried to implement it as a helper, but that produced too much duplicate code. --- smglobals.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'smglobals.h') diff --git a/smglobals.h b/smglobals.h index 06d7b43..b994b53 100644 --- a/smglobals.h +++ b/smglobals.h @@ -10,17 +10,41 @@ #include #include +#include class QAbstractItemModel; class PictureViewer; +class QPixmap; class SmGlobals : public QObject { Q_OBJECT public: + class FrameCache : public QObject { + public: + FrameCache(QObject *parent = 0); + ~FrameCache(); + void readConfig(); + const QPixmap entry(const QString &sourcePath, const QString &when = QString()); + + private: + void readCache(); + void grabFrame(const QString &sourceFile, QString when); + QHash, QString> mFrameCache; + const qint32 mMagic; + const QString mCacheSubDir; + const QString mCacheFileName; + QString mCacheDir; + QString mCacheFile; + QString mWhen; + QString mFfMpegPath; + + }; + ~SmGlobals(); static SmGlobals *instance(); QAbstractItemModel *model(const QString &which); PictureViewer *pictureViewer(); + FrameCache *frameCache(); QSize cursorSize(); private: @@ -30,6 +54,7 @@ class SmGlobals : public QObject { static SmGlobals *mInstance; QHash mModels; PictureViewer *mPictureViewer; + SmGlobals::FrameCache *mFrameCache; QSize mCursorSize; }; -- cgit v1.2.3-70-g09d2