From 46bb242c69c999575b4d67f262bb5676f243651f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 12 Jan 2021 17:53:38 +0100 Subject: mobile/statistics: export ChartListModel to QML For QML, the roles have to be associated dynamically with name. Moreover, the model has to be registered as a QML type to make it accessible from QML. Signed-off-by: Berthold Stoeger --- stats/chartlistmodel.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'stats/chartlistmodel.cpp') diff --git a/stats/chartlistmodel.cpp b/stats/chartlistmodel.cpp index ae9c71748..bce54ce25 100644 --- a/stats/chartlistmodel.cpp +++ b/stats/chartlistmodel.cpp @@ -60,6 +60,18 @@ Qt::ItemFlags ChartListModel::flags(const QModelIndex &index) const : Qt::ItemIsSelectable | Qt::ItemIsEnabled; } +QHash ChartListModel::roleNames() const +{ + QHash roles; + roles[Qt::DisplayRole] = "display"; + roles[IconRole] = "icon"; + roles[IconSizeRole] = "iconSize"; + roles[ChartNameRole] = "chartName"; + roles[IsHeaderRole] = "isHeader"; + roles[Qt::UserRole] = "id"; + return roles; +} + QVariant ChartListModel::data(const QModelIndex &index, int role) const { int row = index.row(); -- cgit v1.2.3-70-g09d2