File indexing completed on 2024-04-28 05:45:32
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2017-2020 Harald Sitter <sitter@kde.org> 0003 0004 #ifndef INSTALLER_H 0005 #define INSTALLER_H 0006 0007 #include <QObject> 0008 #include <QSet> 0009 #include <QList> 0010 0011 #include <memory> 0012 0013 #include "File.h" 0014 0015 class FileResolver; 0016 0017 class Installer : public QObject 0018 { 0019 Q_OBJECT 0020 Q_PROPERTY(bool ready MEMBER m_ready NOTIFY changed) 0021 Q_PROPERTY(bool installing MEMBER m_installing NOTIFY changed) 0022 Q_PROPERTY(bool installed MEMBER m_installed NOTIFY changed) 0023 Q_PROPERTY(QString error MEMBER m_error NOTIFY changed) 0024 // Trivial helper to access files from QML by decaying the shared pointers to raw pointers. 0025 Q_PROPERTY(QList<QObject *> files READ fileQObjects CONSTANT) 0026 public: 0027 explicit Installer(const QStringList &files); 0028 Q_INVOKABLE void resolve(); 0029 Q_INVOKABLE void install(); 0030 0031 [[nodiscard]] QList<QObject *> fileQObjects() const; 0032 0033 signals: 0034 void changed(); 0035 0036 private: 0037 void prepareInstall(); 0038 0039 uint m_pendingResolvers = 0; 0040 // We are capturing all IDs outside the files as well so we can uniq! them 0041 // and ensure we even have anything to install before the user clicks install. 0042 QStringList m_debugPackageIDs; 0043 std::vector<std::shared_ptr<File>> m_files; 0044 bool m_ready = false; 0045 bool m_installing = false; 0046 bool m_installed = false; 0047 QString m_error; 0048 }; 0049 0050 #endif // INSTALLER_H