File indexing completed on 2024-04-28 09:40:58

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 #include "File.h"
0005 
0006 #include <PackageKit/Daemon>
0007 
0008 File::File(QString path, QObject *parent)
0009     : QObject(parent)
0010     , m_path(std::move(path))
0011 {
0012 }
0013 
0014 QStringList File::potentialDebugPackageCandidateNames() const
0015 {
0016     auto pkgName = package();
0017     QStringList candidates{pkgName + QStringLiteral("-dbgsym"), pkgName + QStringLiteral("-dbg")};
0018     if (!m_sourcePackage.isEmpty()) {
0019         // -dbg would be a manual created one, so it should take preference here.
0020         candidates << m_sourcePackage + QStringLiteral("-dbg")
0021                     << m_sourcePackage + QStringLiteral("-dbgsym");
0022     }
0023     return candidates;
0024 }
0025 
0026 QString File::path() const
0027 {
0028     return m_path;
0029 }
0030 
0031 void File::setPath(const QString &path)
0032 {
0033     if (m_path == path) {
0034         return;
0035     }
0036     m_path = path;
0037     Q_EMIT changed();
0038 }
0039 
0040 QString File::packageID() const
0041 {
0042     return m_packageID;
0043 }
0044 
0045 void File::setPackageID(const QString &packageID)
0046 {
0047     m_packageID = packageID;
0048     Q_EMIT changed();
0049 }
0050 
0051 QString File::package() const
0052 {
0053     // Trivial string splitting internally, no use caching.
0054     return PackageKit::Daemon::packageName(packageID());
0055 }
0056 
0057 QString File::sourcePackage() const
0058 {
0059     return m_sourcePackage;
0060 }
0061 
0062 void File::setSourcePackage(const QString &sourcePackageName)
0063 {
0064     m_sourcePackage = sourcePackageName;
0065     Q_EMIT changed();
0066 }
0067 
0068 void File::setDebugPackageIDAndStatus(const QString &debugPackageID, bool installed)
0069 {
0070     m_debugPackageID = debugPackageID;
0071     m_debugPackageInstalled = installed;
0072     Q_EMIT changed();
0073 }
0074 
0075 QString File::debugPackageID() const
0076 {
0077     return m_debugPackageID;
0078 }
0079 
0080 QString File::diagnosticData() const
0081 {
0082     return m_diagnosticData;
0083 }
0084 
0085 void File::setDiagnosticData(const QString &data)
0086 {
0087     m_diagnosticData = data;
0088     Q_EMIT changed();
0089 }
0090 
0091 bool File::isDebugPackageInstalled() const
0092 {
0093     return m_debugPackageInstalled;
0094 }
0095 
0096 void File::setDebugPackageInstalled()
0097 {
0098     m_debugPackageInstalled = true;
0099     Q_EMIT changed();
0100 }
0101 
0102 void File::setResolved()
0103 {
0104     m_resolved = true;
0105     Q_EMIT resolved();
0106 }
0107 
0108 bool File::isResolved() const
0109 {
0110     return m_resolved;
0111 }