diff options
author | flow <flowlnlnln@gmail.com> | 2022-12-18 16:55:09 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2023-01-13 16:23:07 -0300 |
commit | 0e207aba6c4eb67dccef12750c080a64deba6764 (patch) | |
tree | ea9ae07cf83a381352c4d2eff34a7d71995b69de | |
parent | 45d1319891ce87cc1546a316ad550f892d411633 (diff) | |
download | PrismLauncher-0e207aba6c4eb67dccef12750c080a64deba6764.tar.gz PrismLauncher-0e207aba6c4eb67dccef12750c080a64deba6764.tar.bz2 PrismLauncher-0e207aba6c4eb67dccef12750c080a64deba6764.zip |
feat(RD): add roleNames and Q_PROPERTY to ResourceModel
in preparation for QML interop.
Signed-off-by: flow <flowlnlnln@gmail.com>
-rw-r--r-- | launcher/ui/pages/modplatform/ResourceModel.cpp | 15 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ResourceModel.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/launcher/ui/pages/modplatform/ResourceModel.cpp b/launcher/ui/pages/modplatform/ResourceModel.cpp index cf40fef2..eedc5202 100644 --- a/launcher/ui/pages/modplatform/ResourceModel.cpp +++ b/launcher/ui/pages/modplatform/ResourceModel.cpp @@ -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(); diff --git a/launcher/ui/pages/modplatform/ResourceModel.h b/launcher/ui/pages/modplatform/ResourceModel.h index af33bf55..45af33a2 100644 --- a/launcher/ui/pages/modplatform/ResourceModel.h +++ b/launcher/ui/pages/modplatform/ResourceModel.h @@ -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; |