Play-/Source/ui_qt/BootableModel.h

64 lines
1.6 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"
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:
2022-02-19 00:40:29 +00:00
explicit BootableCoverQVariant(std::string = "PH", std::string = "", std::string = "", 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;
std::string GetKey();
std::string GetTitle();
std::string GetPath();
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;
std::string m_path;
2022-02-19 00:40:29 +00:00
std::string m_statusColor;
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
};