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

Method deleteInstance

src/instancemanagerdialog.cpp:492–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492void InstanceManagerDialog::deleteInstance()
493{
494 const auto* i = singleSelection();
495 if (!i) {
496 return;
497 }
498
499 auto& m = InstanceManager::singleton();
500 if (i->isActive()) {
501 QMessageBox::information(this, tr("Deleting instance"),
502 tr("The active instance cannot be deleted."));
503 return;
504 }
505
506 // creating dialog
507
508 const auto Recycle = QMessageBox::Save;
509 const auto Delete = QMessageBox::Yes;
510 const auto Cancel = QMessageBox::Cancel;
511
512 const auto files = i->objectsForDeletion();
513
514 MOBase::TaskDialog dlg(this);
515
516 dlg.title(tr("Deleting instance"))
517 .main(tr("These files and folders will be deleted"))
518 .content(tr("All checked items will be deleted."))
519 .icon(QMessageBox::Warning)
520 .button({tr("Move to the recycle bin"), Recycle})
521 .button({tr("Delete permanently"), Delete})
522 .button({tr("Cancel"), Cancel});
523
524 auto* list = new QListWidget();
525 list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
526 list->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
527 list->setMaximumHeight(160);
528
529 // filling the list
530 for (const auto& f : files) {
531 auto* item = new QListWidgetItem(f.path);
532
533 if (f.mandatoryDelete) {
534 // disable, cannot uncheck mandatory items
535 item->setFlags(item->flags() & (~Qt::ItemIsEnabled));
536
537 // checked by default
538 item->setCheckState(Qt::Checked);
539 } else {
540 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
541
542 // unchecked by default
543 item->setCheckState(Qt::Unchecked);
544 }
545
546 list->addItem(item);
547 }
548
549 dlg.addContent(list);

Callers

nothing calls this directly

Calls 9

objectsForDeletionMethod · 0.80
setFlagsMethod · 0.80
addItemMethod · 0.80
countMethod · 0.80
isActiveMethod · 0.45
iconMethod · 0.45
flagsMethod · 0.45
execMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected