MythTV  master
mythuithemecache.h
Go to the documentation of this file.
1 #ifndef MYTHUICACHE_H
2 #define MYTHUICACHE_H
3 
4 // Qt
5 #include <QMap>
6 #include <QMutex>
7 
8 // MythTV
9 #include "mythimage.h"
10 
12 {
13  kCacheNormal = 0x0,
17 };
18 
19 class MThreadPool;
20 
22 {
23  public:
26 
27  void UpdateImageCache();
28  void SetScreenSize(QSize Size);
29  void ClearThemeCacheDir();
30  QString GetThemeCacheDir();
31  MythImage* LoadCacheImage(QString File, const QString& Label,
32  MythPainter* Painter, ImageCacheMode cacheMode = kCacheNormal);
33  MythImage* CacheImage(const QString& URL, MythImage* Image, bool NoDisk = false);
34  void RemoveFromCacheByFile(const QString& File);
35  bool IsImageInCache(const QString& URL);
36  void IncludeInCacheSize(MythImage* Image);
37  void ExcludeFromCacheSize(MythImage* Image);
38  MThreadPool* GetImageThreadPool();
39 
40  private:
41  QString GetCacheDirByUrl(const QString& URL);
42  void RemoveFromCacheByURL(const QString& URL);
43  MythImage* GetImageFromCache(const QString& URL);
44  void ClearOldImageCache();
45  void RemoveCacheDir(const QString& Dir);
46  static void PruneCacheDir(const QString& Dir);
47 
48  QMap<QString, MythImage *> m_imageCache;
49  QMap<QString, qint64> m_cacheTrack;
50  QMutex m_cacheLock { QMutex::Recursive };
51 #if QT_VERSION < QT_VERSION_CHECK(5,10,0)
52  QAtomicInt m_cacheSize { 0 };
53  QAtomicInt m_maxCacheSize { 30 * 1024 * 1024 };
54 #else
55  QAtomicInteger<qint64> m_cacheSize { 0 };
56  QAtomicInteger<qint64> m_maxCacheSize { 30 * 1024 * 1024 };
57 #endif
58  QString m_themecachedir;
60  MThreadPool* m_imageThreadPool { nullptr };
61 };
62 
63 #endif
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythUIThemeCache::m_cacheScreenSize
QSize m_cacheScreenSize
Definition: mythuithemecache.h:59
MythUIThemeCache::m_imageCache
QMap< QString, MythImage * > m_imageCache
Definition: mythuithemecache.h:48
MythUIThemeCache
Definition: mythuithemecache.h:21
Image
Definition: image.h:30
MythUIThemeCache::m_themecachedir
QString m_themecachedir
Definition: mythuithemecache.h:58
kCacheCheckMemoryOnly
@ kCacheCheckMemoryOnly
Definition: mythuithemecache.h:15
ImageCacheMode
ImageCacheMode
Definition: mythuithemecache.h:11
kCacheNormal
@ kCacheNormal
Definition: mythuithemecache.h:13
kCacheForceStat
@ kCacheForceStat
Definition: mythuithemecache.h:16
kCacheIgnoreDisk
@ kCacheIgnoreDisk
Definition: mythuithemecache.h:14
MThreadPool
Definition: mthreadpool.h:17
mythimage.h
MythPainter
Definition: mythpainter.h:32
MythImage
Definition: mythimage.h:36
MythUIThemeCache::m_cacheTrack
QMap< QString, qint64 > m_cacheTrack
Definition: mythuithemecache.h:49