summaryrefslogtreecommitdiffstats
path: root/gui/pages/ScreenshotsPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/pages/ScreenshotsPage.cpp')
-rw-r--r--gui/pages/ScreenshotsPage.cpp61
1 files changed, 1 insertions, 60 deletions
diff --git a/gui/pages/ScreenshotsPage.cpp b/gui/pages/ScreenshotsPage.cpp
index f3ec0c1d..466b3c19 100644
--- a/gui/pages/ScreenshotsPage.cpp
+++ b/gui/pages/ScreenshotsPage.cpp
@@ -21,66 +21,7 @@
#include "logic/screenshots/ImgurAlbumCreation.h"
#include "logic/tasks/SequentialTask.h"
-template <typename K, typename V>
-class RWStorage
-{
-public:
- void add(K key, V value)
- {
- QWriteLocker l(&lock);
- cache[key] = value;
- stale_entries.remove(key);
- }
- V get(K key)
- {
- QReadLocker l(&lock);
- if(cache.contains(key))
- {
- return cache[key];
- }
- else return V();
- }
- bool get(K key, V& value)
- {
- QReadLocker l(&lock);
- if(cache.contains(key))
- {
- value = cache[key];
- return true;
- }
- else return false;
- }
- bool has(K key)
- {
- QReadLocker l(&lock);
- return cache.contains(key);
- }
- bool stale(K key)
- {
- QReadLocker l(&lock);
- if(!cache.contains(key))
- return true;
- return stale_entries.contains(key);
- }
- void setStale(K key)
- {
- QReadLocker l(&lock);
- if(cache.contains(key))
- {
- stale_entries.insert(key);
- }
- }
- void clear()
- {
- QWriteLocker l(&lock);
- cache.clear();
- }
-private:
- QReadWriteLock lock;
- QMap<K, V> cache;
- QSet<K> stale_entries;
-};
-
+#include "logic/RWStorage.h"
typedef RWStorage<QString, QIcon> SharedIconCache;
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr;