54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include "packageutils.h"
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QSet>
|
|
|
|
struct Tool
|
|
{
|
|
QString packageName;
|
|
QString version;
|
|
QString availableVersion;
|
|
QString architecture;
|
|
QString summary;
|
|
bool installed = false;
|
|
bool available = false;
|
|
bool updateAvailable = false;
|
|
};
|
|
|
|
class ToolModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum Role {
|
|
PackageNameRole = Qt::UserRole + 1,
|
|
VersionRole,
|
|
AvailableVersionRole,
|
|
ArchitectureRole,
|
|
SummaryRole,
|
|
InstalledRole,
|
|
AvailableRole,
|
|
UpdateAvailableRole,
|
|
ConfigurableRole,
|
|
};
|
|
|
|
explicit ToolModel(QObject *parent = nullptr);
|
|
|
|
int rowCount(const QModelIndex &parent = {}) const override;
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
void setPackages(const QList<PackageRecord> &installed,
|
|
const QList<PackageRecord> &available,
|
|
const QSet<QString> &updates = {});
|
|
bool mayInstall(const QString &packageName) const;
|
|
bool mayRemove(const QString &packageName) const;
|
|
|
|
private:
|
|
QList<Tool> m_tools;
|
|
};
|