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

Method setDescription

YACReaderLibrary/comic_vine/select_comic.cpp:135–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void SelectComic::setDescription(const QString &jsonDetail)
136{
137 QJsonParseError Err;
138 QVariantMap sc = QJsonDocument::fromJson(jsonDetail.toUtf8(), &Err).toVariant().toMap();
139
140 if (Err.error != QJsonParseError::NoError) {
141 qDebug("Error detected");
142 return;
143 }
144
145 auto resultMap = sc.value("results").toMap();
146 QVariant descriptionValues = resultMap.value("description");
147 auto description = descriptionValues.toString().trimmed();
148 QVariant deckValues = resultMap.value("deck");
149 auto deck = deckValues.toString().trimmed();
150 bool valid = !descriptionValues.isNull() && descriptionValues.isValid() && !description.isEmpty();
151 bool validDeck = !deckValues.isNull() && deckValues.isValid() && !deck.isEmpty();
152 if (valid) {
153 detailLabel->setText(description.replace("<a", "<a style = 'color:#827A68; text-decoration:none;'"));
154 } else if (validDeck) {
155 detailLabel->setText(deck.replace("<a", "<a style = 'color:#827A68; text-decoration:none;'"));
156 } else {
157 detailLabel->setText(tr("comic description unavailable"));
158 }
159}
160
161QString SelectComic::getSelectedComicId()
162{

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