This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2019-05-20 22:25:19 +02:00

47 lines
1.0 KiB
C++

#ifndef PACKAGES_H
#define PACKAGES_H
#include <QAbstractListModel>
class Package;
class Packages: public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
public:
enum Roles {
RoleId,
RoleDisplayName,
RoleSummary,
RoleInstalledVersion,
RoleCandidateVersion,
RoleChangelog,
RoleUpdateAvailable,
RoleRollbackAvailable
};
Q_ENUM(Roles)
explicit Packages(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
void addPackage(Package *package);
void removePackage(const QString &packageId);
Q_INVOKABLE Package* get(int index) const;
Q_INVOKABLE Package* getPackage(const QString &packageId);
void clear();
signals:
void countChanged();
private:
QList<Package*> m_list;
};
#endif // PACKAGES_H