MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / data

Method data

launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp:136–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136QVariant ListModel::data(const QModelIndex &index, int role) const
137{
138 int pos = index.row();
139 if(pos >= modpacks.size() || pos < 0 || !index.isValid())
140 {
141 return QString("INVALID INDEX %1").arg(pos);
142 }
143
144 Modpack pack = modpacks.at(pos);
145 if(role == Qt::DisplayRole)
146 {
147 return pack.name + "\n" + translatePackType(pack.type);
148 }
149 else if (role == Qt::ToolTipRole)
150 {
151 if(pack.description.length() > 100)
152 {
153 //some magic to prevent to long tooltips and replace html linebreaks
154 QString edit = pack.description.left(97);
155 edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
156 return edit;
157
158 }
159 return pack.description;
160 }
161 else if(role == Qt::DecorationRole)
162 {
163 if(m_logoMap.contains(pack.logo))
164 {
165 return (m_logoMap.value(pack.logo));
166 }
167 QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
168 ((ListModel *)this)->requestLogo(pack.logo);
169 return icon;
170 }
171 else if(role == Qt::ForegroundRole)
172 {
173 if(pack.broken)
174 {
175 //FIXME: Hardcoded color
176 return QColor(255, 0, 50);
177 }
178 else if(pack.bugged)
179 {
180 //FIXME: Hardcoded color
181 //bugged pack, currently only indicates bugged xml
182 return QColor(244, 229, 66);
183 }
184 }
185 else if(role == Qt::UserRole)
186 {
187 QVariant v;
188 v.setValue(pack);
189 return v;
190 }
191
192 return QVariant();
193}

Callers 5

lessThanMethod · 0.45
onTabChangedMethod · 0.45

Calls 10

QStringClass · 0.85
QColorClass · 0.85
lengthMethod · 0.80
appendMethod · 0.80
getThemedIconMethod · 0.80
sizeMethod · 0.45
isValidMethod · 0.45
atMethod · 0.45
containsMethod · 0.45
requestLogoMethod · 0.45

Tested by

no test coverage detected