Add tests for modified, fix history for autotype

Added tests to ensure #1387 works
Fixed issue detected during testing - AutoTypeAssociations were not
pushed to history
This commit is contained in:
Christian Kieschnick
2018-01-15 18:17:56 +01:00
committed by Janek Bevendorff
parent 045f157a63
commit 943dc6cdd6
4 changed files with 57 additions and 5 deletions

View File

@@ -633,7 +633,7 @@ Entry* Entry::clone(CloneFlags flags) const
entry->m_attributes->set(EntryAttributes::PasswordKey, password.toUpper(), m_attributes->isProtected(EntryAttributes::PasswordKey));
}
entry->m_autoTypeAssociations->copyDataFrom(this->m_autoTypeAssociations);
entry->m_autoTypeAssociations->copyDataFrom(m_autoTypeAssociations);
if (flags & CloneIncludeHistory) {
for (Entry* historyItem : m_history) {
Entry* historyItemClone = historyItem->clone(flags & ~CloneIncludeHistory & ~CloneNewUuid);
@@ -679,6 +679,7 @@ void Entry::beginUpdate()
m_tmpHistoryItem->m_data = m_data;
m_tmpHistoryItem->m_attributes->copyDataFrom(m_attributes);
m_tmpHistoryItem->m_attachments->copyDataFrom(m_attachments);
m_tmpHistoryItem->m_autoTypeAssociations->copyDataFrom(m_autoTypeAssociations);
m_modifiedSinceBegin = false;
}

View File

@@ -156,9 +156,13 @@ bool EntryAttachments::operator!=(const EntryAttachments& other) const
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();
QMapIterator<QString, QByteArray> i(m_attachments);
while (i.hasNext()) {
i.next();
if( ! ignoredAttachments.contains( i.value() )){
size += i.key().toUtf8().size() + i.value().size();
}
}
return size;
}