Add convenience methods to access common attributes.

This commit is contained in:
Felix Geyer 2010-08-18 15:08:17 +02:00
parent 48c498890f
commit 84bc5ef463
2 changed files with 60 additions and 0 deletions

View File

@ -91,6 +91,31 @@ const QHash<QString, QByteArray>& Entry::attachments() const
return m_binaries;
}
QString Entry::title() const
{
return m_attributes.value("Title");
}
QString Entry::url() const
{
return m_attributes.value("URL");
}
QString Entry::username() const
{
return m_attributes.value("UserName");
}
QString Entry::password() const
{
return m_attributes.value("Password");
}
QString Entry::notes() const
{
return m_attributes.value("Notes");
}
void Entry::setUuid(const Uuid& uuid)
{
Q_ASSERT(!uuid.isNull());
@ -164,6 +189,31 @@ void Entry::addAttachment(const QString& key, const QByteArray& value)
m_binaries.insert(key, value);
}
void Entry::setTitle(const QString& title)
{
m_attributes.insert("Title", title);
}
void Entry::setUrl(const QString& url)
{
m_attributes.insert("URL", url);
}
void Entry::setUsername(const QString& username)
{
m_attributes.insert("UserName", username);
}
void Entry::setPassword(const QString& password)
{
m_attributes.insert("Password", password);
}
void Entry::setNotes(const QString& notes)
{
m_attributes.insert("Notes", notes);
}
void Entry::setGroup(Group* group)
{
if (m_group) {

View File

@ -53,6 +53,11 @@ public:
const QList<AutoTypeAssociation>& autoTypeAssociations() const;
const QHash<QString, QString>& attributes() const;
const QHash<QString, QByteArray>& attachments() const;
QString title() const;
QString url() const;
QString username() const;
QString password() const;
QString notes() const;
void setUuid(const Uuid& uuid);
void setIcon(int iconNumber);
@ -67,6 +72,11 @@ public:
void addAutoTypeAssociation(const AutoTypeAssociation& assoc);
void addAttribute(const QString& key, const QString& value);
void addAttachment(const QString& key, const QByteArray& value);
void setTitle(const QString& title);
void setUrl(const QString& url);
void setUsername(const QString& username);
void setPassword(const QString& password);
void setNotes(const QString& notes);
void setGroup(Group* group);