mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Implement Entry::image().
This commit is contained in:
parent
bd1ea05017
commit
01694c3271
@ -50,7 +50,7 @@ QImage Database::icon(int number)
|
||||
return QImage();
|
||||
}
|
||||
|
||||
QImage Database::customIcon(const Uuid& uuid)
|
||||
QImage Database::customIcon(const Uuid& uuid) const
|
||||
{
|
||||
return m_customIcons[uuid];
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void setRootGroup(Group* group);
|
||||
Metadata* metadata();
|
||||
static QImage icon(int number);
|
||||
QImage customIcon(const Uuid& uuid);
|
||||
QImage customIcon(const Uuid& uuid) const;
|
||||
Entry* resolveEntry(const Uuid& uuid);
|
||||
Group* resolveGroup(const Uuid& uuid);
|
||||
|
||||
|
@ -17,11 +17,13 @@
|
||||
|
||||
#include "Entry.h"
|
||||
|
||||
#include "Database.h"
|
||||
#include "Group.h"
|
||||
|
||||
Entry::Entry()
|
||||
{
|
||||
m_group = 0;
|
||||
m_db = 0;
|
||||
}
|
||||
|
||||
Uuid Entry::uuid() const
|
||||
@ -31,8 +33,12 @@ Uuid Entry::uuid() const
|
||||
|
||||
QImage Entry::icon() const
|
||||
{
|
||||
// TODO implement
|
||||
return QImage();
|
||||
Q_ASSERT(m_iconNumber != 0 || !m_customIcon.isNull());
|
||||
|
||||
if (m_iconNumber == 0)
|
||||
return m_db->customIcon(m_customIcon);
|
||||
else
|
||||
return Database::icon(m_iconNumber);
|
||||
}
|
||||
|
||||
QColor Entry::foregroundColor() const
|
||||
@ -88,17 +94,22 @@ const QHash<QString, QByteArray>& Entry::attachments() const
|
||||
void Entry::setUuid(const Uuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
|
||||
m_uuid = uuid;
|
||||
}
|
||||
|
||||
void Entry::setIcon(int iconNumber)
|
||||
{
|
||||
Q_ASSERT(iconNumber >= 0);
|
||||
|
||||
m_iconNumber = iconNumber;
|
||||
m_customIcon = Uuid();
|
||||
}
|
||||
|
||||
void Entry::setIcon(const Uuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
|
||||
m_iconNumber = 0;
|
||||
m_customIcon = uuid;
|
||||
}
|
||||
@ -160,5 +171,6 @@ void Entry::setGroup(Group* group)
|
||||
}
|
||||
group->addEntry(this);
|
||||
m_group = group;
|
||||
m_db = group->database();
|
||||
QObject::setParent(group);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "TimeInfo.h"
|
||||
#include "Uuid.h"
|
||||
|
||||
class Database;
|
||||
class Group;
|
||||
|
||||
struct AutoTypeAssociation
|
||||
@ -85,6 +86,7 @@ private:
|
||||
QHash<QString, QByteArray> m_binaries;
|
||||
|
||||
Group* m_group;
|
||||
const Database* m_db;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_ENTRY_H
|
||||
|
@ -88,12 +88,16 @@ void Group::setNotes(const QString& notes)
|
||||
|
||||
void Group::setIcon(int iconNumber)
|
||||
{
|
||||
Q_ASSERT(iconNumber >= 0);
|
||||
|
||||
m_iconNumber = iconNumber;
|
||||
m_customIcon = Uuid();
|
||||
}
|
||||
|
||||
void Group::setIcon(const Uuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
|
||||
m_iconNumber = 0;
|
||||
m_customIcon = uuid;
|
||||
}
|
||||
@ -130,7 +134,11 @@ void Group::setParent(Group* parent)
|
||||
}
|
||||
|
||||
m_parent = parent;
|
||||
m_db = parent->m_db;
|
||||
|
||||
if (m_db != parent->m_db) {
|
||||
recSetDatabase(parent->m_db);
|
||||
}
|
||||
|
||||
QObject::setParent(parent);
|
||||
|
||||
parent->m_children << this;
|
||||
@ -148,12 +156,18 @@ void Group::setParent(Database* db)
|
||||
}
|
||||
|
||||
m_parent = 0;
|
||||
m_db = db;
|
||||
recSetDatabase(db);
|
||||
|
||||
QObject::setParent(db);
|
||||
|
||||
db->setRootGroup(this);
|
||||
}
|
||||
|
||||
const Database* Group::database() const
|
||||
{
|
||||
return m_db;
|
||||
}
|
||||
|
||||
QList<Group*> Group::children() const
|
||||
{
|
||||
return m_children;
|
||||
@ -166,6 +180,8 @@ QList<Entry*> Group::entries() const
|
||||
|
||||
void Group::addEntry(Entry *entry)
|
||||
{
|
||||
Q_ASSERT(entry != 0);
|
||||
|
||||
m_entries << entry;
|
||||
}
|
||||
|
||||
@ -173,3 +189,12 @@ void Group::removeEntry(Entry* entry)
|
||||
{
|
||||
m_entries.removeAll(entry);
|
||||
}
|
||||
|
||||
void Group::recSetDatabase(Database* db)
|
||||
{
|
||||
m_db = db;
|
||||
|
||||
Q_FOREACH (Group* group, m_children) {
|
||||
group->recSetDatabase(db);
|
||||
}
|
||||
}
|
||||
|
@ -54,12 +54,15 @@ public:
|
||||
void setParent(Group* parent);
|
||||
void setParent(Database* db);
|
||||
|
||||
const Database* database() const;
|
||||
QList<Group*> children() const;
|
||||
QList<Entry*> entries() const;
|
||||
void addEntry(Entry* entry);
|
||||
void removeEntry(Entry* entry);
|
||||
|
||||
private:
|
||||
void recSetDatabase(Database* db);
|
||||
|
||||
Database* m_db;
|
||||
Uuid m_uuid;
|
||||
QString m_name;
|
||||
|
@ -260,8 +260,12 @@ Group* Parser::parseGroup()
|
||||
}
|
||||
else if (m_xml.name() == "IconID") {
|
||||
int iconId = readNumber();
|
||||
if (iconId != 0)
|
||||
if (iconId < 0) {
|
||||
raiseError();
|
||||
}
|
||||
else if (iconId != 0) {
|
||||
group->setIcon(iconId);
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "CustomIconUUID") {
|
||||
Uuid uuid = readUuid();
|
||||
@ -326,8 +330,12 @@ Entry* Parser::parseEntry()
|
||||
}
|
||||
else if (m_xml.name() == "IconID") {
|
||||
int iconId = readNumber();
|
||||
if (iconId != 0)
|
||||
if (iconId < 0) {
|
||||
raiseError();
|
||||
}
|
||||
else if (iconId != 0) {
|
||||
entry->setIcon(iconId);
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "CustomIconUUID") {
|
||||
Uuid uuid = readUuid();
|
||||
|
Loading…
Reference in New Issue
Block a user