summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-04-12 15:31:47 +0200
committerTannin <devnull@localhost>2013-04-12 15:31:47 +0200
commit4fbfc9aa54ed4499f54eb7b3cd942337f6b49e58 (patch)
tree43008c44a7adf429abc45d5a81537a118fcf6fa7 /src/mainwindow.cpp
parenta47d9717884953b18b4b29e596d3e5a7d766e56e (diff)
- multi-selection in category window
- profile loading is now slightly more forgiving
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp32
1 files changed, 23 insertions, 9 deletions
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 <http://www.gnu.org/licenses/>.
#include <QIdentityProxyModel>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
+#include <boost/assign.hpp>
#include <Psapi.h>
#include <shlobj.h>
#include <TlHelp32.h>
@@ -2293,7 +2294,6 @@ void MainWindow::refreshFilters()
QString previousFilter = currentItem != NULL ? currentItem->text(0) : tr("<All>");
ui->categoriesList->clear();
- addFilterItem(NULL, tr("<All>"), CategoryFactory::CATEGORY_NONE);
addFilterItem(NULL, tr("<Checked>"), CategoryFactory::CATEGORY_SPECIAL_CHECKED);
addFilterItem(NULL, tr("<Unchecked>"), CategoryFactory::CATEGORY_SPECIAL_UNCHECKED);
addFilterItem(NULL, tr("<Update>"), 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<int> 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("<All>")));
+ } else if (indices.count() > 1) {
+ ui->currentCategoryLabel->setText(QString("(%1)").arg(tr("<Multiple>")));
+ } 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<int> &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));