diff options
| author | Al <gabriel.cortesi@outlook.com> | 2019-05-17 09:18:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-17 09:18:46 +0200 |
| commit | c1db638d924bbec6521147de45f8815c9c9ee5e1 (patch) | |
| tree | 61bf277bb5e2fa3750ba1e30137fc9471a069e9b /src | |
| parent | 50fc72ca8d4d904c0260583bd2c31beabcf14f35 (diff) | |
| parent | 47cca19109d47ccdb70c49f2bdc2e8170cd95ce3 (diff) | |
Merge pull request #715 from isanae/Develop
limit the number of items in the remove mods dialog
Diffstat (limited to 'src')
| -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), |
