mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 08:49:42 -05:00
Copy custom icons when copying/moving entries/groups to another database.
This commit is contained in:
parent
8ed0379136
commit
5a96e19ce9
@ -436,6 +436,27 @@ QList<const Group*> Group::groupsRecursive(bool includeSelf) const
|
|||||||
return groupList;
|
return groupList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSet<Uuid> Group::customIconsRecursive() const
|
||||||
|
{
|
||||||
|
QSet<Uuid> result;
|
||||||
|
|
||||||
|
if (!iconUuid().isNull()) {
|
||||||
|
result.insert(iconUuid());
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_FOREACH (Entry* entry, entriesRecursive(true)) {
|
||||||
|
if (!entry->iconUuid().isNull()) {
|
||||||
|
result.insert(entry->iconUuid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_FOREACH (Group* group, m_children) {
|
||||||
|
result.unite(group->customIconsRecursive());
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Group* Group::clone() const
|
Group* Group::clone() const
|
||||||
{
|
{
|
||||||
// TODO: what to do about custom icons?
|
// TODO: what to do about custom icons?
|
||||||
|
@ -99,6 +99,7 @@ public:
|
|||||||
const QList<Entry*>& entries() const;
|
const QList<Entry*>& entries() const;
|
||||||
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
||||||
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
||||||
|
QSet<Uuid> customIconsRecursive() const;
|
||||||
Group* clone() const;
|
Group* clone() const;
|
||||||
|
|
||||||
QList<Entry*> search(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity,
|
QList<Entry*> search(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity,
|
||||||
|
@ -348,6 +348,17 @@ void Metadata::removeCustomIcon(const Uuid& uuid)
|
|||||||
Q_EMIT modified();
|
Q_EMIT modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Metadata::copyCustomIcons(const QSet<Uuid>& iconList, const Metadata* otherMetadata)
|
||||||
|
{
|
||||||
|
Q_FOREACH (const Uuid& uuid, iconList) {
|
||||||
|
Q_ASSERT(otherMetadata->containsCustomIcon(uuid));
|
||||||
|
|
||||||
|
if (!containsCustomIcon(uuid)) {
|
||||||
|
addCustomIcon(uuid, otherMetadata->customIcon(uuid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Metadata::setRecycleBinEnabled(bool value)
|
void Metadata::setRecycleBinEnabled(bool value)
|
||||||
{
|
{
|
||||||
set(m_recycleBinEnabled, value);
|
set(m_recycleBinEnabled, value);
|
||||||
|
@ -91,6 +91,7 @@ public:
|
|||||||
// void setAutoEnableVisualHiding(bool value);
|
// void setAutoEnableVisualHiding(bool value);
|
||||||
void addCustomIcon(const Uuid& uuid, const QImage& icon);
|
void addCustomIcon(const Uuid& uuid, const QImage& icon);
|
||||||
void removeCustomIcon(const Uuid& uuid);
|
void removeCustomIcon(const Uuid& uuid);
|
||||||
|
void copyCustomIcons(const QSet<Uuid>& iconList, const Metadata* otherMetadata);
|
||||||
void setRecycleBinEnabled(bool value);
|
void setRecycleBinEnabled(bool value);
|
||||||
void setRecycleBin(Group* group);
|
void setRecycleBin(Group* group);
|
||||||
void setRecycleBinChanged(const QDateTime& value);
|
void setRecycleBinChanged(const QDateTime& value);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "core/DatabaseIcons.h"
|
#include "core/DatabaseIcons.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
|
#include "core/Metadata.h"
|
||||||
#include "core/Tools.h"
|
#include "core/Tools.h"
|
||||||
|
|
||||||
GroupModel::GroupModel(Database* db, QObject* parent)
|
GroupModel::GroupModel(Database* db, QObject* parent)
|
||||||
@ -262,6 +263,14 @@ bool GroupModel::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||||||
group = dragGroup->clone();
|
group = dragGroup->clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database* sourceDb = dragGroup->database();
|
||||||
|
Database* targetDb = parentGroup->database();
|
||||||
|
|
||||||
|
if (sourceDb != targetDb) {
|
||||||
|
QSet<Uuid> customIcons = group->customIconsRecursive();
|
||||||
|
targetDb->metadata()->copyCustomIcons(customIcons, sourceDb->metadata());
|
||||||
|
}
|
||||||
|
|
||||||
group->setParent(parentGroup, row);
|
group->setParent(parentGroup, row);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -292,6 +301,16 @@ bool GroupModel::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||||||
entry = dragEntry->clone();
|
entry = dragEntry->clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database* sourceDb = dragEntry->group()->database();
|
||||||
|
Database* targetDb = parentGroup->database();
|
||||||
|
Uuid customIcon = entry->iconUuid();
|
||||||
|
|
||||||
|
if (sourceDb != targetDb && !customIcon.isNull()
|
||||||
|
&& !targetDb->metadata()->containsCustomIcon(customIcon)) {
|
||||||
|
targetDb->metadata()->addCustomIcon(customIcon,
|
||||||
|
sourceDb->metadata()->customIcon(customIcon));
|
||||||
|
}
|
||||||
|
|
||||||
entry->setGroup(parentGroup);
|
entry->setGroup(parentGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user