QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
elementscollectioncache.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef ELEMENTS_COLLECTION_CACHE_H
19#define ELEMENTS_COLLECTION_CACHE_H
20
22
23#include <QSqlDatabase>
24
31class ElementsCollectionCache : public QObject
32{
33 public:
34 // constructor, destructor
35 ElementsCollectionCache(const QString &database_path,
36 QObject * = nullptr);
37 ~ElementsCollectionCache() override;
38
39 // methods
40 public:
41 void setLocale(const QString &);
42 QString locale() const;
43 bool setPixmapStorageFormat(const QString &);
44 QString pixmapStorageFormat() const;
45 bool fetchElement(ElementsLocation &location);
46 QString name() const;
47 QPixmap pixmap() const;
48 bool fetchData(const ElementsLocation &);
49 bool fetchNameFromCache(const QString &path, const QUuid &uuid);
50 bool fetchPixmapFromCache(const QString &path, const QUuid &uuid);
51 bool cacheName(const QString &path,
52 const QUuid &uuid = QUuid::createUuid());
53 bool cachePixmap(const QString &path,
54 const QUuid &uuid = QUuid::createUuid());
55
56 // attributes
57 private:
58 QSqlDatabase cache_db_;
59 QSqlQuery *select_name_;
60 QSqlQuery *select_pixmap_;
61 QSqlQuery *insert_name_;
62 QSqlQuery *insert_pixmap_;
63 QString locale_;
65 QString current_name_;
67};
68#endif
Definition elementscollectioncache.h:32
QSqlQuery * insert_name_
Prepared statement to insert names into the cache.
Definition elementscollectioncache.h:61
bool fetchNameFromCache(const QString &path, const QUuid &uuid)
ElementsCollectionCache::fetchNameFromCache Retrieve the name for an element, given its path and uuid...
Definition elementscollectioncache.cpp:223
bool setPixmapStorageFormat(const QString &)
Definition elementscollectioncache.cpp:121
bool cachePixmap(const QString &path, const QUuid &uuid=QUuid::createUuid())
ElementsCollectionCache::cachePixmap Cache the current (i.e. last retrieved) pixmap.
Definition elementscollectioncache.cpp:306
QSqlQuery * select_pixmap_
Prepared statement to fetch pixmaps from the cache.
Definition elementscollectioncache.h:60
void setLocale(const QString &)
Definition elementscollectioncache.cpp:103
QString pixmapStorageFormat() const
Definition elementscollectioncache.cpp:133
bool cacheName(const QString &path, const QUuid &uuid=QUuid::createUuid())
ElementsCollectionCache::cacheName Cache the current (i.e. last retrieved) name The cache entry will ...
Definition elementscollectioncache.cpp:283
QString current_name_
Last name fetched.
Definition elementscollectioncache.h:65
bool fetchData(const ElementsLocation &)
Definition elementscollectioncache.cpp:199
QPixmap pixmap() const
Definition elementscollectioncache.cpp:187
QSqlDatabase cache_db_
Object providing access to the SQLite database this cache relies on.
Definition elementscollectioncache.h:58
QString name() const
Definition elementscollectioncache.cpp:179
QSqlQuery * insert_pixmap_
Prepared statement to insert pixmaps into the cache.
Definition elementscollectioncache.h:62
QString pixmap_storage_format_
Storage format for cached pixmaps.
Definition elementscollectioncache.h:64
QString locale_
Locale to be used when dealing with names.
Definition elementscollectioncache.h:63
bool fetchElement(ElementsLocation &location)
ElementsCollectionCache::fetchElement Retrieve the data for a given element, using the cache if avail...
Definition elementscollectioncache.cpp:147
QPixmap current_pixmap_
Last pixmap fetched.
Definition elementscollectioncache.h:66
bool fetchPixmapFromCache(const QString &path, const QUuid &uuid)
ElementsCollectionCache::fetchPixmapFromCache Retrieve the pixmap for an element, given its path and ...
Definition elementscollectioncache.cpp:252
~ElementsCollectionCache() override
Definition elementscollectioncache.cpp:90
QSqlQuery * select_name_
Prepared statement to fetch names from the cache.
Definition elementscollectioncache.h:59
QString locale() const
Definition elementscollectioncache.cpp:110
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition elementslocation.h:47