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
102 static std::pair<QVector<int>,QVector<int>> tagsForStorage(const QString &resourceType, const QString &storageLocation);
106 static QVector<int> resourcesForStorage(const QString &resourceType, const QString &storageLocation);
107 static int resourceIdForResource(const QString &resourceFileName, const QString &resourceType, const QString &storageLocation);
108 static bool resourceNeedsUpdating(int resourceId, QDateTime timestamp);
109
119 static bool addResourceVersion(int resourceId, QDateTime timestamp, KisResourceStorageSP storage, KoResourceSP resource);
120
121 static bool addResourceVersionImpl(int resourceId, QDateTime timestamp, KisResourceStorageSP storage, KoResourceSP resource);
122 static bool removeResourceVersionImpl(int resourceId, int version, KisResourceStorageSP storage);
123
124 static bool updateResourceTableForResourceIfNeeded(int resourceId, const QString &resourceType, KisResourceStorageSP storage);
125 static bool makeResourceTheCurrentVersion(int resourceId, KoResourceSP resource);
126 static bool removeResourceCompletely(int resourceId);
127
129 static bool getResourceIdFromFilename(QString filename, QString resourceType, QString storageLocation, int &outResourceId);
131 static bool getResourceIdFromVersionedFilename(QString filename, QString resourceType, QString storageLocation, int& outResourceId);
132 static bool getAllVersionsLocations(int resourceId, QStringList &outVersionsLocationsList);
133
134
135 static bool addResource(KisResourceStorageSP storage, QDateTime timestamp, KoResourceSP resource, const QString &resourceType);
136 static bool addResources(KisResourceStorageSP storage, QString resourceType);
137
139 static bool setResourceActive(int resourceId, bool active = false);
140
141 static bool tagResource(const QString &resourceFileName, KisTagSP tag, const QString &resourceType);
142 static bool hasTag(const QString &url, const QString &resourceType);
143 static bool linkTagToStorage(const QString &url, const QString &resourceType, const QString &storageLocation);
144 static bool addTag(const QString &resourceType, const QString storageLocation, KisTagSP tag);
145 static bool addTags(KisResourceStorageSP storage, QString resourceType);
146
152 static bool registerStorageType(const KisResourceStorage::StorageType storageType);
153 static bool addStorage(KisResourceStorageSP storage, bool preinstalled);
154 static bool addStorageTags(KisResourceStorageSP storage);
155
157 static bool deleteStorage(KisResourceStorageSP storage);
160 static bool deleteStorage(QString location);
161 static bool synchronizeStorage(KisResourceStorageSP storage);
162
169 static QMap<QString, QVariant> metaDataForId(int id, const QString &tableName);
170
178 static bool updateMetaDataForId(const QMap<QString, QVariant> map, int id, const QString &tableName);
179 static bool addMetaDataForId(const QMap<QString, QVariant> map, int id, const QString &tableName);
180
187 static bool removeOrphanedMetaData();
188
189 static bool s_valid;
190 static QString s_lastError;
191};
192
193#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...