diff --git a/src/base/QXmppBitsOfBinaryData.cpp b/src/base/QXmppBitsOfBinaryData.cpp index 6f9226de4..9aa7cc8b9 100644 --- a/src/base/QXmppBitsOfBinaryData.cpp +++ b/src/base/QXmppBitsOfBinaryData.cpp @@ -215,6 +215,26 @@ QXmppBitsOfBinaryDataList::QXmppBitsOfBinaryDataList() = default; QXmppBitsOfBinaryDataList::~QXmppBitsOfBinaryDataList() = default; /// \cond + +/// +/// \brief Finds the data for a uri +/// \return Data belonging to the uri +/// +/// \since QXmpp 1.5 +/// +std::optional QXmppBitsOfBinaryDataList::find(const QXmppBitsOfBinaryContentId &cid) const +{ + const auto thumbnailData = std::find_if(begin(), end(), [&](const auto &bobBlob) { + return bobBlob.cid() == cid; + }); + + if (thumbnailData != end()) { + return *thumbnailData; + } else { + return {}; + } +} + void QXmppBitsOfBinaryDataList::parse(const QDomElement &element) { // clear previous data elements diff --git a/src/base/QXmppBitsOfBinaryDataList.h b/src/base/QXmppBitsOfBinaryDataList.h index 671cd7fb6..9d956b697 100644 --- a/src/base/QXmppBitsOfBinaryDataList.h +++ b/src/base/QXmppBitsOfBinaryDataList.h @@ -8,6 +8,7 @@ #include "QXmppBitsOfBinaryData.h" #include +#include class QDomElement; class QXmlStreamWriter; @@ -18,6 +19,8 @@ class QXMPP_EXPORT QXmppBitsOfBinaryDataList : public QVector find(const QXmppBitsOfBinaryContentId &cid) const; + /// \cond void parse(const QDomElement &element); void toXml(QXmlStreamWriter *writer) const;