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

Method data

launcher/ui/pages/modplatform/ftb/FtbListModel.cpp:45–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45QVariant ListModel::data(const QModelIndex &index, int role) const
46{
47 int pos = index.row();
48 if(pos >= modpacks.size() || pos < 0 || !index.isValid())
49 {
50 return QString("INVALID INDEX %1").arg(pos);
51 }
52
53 ModpacksCH::Modpack pack = modpacks.at(pos);
54 if(role == Qt::DisplayRole)
55 {
56 return pack.name;
57 }
58 else if (role == Qt::ToolTipRole)
59 {
60 return pack.synopsis;
61 }
62 else if(role == Qt::DecorationRole)
63 {
64 QIcon placeholder = APPLICATION->getThemedIcon("screenshot-placeholder");
65
66 auto iter = m_logoMap.find(pack.name);
67 if (iter != m_logoMap.end()) {
68 auto & logo = *iter;
69 if(!logo.result.isNull()) {
70 return logo.result;
71 }
72 return placeholder;
73 }
74
75 for(auto art : pack.art) {
76 if(art.type == "square") {
77 ((ListModel *)this)->requestLogo(pack.name, art.url);
78 }
79 }
80 return placeholder;
81 }
82 else if(role == Qt::UserRole)
83 {
84 QVariant v;
85 v.setValue(pack);
86 return v;
87 }
88
89 return QVariant();
90}
91
92void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback)
93{

Callers 3

filterAcceptsRowMethod · 0.45
lessThanMethod · 0.45
onSelectionChangedMethod · 0.45

Calls 8

QStringClass · 0.85
getThemedIconMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45
isValidMethod · 0.45
atMethod · 0.45
findMethod · 0.45
requestLogoMethod · 0.45

Tested by

no test coverage detected