9#include <QJsonDocument>
13using namespace KGAPI2::Blogger;
15class Q_DECL_HIDDEN Post::Private
34 uint commentsCount = 0;
39 double longitude = -1;
44Post::Private::Private()
63void Post::setId(
const QString &
id)
73void Post::setBlogId(
const QString &
id)
83void Post::setPublished(
const QDateTime &published)
85 d->published = published;
93void Post::setUpdated(
const QDateTime &updated)
103void Post::setUrl(
const QUrl &url)
113void Post::setTitle(
const QString &title)
123void Post::setContent(
const QString &content)
125 d->content = content;
133QString Post::authorName()
const
135 return d->authorName;
138QUrl Post::authorUrl()
const
143QUrl Post::authorImageUrl()
const
145 return d->authorImageUrl;
148uint Post::commentsCount()
const
150 return d->commentsCount;
163QVariant Post::customMetaData()
const
165 return d->customMetaData;
168void Post::setCustomMetaData(
const QVariant &metadata)
170 d->customMetaData = metadata;
178void Post::setLocation(
const QString &location)
183double Post::latitude()
const
188void Post::setLatitude(
double lat)
193double Post::longitude()
const
198void Post::setLongitute(
double lng)
221 const QVariantMap
map = json.
toMap();
223 post->d->id =
map[QStringLiteral(
"id")].toString();
224 post->d->blogId =
map[QStringLiteral(
"blog")].toMap()[QStringLiteral(
"id")].toString();
227 post->d->url =
map[QStringLiteral(
"url")].toUrl();
228 post->d->title =
map[QStringLiteral(
"title")].toString();
229 post->d->content =
map[QStringLiteral(
"content")].toString();
230 const QVariantMap author =
map[QStringLiteral(
"author")].toMap();
231 post->d->authorId = author[QStringLiteral(
"id")].toString();
232 post->d->authorName = author[QStringLiteral(
"displayName")].toString();
233 post->d->authorUrl = author[QStringLiteral(
"url")].toUrl();
234 post->d->authorImageUrl = author[QStringLiteral(
"image")].toMap()[QStringLiteral(
"url")].toUrl();
235 post->d->commentsCount =
map[QStringLiteral(
"replies")].toMap()[QStringLiteral(
"totalItems")].toUInt();
236 post->d->labels =
map[QStringLiteral(
"labels")].toStringList();
237 post->d->customMetaData =
map[QStringLiteral(
"customMetaData")];
238 const QVariantMap location =
map[QStringLiteral(
"location")].toMap();
243 const QVariantList variantList =
map[QStringLiteral(
"images")].toList();
244 for (
const QVariant &url : variantList) {
245 post->d->images << url.toMap()[QStringLiteral(
"url")].toUrl();
247 post->d->status =
map[QStringLiteral(
"status")].toString();
255 json[QStringLiteral(
"kind")] = QStringLiteral(
"blogger#post");
256 if (!post->d->id.isEmpty()) {
257 json[QStringLiteral(
"id")] = post->d->id;
259 if (!post->d->blogId.isEmpty()) {
261 blog[QStringLiteral(
"id")] = post->d->blogId;
262 json[QStringLiteral(
"blog")] = blog;
265 if (post->d->published.isValid()) {
266 json[QStringLiteral(
"published")] = post->d->published.toString(
Qt::ISODate);
268 if (post->d->updated.isValid()) {
269 json[QStringLiteral(
"updated")] = post->d->updated.toString(
Qt::ISODate);
271 json[QStringLiteral(
"title")] = post->d->title;
272 json[QStringLiteral(
"content")] = post->d->content;
273 if (!post->d->labels.isEmpty()) {
274 json[QStringLiteral(
"labels")] = post->d->labels;
276 if (!post->d->customMetaData.isNull()) {
280 if (!post->d->location.isEmpty() && post->d->latitude > -1 && post->d->longitude > -1) {
282 location[QStringLiteral(
"name")] = post->d->location;
283 location[QStringLiteral(
"lat")] = post->d->latitude;
284 location[QStringLiteral(
"lng")] = post->d->longitude;
285 json[QStringLiteral(
"location")] =
location;
287 if (!post->d->images.isEmpty()) {
289 for (
const QUrl &url : std::as_const(post->d->images)) {
291 image[QStringLiteral(
"url")] = url.toString();
294 json[QStringLiteral(
"images")] = images;
308 const QVariantMap
map = json.
toMap();
313 return Private::fromJSON(map);
324 const QVariantMap
map = json.
toMap();
329 if (!map[QStringLiteral(
"nextPageToken")].
toString().isEmpty()) {
332 query.removeQueryItem(QStringLiteral(
"pageToken"));
333 query.addQueryItem(QStringLiteral(
"pageToken"), map[QStringLiteral(
"nextPageToken")].
toString());
337 const QVariantList variantList =
map[QStringLiteral(
"items")].toList();
339 for (
const QVariant &item : variantList) {
340 list << Private::fromJSON(item);
Structure to store additional information about a feed.
QUrl requestUrl
Original URL of the request.
QUrl nextPageUrl
Link to next page of feed.
Q_SCRIPTABLE CaptureState status()
std::optional< QSqlQuery > query(const QString &queryStatement)
char * toString(const EngineQuery &query)
A job to fetch a single map tile described by a StaticMapUrl.
QVariant location(const QVariant &res)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
QJsonDocument fromVariant(const QVariant &variant)
bool isNull() const const
QByteArray toJson(JsonFormat format) const const
QVariant toVariant() const const
void reserve(qsizetype size)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
void setQuery(const QString &query, ParsingMode mode)
double toDouble(bool *ok) const const
QMap< QString, QVariant > toMap() const const
QString toString() const const