File indexing completed on 2024-06-16 05:00:14

0001 /*
0002     bodypartformatterfactory.h
0003 
0004     This file is part of KMail, the KDE mail client.
0005     SPDX-FileCopyrightText: 2004 Marc Mutz <mutz@kde.org>
0006     SPDX-FileCopyrightText: 2004 Ingo Kloecker <kloecker@kde.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 #include "mimetreeparser_export.h"
0014 
0015 #include <QList>
0016 #include <memory>
0017 namespace MimeTreeParser
0018 {
0019 namespace Interface
0020 {
0021 class BodyPartFormatter;
0022 }
0023 
0024 class BodyPartFormatterFactoryPrivate;
0025 
0026 /** The place to obtain BodyPartFormatter candidates for a given mime type. */
0027 class MIMETREEPARSER_EXPORT BodyPartFormatterFactory
0028 {
0029 public:
0030     BodyPartFormatterFactory();
0031     virtual ~BodyPartFormatterFactory();
0032 
0033     static BodyPartFormatterFactory *instance();
0034 
0035     /**
0036      *  Returns all suitable formatters for the given mimetype.
0037      *  The candidates are ordered by priority, with the catch-call
0038      *  formatter coming last.
0039      */
0040     [[nodiscard]] QList<const Interface::BodyPartFormatter *> formattersForType(const QString &mimeType) const;
0041 
0042 protected:
0043     void insert(const QString &mimeType, const Interface::BodyPartFormatter *formatter, int priority);
0044     virtual void loadPlugins();
0045 
0046 private:
0047     Q_DISABLE_COPY(BodyPartFormatterFactory)
0048     std::unique_ptr<BodyPartFormatterFactoryPrivate> const d;
0049     friend class BodyPartFormatterFactoryPrivate;
0050 };
0051 }