From 3ea0592b531daf2f2119ebaa379eea48aa3d948a Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Wed, 3 Dec 2014 23:36:24 +0100 Subject: [PATCH] Add hasKey() convenience methods. --- src/core/EntryAttachments.cpp | 5 +++++ src/core/EntryAttachments.h | 1 + src/core/EntryAttributes.cpp | 5 +++++ src/core/EntryAttributes.h | 1 + 4 files changed, 12 insertions(+) diff --git a/src/core/EntryAttachments.cpp b/src/core/EntryAttachments.cpp index e39bf4189..7bd080bfa 100644 --- a/src/core/EntryAttachments.cpp +++ b/src/core/EntryAttachments.cpp @@ -27,6 +27,11 @@ QList EntryAttachments::keys() const return m_attachments.keys(); } +bool EntryAttachments::hasKey(const QString& key) const +{ + return m_attachments.keys().contains(key); +} + QList EntryAttachments::values() const { return m_attachments.values(); diff --git a/src/core/EntryAttachments.h b/src/core/EntryAttachments.h index b482f42e3..3446b315c 100644 --- a/src/core/EntryAttachments.h +++ b/src/core/EntryAttachments.h @@ -30,6 +30,7 @@ class EntryAttachments : public QObject public: explicit EntryAttachments(QObject* parent = Q_NULLPTR); QList keys() const; + bool hasKey(const QString& key) const; QList values() const; QByteArray value(const QString& key) const; void set(const QString& key, const QByteArray& value); diff --git a/src/core/EntryAttributes.cpp b/src/core/EntryAttributes.cpp index a950390cd..01dcf9624 100644 --- a/src/core/EntryAttributes.cpp +++ b/src/core/EntryAttributes.cpp @@ -36,6 +36,11 @@ QList EntryAttributes::keys() const return m_attributes.keys(); } +bool EntryAttributes::hasKey(const QString& key) const +{ + return m_attributes.keys().contains(key); +} + QList EntryAttributes::customKeys() { QList customKeys; diff --git a/src/core/EntryAttributes.h b/src/core/EntryAttributes.h index 0eba4332c..334eb0ab3 100644 --- a/src/core/EntryAttributes.h +++ b/src/core/EntryAttributes.h @@ -32,6 +32,7 @@ class EntryAttributes : public QObject public: explicit EntryAttributes(QObject* parent = Q_NULLPTR); QList keys() const; + bool hasKey(const QString& key) const; QList customKeys(); QString value(const QString& key) const; bool isProtected(const QString& key) const;