From 38eb03c306bc1317ac09195656ea10e413157c4e Mon Sep 17 00:00:00 2001 From: Tannin Date: Tue, 31 Mar 2015 17:48:07 +0200 Subject: bugfix: modlist automatically scrolled to the top after closing context menu --- src/mainwindow.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 49bfe117..34bc6dc2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2014,7 +2014,6 @@ void MainWindow::addCategoryFilters(QTreeWidgetItem *root, const std::set & } } - void MainWindow::refreshFilters() { QItemSelection currentSelection = ui->modList->selectionModel()->selection(); @@ -2038,11 +2037,10 @@ void MainWindow::refreshFilters() addFilterItem(nullptr, tr(""), CategoryFactory::CATEGORY_SPECIAL_NOTENDORSED, ModListSortProxy::TYPE_SPECIAL); addContentFilters(); - std::set categoriesUsed; for (unsigned int modIdx = 0; modIdx < ModInfo::getNumMods(); ++modIdx) { ModInfo::Ptr modInfo = ModInfo::getByIndex(modIdx); - BOOST_FOREACH (int categoryID, modInfo->getCategories()) { + for (int categoryID : modInfo->getCategories()) { int currentID = categoryID; // also add parents so they show up in the tree while (currentID != 0) { @@ -2061,7 +2059,11 @@ void MainWindow::refreshFilters() } } ui->modList->selectionModel()->select(currentSelection, QItemSelectionModel::Select); - QModelIndexList matchList = ui->modList->model()->match(ui->modList->model()->index(0, 0), Qt::DisplayRole, currentIndexName); + QModelIndexList matchList; + if (currentIndexName.isValid()) { + matchList = ui->modList->model()->match(ui->modList->model()->index(0, 0), Qt::DisplayRole, currentIndexName); + } + if (matchList.size() > 0) { ui->modList->setCurrentIndex(matchList.at(0)); } -- cgit v1.3.1