From b68fb0a060458aa8b113b67a3b6d9b157fcf4e2e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 12 Sep 2011 21:29:00 +0200 Subject: [PATCH] be sure to include ALL role names some dataengines can have a different set of keys for each item (ie metadata dataengine) the whole mapped roles must be the complete superset this is not very efficient, but unfortunately is necessary. (another reason why DataContainers should become models) --- declarativeimports/core/datamodel.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/declarativeimports/core/datamodel.cpp b/declarativeimports/core/datamodel.cpp index d4f28c0a4..eb56b4fe1 100644 --- a/declarativeimports/core/datamodel.cpp +++ b/declarativeimports/core/datamodel.cpp @@ -262,19 +262,23 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list) if (!list.isEmpty()) { if (list.first().canConvert()) { - foreach (const QString& roleName, list.first().value().keys()) { - if (!m_roleIds.contains(roleName)) { - ++m_maxRoleId; - m_roleNames[m_maxRoleId] = roleName.toLatin1(); - m_roleIds[roleName] = m_maxRoleId; + foreach (const QVariant &item, list) { + foreach (const QString& roleName, item.value().keys()) { + if (!m_roleIds.contains(roleName)) { + ++m_maxRoleId; + m_roleNames[m_maxRoleId] = roleName.toLatin1(); + m_roleIds[roleName] = m_maxRoleId; + } } } } else { - foreach (const QString& roleName, list.first().value().keys()) { - if (!m_roleIds.contains(roleName)) { - ++m_maxRoleId; - m_roleNames[m_maxRoleId] = roleName.toLatin1(); - m_roleIds[roleName] = m_maxRoleId; + foreach (const QVariant &item, list) { + foreach (const QString& roleName, item.value().keys()) { + if (!m_roleIds.contains(roleName)) { + ++m_maxRoleId; + m_roleNames[m_maxRoleId] = roleName.toLatin1(); + m_roleIds[roleName] = m_maxRoleId; + } } } }