Add EntryAttributes::rename().

This commit is contained in:
Felix Geyer 2012-04-27 12:34:15 +02:00
parent de4b90cdf1
commit 7c094d4723
2 changed files with 18 additions and 0 deletions

View File

@ -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)) {

View File

@ -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();