Always add the default attributes to Entry and don't allow to delete them.

This commit is contained in:
Felix Geyer 2011-07-07 12:42:08 +02:00
parent a299dd9715
commit be934b2fce
2 changed files with 16 additions and 2 deletions

View File

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

View File

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