diff options
author | Felix Geyer <debfx@fobos.de> | 2011-07-07 14:42:08 +0400 |
---|---|---|
committer | Felix Geyer <debfx@fobos.de> | 2011-07-07 14:42:08 +0400 |
commit | be934b2fcece56b4ba4f9a733721cc85a5f653a3 (patch) | |
tree | 2946e4b6a00de7ee4d1a3be68e89a153f054eb7d /src | |
parent | a299dd9715443efd2bfb35f3ba155b2e06f4a0a7 (diff) |
Always add the default attributes to Entry and don't allow to delete them.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/Entry.cpp | 16 | ||||
-rw-r--r-- | src/core/Entry.h | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index a71ffae31..baabcde57 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -22,12 +22,18 @@ #include "Group.h" #include "Metadata.h" +const QStringList Entry::m_defaultAttibutes(QStringList() << "Title" << "URL" << "UserName" << "Password" << "Notes"); + Entry::Entry() { m_group = 0; m_db = 0; m_iconNumber = 0; // TODO change? + + Q_FOREACH (const QString& key, m_defaultAttibutes) { + addAttribute(key, ""); + } } Entry::~Entry() @@ -226,14 +232,15 @@ void Entry::addAttribute(const QString& key, const QString& value, bool protect) m_protectedAttributes.insert(key); } - // TODO add all visible columns - if (key == "Title") { + if (isDefaultAttributue(key)) { Q_EMIT dataChanged(this); } } void Entry::removeAttribute(const QString& key) { + Q_ASSERT(!isDefaultAttributue(key)); + m_attributes.remove(key); m_protectedAttributes.remove(key); } @@ -309,3 +316,8 @@ void Entry::setGroup(Group* group) m_db = group->database(); QObject::setParent(group); } + +bool Entry::isDefaultAttributue(const QString& key) +{ + return m_defaultAttibutes.contains(key); +} diff --git a/src/core/Entry.h b/src/core/Entry.h index b1fc8e77f..303f12da8 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -95,6 +95,7 @@ public: Group* group(); void setGroup(Group* group); + static bool isDefaultAttributue(const QString& key); Q_SIGNALS: void dataChanged(Entry* entry); @@ -120,6 +121,7 @@ private: QList<Entry*> m_history; Group* m_group; const Database* m_db; + const static QStringList m_defaultAttibutes; }; #endif // KEEPASSX_ENTRY_H |