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 m_history; Group* m_group; const Database* m_db; + const static QStringList m_defaultAttibutes; }; #endif // KEEPASSX_ENTRY_H