29 lines
601 B
C++
29 lines
601 B
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <QPixmap>
|
|
|
|
class MemoryImageCache {
|
|
public:
|
|
MemoryImageCache(size_t maxsize = 25);
|
|
|
|
void addImage(QPixmap, const std::string& title, int type);
|
|
QPixmap getImage(const std::string& title, int type);
|
|
private:
|
|
void cleanUp();
|
|
|
|
struct CachedImage {
|
|
time_t lastaccessed = 0;
|
|
QPixmap imageref;
|
|
std::string title;
|
|
int type;
|
|
|
|
bool operator<(const CachedImage& other) const;
|
|
};
|
|
static std::function<bool(const CachedImage&)> getImageMatcher(const std::string& title, int type);
|
|
|
|
std::list<CachedImage> cache;
|
|
size_t maxsize;
|
|
};
|