File indexing completed on 2024-11-17 04:55:43

0001 /*
0002  *   SPDX-FileCopyrightText: 2016 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include <PackageKit/Transaction>
0010 #include <resources/AbstractSourcesBackend.h>
0011 
0012 class QStandardItem;
0013 class PKSourcesModel;
0014 
0015 class PackageKitSourcesBackend : public AbstractSourcesBackend
0016 {
0017     Q_OBJECT
0018 public:
0019     PackageKitSourcesBackend(AbstractResourcesBackend *parent);
0020 
0021     QString idDescription() override;
0022 
0023     bool supportsAdding() const override
0024     {
0025         return false;
0026     }
0027     bool addSource(const QString &id) override;
0028     bool removeSource(const QString &id) override;
0029 
0030     QAbstractItemModel *sources() override;
0031     QVariantList actions() const override;
0032 
0033     void transactionError(PackageKit::Transaction::Error, const QString &message);
0034 
0035 private:
0036     void resetSources();
0037     void addRepositoryDetails(const QString &id, const QString &description, bool enabled);
0038     QStandardItem *findItemForId(const QString &id) const;
0039 
0040     PKSourcesModel *m_sources;
0041     QVariantList m_actions;
0042 };