mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-23 16:31:28 -05:00
Feature : clip command (#578)
This commit is contained in:
parent
6c050c55d9
commit
a2e82dc883
15 changed files with 250 additions and 41 deletions
|
|
@ -483,7 +483,24 @@ QList<Entry*> Group::entriesRecursive(bool includeHistoryItems) const
|
|||
return entryList;
|
||||
}
|
||||
|
||||
Entry* Group::findEntry(const Uuid& uuid)
|
||||
Entry* Group::findEntry(QString entryId)
|
||||
{
|
||||
Q_ASSERT(!entryId.isEmpty());
|
||||
Q_ASSERT(!entryId.isNull());
|
||||
|
||||
if (Uuid::isUuid(entryId)) {
|
||||
Uuid entryUuid = Uuid::fromHex(entryId);
|
||||
for (Entry* entry : entriesRecursive(false)) {
|
||||
if (entry->uuid() == entryUuid) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return findEntryByPath(entryId);
|
||||
}
|
||||
|
||||
Entry* Group::findEntryByUuid(const Uuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
for (Entry* entry : asConst(m_entries)) {
|
||||
|
|
@ -495,6 +512,29 @@ Entry* Group::findEntry(const Uuid& uuid)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Entry* Group::findEntryByPath(QString entryPath, QString basePath)
|
||||
{
|
||||
|
||||
Q_ASSERT(!entryPath.isEmpty());
|
||||
Q_ASSERT(!entryPath.isNull());
|
||||
|
||||
for (Entry* entry : asConst(m_entries)) {
|
||||
QString currentEntryPath = basePath + entry->title();
|
||||
if (entryPath == currentEntryPath) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
for (Group* group : asConst(m_children)) {
|
||||
Entry* entry = group->findEntryByPath(entryPath, basePath + group->name() + QString("/"));
|
||||
if (entry != nullptr) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<const Group*> Group::groupsRecursive(bool includeSelf) const
|
||||
{
|
||||
QList<const Group*> groupList;
|
||||
|
|
@ -551,10 +591,10 @@ void Group::merge(const Group* other)
|
|||
const QList<Entry*> dbEntries = other->entries();
|
||||
for (Entry* entry : dbEntries) {
|
||||
// entries are searched by uuid
|
||||
if (!findEntry(entry->uuid())) {
|
||||
if (!findEntryByUuid(entry->uuid())) {
|
||||
entry->clone(Entry::CloneNoFlags)->setGroup(this);
|
||||
} else {
|
||||
resolveConflict(findEntry(entry->uuid()), entry);
|
||||
resolveConflict(findEntryByUuid(entry->uuid()), entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue