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 "Group.h"
#include "Metadata.h" #include "Metadata.h"
const QStringList Entry::m_defaultAttibutes(QStringList() << "Title" << "URL" << "UserName" << "Password" << "Notes");
Entry::Entry() Entry::Entry()
{ {
m_group = 0; m_group = 0;
m_db = 0; m_db = 0;
m_iconNumber = 0; // TODO change? m_iconNumber = 0; // TODO change?
Q_FOREACH (const QString& key, m_defaultAttibutes) {
addAttribute(key, "");
}
} }
Entry::~Entry() Entry::~Entry()
@ -226,14 +232,15 @@ void Entry::addAttribute(const QString& key, const QString& value, bool protect)
m_protectedAttributes.insert(key); m_protectedAttributes.insert(key);
} }
// TODO add all visible columns if (isDefaultAttributue(key)) {
if (key == "Title") {
Q_EMIT dataChanged(this); Q_EMIT dataChanged(this);
} }
} }
void Entry::removeAttribute(const QString& key) void Entry::removeAttribute(const QString& key)
{ {
Q_ASSERT(!isDefaultAttributue(key));
m_attributes.remove(key); m_attributes.remove(key);
m_protectedAttributes.remove(key); m_protectedAttributes.remove(key);
} }
@ -309,3 +316,8 @@ void Entry::setGroup(Group* group)
m_db = group->database(); m_db = group->database();
QObject::setParent(group); QObject::setParent(group);
} }
bool Entry::isDefaultAttributue(const QString& key)
{
return m_defaultAttibutes.contains(key);
}

View file

@ -95,6 +95,7 @@ public:
Group* group(); Group* group();
void setGroup(Group* group); void setGroup(Group* group);
static bool isDefaultAttributue(const QString& key);
Q_SIGNALS: Q_SIGNALS:
void dataChanged(Entry* entry); void dataChanged(Entry* entry);
@ -120,6 +121,7 @@ private:
QList<Entry*> m_history; QList<Entry*> m_history;
Group* m_group; Group* m_group;
const Database* m_db; const Database* m_db;
const static QStringList m_defaultAttibutes;
}; };
#endif // KEEPASSX_ENTRY_H #endif // KEEPASSX_ENTRY_H