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

Method data

launcher/ui/pages/modplatform/ModModel.cpp:45–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45auto ListModel::data(const QModelIndex& index, int role) const -> QVariant
46{
47 int pos = index.row();
48 if (pos >= modpacks.size() || pos < 0 || !index.isValid()) {
49 return QString("INVALID INDEX %1").arg(pos);
50 }
51
52 ModPlatform::IndexedPack pack = modpacks.at(pos);
53 switch (role) {
54 case Qt::ToolTipRole: {
55 if (pack.description.length() > 100) {
56 // some magic to prevent to long tooltips and replace html linebreaks
57 QString edit = pack.description.left(97);
58 edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
59 return edit;
60 }
61 return pack.description;
62 }
63 case Qt::DecorationRole: {
64 if (m_logoMap.contains(pack.logoName)) {
65 return m_logoMap.value(pack.logoName);
66 }
67 QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
68 // un-const-ify this
69 ((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
70 return icon;
71 }
72 case Qt::SizeHintRole:
73 return QSize(0, 58);
74 case Qt::UserRole: {
75 QVariant v;
76 v.setValue(pack);
77 return v;
78 }
79 // Custom data
80 case UserDataTypes::TITLE:
81 return pack.name;
82 case UserDataTypes::DESCRIPTION:
83 return pack.description;
84 case UserDataTypes::SELECTED:
85 return m_parent->getDialog()->isModSelected(pack.name);
86 default:
87 break;
88 }
89
90 return {};
91}
92
93bool ListModel::setData(const QModelIndex &index, const QVariant &value, int role)
94{

Callers 11

changeActiveAccountMethod · 0.45
addInstanceMethod · 0.45
deleteGroupMethod · 0.45
instanceActivatedMethod · 0.45
instanceChangedMethod · 0.45
onSelectionChangedMethod · 0.45
updateButtonStatesMethod · 0.45

Calls 11

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

Tested by

no test coverage detected