summaryrefslogtreecommitdiff
path: root/src/modlist.cpp
diff options
context:
space:
mode:
authorLostDragonist <lost.dragonist@gmail.com>2019-01-22 17:57:46 -0600
committerLostDragonist <lost.dragonist@gmail.com>2019-01-22 17:57:46 -0600
commit0ab87850c4cb405b93c592e455a9d052ec84f66f (patch)
tree5fe08b611e70a3f0bff446dd3632de3acb1f33fb /src/modlist.cpp
parent952a9c2dedf63e4b9b182b7dce379c4fe7898355 (diff)
parent5800f2b7b32b564352b029b2f9a5fe27d05ee14c (diff)
Merge remote-tracking branch 'remotes/origin/Develop' into archive_conflicts_2
Diffstat (limited to 'src/modlist.cpp')
-rw-r--r--src/modlist.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp
index 178b4b16..2e6959d5 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -540,7 +540,7 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role)
m_Profile->setModEnabled(modID, enabled);
m_Modified = true;
m_LastCheck.restart();
- emit modlist_changed(index, role);
+ emit modlistChanged(index, role);
}
result = true;
emit dataChanged(index, index);
@@ -575,7 +575,7 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role)
int newID = value.toInt(&ok);
if (ok) {
info->setNexusID(newID);
- emit modlist_changed(index, role);
+ emit modlistChanged(index, role);
result = true;
} else {
result = false;
@@ -1314,12 +1314,24 @@ bool ModList::toggleSelection(QAbstractItemView *itemView)
QItemSelectionModel *selectionModel = itemView->selectionModel();
+ QList<unsigned int> modsToEnable;
+ QList<unsigned int> modsToDisable;
+ QModelIndexList dirtyMods;
for (QModelIndex idx : selectionModel->selectedRows()) {
int modId = idx.data(Qt::UserRole + 1).toInt();
- m_Profile->setModEnabled(modId, !m_Profile->modEnabled(modId));
- emit modlist_changed(idx, 0);
+ if (m_Profile->modEnabled(modId)) {
+ modsToDisable.append(modId);
+ dirtyMods.append(idx);
+ } else {
+ modsToEnable.append(modId);
+ dirtyMods.append(idx);
+ }
}
+ m_Profile->setModsEnabled(modsToEnable, modsToDisable);
+
+ emit modlistChanged(dirtyMods, 0);
+
m_Modified = true;
m_LastCheck.restart();
@@ -1358,32 +1370,28 @@ bool ModList::eventFilter(QObject *obj, QEvent *event)
return QAbstractItemModel::eventFilter(obj, event);
}
-
+//note: caller needs to make sure sort proxy is updated
void ModList::enableSelected(const QItemSelectionModel *selectionModel)
{
if (selectionModel->hasSelection()) {
- bool dirty = false;
+ QList<unsigned int> modsToEnable;
for (auto row : selectionModel->selectedRows(COL_PRIORITY)) {
int modID = m_Profile->modIndexByPriority(row.data().toInt());
- if (!m_Profile->modEnabled(modID)) {
- m_Profile->setModEnabled(modID, true);
- emit modlist_changed(row, 0);
- }
+ modsToEnable.append(modID);
}
+ m_Profile->setModsEnabled(modsToEnable, QList<unsigned int>());
}
}
-
+//note: caller needs to make sure sort proxy is updated
void ModList::disableSelected(const QItemSelectionModel *selectionModel)
{
if (selectionModel->hasSelection()) {
- bool dirty = false;
+ QList<unsigned int> modsToDisable;
for (auto row : selectionModel->selectedRows(COL_PRIORITY)) {
int modID = m_Profile->modIndexByPriority(row.data().toInt());
- if (m_Profile->modEnabled(modID)) {
- m_Profile->setModEnabled(modID, false);
- emit modlist_changed(row, 0);
- }
+ modsToDisable.append(modID);
}
+ m_Profile->setModsEnabled(QList<unsigned int>(), modsToDisable);
}
}