KOSMIndoorMap
13using namespace Wikidata;
15Item::Item() =
default;
22Item::~Item() =
default;
24std::vector<QVariant> Item::values(
P property)
const
26 std::vector<QVariant> values;
27 std::vector<bool> prefRank;
29 auto propA = m_data.value(
"claims"_L1).toObject().value(
property.toString()).toArray();
30 for (
const auto & propV : propA) {
31 const auto propObj = propV.toObject();
32 const auto rank = propObj.value(
"rank"_L1).toString();
33 if (rank ==
"deprecated"_L1) {
36 const auto valueObj = propObj.value(
"mainsnak"_L1).toObject().value(
"datavalue"_L1).toObject();
37 const auto type = valueObj.value(
"type"_L1).toString();
38 if (type ==
"string"_L1) {
39 values.push_back(valueObj.value(
"value"_L1).toString());
40 }
else if (type ==
"wikibase-entityid"_L1) {
41 values.push_back(
QVariant::fromValue(Wikidata::Q(valueObj.value(
"value"_L1).toObject().value(
"id"_L1).toString())));
45 prefRank.push_back(rank ==
"preferred"_L1);
49 if (std::any_of(prefRank.begin(), prefRank.end(), [](
bool v) { return v; })) {
51 for (
auto it = values.begin(); it != values.end();) {
55 it = values.erase(it);
66 return vals.empty() ? QVariant() : vals[0];
70Image::Image() =
default;
76Image::~Image() =
default;
80 return m_data.value(
"title"_L1).toString().
mid(5);
83uint64_t Image::fileSize()
const
85 return imageInfo().value(
"size"_L1).
toInt();
88uint32_t Image::width()
const
90 return imageInfo().value(
"width"_L1).toInt();
93uint32_t Image::height()
const
95 return imageInfo().value(
"height"_L1).toInt();
98QString Image::mimeType()
const
100 return imageInfo().value(
"mime"_L1).toString();
103QString Image::license()
const
105 const auto extmeta = imageInfo().value(
"extmetadata"_L1).toObject();
106 return extmeta.value(
"LicenseShortName"_L1).toObject().value(
"value"_L1).toString();
109QJsonObject Image::imageInfo()
const
111 const auto ii = m_data.value(
"imageinfo"_L1).toArray();
115 return ii.at(0).toObject();
Wikidata property identifier.
Wikidata item identifier.
QVariant property(const char *name) const const
QString mid(qsizetype position, qsizetype n) const const
int toInt(bool *ok, int base) const const
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:54:42 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.