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-2021 Harald Sitter <sitter@kde.org>
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 
0008 class File : public QObject
0009 {
0010     Q_OBJECT
0011     // The path of the file that is meant to get debug symbols (incoming arg). May change because of usr-merge conversion.
0012     Q_PROPERTY(QString path READ path NOTIFY changed)
0013     // The package the file belongs to. This is the packagekit id!
0014     Q_PROPERTY(QString packageID READ packageID NOTIFY changed)
0015     // The package the file belongs to.
0016     Q_PROPERTY(QString package READ package NOTIFY changed)
0017     // The source package that created the package.
0018     Q_PROPERTY(QString sourcePackage READ sourcePackage NOTIFY changed)
0019     // The candidate names for debug packages. These are likely name
0020     // combinations of packages that may provide debug packages in order of preference.
0021     // These are packagekit ids not actual package names!
0022     Q_PROPERTY(QString debugPackageID READ debugPackageID NOTIFY changed)
0023     Q_PROPERTY(bool debugPackageInstalled READ isDebugPackageInstalled NOTIFY changed)
0024     // Diagnostic data multiline string. Only set when the file couldn't be resolved.
0025     Q_PROPERTY(QString diagnosticData READ diagnosticData NOTIFY changed)
0026     // When completely resolved
0027     Q_PROPERTY(bool resolved READ isResolved NOTIFY resolved)
0028 public:
0029     explicit File(QString path, QObject *parent = nullptr);
0030 
0031     // All possibly name permutations of the debug package associated with this
0032     // file.
0033     [[nodiscard]] QStringList potentialDebugPackageCandidateNames() const;
0034 
0035     [[nodiscard]] QString path() const;
0036     void setPath(const QString &path);
0037 
0038     [[nodiscard]] QString package() const;
0039     [[nodiscard]] QString packageID() const;
0040     void setPackageID(const QString &packageID);
0041 
0042     [[nodiscard]] QString sourcePackage() const;
0043     void setSourcePackage(const QString &sourcePackageName);
0044 
0045     [[nodiscard]] bool isDebugPackageInstalled() const;
0046     void setDebugPackageInstalled();
0047 
0048     [[nodiscard]] QString debugPackageID() const;
0049     void setDebugPackageIDAndStatus(const QString &debugPackageID, bool installed);
0050 
0051     [[nodiscard]] QString diagnosticData() const;
0052     void setDiagnosticData(const QString &data);
0053 
0054     [[nodiscard]] bool isResolved() const;
0055     void setResolved();
0056 
0057 Q_SIGNALS:
0058     void changed();
0059     void resolved();
0060 
0061 private:
0062     QString m_path;
0063     QString m_packageID;
0064     QString m_sourcePackage;
0065     QString m_debugPackageID;
0066     bool m_debugPackageInstalled = false;
0067     QString m_diagnosticData;
0068 
0069     bool m_resolved = false;
0070 };