Add support for working with multiple entry attachments at once
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "EntryAttachments.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
EntryAttachments::EntryAttachments(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
@@ -71,7 +73,8 @@ void EntryAttachments::set(const QString& key, const QByteArray& value)
|
||||
void EntryAttachments::remove(const QString& key)
|
||||
{
|
||||
if (!m_attachments.contains(key)) {
|
||||
Q_ASSERT(false);
|
||||
Q_ASSERT_X(false, "EntryAttachments::remove",
|
||||
qPrintable(QString("Can't find attachment for key %1").arg(key)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,6 +86,31 @@ void EntryAttachments::remove(const QString& key)
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void EntryAttachments::remove(const QStringList &keys)
|
||||
{
|
||||
if (keys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool isModified = false;
|
||||
for (const QString &key: keys) {
|
||||
if (!m_attachments.contains(key)) {
|
||||
Q_ASSERT_X(false, "EntryAttachments::remove",
|
||||
qPrintable(QString("Can't find attachment for key %1").arg(key)));
|
||||
continue;
|
||||
}
|
||||
|
||||
isModified = true;
|
||||
emit aboutToBeRemoved(key);
|
||||
m_attachments.remove(key);
|
||||
emit removed(key);
|
||||
}
|
||||
|
||||
if (isModified) {
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void EntryAttachments::clear()
|
||||
{
|
||||
if (m_attachments.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user