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