1 /*
2 * This file is part of Converseen, an open-source batch image converter
3 * and resizer.
4 *
5 * (C) Francesco Mondello 2009 - 2021
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 *
22 */
23 
24 #ifndef CACHINGSYSTEM_H
25 #define CACHINGSYSTEM_H
26 
27 #include <QCache>
28 #include <QImage>
29 
30 class CachedImageObject
31 {
32 public:
33     QImage thumbnail;
34     QString id;
35     int orig_w;
36     int orig_h;
37     double orig_dens_x;
38     double orig_dens_y;
39 };
40 
41 class CachingSystem
42 {
43 public:
44     static void init();
45     static void insert(QString id, QImage thumbnail, int orig_w, int orig_h, double orig_dens_x, double orig_dens_y);
46     static bool find(QString key);
47     static void clear();
48     static void remove(QString key);
49 
50     static QImage thumbnail();
51     static int originalWidth();
52     static int originalHeight();
53     static double originalDensityX();
54     static double originalDensityY();
55 
56     static QCache<QString, CachedImageObject> *imageCache;
57 private:
58     static CachedImageObject *currObj;
59     static int m_orig_w;
60 };
61 
62 #endif // CACHINGSYSTEM_H
63