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)
This commit is contained in:
Marco Martin 2011-09-12 21:29:00 +02:00
parent 7e461fd166
commit b68fb0a060

View File

@ -262,19 +262,23 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list)
if (!list.isEmpty()) {
if (list.first().canConvert<QVariantHash>()) {
foreach (const QString& roleName, list.first().value<QVariantHash>().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<QVariantHash>().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<QVariantMap>().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<QVariantMap>().keys()) {
if (!m_roleIds.contains(roleName)) {
++m_maxRoleId;
m_roleNames[m_maxRoleId] = roleName.toLatin1();
m_roleIds[roleName] = m_maxRoleId;
}
}
}
}