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

Method setResourceEnabled

launcher/minecraft/mod/ResourceFolderModel.cpp:184–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184bool ResourceFolderModel::setResourceEnabled(const QModelIndexList &indexes, EnableAction action)
185{
186 if (!m_can_interact)
187 return false;
188
189 if (indexes.isEmpty())
190 return true;
191
192 bool succeeded = true;
193 for (auto const& idx : indexes) {
194 if (!validateIndex(idx) || idx.column() != 0)
195 continue;
196
197 int row = idx.row();
198
199 auto& resource = m_resources[row];
200
201 // Preserve the row, but change its ID
202 auto old_id = resource->internal_id();
203 if (!resource->enable(action)) {
204 succeeded = false;
205 continue;
206 }
207
208 auto new_id = resource->internal_id();
209 if (m_resources_index.contains(new_id)) {
210 // FIXME: https://github.com/PolyMC/PolyMC/issues/550
211 }
212
213 m_resources_index.remove(old_id);
214 m_resources_index[new_id] = row;
215
216 emit dataChanged(index(row, 0), index(row, columnCount(QModelIndex()) - 1));
217 }
218
219 return succeeded;
220}
221
222static QMutex s_update_task_mutex;
223bool ResourceFolderModel::update()

Callers 3

itemActivatedMethod · 0.80
enableItemMethod · 0.80
disableItemMethod · 0.80

Calls 6

QModelIndexClass · 0.85
isEmptyMethod · 0.80
internal_idMethod · 0.80
enableMethod · 0.45
containsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected