lolautoaccept/include/memoryimagecache.h

29 lines
586 B
C
Raw Permalink Normal View History

2022-04-23 22:28:01 +02:00
#pragma once
#include <functional>
2023-05-31 22:22:23 +02:00
#include <QString>
2022-07-02 17:44:29 +02:00
#include <QPixmap>
2022-04-23 22:28:01 +02:00
class MemoryImageCache {
public:
MemoryImageCache(size_t maxsize = 25);
2023-05-31 22:22:23 +02:00
void addImage(QPixmap, const QString& title, int type);
QPixmap getImage(const QString& title, int type);
2022-04-23 22:28:01 +02:00
private:
void cleanUp();
struct CachedImage {
time_t lastaccessed = 0;
2022-07-02 17:44:29 +02:00
QPixmap imageref;
2023-05-31 22:22:23 +02:00
QString title;
2022-04-23 22:28:01 +02:00
int type;
bool operator<(const CachedImage& other) const;
};
2023-05-31 22:22:23 +02:00
static std::function<bool(const CachedImage&)> getImageMatcher(const QString& title, int type);
2022-04-23 22:28:01 +02:00
std::list<CachedImage> cache;
size_t maxsize;
};