Extend LocationsModel to include asset and auther roles

Needed for compatibility with the standard map marker.
This commit is contained in:
Volker Krause
2023-06-17 14:38:05 +02:00
parent 898f0c962a
commit a02dd4ab87
2 changed files with 11 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ void LocationsModel::addLocation(const RoomMessageEvent *event)
.eventId = event->id(),
.latitude = latitude,
.longitude = longitude,
.text = event->contentJson()["body"].toString(),
.content = event->contentJson(),
.author = dynamic_cast<NeoChatUser *>(m_room->user(event->senderId())),
};
endInsertRows();
@@ -80,6 +80,8 @@ QHash<int, QByteArray> LocationsModel::roleNames() const
{LongitudeRole, "longitude"},
{LatitudeRole, "latitude"},
{TextRole, "text"},
{AssetRole, "asset"},
{AuthorRole, "author"},
};
}
@@ -91,7 +93,11 @@ QVariant LocationsModel::data(const QModelIndex &index, int roleName) const
} else if (roleName == LatitudeRole) {
return m_locations[row].latitude;
} else if (roleName == TextRole) {
return m_locations[row].text;
return m_locations[row].content["body"_ls].toString();
} else if (roleName == AssetRole) {
return m_locations[row].content["org.matrix.msc3488.asset"_ls].toObject()["type"_ls].toString();
} else if (roleName == AuthorRole) {
return m_room->getUser(m_locations[row].author);
}
return {};
}