1 /*
2     SPDX-FileCopyrightText: 2010 Daniel Laidig <laidig@kde.org>
3     SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #ifndef PRACTICE_IMAGECACHE_H
7 #define PRACTICE_IMAGECACHE_H
8 
9 #include <QDateTime>
10 #include <QHash>
11 #include <QImage>
12 #include <QStringList>
13 
14 class QSize;
15 class QDebug;
16 
17 namespace Practice
18 {
19 class ImageCache
20 {
21 public:
ImageCache()22     ImageCache()
23     {
24     }
25     // set a list of filenames which should be checked for timestamps
26     void setFilenames(const QStringList &filename);
27 
28     void updateImage(const QString &id, const QImage &image);
29     QSize imageSize(const QString &id);
30     QImage getImage(const QString &id);
isEmpty()31     bool isEmpty()
32     {
33         return m_images.isEmpty();
34     }
35 
36     void setSaveFilename(const QString &filename);
37     void openCache();
38     void saveCache();
39 
40     friend QDebug operator<<(QDebug dbg, const Practice::ImageCache &c);
41 
42 private:
43     QHash<QString, QImage> m_images;
44     QList<QDateTime> m_timestamps;
45     QStringList m_filenames;
46     QString m_saveFilename;
47 };
48 
49 QDebug operator<<(QDebug dbg, const Practice::ImageCache &c);
50 
51 }
52 
53 #endif // PRACTICE_IMAGECACHE_H
54