MCPcopy Create free account
hub / github.com/MultiMC/Launcher / data

Method data

launcher/InstanceList.cpp:125–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125QVariant InstanceList::data(const QModelIndex &index, int role) const
126{
127 if (!index.isValid())
128 {
129 return QVariant();
130 }
131 BaseInstance *pdata = static_cast<BaseInstance *>(index.internalPointer());
132 switch (role)
133 {
134 case InstancePointerRole:
135 {
136 QVariant v = qVariantFromValue((void *)pdata);
137 return v;
138 }
139 case InstanceIDRole:
140 {
141 return pdata->id();
142 }
143 case Qt::EditRole:
144 case Qt::DisplayRole:
145 {
146 return pdata->name();
147 }
148 case Qt::AccessibleTextRole:
149 {
150 return tr("%1 Instance").arg(pdata->name());
151 }
152 case Qt::ToolTipRole:
153 {
154 return pdata->instanceRoot();
155 }
156 case Qt::DecorationRole:
157 {
158 return pdata->iconKey();
159 }
160 // HACK: see InstanceView.h in gui!
161 case GroupRole:
162 {
163 return getInstanceGroup(pdata->id());
164 }
165 default:
166 break;
167 }
168 return QVariant();
169}
170
171bool InstanceList::setData(const QModelIndex& index, const QVariant& value, int role)
172{

Callers

nothing calls this directly

Calls 5

instanceRootMethod · 0.80
isValidMethod · 0.45
idMethod · 0.45
nameMethod · 0.45
iconKeyMethod · 0.45

Tested by

no test coverage detected