Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit b55d006

Browse files
committed
Add convinience data retrieval method to QXmppBitsOfBinaryDataList
1 parent f762f73 commit b55d006

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/base/QXmppBitsOfBinaryData.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,24 @@ QXmppBitsOfBinaryDataList::QXmppBitsOfBinaryDataList() = default;
215215
QXmppBitsOfBinaryDataList::~QXmppBitsOfBinaryDataList() = default;
216216

217217
/// \cond
218+
219+
///
220+
/// \brief finds the data for a uri
221+
/// \param uri cid uri
222+
/// \return data belonging to the uri
223+
///
224+
/// \since QXmpp 1.5
225+
///
226+
const QXmppBitsOfBinaryData &QXmppBitsOfBinaryDataList::forCidUri(const QString &uri) const
227+
{
228+
auto cid = QXmppBitsOfBinaryContentId::fromCidUrl(uri);
229+
const auto thumbnailData = std::find_if(begin(), end(), [&](const auto &bobBlob) {
230+
return bobBlob.cid() == cid;
231+
});
232+
233+
return *thumbnailData;
234+
}
235+
218236
void QXmppBitsOfBinaryDataList::parse(const QDomElement &element)
219237
{
220238
// clear previous data elements

src/base/QXmppBitsOfBinaryDataList.h

+3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111

1212
class QDomElement;
1313
class QXmlStreamWriter;
14+
class QUrl;
1415

1516
class QXMPP_EXPORT QXmppBitsOfBinaryDataList : public QVector<QXmppBitsOfBinaryData>
1617
{
1718
public:
1819
QXmppBitsOfBinaryDataList();
1920
~QXmppBitsOfBinaryDataList();
2021

22+
const QXmppBitsOfBinaryData &forCidUri(const QString &uri) const;
23+
2124
/// \cond
2225
void parse(const QDomElement &element);
2326
void toXml(QXmlStreamWriter *writer) const;

0 commit comments

Comments
 (0)