summary refs log tree commit diff
path: root/src/timeline2/TimelineModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/timeline2/TimelineModel.cpp')
-rw-r--r--src/timeline2/TimelineModel.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/timeline2/TimelineModel.cpp b/src/timeline2/TimelineModel.cpp

index 83d1e417..d624c938 100644 --- a/src/timeline2/TimelineModel.cpp +++ b/src/timeline2/TimelineModel.cpp
@@ -87,8 +87,9 @@ eventFormattedBody(const mtx::events::RoomEvent<T> &e) if (pos != std::string::npos) temp.erase(pos, std::string("</mx-reply>").size()); return QString::fromStdString(temp); - } else - return QString::fromStdString(e.content.body); + } else { + return QString::fromStdString(e.content.body).toHtmlEscaped().replace("\n", "<br>"); + } } template<class T> @@ -139,6 +140,20 @@ eventFilename(const mtx::events::RoomEvent<mtx::events::msg::File> &e) } template<class T> +auto +eventFilesize(const mtx::events::RoomEvent<T> &e) -> decltype(e.content.info.size) +{ + return e.content.info.size; +} + +template<class T> +int64_t +eventFilesize(const T &) +{ + return 0; +} + +template<class T> QString eventMimeType(const T &) { @@ -341,6 +356,7 @@ TimelineModel::roleNames() const {Timestamp, "timestamp"}, {Url, "url"}, {Filename, "filename"}, + {Filesize, "filesize"}, {MimeType, "mimetype"}, {Height, "height"}, {Width, "width"}, @@ -423,6 +439,12 @@ TimelineModel::data(const QModelIndex &index, int role) const case Filename: return QVariant(boost::apply_visitor( [](const auto &e) -> QString { return eventFilename(e); }, event)); + case Filesize: + return QVariant(boost::apply_visitor( + [](const auto &e) -> QString { + return utils::humanReadableFileSize(eventFilesize(e)); + }, + event)); case MimeType: return QVariant(boost::apply_visitor( [](const auto &e) -> QString { return eventMimeType(e); }, event));