2022-01-13 23:37:46 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-16 20:00:10 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <QListView>
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
#include "ui_shared/BootablesDbClient.h"
|
|
|
|
|
|
|
|
class BootableModel : public QAbstractTableModel
|
|
|
|
{
|
2019-01-17 12:26:47 +00:00
|
|
|
Q_OBJECT
|
2019-01-16 20:00:10 +00:00
|
|
|
|
|
|
|
public:
|
2019-01-17 21:52:23 +00:00
|
|
|
BootableModel(QObject* parent, std::vector<BootablesDb::Bootable>&);
|
2019-01-16 20:00:10 +00:00
|
|
|
|
2019-01-17 12:26:47 +00:00
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
|
|
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
|
2019-01-16 20:00:10 +00:00
|
|
|
|
2019-01-17 12:26:47 +00:00
|
|
|
QSize SizeHint();
|
|
|
|
BootablesDb::Bootable GetBootable(const QModelIndex&);
|
2019-01-16 20:00:10 +00:00
|
|
|
void removeItem(const QModelIndex&);
|
2019-05-19 16:16:24 +01:00
|
|
|
void SetWidth(int);
|
2019-01-17 12:26:47 +00:00
|
|
|
|
2019-01-16 20:00:10 +00:00
|
|
|
private:
|
2019-01-17 21:52:23 +00:00
|
|
|
std::vector<BootablesDb::Bootable>& m_bootables;
|
2019-01-16 20:00:10 +00:00
|
|
|
};
|
|
|
|
|
2022-01-18 16:47:28 +00:00
|
|
|
class BootableCoverQVariant
|
2019-01-16 20:00:10 +00:00
|
|
|
{
|
2019-01-17 12:26:47 +00:00
|
|
|
|
2019-01-16 20:00:10 +00:00
|
|
|
public:
|
2023-03-08 13:13:19 -05:00
|
|
|
explicit BootableCoverQVariant(std::string = "PH", std::string = "", fs::path = "", BootablesDb::BootableStateList = {});
|
2022-01-18 16:47:28 +00:00
|
|
|
~BootableCoverQVariant() = default;
|
2019-01-16 20:00:10 +00:00
|
|
|
|
2019-01-17 12:26:47 +00:00
|
|
|
void paint(QPainter* painter, const QRect& rect, const QPalette& palette, int mode) const;
|
2019-01-16 20:00:10 +00:00
|
|
|
QSize sizeHint() const;
|
|
|
|
|
2023-03-08 13:13:19 -05:00
|
|
|
std::string GetKey() const;
|
|
|
|
std::string GetTitle() const;
|
|
|
|
fs::path GetPath() const;
|
2022-02-19 00:03:53 +00:00
|
|
|
bool HasState(std::string);
|
2022-01-15 00:17:41 +00:00
|
|
|
|
2019-01-16 20:00:10 +00:00
|
|
|
private:
|
2019-05-19 16:16:24 +01:00
|
|
|
int GetPadding() const;
|
2019-01-17 12:26:47 +00:00
|
|
|
std::string m_key;
|
2019-01-20 00:21:21 +00:00
|
|
|
std::string m_title;
|
2023-03-08 13:13:19 -05:00
|
|
|
fs::path m_path;
|
2022-02-19 00:40:29 +00:00
|
|
|
std::string m_statusColor;
|
2022-02-19 00:03:53 +00:00
|
|
|
BootablesDb::BootableStateList m_states;
|
2019-01-16 20:00:10 +00:00
|
|
|
};
|
|
|
|
|
2022-01-18 16:47:28 +00:00
|
|
|
Q_DECLARE_METATYPE(BootableCoverQVariant)
|
2019-01-16 20:00:10 +00:00
|
|
|
|
|
|
|
class BootImageItemDelegate : public QStyledItemDelegate
|
|
|
|
{
|
2019-01-17 12:26:47 +00:00
|
|
|
Q_OBJECT
|
2019-01-16 20:00:10 +00:00
|
|
|
|
|
|
|
public:
|
2019-01-20 02:51:16 +00:00
|
|
|
BootImageItemDelegate(QWidget* parent = 0);
|
2019-01-16 20:00:10 +00:00
|
|
|
|
2019-01-17 12:26:47 +00:00
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
2019-01-16 20:00:10 +00:00
|
|
|
};
|