File indexing completed on 2025-03-09 04:54:12
0001 /* 0002 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "messagecore_export.h" 0010 0011 #include "attachmentpart.h" 0012 0013 #include <KJob> 0014 0015 namespace MessageCore 0016 { 0017 /** 0018 * @short A base class for jobs to load attachments from different sources. 0019 * 0020 * @author Constantin Berzan <exit3219@gmail.com> 0021 */ 0022 class MESSAGECORE_EXPORT AttachmentLoadJob : public KJob 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 /** 0028 * Creates a new attachment load job. 0029 * 0030 * @param parent The parent object. 0031 */ 0032 explicit AttachmentLoadJob(QObject *parent = nullptr); 0033 0034 /** 0035 * Destroys the attachment load job. 0036 */ 0037 ~AttachmentLoadJob() override; 0038 0039 /** 0040 * Starts the attachment load job. 0041 */ 0042 void start() override; 0043 0044 /** 0045 * Returns the loaded attachment. 0046 */ 0047 [[nodiscard]] AttachmentPart::Ptr attachmentPart() const; 0048 0049 protected: 0050 /** 0051 * Subclasses use this method to set the loaded @p part. 0052 */ 0053 void setAttachmentPart(const AttachmentPart::Ptr &part); 0054 0055 protected Q_SLOTS: 0056 virtual void doStart() = 0; 0057 0058 private: 0059 //@cond PRIVATE 0060 class AttachmentLoadJobPrivate; 0061 std::unique_ptr<AttachmentLoadJobPrivate> const d; 0062 //@endcond 0063 }; 0064 }