File indexing completed on 2024-04-14 03:49:10

0001 /*
0002     SPDX-FileCopyrightText: 2010 Daniel Laidig <laidig@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef PRACTICE_IMAGECACHE_H
0007 #define PRACTICE_IMAGECACHE_H
0008 
0009 #include <QDateTime>
0010 #include <QHash>
0011 #include <QImage>
0012 #include <QStringList>
0013 
0014 class QSize;
0015 class QDebug;
0016 
0017 namespace Practice
0018 {
0019 class ImageCache
0020 {
0021 public:
0022     ImageCache()
0023     {
0024     }
0025     // set a list of filenames which should be checked for timestamps
0026     void setFilenames(const QStringList &filename);
0027 
0028     void updateImage(const QString &id, const QImage &image);
0029     QSize imageSize(const QString &id);
0030     QImage getImage(const QString &id);
0031     bool isEmpty()
0032     {
0033         return m_images.isEmpty();
0034     }
0035 
0036     void setSaveFilename(const QString &filename);
0037     void openCache();
0038     void saveCache();
0039 
0040     friend QDebug operator<<(QDebug dbg, const Practice::ImageCache &c);
0041 
0042 private:
0043     QHash<QString, QImage> m_images;
0044     QList<QDateTime> m_timestamps;
0045     QStringList m_filenames;
0046     QString m_saveFilename;
0047 };
0048 
0049 QDebug operator<<(QDebug dbg, const Practice::ImageCache &c);
0050 
0051 }
0052 
0053 #endif // PRACTICE_IMAGECACHE_H