MCPcopy Create free account
hub / github.com/YACReader/yacreader / setDescription

Method setDescription

YACReaderLibrary/comic_vine/select_volume.cpp:179–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void SelectVolume::setDescription(const QString &jsonDetail)
180{
181 QJsonParseError Err;
182 QVariantMap sc = QJsonDocument::fromJson(jsonDetail.toUtf8(), &Err).toVariant().toMap();
183
184 if (Err.error != QJsonParseError::NoError) {
185 qDebug("Error detected");
186 return;
187 }
188
189 auto resultMap = sc.value("results").toMap();
190 QVariant descriptionValues = resultMap.value("description");
191 auto description = descriptionValues.toString().trimmed();
192 QVariant deckValues = resultMap.value("deck");
193 auto deck = deckValues.toString().trimmed();
194 bool valid = !descriptionValues.isNull() && descriptionValues.isValid() && !description.isEmpty();
195 bool validDeck = !deckValues.isNull() && deckValues.isValid() && !deck.isEmpty();
196 if (valid) {
197 selectedVolumeDescription = description;
198 detailLabel->setText(description.replace("<a", "<a style = 'color:#827A68; text-decoration:none;'"));
199 } else if (validDeck) {
200 selectedVolumeDescription = deck;
201 detailLabel->setText(deck.replace("<a", "<a style = 'color:#827A68; text-decoration:none;'"));
202 } else {
203 detailLabel->setText(tr("volume description unavailable"));
204 }
205}
206
207SelectedVolumeInfo SelectVolume::getSelectedVolumeInfo()
208{

Callers

nothing calls this directly

Calls 5

toStringMethod · 0.80
isEmptyMethod · 0.80
replaceMethod · 0.80
isValidMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected