Krita Source Code Documentation
Loading...
Searching...
No Matches
KisResourceCacheDb.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef KISRESOURCECACHEDB_H
8#define KISRESOURCECACHEDB_H
9
10#include <QObject>
11
12#include <kritaresources_export.h>
13
14#include <KisResourceStorage.h>
15
23class KRITARESOURCES_EXPORT KisResourceCacheDb
24{
25public:
26
27 static const QString resourceCacheDbFilename;
28 static const QString databaseVersion;
29 static QStringList storageTypes;
30 static QStringList disabledBundles;
31
36 static bool isValid();
37
41 static QString lastError();
42
50 static bool initialize(const QString &location);
53 static void deleteTemporaryResources();
54
56 static void performHouseKeepingOnExit();
57
61 static void setForeignKeysStateImpl(bool isEnabled);
62
66 static bool getForeignKeysStateImpl();
67
72 static void synchronizeForeignKeysState();
73
74private:
75
76 friend class KisResourceLocator;
77 friend class TestResourceLocator;
78 friend class TestResourceCacheDb;
79 friend class KisAllTagsModel;
82 friend class KisDocument;
84
85 explicit KisResourceCacheDb(); // Deleted
86 ~KisResourceCacheDb(); // Deleted
93 static bool registerResourceType(const QString &resourceType);
94
95 static QVector<int> resourcesForStorage(const QString &resourceType, const QString &storageLocation);
96 static int resourceIdForResource(const QString &resourceFileName, const QString &resourceType, const QString &storageLocation);
97 static bool resourceNeedsUpdating(int resourceId, QDateTime timestamp);
98
108 static bool addResourceVersion(int resourceId, QDateTime timestamp, KisResourceStorageSP storage, KoResourceSP resource);
109
110 static bool addResourceVersionImpl(int resourceId, QDateTime timestamp, KisResourceStorageSP storage, KoResourceSP resource);
111 static bool removeResourceVersionImpl(int resourceId, int version, KisResourceStorageSP storage);
112
113 static bool updateResourceTableForResourceIfNeeded(int resourceId, const QString &resourceType, KisResourceStorageSP storage);
114 static bool makeResourceTheCurrentVersion(int resourceId, KoResourceSP resource);
115 static bool removeResourceCompletely(int resourceId);
116
118 static bool getResourceIdFromFilename(QString filename, QString resourceType, QString storageLocation, int &outResourceId);
120 static bool getResourceIdFromVersionedFilename(QString filename, QString resourceType, QString storageLocation, int& outResourceId);
121 static bool getAllVersionsLocations(int resourceId, QStringList &outVersionsLocationsList);
122
123
124 static bool addResource(KisResourceStorageSP storage, QDateTime timestamp, KoResourceSP resource, const QString &resourceType);
125 static bool addResources(KisResourceStorageSP storage, QString resourceType);
126
128 static bool setResourceActive(int resourceId, bool active = false);
129
130 static bool tagResource(const QString &resourceFileName, KisTagSP tag, const QString &resourceType);
131 static bool hasTag(const QString &url, const QString &resourceType);
132 static bool linkTagToStorage(const QString &url, const QString &resourceType, const QString &storageLocation);
133 static bool addTag(const QString &resourceType, const QString storageLocation, KisTagSP tag);
134 static bool addTags(KisResourceStorageSP storage, QString resourceType);
135
141 static bool registerStorageType(const KisResourceStorage::StorageType storageType);
142 static bool addStorage(KisResourceStorageSP storage, bool preinstalled);
143 static bool addStorageTags(KisResourceStorageSP storage);
144
146 static bool deleteStorage(KisResourceStorageSP storage);
149 static bool deleteStorage(QString location);
150 static bool synchronizeStorage(KisResourceStorageSP storage);
151
158 static QMap<QString, QVariant> metaDataForId(int id, const QString &tableName);
159
167 static bool updateMetaDataForId(const QMap<QString, QVariant> map, int id, const QString &tableName);
168 static bool addMetaDataForId(const QMap<QString, QVariant> map, int id, const QString &tableName);
169
176 static bool removeOrphanedMetaData();
177
178 static bool s_valid;
179 static QString s_lastError;
180};
181
182#endif // KISRESOURCECACHEDB_H
The KisAllresourcesModel class provides access to the cache database for a particular resource type....
The KisResourceCacheDb class encapsulates the database that caches information about the resources av...
KisResourceCacheDb operator=(const KisResourceCacheDb &)
The KisResourceLoaderRegistry class manages the loader plugins for resources. Every resource can be l...