| 76 | } |
| 77 | |
| 78 | void InfoFrame::updateWithMod(Mod const& m) |
| 79 | { |
| 80 | if (m.type() == ResourceType::FOLDER) { |
| 81 | clear(); |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | QString text = ""; |
| 86 | QString name = ""; |
| 87 | QString link = m.metaurl(); |
| 88 | if (m.name().isEmpty()) |
| 89 | name = m.internal_id(); |
| 90 | else |
| 91 | name = m.name(); |
| 92 | |
| 93 | if (link.isEmpty()) |
| 94 | text = name; |
| 95 | else { |
| 96 | text = "<a href=\"" + link + "\">" + name + "</a>"; |
| 97 | } |
| 98 | if (!m.authors().isEmpty()) |
| 99 | text += " by " + m.authors().join(", "); |
| 100 | |
| 101 | setName(text); |
| 102 | |
| 103 | if (m.description().isEmpty()) { |
| 104 | setDescription(QString()); |
| 105 | } else { |
| 106 | setDescription(m.description()); |
| 107 | } |
| 108 | |
| 109 | setImage(m.icon({ 64, 64 })); |
| 110 | |
| 111 | auto licenses = m.licenses(); |
| 112 | QString licenseText = ""; |
| 113 | if (!licenses.empty()) { |
| 114 | for (auto l : licenses) { |
| 115 | if (!licenseText.isEmpty()) { |
| 116 | licenseText += "\n"; // add newline between licenses |
| 117 | } |
| 118 | if (!l.name.isEmpty()) { |
| 119 | if (l.url.isEmpty()) { |
| 120 | licenseText += l.name; |
| 121 | } else { |
| 122 | licenseText += "<a href=\"" + l.url + "\">" + l.name + "</a>"; |
| 123 | } |
| 124 | } else if (!l.url.isEmpty()) { |
| 125 | licenseText += "<a href=\"" + l.url + "\">" + l.url + "</a>"; |
| 126 | } |
| 127 | if (!l.description.isEmpty() && l.description != l.name) { |
| 128 | licenseText += " " + l.description; |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | if (!licenseText.isEmpty()) { |
| 133 | setLicense(tr("License: %1").arg(licenseText)); |
| 134 | } else { |
| 135 | setLicense(); |
no test coverage detected