mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-24 08:43:29 -05:00
parent
c36481edae
commit
de4b90cdf1
6 changed files with 62 additions and 0 deletions
|
|
@ -404,6 +404,13 @@ void Entry::setGroup(Group* group)
|
||||||
m_group->removeEntry(this);
|
m_group->removeEntry(this);
|
||||||
if (m_group->database() && m_group->database() != group->database()) {
|
if (m_group->database() && m_group->database() != group->database()) {
|
||||||
m_group->database()->addDeletedObject(m_uuid);
|
m_group->database()->addDeletedObject(m_uuid);
|
||||||
|
|
||||||
|
// copy custom icon to the new database
|
||||||
|
if (!iconUuid().isNull() && group->database()
|
||||||
|
&& m_group->database()->metadata()->containsCustomIcon(iconUuid())
|
||||||
|
&& !group->database()->metadata()->containsCustomIcon(iconUuid())) {
|
||||||
|
group->database()->metadata()->addCustomIcon(iconUuid(), icon());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,13 @@ void Group::setParent(Group* parent, int index)
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
if (m_db) {
|
if (m_db) {
|
||||||
recCreateDelObjects();
|
recCreateDelObjects();
|
||||||
|
|
||||||
|
// copy custom icon to the new database
|
||||||
|
if (!iconUuid().isNull() && parent->m_db
|
||||||
|
&& m_db->metadata()->containsCustomIcon(iconUuid())
|
||||||
|
&& !parent->m_db->metadata()->containsCustomIcon(iconUuid())) {
|
||||||
|
parent->m_db->metadata()->addCustomIcon(iconUuid(), icon());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m_db != parent->m_db) {
|
if (m_db != parent->m_db) {
|
||||||
recSetDatabase(parent->m_db);
|
recSetDatabase(parent->m_db);
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,11 @@ QImage Metadata::customIcon(const Uuid& uuid) const
|
||||||
return m_customIcons.value(uuid);
|
return m_customIcons.value(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Metadata::containsCustomIcon(const Uuid& uuid) const
|
||||||
|
{
|
||||||
|
return m_customIcons.contains(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
QHash<Uuid, QImage> Metadata::customIcons() const
|
QHash<Uuid, QImage> Metadata::customIcons() const
|
||||||
{
|
{
|
||||||
return m_customIcons;
|
return m_customIcons;
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ public:
|
||||||
bool protectNotes() const;
|
bool protectNotes() const;
|
||||||
// bool autoEnableVisualHiding() const;
|
// bool autoEnableVisualHiding() const;
|
||||||
QImage customIcon(const Uuid& uuid) const;
|
QImage customIcon(const Uuid& uuid) const;
|
||||||
|
bool containsCustomIcon(const Uuid& uuid) const;
|
||||||
QHash<Uuid, QImage> customIcons() const;
|
QHash<Uuid, QImage> customIcons() const;
|
||||||
bool recycleBinEnabled() const;
|
bool recycleBinEnabled() const;
|
||||||
Group* recycleBin();
|
Group* recycleBin();
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
|
#include "core/Metadata.h"
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
|
|
||||||
void TestGroup::initTestCase()
|
void TestGroup::initTestCase()
|
||||||
|
|
@ -293,4 +294,44 @@ void TestGroup::testDeleteSignals()
|
||||||
delete db2;
|
delete db2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestGroup::testCopyCustomIcon()
|
||||||
|
{
|
||||||
|
Database* dbSource = new Database();
|
||||||
|
|
||||||
|
Uuid groupIconUuid = Uuid::random();
|
||||||
|
QImage groupIcon(16, 16, QImage::Format_RGB32);
|
||||||
|
groupIcon.setPixel(0, 0, qRgb(255, 0, 0));
|
||||||
|
dbSource->metadata()->addCustomIcon(groupIconUuid, groupIcon);
|
||||||
|
|
||||||
|
Uuid entryIconUuid = Uuid::random();
|
||||||
|
QImage entryIcon(16, 16, QImage::Format_RGB32);
|
||||||
|
entryIcon.setPixel(0, 0, qRgb(255, 0, 0));
|
||||||
|
dbSource->metadata()->addCustomIcon(entryIconUuid, entryIcon);
|
||||||
|
|
||||||
|
Group* group = new Group();
|
||||||
|
group->setParent(dbSource->rootGroup());
|
||||||
|
group->setIcon(groupIconUuid);
|
||||||
|
QCOMPARE(group->icon(), groupIcon);
|
||||||
|
|
||||||
|
Entry* entry = new Entry();
|
||||||
|
entry->setGroup(dbSource->rootGroup());
|
||||||
|
entry->setIcon(entryIconUuid);
|
||||||
|
QCOMPARE(entry->icon(), entryIcon);
|
||||||
|
|
||||||
|
Database* dbTarget = new Database();
|
||||||
|
|
||||||
|
group->setParent(dbTarget->rootGroup());
|
||||||
|
QVERIFY(dbTarget->metadata()->containsCustomIcon(groupIconUuid));
|
||||||
|
QCOMPARE(dbTarget->metadata()->customIcon(groupIconUuid), groupIcon);
|
||||||
|
QCOMPARE(group->icon(), groupIcon);
|
||||||
|
|
||||||
|
entry->setGroup(dbTarget->rootGroup());
|
||||||
|
QVERIFY(dbTarget->metadata()->containsCustomIcon(entryIconUuid));
|
||||||
|
QCOMPARE(dbTarget->metadata()->customIcon(entryIconUuid), entryIcon);
|
||||||
|
QCOMPARE(entry->icon(), entryIcon);
|
||||||
|
|
||||||
|
delete dbSource;
|
||||||
|
delete dbTarget;
|
||||||
|
}
|
||||||
|
|
||||||
KEEPASSX_QTEST_CORE_MAIN(TestGroup)
|
KEEPASSX_QTEST_CORE_MAIN(TestGroup)
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ private Q_SLOTS:
|
||||||
void testSignals();
|
void testSignals();
|
||||||
void testEntries();
|
void testEntries();
|
||||||
void testDeleteSignals();
|
void testDeleteSignals();
|
||||||
|
void testCopyCustomIcon();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_TESTGROUP_H
|
#endif // KEEPASSX_TESTGROUP_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue