libQuotient
A Qt library for building matrix clients
|
Mix-in class representing info
subobject in content JSON.
More...
#include <eventcontent.h>
Public Member Functions | |
FileInfo ()=default | |
FileInfo (const QFileInfo &fi) | |
Construct from a QFileInfo object. More... | |
FileInfo (FileSourceInfo sourceInfo, qint64 payloadSize=-1, const QMimeType &mimeType={}, QString originalFilename={}) | |
FileInfo (FileSourceInfo sourceInfo, const QJsonObject &infoJson, QString originalFilename={}) | |
Construct from a JSON info payload. More... | |
bool | isValid () const |
QUrl | url () const |
QString | mediaId () const |
Extract media id from the URL. More... | |
Public Attributes | |
FileSourceInfo | source |
QJsonObject | originalInfoJson |
QMimeType | mimeType |
qint64 | payloadSize = 0 |
QString | originalName |
Mix-in class representing info
subobject in content JSON.
This is one of base classes for content types that deal with files or URLs. It stores file metadata attributes, such as size, MIME type etc. found in the content/info
subobject of event JSON payloads. Actual content classes derive from this class and Base that provides a polymorphic interface to access data in the mix-in. FileInfo (as well as ImageInfo, that adds image size to the metadata) is NOT polymorphic and is used in a non-polymorphic way to store thumbnail metadata (in a separate instance), next to the metadata on the file itself.
If you need to make a new content (not info) class based on files/URLs take UrlBasedContent as the example, i.e.:
info
subobject (not the whole content JSON) down to FileInfo/ImageInfo.info
subobject in the JSON payload.Definition at line 91 of file eventcontent.h.
|
default |
|
explicit |
Construct from a QFileInfo object.
fi | a QFileInfo object referring to an existing file |
|
explicit |
Quotient::EventContent::FileInfo::FileInfo | ( | FileSourceInfo | sourceInfo, |
const QJsonObject & | infoJson, | ||
QString | originalFilename = {} |
||
) |
Construct from a JSON info
payload.
Make sure to pass the info
subobject of content JSON, not the whole JSON content.
bool Quotient::EventContent::FileInfo::isValid | ( | ) | const |
|
inline |
Extract media id from the URL.
This can be used, e.g., to construct a QML-facing image:// URI as follows:
Definition at line 115 of file eventcontent.h.
QUrl Quotient::EventContent::FileInfo::url | ( | ) | const |
QMimeType Quotient::EventContent::FileInfo::mimeType |
Definition at line 119 of file eventcontent.h.
QJsonObject Quotient::EventContent::FileInfo::originalInfoJson |
Definition at line 118 of file eventcontent.h.
QString Quotient::EventContent::FileInfo::originalName |
Definition at line 121 of file eventcontent.h.
qint64 Quotient::EventContent::FileInfo::payloadSize = 0 |
Definition at line 120 of file eventcontent.h.
FileSourceInfo Quotient::EventContent::FileInfo::source |
Definition at line 117 of file eventcontent.h.