File indexing completed on 2024-06-23 05:18:32
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Thomas McGuire <mcguire@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 #pragma once 0007 0008 #include "messagecomposer_export.h" 0009 0010 #include <KJob> 0011 #include <QUrl> 0012 0013 class QTextEdit; 0014 0015 namespace KIO 0016 { 0017 class Job; 0018 } 0019 0020 namespace MessageComposer 0021 { 0022 class InsertTextFileJobPrivate; 0023 /** 0024 * A job that downloads a given URL, interprets the result as a text file with the 0025 * given encoding and then inserts the text into the editor. 0026 */ 0027 class MESSAGECOMPOSER_EXPORT InsertTextFileJob : public KJob 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 explicit InsertTextFileJob(QTextEdit *editor, const QUrl &url); 0033 ~InsertTextFileJob() override; 0034 0035 void setEncoding(const QString &encoding); 0036 void start() override; 0037 0038 private: 0039 void slotGetJobFinished(KJob *job); 0040 void slotFileData(KIO::Job *job, const QByteArray &data); 0041 std::unique_ptr<InsertTextFileJobPrivate> const d; 0042 }; 0043 }