Messagelib

imagecollector.cpp
1/* -*- c++ -*-
2 * imagecollector.cpp
3 *
4 * This file is part of KMail, the KDE mail client.
5 * SPDX-FileCopyrightText: 2004 Marc Mutz <mutz@kde.org>
6 * SPDX-FileCopyrightText: 2011 Torgny Nyblom <nyblom@kde.org>
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11#include "imagecollector.h"
12
13#include "messagecore_debug.h"
14#include <KMime/Content>
15
16class MessageCore::ImageCollector::ImageCollectorPrivate
17{
18public:
19 std::vector<KMime::Content *> mImages;
20};
21
23 : d(new ImageCollectorPrivate)
24{
25}
26
28
30{
31 if (!node) {
32 return;
33 }
34
35 if (const auto ct = node->contentType(false); ct->isImage() && node->parent()) {
36 const KMime::Content *parent = node->parent();
37 if (const auto parentCt = parent->contentType(); parentCt->isMultipart() && parentCt->isSubtype("related")) {
38 qCWarning(MESSAGECORE_LOG) << "Adding image" << node->contentID(false);
39 d->mImages.push_back(node);
40 }
41 }
42
43 const auto children = node->contents();
44 for (const auto child : children) {
45 collectImagesFrom(child);
46 }
47}
48
49const std::vector<KMime::Content *> &MessageCore::ImageCollector::images() const
50{
51 return d->mImages;
52}
const Headers::ContentType * contentType() const
Content * parent()
const Headers::ContentID * contentID() const
QList< Content * > contents()
void collectImagesFrom(KMime::Content *content)
Starts collecting the images.
ImageCollector()
Creates a new image collector.
const std::vector< KMime::Content * > & images() const
Returns the collected images.
~ImageCollector()
Destroys the image collector.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.