32 const QString storageLocation =
34 const QString resourceType = query.value(
"resource_type").toString();
35 const QString filename = query.value(useResourcePrefix ?
"resource_filename" :
"filename").toString();
44 const int resourceId = query.value(useResourcePrefix ?
"resource_id" :
"id").toInt();
49 result = thumbQuery.prepare(
"SELECT thumbnail FROM resources WHERE resources.id = :resource_id");
51 qWarning() <<
"Failed to prepare query for thumbnail of" << resourceId << thumbQuery.lastError();
55 thumbQuery.bindValue(
":resource_id", resourceId);
57 result = thumbQuery.exec();
60 qWarning() <<
"Failed to execute query for thumbnail of" << resourceId << thumbQuery.lastError();
64 if (!thumbQuery.next()) {
65 qWarning() <<
"Failed to find thumbnail of" << resourceId;
69 QByteArray ba = thumbQuery.value(
"thumbnail").toByteArray();
71 buf.open(QBuffer::ReadOnly);
72 img.load(&buf,
"PNG");
81 const QString resourceType = query.value(
"resource_type").toString();
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");
104 return query.value(useResourcePrefix ?
"resource_active" :
"status");
106 return query.value(
"location");
108 return query.value(
"resource_type");
111 QString storageLocation = query.value(
"location").toString();
112 QString filename = query.value(useResourcePrefix ?
"resource_filename" :
"filename").toString();
121 return resource->isDirty();
125 return query.value(
"resource_active");
127 return query.value(useResourcePrefix ?
"resource_storage_active" :
"storage_active");
133 case Qt::DecorationRole:
140 case Qt::CheckStateRole: {
143 if (query.value(useResourcePrefix ?
"resource_active" :
"status").toInt() == 0) {
144 return Qt::Unchecked;
149 const QString storageLocation = query.value(
"location").toString();
150 const QString filename = query.value(useResourcePrefix ?
"resource_filename" :
"filename").toString();
154 return Qt::Unchecked;
158 query.value(useResourcePrefix ?
"resource_id" :
"id").toInt());
159 return resource->isDirty() ? Qt::Checked : Qt::Unchecked;
163 if (query.value(
"resource_active").toInt() == 0) {
164 return Qt::Unchecked;
169 if (query.value(useResourcePrefix ?
"resource_storage_active" :
"storage_active").toInt() == 0) {
170 return Qt::Unchecked;
178 case Qt::StatusTipRole:
180 case Qt::ToolTipRole:
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");
201 return query.value(useResourcePrefix ?
"resource_active" :
"status");
203 return query.value(
"location");
205 return query.value(
"resource_type");
210 Q_FOREACH(
const KisTagSP tag, resourceModel->
tagsForResource(query.value(useResourcePrefix ?
"resource_id" :
"id").toInt())) {
211 tagNames << tag->name();
217 QString storageLocation = query.value(
"location").toString();
218 QString filename = query.value(useResourcePrefix ?
"resource_filename" :
"filename").toString();
227 return resource->isDirty();
237 return query.value(
"resource_active");
241 return query.value(useResourcePrefix ?
"resource_storage_active" :
"storage_active");
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.";
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;
279 if (!missingResources.isEmpty()) {
280 QString resourcesList;
281 Q_FOREACH (
const QString &resource, missingResources) {
282 resourcesList +=
"<li>" + resource +
"</li>";
287 "<ul style=\"list-style-type: disc; margin: 0px;\">%2</ul>")
288 .arg(i18n(
"Some resources are missing:"), resourcesList);
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 ...