diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-05-16 23:47:02 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-05-16 23:47:02 -0400 |
| commit | 47cca19109d47ccdb70c49f2bdc2e8170cd95ce3 (patch) | |
| tree | 61bf277bb5e2fa3750ba1e30137fc9471a069e9b /src/mainwindow.cpp | |
| parent | 50fc72ca8d4d904c0260583bd2c31beabcf14f35 (diff) | |
when removing mods, limit the number of items in the list so the dialog stays at a sane height
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 02c65266..9108464f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2628,18 +2628,34 @@ void MainWindow::modListSectionResized(int logicalIndex, int oldSize, int newSiz void MainWindow::removeMod_clicked() { + const int max_items = 20; + try { QItemSelectionModel *selection = ui->modList->selectionModel(); if (selection->hasSelection() && selection->selectedRows().count() > 1) { QString mods; QStringList modNames; + + int i = 0; for (QModelIndex idx : selection->selectedRows()) { QString name = idx.data().toString(); if (!ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt())->isRegular()) { continue; } - mods += "<li>" + name + "</li>"; + + // adds an item for the mod name until `i` reaches `max_items`, which + // adds one "..." item; subsequent mods are not shown on the list but + // are still added to `modNames` below so they can be removed correctly + + if (i < max_items) { + mods += "<li>" + name + "</li>"; + } + else if (i == max_items) { + mods += "<li>...</li>"; + } + modNames.append(ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt())->name()); + ++i; } if (QMessageBox::question(this, tr("Confirm"), tr("Remove the following mods?<br><ul>%1</ul>").arg(mods), |
