Fix bug with next/prev buttons in PrintingSelector (#6453)

* Hacky fix and debug messages

* remove debug

* add todo
This commit is contained in:
RickyRister
2025-12-31 03:00:23 -08:00
committed by GitHub
parent daa7db7ce3
commit 968be8a06f

View File

@@ -571,6 +571,15 @@ void DeckEditorDeckDockWidget::changeSelectedCard(int changeBy)
// Get the current index of the selected item
auto deckViewCurrentIndex = deckView->currentIndex();
// For some reason, if the deckModel is modified but the view is not manually reselected,
// currentIndex will return an index for the underlying deckModel instead of the proxy.
// That index will return an invalid index when indexBelow/indexAbove crosses a header node,
// causing the selection to fail to move down.
/// \todo Figure out why it's happening so we can do a proper fix instead of a hacky workaround
if (deckViewCurrentIndex.model() == proxy->sourceModel()) {
deckViewCurrentIndex = proxy->mapFromSource(deckViewCurrentIndex);
}
auto nextIndex = deckViewCurrentIndex.siblingAtRow(deckViewCurrentIndex.row() + changeBy);
if (!nextIndex.isValid()) {
nextIndex = deckViewCurrentIndex;