summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-29 01:35:02 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:15 +0100
commitd979e60aed14b368ac9badf0b88c06f61c17893b (patch)
treee9b3357349da605308014bae9a28f0836997b655 /src/mainwindow.cpp
parent7a65cc64885724c409f2deadaac925c66a9b00ee (diff)
Fix automatic refresh of the collapsible separator proxy.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp50
1 files changed, 0 insertions, 50 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9ca7e534..1891e496 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2439,58 +2439,8 @@ void MainWindow::esplist_changed()
updatePluginCount();
}
-QModelIndex MainWindow::modViewIndexToModel(const QModelIndex& index) const
-{
- auto sindex = index;
-
- // remove the sort proxy.
- sindex = m_ModListSortProxy->mapToSource(index);
-
- // if there is another proxy
- if (auto* proxy = qobject_cast<QAbstractProxyModel*>(m_ModListSortProxy->sourceModel())) {
- sindex = proxy->mapToSource(sindex);
- }
-
- return sindex;
-}
-
-QModelIndex MainWindow::modModelIndexToView(const QModelIndex& index) const
-{
- auto dindex = index;
-
- // if there is another proxy than the sort
- if (auto* proxy = qobject_cast<QAbstractProxyModel*>(m_ModListSortProxy->sourceModel())) {
- dindex = proxy->mapFromSource(dindex);
- }
-
- // add the sort proxy
- dindex = m_ModListSortProxy->mapFromSource(dindex);
-
- return dindex;
-
-}
-
void MainWindow::onModPrioritiesChanged(std::vector<int> const& indices)
{
- // if we have collapsible separators, we need to refresh, expand if necessary,
- // and recreate the selection
- if (m_ModListSortProxy->sourceModel() == m_ModListByPriorityProxy) {
-
- // manually retain the selection and restore it after
- QModelIndex current = modViewIndexToModel(ui->modList->currentIndex());
- std::vector<QModelIndex> selected;
- for (const auto& idx : ui->modList->selectionModel()->selectedRows()) {
- selected.push_back(modViewIndexToModel(idx));
- }
-
- m_ModListByPriorityProxy->refresh();
-
- ui->modList->setCurrentIndex(modModelIndexToView(current));
- for (auto idx : selected) {
- ui->modList->selectionModel()->select(modModelIndexToView(idx), QItemSelectionModel::Select | QItemSelectionModel::Rows);
- }
- }
-
for (unsigned int i = 0; i < m_OrganizerCore.currentProfile()->numMods(); ++i) {
int priority = m_OrganizerCore.currentProfile()->getModPriority(i);
if (m_OrganizerCore.currentProfile()->modEnabled(i)) {