File indexing completed on 2024-06-02 06:03:21

0001 /*
0002     This file is part of the Kasten Framework, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_TESTDOCUMENTFILEWRITETHREAD_HPP
0010 #define KASTEN_TESTDOCUMENTFILEWRITETHREAD_HPP
0011 
0012 // Qt
0013 #include <QByteArray>
0014 #include <QThread>
0015 
0016 class QFile;
0017 
0018 namespace Kasten {
0019 
0020 class TestDocument;
0021 
0022 class TestDocumentFileWriteThread : public QThread
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     TestDocumentFileWriteThread(QObject* parent, const QByteArray& header,
0028                                 TestDocument* document, QFile* file);
0029     ~TestDocumentFileWriteThread() override;
0030 
0031 public: // QThread API
0032     void run() override;
0033 
0034 public:
0035     bool success() const;
0036 
0037 Q_SIGNALS:
0038     void documentWritten(bool success);
0039 
0040 private:
0041     const QByteArray mHeader;
0042     const TestDocument* mDocument;
0043     QFile* mFile;
0044 
0045     bool mSuccess = false;
0046 };
0047 
0048 inline TestDocumentFileWriteThread::TestDocumentFileWriteThread(QObject* parent, const QByteArray& header,
0049                                                                 TestDocument* document, QFile* file)
0050     : QThread(parent)
0051     , mHeader(header)
0052     , mDocument(document)
0053     , mFile(file)
0054 {}
0055 
0056 inline bool TestDocumentFileWriteThread::success() const { return mSuccess; }
0057 
0058 }
0059 
0060 #endif