80{
81 const QString resourceType = query.value("resource_type").toString();
82
83 switch(role) {
84 case Qt::FontRole:
85 return QFont();
86 case Qt::DisplayRole:
87 {
88 switch(column) {
90 return query.value(useResourcePrefix ? "resource_id" : "id");
92 return query.value("storage_id");
94 return query.value(useResourcePrefix ? "resource_name" : "name");
96 return query.value(useResourcePrefix ? "resource_filename" : "filename");
98 return query.value(useResourcePrefix ? "resource_tooltip" : "tooltip");
100 {
102 }
104 return query.value(useResourcePrefix ? "resource_active" : "status");
106 return query.value("location");
108 return query.value("resource_type");
110 {
111 QString storageLocation = query.value("location").toString();
112 QString filename = query.value(useResourcePrefix ?
"resource_filename" :
"filename").
toString();
113
114
116 return false;
117 }
118 else {
119
121 return resource->isDirty();
122 }
123 }
125 return query.value("resource_active");
127 return query.value(useResourcePrefix ? "resource_storage_active" : "storage_active");
128 default:
129 ;
130 };
131 Q_FALLTHROUGH();
132 }
133 case Qt::DecorationRole:
134 {
137 }
138 return QVariant();
139 }
140 case Qt::CheckStateRole: {
141 switch (column) {
143 if (query.value(useResourcePrefix ?
"resource_active" :
"status").
toInt() == 0) {
144 return Qt::Unchecked;
145 } else {
146 return Qt::Checked;
147 }
149 const QString storageLocation = query.value("location").toString();
150 const QString filename = query.value(useResourcePrefix ?
"resource_filename" :
"filename").
toString();
151
152
154 return Qt::Unchecked;
155 } else {
156
158 query.value(useResourcePrefix ?
"resource_id" :
"id").
toInt());
159 return resource->isDirty() ? Qt::Checked : Qt::Unchecked;
160 }
161 }
163 if (query.value("resource_active").toInt() == 0) {
164 return Qt::Unchecked;
165 } else {
166 return Qt::Checked;
167 }
169 if (query.value(useResourcePrefix ?
"resource_storage_active" :
"storage_active").
toInt() == 0) {
170 return Qt::Unchecked;
171 } else {
172 return Qt::Checked;
173 }
174 default:
175 return {};
176 };
177 }
178 case Qt::StatusTipRole:
179 return QVariant();
180 case Qt::ToolTipRole:
181 Q_FALLTHROUGH();
182 case Qt::WhatsThisRole:
183 return query.value(useResourcePrefix ? "resource_tooltip" : "tooltip");
185 return query.value(useResourcePrefix ? "resource_id" : "id");
187 return query.value("storage_id");
189 return query.value(useResourcePrefix ? "resource_name" : "name");
191 return query.value(useResourcePrefix ? "resource_filename" : "filename");
193 return query.value(useResourcePrefix ? "resource_tooltip" : "tooltip");
195 return query.value(useResourcePrefix ? "resource_md5sum" : "md5sum");
197 {
199 }
201 return query.value(useResourcePrefix ? "resource_active" : "status");
203 return query.value("location");
205 return query.value("resource_type");
207 {
211 tagNames << tag->name();
212 }
213 return tagNames;
214 }
216 {
217 QString storageLocation = query.value("location").toString();
218 QString filename = query.value(useResourcePrefix ?
"resource_filename" :
"filename").
toString();
219
220
222 return false;
223 }
224 else {
225
227 return resource->isDirty();
228 }
229 }
231 {
234 }
236 {
237 return query.value("resource_active");
238 }
240 {
241 return query.value(useResourcePrefix ? "resource_storage_active" : "storage_active");
242 }
244 {
247 const int id = query.value(useResourcePrefix ?
"resource_id" :
"id").
toInt();
249 metaDataModel->
metaDataValue(
id,
"dependent_resources_filenames").toStringList();
250 if (!requiredBrushes.isEmpty()) {
252 Q_FOREACH (const QString brushFile, requiredBrushes) {
254 qWarning() << "dependent resource" << brushFile << "misses.";
255 return true;
256 }
257 }
258 }
259 }
260
261 return false;
262 }
264 {
267 const int id = query.value(useResourcePrefix ?
"resource_id" :
"id").
toInt();
269 metaDataModel->
metaDataValue(
id,
"dependent_resources_filenames").toStringList();
271 if (!requiredBrushes.isEmpty()) {
273 Q_FOREACH (const QString brushFile, requiredBrushes) {
275 missingResources << brushFile;
276 break;
277 }
278 }
279 if (!missingResources.isEmpty()) {
280 QString resourcesList;
281 Q_FOREACH (const QString &resource, missingResources) {
282 resourcesList += "<li>" + resource + "</li>";
283 }
284
285 return QString(
286 "%1</br>"
287 "<ul style=\"list-style-type: disc; margin: 0px;\">%2</ul>")
288 .arg(i18n("Some resources are missing:"), resourcesList);
289 }
290 }
291 }
292 return QVariant();
293 }
294 default:
295 ;
296 }
297
298 return QVariant();
299}
@ Status
Whether the resource is active. Duplicate of ResourceActive.
@ ResourceActive
Whether the current resource is active.
@ Dirty
A dirty resource is one that has been modified locally but not saved.
@ MetaData
MetaData is a map of key, value pairs that is associated with this resource.
@ BrokenStatus
Whether the resource is broken (bool)
@ StorageActive
Whether the current resource's storage is active.
The KisAllresourcesModel class provides access to the cache database for a particular resource type....
bool resourceExists(const QString &md5, const QString &filename, const QString &name)
resourceExists checks whether there is a resource with, in order, the given md5, the filename or the ...
QVector< KisTagSP > tagsForResource(int resourceId) const
QMap< QString, QVariant > metaDataForResource(int id) const
metaDataForResource
KoResourceSP resourceForId(int resourceId)
resourceForId returns the resource with the given id, or 0 if no such resource exists....
static KisAllResourcesModel * resourceModel(const QString &resourceType)
static KisResourceMetaDataModel * resourceMetadataModel()
static QImage getThumbnailFromQuery(const QSqlQuery &query, bool useResourcePrefix)
const QString PaintOpPresets