diff --git a/src/core/EntryAttributes.cpp b/src/core/EntryAttributes.cpp index e9505e65..1f5b0931 100644 --- a/src/core/EntryAttributes.cpp +++ b/src/core/EntryAttributes.cpp @@ -100,6 +100,23 @@ void EntryAttributes::remove(const QString& key) Q_EMIT modified(); } +void EntryAttributes::rename(const QString& oldKey, const QString& newKey) +{ + Q_ASSERT(!isDefaultAttribute(oldKey)); + Q_ASSERT(!isDefaultAttribute(newKey)); + + if (!m_attributes.contains(oldKey)) { + Q_ASSERT(false); + return; + } + + QString data = value(oldKey); + bool protect = isProtected(oldKey); + + remove(oldKey); + set(newKey, data, protect); +} + void EntryAttributes::copyCustomKeysFrom(const EntryAttributes* other) { if (!areCustomKeysDifferent(other)) { diff --git a/src/core/EntryAttributes.h b/src/core/EntryAttributes.h index 43c0fd7f..2dc63fa8 100644 --- a/src/core/EntryAttributes.h +++ b/src/core/EntryAttributes.h @@ -34,6 +34,7 @@ public: bool isProtected(const QString& key) const; void set(const QString& key, const QString& value, bool protect = false); void remove(const QString& key); + void rename(const QString& oldKey, const QString& newKey); void copyCustomKeysFrom(const EntryAttributes* other); bool areCustomKeysDifferent(const EntryAttributes* other); void clear();