mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-05 20:39:59 -08:00
[VDE] Be saner about proxy indices
This commit is contained in:
@@ -588,7 +588,7 @@ bool DeckEditorDeckDockWidget::swapCard(const QModelIndex ¤tIndex)
|
||||
QModelIndex newCardIndex = card ? deckModel->addCard(card, otherZoneName)
|
||||
// Third argument (true) says create the card no matter what, even if not in DB
|
||||
: deckModel->addPreferredPrintingCard(cardName, otherZoneName, true);
|
||||
recursiveExpand(proxy->mapToSource(newCardIndex));
|
||||
recursiveExpand(proxy->mapFromSource(newCardIndex));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -609,8 +609,18 @@ void DeckEditorDeckDockWidget::actDecrementCard(const ExactCard &card, QString z
|
||||
}
|
||||
|
||||
deckView->clearSelection();
|
||||
deckView->setCurrentIndex(proxy->mapToSource(idx));
|
||||
offsetCountAtIndex(idx, -1);
|
||||
setCurrentProxyIndex(idx);
|
||||
offsetCountAtIndex(proxy->mapFromSource(idx), -1);
|
||||
}
|
||||
|
||||
void DeckEditorDeckDockWidget::setCurrentProxyIndex(const QModelIndex &index)
|
||||
{
|
||||
deckView->setCurrentIndex(proxy->mapFromSource(index));
|
||||
}
|
||||
|
||||
void DeckEditorDeckDockWidget::scrollToProxyIndex(const QModelIndex &index)
|
||||
{
|
||||
deckView->setCurrentIndex(proxy->mapFromSource(index));
|
||||
}
|
||||
|
||||
void DeckEditorDeckDockWidget::actDecrementSelection()
|
||||
|
||||
@@ -70,6 +70,8 @@ public slots:
|
||||
void actRemoveCard();
|
||||
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
||||
void expandAll();
|
||||
void setCurrentProxyIndex(const QModelIndex &index);
|
||||
void scrollToProxyIndex(const QModelIndex &index);
|
||||
|
||||
signals:
|
||||
void nameChanged();
|
||||
|
||||
@@ -190,7 +190,7 @@ void CardAmountWidget::addPrinting(const QString &zone)
|
||||
newCardIndex = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
|
||||
rootCard.getPrinting().getProperty("num"));
|
||||
|
||||
deckView->setCurrentIndex(newCardIndex);
|
||||
deckEditor->deckDockWidget->setCurrentProxyIndex(newCardIndex);
|
||||
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
|
||||
deckEditor->setModified(true);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ void CardAmountWidget::offsetCountAtIndex(const QModelIndex &idx, int offset)
|
||||
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
||||
const int new_count = count + offset;
|
||||
|
||||
deckView->setCurrentIndex(numberIndex);
|
||||
deckEditor->deckDockWidget->setCurrentProxyIndex(numberIndex);
|
||||
|
||||
if (new_count <= 0) {
|
||||
deckModel->removeRow(idx.row(), idx.parent());
|
||||
|
||||
@@ -185,7 +185,7 @@ void PrintingSelector::selectCard(const int changeBy)
|
||||
}
|
||||
|
||||
if (nextIndex.isValid()) {
|
||||
deckView->setCurrentIndex(nextIndex);
|
||||
deckEditor->deckDockWidget->setCurrentProxyIndex(nextIndex);
|
||||
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void AbstractTabDeckEditor::addCardHelper(const ExactCard &card, QString zoneNam
|
||||
QModelIndex newCardIndex = deckDockWidget->deckModel->addCard(card, zoneName);
|
||||
deckDockWidget->expandAll();
|
||||
deckDockWidget->deckView->clearSelection();
|
||||
deckDockWidget->deckView->setCurrentIndex(newCardIndex);
|
||||
deckDockWidget->setCurrentProxyIndex(newCardIndex);
|
||||
setModified(true);
|
||||
|
||||
databaseDisplayDockWidget->searchEdit->setSelection(0, databaseDisplayDockWidget->searchEdit->text().length());
|
||||
|
||||
@@ -232,8 +232,8 @@ void TabDeckEditorVisual::processMainboardCardClick(QMouseEvent *event,
|
||||
return;
|
||||
} else {
|
||||
// Normal click = clear selection, select this, set current
|
||||
deckDockWidget->deckView->setCurrentIndex(idx);
|
||||
deckDockWidget->deckView->scrollTo(idx);
|
||||
deckDockWidget->setCurrentProxyIndex(idx);
|
||||
deckDockWidget->scrollToProxyIndex(idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user