MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / updateList

Method updateList

src/instancemanagerdialog.cpp:267–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267void InstanceManagerDialog::updateList()
268{
269 const auto prevSelIndex = singleSelectionIndex();
270 const auto* prevSel = singleSelection();
271
272 m_model->clear();
273
274 std::size_t sel = NoSelection;
275
276 // creating items for instances
277 for (std::size_t i = 0; i < m_instances.size(); ++i) {
278 const auto& ii = *m_instances[i];
279
280 auto* item = new QStandardItem(ii.displayName());
281 item->setIcon(instanceIcon(m_pc, ii));
282
283 m_model->appendRow(item);
284
285 if (&ii == prevSel) {
286 sel = i;
287 }
288 }
289
290 // keep current selection or select the next one if there was a selection;
291 // there's no selection when opening the dialog, that's handled in the ctor
292 if (prevSel) {
293 if (m_instances.empty()) {
294 select(-1);
295 } else {
296 if (sel == NoSelection) {
297 if (prevSelIndex >= m_instances.size()) {
298 sel = m_instances.size() - 1;
299 } else {
300 sel = prevSelIndex;
301 }
302 }
303
304 select(sel);
305 }
306 }
307}
308
309void InstanceManagerDialog::select(std::size_t i)
310{

Callers

nothing calls this directly

Calls 6

instanceIconFunction · 0.85
setIconMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
displayNameMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected