File indexing completed on 2024-05-05 04:39:25
0001 /* 0002 SPDX-FileCopyrightText: 2020 Milian Wolff <mail@milianw.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <KJob> 0010 #include <QFutureWatcher> 0011 0012 namespace KDevelop 0013 { 0014 class IProject; 0015 } 0016 0017 struct CMakeProjectData; 0018 0019 namespace CMake { 0020 namespace FileApi { 0021 class ImportJob : public KJob 0022 { 0023 Q_OBJECT 0024 public: 0025 enum { 0026 // Add a "random" number to KJob::UserDefinedError and hopefully avoid 0027 // clashes with OutputJob's, OutputExecuteJob's, etc. error codes. 0028 InvalidProjectDataError = UserDefinedError + 172 0029 }; 0030 0031 explicit ImportJob(KDevelop::IProject* project, QObject* parent = nullptr); 0032 ~ImportJob(); 0033 0034 /// Call this function if outdated data is going to be discarded to let this job return earlier. 0035 /// After this is called, outdated data is considered invalid. Thus when the data is outdated, the job 0036 /// finishes with InvalidProjectDataError, or emits invalid data if setEmitInvalidData() has been called. 0037 void setInvalidateOutdatedData(); 0038 0039 /// If this function is called, the job finishes without error and 0040 /// dataAvailable() signal is emitted when project data is invalid. 0041 void setEmitInvalidData(); 0042 0043 void start() override; 0044 0045 Q_SIGNALS: 0046 void dataAvailable(const CMakeProjectData& data); 0047 0048 private: 0049 KDevelop::IProject* m_project = nullptr; 0050 QFutureWatcher<CMakeProjectData> m_futureWatcher; 0051 bool m_invalidateOutdatedData = false; 0052 bool m_emitInvalidData = false; 0053 }; 0054 } 0055 }