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 #include "testdocumentfilewritejob.hpp"
0010 
0011 // lib
0012 #include "testdocumentfilesynchronizer.hpp"
0013 #include "testdocumentfilewritethread.hpp"
0014 #include "testdocument.hpp"
0015 // Qt
0016 #include <QCoreApplication>
0017 
0018 namespace Kasten {
0019 
0020 TestDocumentFileWriteJob::TestDocumentFileWriteJob(TestDocumentFileSynchronizer* synchronizer)
0021     : AbstractFileSystemSyncToRemoteJob(synchronizer)
0022 {}
0023 
0024 TestDocumentFileWriteJob::~TestDocumentFileWriteJob() = default;
0025 
0026 void TestDocumentFileWriteJob::startWriteToFile()
0027 {
0028     auto* testSynchronizer = qobject_cast<TestDocumentFileSynchronizer*>(synchronizer());
0029     auto* document = qobject_cast<TestDocument*>(synchronizer()->document());
0030 
0031     auto* writeThread = new TestDocumentFileWriteThread(this, testSynchronizer->header(),  document, file());
0032     writeThread->start();
0033     while (!writeThread->wait(100)) {
0034         QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
0035     }
0036 
0037     const bool success = writeThread->success();
0038     delete writeThread;
0039 
0040     completeWrite(success);
0041 }
0042 
0043 }
0044 
0045 #include "moc_testdocumentfilewritejob.cpp"