From 9e9d075cd47288213bbc832996724721805dc6b8 Mon Sep 17 00:00:00 2001 From: Chris Josten Date: Sun, 27 Sep 2020 17:05:49 +0200 Subject: [PATCH] Fix models acting weird when changing sort Apparently the Jellyfin server may include different fields in the resposne depending on which SortOrder you use. This causes the model to generate new roleNames when changing its sortOrder, but the QML part does not know of this happening and there's no way of notifying the QML part as far as I'm aware of (if so, let me know). So whenever new generateFields() is called, it shouldn't reset its roleNames map and recreate it anew, rather, just append the new roleNames to the current map. If a model in QML wants to use information used in fields which are added by changing SortOrder, please add those fields explicitly in Fields. --- src/jellyfinapimodel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jellyfinapimodel.cpp b/src/jellyfinapimodel.cpp index 6740c74..7e1f4d4 100644 --- a/src/jellyfinapimodel.cpp +++ b/src/jellyfinapimodel.cpp @@ -121,7 +121,6 @@ void ApiModel::load(LoadType type) { void ApiModel::generateFields() { if (m_array.size() == 0) return; this->beginResetModel(); - m_roles.clear(); int i = Qt::UserRole + 1; if (!m_array[0].isObject()) { qWarning() << "Iterator is not an object?";