aboutsummaryrefslogtreecommitdiff
path: root/lib/events/eventcontent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 21:34:00 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 21:34:00 +0900
commit6a9de91752dfe75e185bf90ab856367b2c804582 (patch)
tree2a12ecc84bf0055e317ef2e4aeec3439d92b2035 /lib/events/eventcontent.cpp
parentd5397fe5ae2ca34d5cfb11394dac17728a2b50ce (diff)
parent5d1dd53890611376873f6f959e206d5a56cfff70 (diff)
downloadlibquotient-6a9de91752dfe75e185bf90ab856367b2c804582.tar.gz
libquotient-6a9de91752dfe75e185bf90ab856367b2c804582.zip
Merge branch 'kitsune-events-rewritten'
Diffstat (limited to 'lib/events/eventcontent.cpp')
-rw-r--r--lib/events/eventcontent.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp
index f5974b46..a6b1c763 100644
--- a/lib/events/eventcontent.cpp
+++ b/lib/events/eventcontent.cpp
@@ -17,8 +17,8 @@
*/
#include "eventcontent.h"
+#include "util.h"
-#include <QtCore/QUrl>
#include <QtCore/QMimeDatabase>
using namespace QMatrixClient::EventContent;
@@ -39,9 +39,9 @@ FileInfo::FileInfo(const QUrl& u, int payloadSize, const QMimeType& mimeType,
FileInfo::FileInfo(const QUrl& u, const QJsonObject& infoJson,
const QString& originalFilename)
: originalInfoJson(infoJson)
- , mimeType(QMimeDatabase().mimeTypeForName(infoJson["mimetype"].toString()))
+ , mimeType(QMimeDatabase().mimeTypeForName(infoJson["mimetype"_ls].toString()))
, url(u)
- , payloadSize(infoJson["size"].toInt())
+ , payloadSize(infoJson["size"_ls].toInt())
, originalName(originalFilename)
{
if (!mimeType.isValid())
@@ -51,8 +51,8 @@ FileInfo::FileInfo(const QUrl& u, const QJsonObject& infoJson,
void FileInfo::fillInfoJson(QJsonObject* infoJson) const
{
Q_ASSERT(infoJson);
- infoJson->insert("size", payloadSize);
- infoJson->insert("mimetype", mimeType.name());
+ infoJson->insert(QStringLiteral("size"), payloadSize);
+ infoJson->insert(QStringLiteral("mimetype"), mimeType.name());
}
ImageInfo::ImageInfo(const QUrl& u, int fileSize, QMimeType mimeType,
@@ -63,23 +63,24 @@ ImageInfo::ImageInfo(const QUrl& u, int fileSize, QMimeType mimeType,
ImageInfo::ImageInfo(const QUrl& u, const QJsonObject& infoJson,
const QString& originalFilename)
: FileInfo(u, infoJson, originalFilename)
- , imageSize(infoJson["w"].toInt(), infoJson["h"].toInt())
+ , imageSize(infoJson["w"_ls].toInt(), infoJson["h"_ls].toInt())
{ }
void ImageInfo::fillInfoJson(QJsonObject* infoJson) const
{
FileInfo::fillInfoJson(infoJson);
- infoJson->insert("w", imageSize.width());
- infoJson->insert("h", imageSize.height());
+ infoJson->insert(QStringLiteral("w"), imageSize.width());
+ infoJson->insert(QStringLiteral("h"), imageSize.height());
}
Thumbnail::Thumbnail(const QJsonObject& infoJson)
- : ImageInfo(infoJson["thumbnail_url"].toString(),
- infoJson["thumbnail_info"].toObject())
+ : ImageInfo(infoJson["thumbnail_url"_ls].toString(),
+ infoJson["thumbnail_info"_ls].toObject())
{ }
void Thumbnail::fillInfoJson(QJsonObject* infoJson) const
{
- infoJson->insert("thumbnail_url", url.toString());
- infoJson->insert("thumbnail_info", toInfoJson<ImageInfo>(*this));
+ infoJson->insert(QStringLiteral("thumbnail_url"), url.toString());
+ infoJson->insert(QStringLiteral("thumbnail_info"),
+ toInfoJson<ImageInfo>(*this));
}