feat(RD): add roleNames and Q_PROPERTY to ResourceModel
in preparation for QML interop. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
45d1319891
commit
0e207aba6c
@ -79,6 +79,21 @@ auto ResourceModel::data(const QModelIndex& index, int role) const -> QVariant
|
||||
return {};
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ResourceModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
|
||||
roles[Qt::ToolTipRole] = "toolTip";
|
||||
roles[Qt::DecorationRole] = "decoration";
|
||||
roles[Qt::SizeHintRole] = "sizeHint";
|
||||
roles[Qt::UserRole] = "pack";
|
||||
roles[UserDataTypes::TITLE] = "title";
|
||||
roles[UserDataTypes::DESCRIPTION] = "description";
|
||||
roles[UserDataTypes::SELECTED] = "selected";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
bool ResourceModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
int pos = index.row();
|
||||
|
@ -21,11 +21,14 @@ namespace ResourceDownload {
|
||||
class ResourceModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString search_term MEMBER m_search_term WRITE setSearchTerm)
|
||||
|
||||
public:
|
||||
ResourceModel(BaseInstance const&, ResourceAPI* api);
|
||||
~ResourceModel() override;
|
||||
|
||||
[[nodiscard]] auto data(const QModelIndex&, int role) const -> QVariant override;
|
||||
[[nodiscard]] auto roleNames() const -> QHash<int, QByteArray> override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
||||
|
||||
[[nodiscard]] virtual auto debugName() const -> QString;
|
||||
|
Loading…
Reference in New Issue
Block a user