From 4fbfc9aa54ed4499f54eb7b3cd942337f6b49e58 Mon Sep 17 00:00:00 2001 From: Tannin Date: Fri, 12 Apr 2013 15:31:47 +0200 Subject: - multi-selection in category window - profile loading is now slightly more forgiving --- src/mainwindow.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2efbdc0f..65633ab1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -87,6 +87,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include #include @@ -2293,7 +2294,6 @@ void MainWindow::refreshFilters() QString previousFilter = currentItem != NULL ? currentItem->text(0) : tr(""); ui->categoriesList->clear(); - addFilterItem(NULL, tr(""), CategoryFactory::CATEGORY_NONE); addFilterItem(NULL, tr(""), CategoryFactory::CATEGORY_SPECIAL_CHECKED); addFilterItem(NULL, tr(""), CategoryFactory::CATEGORY_SPECIAL_UNCHECKED); addFilterItem(NULL, tr(""), CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE); @@ -3010,14 +3010,28 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) } -void MainWindow::on_categoriesList_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *) +void MainWindow::on_categoriesList_itemSelectionChanged() { - if (current != NULL) { - int filter = current->data(0, Qt::UserRole).toInt(); - m_ModListSortProxy->setCategoryFilter(filter); - ui->currentCategoryLabel->setText(QString("(%1)").arg(current->text(0))); - ui->modList->reset(); +// int filter = current->data(0, Qt::UserRole).toInt(); + QModelIndexList indices = ui->categoriesList->selectionModel()->selectedRows(); + std::vector categories; + foreach (const QModelIndex &index, indices) { + int categoryId = index.data(Qt::UserRole).toInt(); + if (categoryId != CategoryFactory::CATEGORY_NONE) { + categories.push_back(categoryId); + } + } + + m_ModListSortProxy->setCategoryFilter(categories); +// ui->currentCategoryLabel->setText(QString("(%1)").arg(current->text(0))); + if (indices.count() == 0) { + ui->currentCategoryLabel->setText(QString("(%1)").arg(tr(""))); + } else if (indices.count() > 1) { + ui->currentCategoryLabel->setText(QString("(%1)").arg(tr(""))); + } else { + ui->currentCategoryLabel->setText(QString("(%1)").arg(indices.first().data().toString())); } + ui->modList->reset(); } @@ -3720,7 +3734,7 @@ void MainWindow::modDetailsUpdated(bool) --m_ModsToUpdate; if (m_ModsToUpdate == 0) { statusBar()->hide(); - m_ModListSortProxy->setCategoryFilter(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE); + m_ModListSortProxy->setCategoryFilter(boost::assign::list_of(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE)); for (int i = 0; i < ui->categoriesList->topLevelItemCount(); ++i) { if (ui->categoriesList->topLevelItem(i)->data(0, Qt::UserRole) == CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE) { ui->categoriesList->setCurrentItem(ui->categoriesList->topLevelItem(i)); @@ -3759,7 +3773,7 @@ void MainWindow::nxmUpdatesAvailable(const std::vector &modIDs, QVariant us if (m_ModsToUpdate <= 0) { statusBar()->hide(); - m_ModListSortProxy->setCategoryFilter(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE); + m_ModListSortProxy->setCategoryFilter(boost::assign::list_of(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE)); for (int i = 0; i < ui->categoriesList->topLevelItemCount(); ++i) { if (ui->categoriesList->topLevelItem(i)->data(0, Qt::UserRole) == CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE) { ui->categoriesList->setCurrentItem(ui->categoriesList->topLevelItem(i)); -- cgit v1.3.1