MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / updateWithMod

Method updateWithMod

launcher/ui/widgets/InfoFrame.cpp:78–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void 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();

Callers 1

onSelectionChangedMethod · 0.80

Calls 12

QStringClass · 0.85
metaurlMethod · 0.80
internal_idMethod · 0.80
authorsMethod · 0.80
licensesMethod · 0.80
issueTrackerMethod · 0.80
typeMethod · 0.45
isEmptyMethod · 0.45
nameMethod · 0.45
descriptionMethod · 0.45
iconMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected