diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-27 14:55:20 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:14 +0100 |
| commit | d0512da75805be194d949a6d6bac8184314da0e6 (patch) | |
| tree | 27758203a442e3e90510d8c5d8f89848d6f5ffd8 /src/mainwindow.cpp | |
| parent | be0d6aef00891286f33242073627611413ad79c4 (diff) | |
Use an intermediate structure to store the separator tree.
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ddde1d9b..be879dc6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -544,14 +544,22 @@ MainWindow::MainWindow(Settings &settings processUpdates(); ui->statusBar->updateNormalMessage(m_OrganizerCore); - - on_groupCombo_currentIndexChanged(0); } void MainWindow::setupModList() { - m_ModListSortProxy = m_OrganizerCore.createModListProxyModel(); + m_ModListByPriorityProxy = new ModListByPriorityProxy(m_OrganizerCore.currentProfile(), &m_OrganizerCore); + connect(ui->modList, SIGNAL(expanded(QModelIndex)), m_ModListByPriorityProxy, SLOT(expanded(QModelIndex))); + connect(ui->modList, SIGNAL(collapsed(QModelIndex)), m_ModListByPriorityProxy, SLOT(collapsed(QModelIndex))); + connect(m_ModListByPriorityProxy, SIGNAL(expandItem(QModelIndex)), this, SLOT(expandModList(QModelIndex))); + + m_ModListSortProxy = new ModListSortProxy(m_OrganizerCore.currentProfile(), &m_OrganizerCore); ui->modList->setModel(m_ModListSortProxy); + + m_ModListByPriorityProxy->setSourceModel(m_OrganizerCore.modList()); + m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); + emit m_OrganizerCore.modList()->layoutChanged(); + ui->modList->sortByColumn(ModList::COL_PRIORITY, Qt::AscendingOrder); @@ -1267,15 +1275,7 @@ void MainWindow::espFilterChanged(const QString &filter) void MainWindow::expandModList(const QModelIndex &index) { - QAbstractItemModel *model = ui->modList->model(); - - for (int i = 0; i < model->rowCount(); ++i) { - QModelIndex targetIdx = model->index(i, 0); - if (model->data(targetIdx).toString() == index.data().toString()) { - ui->modList->expand(targetIdx); - break; - } - } + ui->modList->expand(m_ModListSortProxy->mapFromSource(index)); } @@ -1679,6 +1679,7 @@ void MainWindow::activateSelectedProfile() m_OrganizerCore.setCurrentProfile(ui->profileBox->currentText()); m_ModListSortProxy->setProfile(m_OrganizerCore.currentProfile()); + m_ModListByPriorityProxy->setProfile(m_OrganizerCore.currentProfile()); m_SavesTab->refreshSaveList(); m_OrganizerCore.refresh(); @@ -5951,8 +5952,8 @@ void MainWindow::on_groupCombo_currentIndexChanged(int index) connect(ui->modList, SIGNAL(collapsed(QModelIndex)), newModel, SLOT(collapsed(QModelIndex))); connect(newModel, SIGNAL(expandItem(QModelIndex)), this, SLOT(expandModList(QModelIndex))); } else { - m_ModListSortProxy->setSourceModel(new ModListByPriorityProxy(m_OrganizerCore.modList(), this)); - // m_ModListSortProxy->setSourceModel(m_OrganizerCore.modList()); + m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); + emit m_OrganizerCore.modList()->layoutChanged(); } modFilterActive(m_ModListSortProxy->isFilterActive()); } |
