Commit 14d2d4a6 authored by Alberto Mardegan's avatar Alberto Mardegan

Writer: keep Metadata alive

Put the Metadata class as a member of Writer, in order to ensure it has
the same lifetime.
Then there's no need to keep the boolean "embed" field: we just mirror
the one from Metadata.
parent da854c94
...@@ -60,16 +60,17 @@ public: ...@@ -60,16 +60,17 @@ public:
void setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags, bool adding); void setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags, bool adding);
private: private:
bool m_embed; Metadata m_metadata;
mutable Writer *q_ptr; mutable Writer *q_ptr;
}; };
} // namespace } // namespace
WriterPrivate::WriterPrivate(Writer *q): WriterPrivate::WriterPrivate(Writer *q):
m_embed(false),
q_ptr(q) q_ptr(q)
{ {
QObject::connect(&m_metadata, SIGNAL(embedChanged()),
q, SIGNAL(embedChanged()));
} }
WriterPrivate::~WriterPrivate() WriterPrivate::~WriterPrivate()
...@@ -81,9 +82,6 @@ void WriterPrivate::setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags, ...@@ -81,9 +82,6 @@ void WriterPrivate::setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags,
{ {
Database *db = Database::instance(); Database *db = Database::instance();
Metadata metadata;
metadata.setEmbed(m_embed);
db->transaction(); db->transaction();
Q_FOREACH(PhotoId id, ids) { Q_FOREACH(PhotoId id, ids) {
...@@ -111,8 +109,8 @@ void WriterPrivate::setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags, ...@@ -111,8 +109,8 @@ void WriterPrivate::setPhotoTags(QList<PhotoId> ids, const QList<Tag> &tags,
db->setTags(id, tags); db->setTags(id, tags);
} }
metadata.writeTags(photo.url().toLocalFile(), m_metadata.writeTags(photo.url().toLocalFile(),
Tag::tagNames(metadataTags)); Tag::tagNames(metadataTags));
} }
db->commit(); db->commit();
...@@ -132,15 +130,13 @@ Writer::~Writer() ...@@ -132,15 +130,13 @@ Writer::~Writer()
void Writer::setEmbed(bool embed) void Writer::setEmbed(bool embed)
{ {
Q_D(Writer); Q_D(Writer);
if (d->m_embed == embed) return; d->m_metadata.setEmbed(embed);
d->m_embed = embed;
Q_EMIT embedChanged();
} }
bool Writer::embed() const bool Writer::embed() const
{ {
Q_D(const Writer); Q_D(const Writer);
return d->m_embed; return d->m_metadata.embed();
} }
void Writer::setPhotoTags(const QVariant &photoIds, const QList<Tag> &tags) void Writer::setPhotoTags(const QVariant &photoIds, const QList<Tag> &tags)
......
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