| 133 | } |
| 134 | |
| 135 | void 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 | |
| 161 | QString SelectComic::getSelectedComicId() |
| 162 | { |