mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Add extend entry-size calculation (resolved #1387)
Extended the calculation for the size of history items to match KeePass2 Small refactoring regarding readability in EntryAttachements
This commit is contained in:
committed by
Janek Bevendorff
parent
83f1a53d32
commit
045f157a63
@@ -18,6 +18,7 @@
|
||||
#include "EntryAttachments.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QSet>
|
||||
|
||||
EntryAttachments::EntryAttachments(QObject* parent)
|
||||
: QObject(parent)
|
||||
@@ -34,9 +35,9 @@ bool EntryAttachments::hasKey(const QString& key) const
|
||||
return m_attachments.contains(key);
|
||||
}
|
||||
|
||||
QList<QByteArray> EntryAttachments::values() const
|
||||
QSet<QByteArray> EntryAttachments::values() const
|
||||
{
|
||||
return m_attachments.values();
|
||||
return m_attachments.values().toSet();
|
||||
}
|
||||
|
||||
QByteArray EntryAttachments::value(const QString& key) const
|
||||
@@ -151,3 +152,13 @@ bool EntryAttachments::operator!=(const EntryAttachments& other) const
|
||||
{
|
||||
return m_attachments != other.m_attachments;
|
||||
}
|
||||
|
||||
int EntryAttachments::attachmentsSize(const QSet<QByteArray> &ignoredAttachments) const
|
||||
{
|
||||
int size = 0;
|
||||
const QSet<QByteArray> consideredAttachments = m_attachments.values().toSet() - ignoredAttachments;
|
||||
for (const QByteArray& attachment : consideredAttachments) {
|
||||
size += attachment.size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user