diff --git a/src/core/EntryAttachments.cpp b/src/core/EntryAttachments.cpp index a53d0f93..2843f931 100644 --- a/src/core/EntryAttachments.cpp +++ b/src/core/EntryAttachments.cpp @@ -112,6 +112,10 @@ void EntryAttachments::copyFrom(const EntryAttachments* other) void EntryAttachments::clear() { + if (m_attachments.isEmpty()) { + return; + } + Q_EMIT aboutToBeReset(); m_attachments.clear(); diff --git a/src/core/EntryAttributes.cpp b/src/core/EntryAttributes.cpp index 36cf3a6a..dd27b82e 100644 --- a/src/core/EntryAttributes.cpp +++ b/src/core/EntryAttributes.cpp @@ -22,9 +22,7 @@ const QStringList EntryAttributes::m_defaultAttibutes(QStringList() << "Title" < EntryAttributes::EntryAttributes(QObject* parent) : QObject(parent) { - Q_FOREACH (const QString& key, m_defaultAttibutes) { - set(key, ""); - } + clear(); } QList EntryAttributes::keys() const @@ -123,11 +121,19 @@ void EntryAttributes::copyFrom(const EntryAttributes* other) void EntryAttributes::clear() { + if (m_attributes.keys().size() == m_defaultAttibutes.size() && m_protectedAttributes.isEmpty()) { + return; + } + Q_EMIT aboutToBeReset(); m_attributes.clear(); m_protectedAttributes.clear(); + Q_FOREACH (const QString& key, m_defaultAttibutes) { + m_attributes.insert(key, ""); + } + Q_EMIT reset(); Q_EMIT modified(); }