QElectroTech 0.100.0-dev
|
#include <elementscollectioncache.h>
Inherits QObject.
Public Member Functions | |
ElementsCollectionCache (const QString &database_path, QObject *=nullptr) | |
~ElementsCollectionCache () override | |
void | setLocale (const QString &) |
QString | locale () const |
bool | setPixmapStorageFormat (const QString &) |
QString | pixmapStorageFormat () const |
bool | fetchElement (ElementsLocation &location) |
ElementsCollectionCache::fetchElement Retrieve the data for a given element, using the cache if available, filling it otherwise. Data are then available through pixmap() and name() methods. | |
QString | name () const |
QPixmap | pixmap () const |
bool | fetchData (const ElementsLocation &) |
bool | fetchNameFromCache (const QString &path, const QUuid &uuid) |
ElementsCollectionCache::fetchNameFromCache Retrieve the name for an element, given its path and uuid The value is then available through the name() method. | |
bool | fetchPixmapFromCache (const QString &path, const QUuid &uuid) |
ElementsCollectionCache::fetchPixmapFromCache Retrieve the pixmap for an element, given its path and uuid. It is then available through the pixmap() method. | |
bool | cacheName (const QString &path, const QUuid &uuid=QUuid::createUuid()) |
ElementsCollectionCache::cacheName Cache the current (i.e. last retrieved) name The cache entry will use the locale set via setLocale(). | |
bool | cachePixmap (const QString &path, const QUuid &uuid=QUuid::createUuid()) |
ElementsCollectionCache::cachePixmap Cache the current (i.e. last retrieved) pixmap. | |
Private Attributes | |
QSqlDatabase | cache_db_ |
Object providing access to the SQLite database this cache relies on. | |
QSqlQuery * | select_name_ |
Prepared statement to fetch names from the cache. | |
QSqlQuery * | select_pixmap_ |
Prepared statement to fetch pixmaps from the cache. | |
QSqlQuery * | insert_name_ |
Prepared statement to insert names into the cache. | |
QSqlQuery * | insert_pixmap_ |
Prepared statement to insert pixmaps into the cache. | |
QString | locale_ |
Locale to be used when dealing with names. | |
QString | pixmap_storage_format_ |
Storage format for cached pixmaps. | |
QString | current_name_ |
Last name fetched. | |
QPixmap | current_pixmap_ |
Last pixmap fetched. | |
This class implements a SQLite cache for data related to elements collections, mainly names and pixmaps. This avoids the cost of parsing XML definitions of elements and building full CustomElement objects when (re)loading the elements panel.
ElementsCollectionCache::ElementsCollectionCache | ( | const QString & | database_path, |
QObject * | parent = nullptr |
||
) |
Construct a cache for elements collections.
database_path | Path of the SQLite database to open. |
parent | Parent QObject |
|
override |
Destructor
bool ElementsCollectionCache::cacheName | ( | const QString & | path, |
const QUuid & | uuid = QUuid::createUuid() |
||
) |
ElementsCollectionCache::cacheName Cache the current (i.e. last retrieved) name The cache entry will use the locale set via setLocale().
path | : Element path (as obtained using ElementsLocation::toString()) |
uuid | :Element uuid |
bool ElementsCollectionCache::cachePixmap | ( | const QString & | path, |
const QUuid & | uuid = QUuid::createUuid() |
||
) |
ElementsCollectionCache::cachePixmap Cache the current (i.e. last retrieved) pixmap.
path | : Element path (as obtained using ElementsLocation::toString()) |
uuid | : Element uuid |
bool ElementsCollectionCache::fetchData | ( | const ElementsLocation & | location | ) |
Retrieve the data by building the full CustomElement object matching the given location, without using the cache. Data are then available through pixmap() and name() methods.
location | Location of a given Element. |
bool ElementsCollectionCache::fetchElement | ( | ElementsLocation & | location | ) |
ElementsCollectionCache::fetchElement Retrieve the data for a given element, using the cache if available, filling it otherwise. Data are then available through pixmap() and name() methods.
location | The definition of an element. |
bool ElementsCollectionCache::fetchNameFromCache | ( | const QString & | path, |
const QUuid & | uuid | ||
) |
ElementsCollectionCache::fetchNameFromCache Retrieve the name for an element, given its path and uuid The value is then available through the name() method.
path | : Element path (as obtained using ElementsLocation::toString()) |
uuid | : Element uuid |
bool ElementsCollectionCache::fetchPixmapFromCache | ( | const QString & | path, |
const QUuid & | uuid | ||
) |
ElementsCollectionCache::fetchPixmapFromCache Retrieve the pixmap for an element, given its path and uuid. It is then available through the pixmap() method.
path | : Element path (as obtained using ElementsLocation::toString()) |
uuid | : Element uuid |
QString ElementsCollectionCache::locale | ( | ) | const |
QString ElementsCollectionCache::name | ( | ) | const |
QPixmap ElementsCollectionCache::pixmap | ( | ) | const |
QString ElementsCollectionCache::pixmapStorageFormat | ( | ) | const |
void ElementsCollectionCache::setLocale | ( | const QString & | locale | ) |
Define the locale to be used when dealing with names.
locale | New locale to be used. |
bool ElementsCollectionCache::setPixmapStorageFormat | ( | const QString & | format | ) |
Define the storage format for the pixmaps within the SQLite database. See Qt's QPixmap documentation for more information.
format | The new pixmap storage format. |
|
private |
Object providing access to the SQLite database this cache relies on.
|
private |
Last name fetched.
|
private |
Last pixmap fetched.
|
private |
Prepared statement to insert names into the cache.
|
private |
Prepared statement to insert pixmaps into the cache.
|
private |
Locale to be used when dealing with names.
|
private |
Storage format for cached pixmaps.
|
private |
Prepared statement to fetch names from the cache.
|
private |
Prepared statement to fetch pixmaps from the cache.