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:
Christian Kieschnick
2018-01-15 17:20:16 +01:00
committed by Janek Bevendorff
parent 83f1a53d32
commit 045f157a63
7 changed files with 34 additions and 12 deletions

View File

@@ -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;
}