Commit aabb5113 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add tags to the database

parent 7104471e
......@@ -34,7 +34,7 @@ public:
QString url() const override { return QString(); }
QString name() const override { return QString(); }
QString comment() const override {return QString(); }
QSharedPointer<KisTag> tag() const override { return 0; }
KisTagSP tag() const override { return 0; }
private:
QString m_location;
......
......@@ -35,7 +35,7 @@ public:
QString url() const override { return QString(); }
QString name() const override { return QString(); }
QString comment() const override {return QString(); }
QSharedPointer<KisTag> tag() const override { return 0; }
KisTagSP tag() const override { return 0; }
private:
......
......@@ -36,7 +36,7 @@ public:
QString url() const override { return QString(); }
QString name() const override { return QString(); }
QString comment() const override {return QString(); }
QSharedPointer<KisTag> tag() const override { return 0; }
KisTagSP tag() const override { return 0; }
private:
......
......@@ -56,14 +56,14 @@ public:
QString name() const override { return m_tag ? m_tag->name() : QString(); }
QString comment() const override {return m_tag ? m_tag->comment() : QString(); }
QSharedPointer<KisTag> tag() const
KisTagSP tag() const
{
return m_tag;
}
private:
bool load(QSharedPointer<KisTag> tag) const
bool load(KisTagSP tag) const
{
QFile f(m_dirIterator->filePath());
if (f.exists()) {
......@@ -79,7 +79,7 @@ private:
QScopedPointer<QDirIterator> m_dirIterator;
QString m_location;
QString m_resourceType;
QSharedPointer<KisTag> m_tag;
KisTagSP m_tag;
};
......
This diff is collapsed.
......@@ -66,12 +66,14 @@ private:
KisResourceCacheDb operator=(const KisResourceCacheDb&);
static int resourceIdForResource(KoResourceSP resource, const QString &resourceType);
static bool resourceNeedsUpdating(int resourceId, QDateTime timestamp);
static bool addResourceVersion(int resourceId, QDateTime timestamp, KisResourceStorageSP storage, KoResourceSP resource);
static bool hasResource(KisResourceStorageSP storage, KoResourceSP resource, const QString &resourceType);
static bool addResource(KisResourceStorageSP storage, QDateTime timestamp, KoResourceSP resource, const QString &resourceType);
static bool addResources(KisResourceStorageSP storage, QString resourceType);
static bool addTag(KisResourceStorageSP storage, const QString &resourceType, const QString url, const QString name, const QString comment);
static bool hasTag(const QString &url, const QString &resourceType);
static bool addTag(const QString &resourceType, const QString url, const QString name, const QString comment);
static bool addTags(KisResourceStorageSP storage, QString resourceType);
static bool addStorage(KisResourceStorageSP storage, bool preinstalled);
......
......@@ -70,7 +70,7 @@ public:
virtual QString comment() const = 0;
/// A tag object on which we can set properties and which we can save
virtual QSharedPointer<KisTag> tag() const = 0;
virtual KisTagSP tag() const = 0;
};
class ResourceIterator
......
......@@ -22,6 +22,8 @@
#include <QString>
#include <QScopedPointer>
#include <QSharedPointer>
class QIODevice;
#include "kritaresources_export.h"
......@@ -66,4 +68,6 @@ private:
QScopedPointer<Private> d;
};
typedef QSharedPointer<KisTag> KisTagSP;
#endif // KISTAGLOADER_H
......@@ -16,5 +16,6 @@
<file alias="create_index_storages.sql">sql/create_index_storages.sql</file>
<file alias="select_resource.sql">sql/select_resource.sql</file>
<file alias="select_resource_id.sql">sql/select_resource_id.sql</file>
<file alias="select_tag.sql">sql/select_tag.sql</file>
</qresource>
</RCC>
......@@ -3,7 +3,8 @@ CREATE TABLE IF NOT EXISTS tags (
, url TEXT
, name TEXT
, comment TEXT
, storage_id INTEGER
, resource_type_id INTEGER
, active INTEGER
, FOREIGN KEY(storage_id) REFERENCES storages(id)
, FOREIGN KEY(resource_type_id) REFERENCES resource_types(id)
, UNIQUE (url, resource_type_id)
);
SELECT id
FROM tags
WHERE url = :url
AND resource_type_id =
(SELECT resource_type_id
FROM resource_types
WHERE name = :resource_type);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment