Fix code-style issues
Fixed issues pointed out during review
This commit is contained in:
committed by
Janek Bevendorff
parent
943dc6cdd6
commit
258438f01f
@@ -106,7 +106,7 @@ int AutoTypeAssociations::size() const
|
||||
int AutoTypeAssociations::associationsSize() const
|
||||
{
|
||||
int size = 0;
|
||||
foreach (const Association &association, m_associations) {
|
||||
for (const Association &association : m_associations) {
|
||||
size += association.sequence.toUtf8().size() + association.window.toUtf8().size();
|
||||
}
|
||||
return size;
|
||||
|
||||
@@ -586,6 +586,7 @@ void Entry::truncateHistory()
|
||||
|
||||
QMutableListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
const QRegularExpression delimiter(",|:|;");
|
||||
while (i.hasPrevious()) {
|
||||
Entry* historyItem = i.previous();
|
||||
|
||||
@@ -594,7 +595,8 @@ void Entry::truncateHistory()
|
||||
size += historyItem->attributes()->attributesSize();
|
||||
size += historyItem->autoTypeAssociations()->associationsSize();
|
||||
size += historyItem->attachments()->attachmentsSize(foundAttachments);
|
||||
foreach( const QString &tag, historyItem->tags().split(QRegExp(",|;|:"), QString::SkipEmptyParts)){
|
||||
const QStringList tags = historyItem->tags().split(delimiter, QString::SkipEmptyParts);
|
||||
for (const QString& tag : tags) {
|
||||
size += tag.toUtf8().size();
|
||||
}
|
||||
foundAttachments += historyItem->attachments()->values();
|
||||
|
||||
@@ -153,16 +153,13 @@ bool EntryAttachments::operator!=(const EntryAttachments& other) const
|
||||
return m_attachments != other.m_attachments;
|
||||
}
|
||||
|
||||
int EntryAttachments::attachmentsSize(const QSet<QByteArray> &ignoredAttachments) const
|
||||
int EntryAttachments::attachmentsSize(const QSet<QByteArray>& ignoredAttachments) const
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
QMapIterator<QString, QByteArray> i(m_attachments);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if( ! ignoredAttachments.contains( i.value() )){
|
||||
size += i.key().toUtf8().size() + i.value().size();
|
||||
}
|
||||
for (auto it = m_attachments.constBegin(); it != m_attachments.constEnd(); ++it) {
|
||||
if (!ignoredAttachments.contains(it.value())) {
|
||||
size += it.key().toUtf8().size() + it.value().size();
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
void copyDataFrom(const EntryAttachments* other);
|
||||
bool operator==(const EntryAttachments& other) const;
|
||||
bool operator!=(const EntryAttachments& other) const;
|
||||
int attachmentsSize(const QSet<QByteArray> &ignoredAttachments) const;
|
||||
int attachmentsSize(const QSet<QByteArray>& ignoredAttachments) const;
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
@@ -286,11 +286,8 @@ void EntryAttributes::clear()
|
||||
int EntryAttributes::attributesSize() const
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
QMapIterator<QString, QString> i(m_attributes);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
size += i.key().toUtf8().size() + i.value().toUtf8().size();
|
||||
for (auto it = m_attributes.constBegin(); it != m_attributes.constEnd(); ++it) {
|
||||
size += it.key().toUtf8().size() + it.value().toUtf8().size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user