Play-/Source/ui_qt/BootableModel.h

69 lines
1.9 KiB
C
Raw Normal View History

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"
2024-10-22 11:11:49 +01:00
#include "ui_shared/BootableUtils.h"
2019-01-16 20:00:10 +00:00
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&);
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:
2024-10-22 11:11:49 +01:00
explicit BootableCoverQVariant(std::string = "PH", std::string = "", fs::path = "", BootablesDb::BootableStateList = {}, BootableUtils::BOOTABLE_TYPE = BootableUtils::UNKNOWN);
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;
std::string GetKey() const;
std::string GetTitle() const;
fs::path GetPath() const;
2022-02-19 00:03:53 +00:00
bool HasState(std::string);
2024-10-17 21:40:04 +01:00
int GetBootableType() const;
2019-01-16 20:00:10 +00:00
private:
int GetPadding() const;
2019-01-17 12:26:47 +00:00
std::string m_key;
std::string m_title;
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;
2024-10-22 11:11:49 +01:00
BootableUtils::BOOTABLE_TYPE m_bootableType;
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
};