diff --git a/src/models/locationsmodel.cpp b/src/models/locationsmodel.cpp index 717b03574..777f517d4 100644 --- a/src/models/locationsmodel.cpp +++ b/src/models/locationsmodel.cpp @@ -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(m_room->user(event->senderId())), }; endInsertRows(); @@ -80,6 +80,8 @@ QHash 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 {}; } diff --git a/src/models/locationsmodel.h b/src/models/locationsmodel.h index 00280c64c..0dc582391 100644 --- a/src/models/locationsmodel.h +++ b/src/models/locationsmodel.h @@ -19,6 +19,8 @@ public: TextRole = Qt::DisplayRole, LongitudeRole, LatitudeRole, + AssetRole, + AuthorRole, }; Q_ENUM(Roles) Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged) @@ -42,7 +44,7 @@ private: QString eventId; float latitude; float longitude; - QString text; + QJsonObject content; NeoChatUser *author; }; QList m_locations;