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)
|
QModelIndex newCardIndex = card ? deckModel->addCard(card, otherZoneName)
|
||||||
// Third argument (true) says create the card no matter what, even if not in DB
|
// Third argument (true) says create the card no matter what, even if not in DB
|
||||||
: deckModel->addPreferredPrintingCard(cardName, otherZoneName, true);
|
: deckModel->addPreferredPrintingCard(cardName, otherZoneName, true);
|
||||||
recursiveExpand(proxy->mapToSource(newCardIndex));
|
recursiveExpand(proxy->mapFromSource(newCardIndex));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -609,8 +609,18 @@ void DeckEditorDeckDockWidget::actDecrementCard(const ExactCard &card, QString z
|
|||||||
}
|
}
|
||||||
|
|
||||||
deckView->clearSelection();
|
deckView->clearSelection();
|
||||||
deckView->setCurrentIndex(proxy->mapToSource(idx));
|
setCurrentProxyIndex(idx);
|
||||||
offsetCountAtIndex(idx, -1);
|
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()
|
void DeckEditorDeckDockWidget::actDecrementSelection()
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ public slots:
|
|||||||
void actRemoveCard();
|
void actRemoveCard();
|
||||||
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
||||||
void expandAll();
|
void expandAll();
|
||||||
|
void setCurrentProxyIndex(const QModelIndex &index);
|
||||||
|
void scrollToProxyIndex(const QModelIndex &index);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ void CardAmountWidget::addPrinting(const QString &zone)
|
|||||||
newCardIndex = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
|
newCardIndex = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
|
||||||
rootCard.getPrinting().getProperty("num"));
|
rootCard.getPrinting().getProperty("num"));
|
||||||
|
|
||||||
deckView->setCurrentIndex(newCardIndex);
|
deckEditor->deckDockWidget->setCurrentProxyIndex(newCardIndex);
|
||||||
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
|
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
|
||||||
deckEditor->setModified(true);
|
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 count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
||||||
const int new_count = count + offset;
|
const int new_count = count + offset;
|
||||||
|
|
||||||
deckView->setCurrentIndex(numberIndex);
|
deckEditor->deckDockWidget->setCurrentProxyIndex(numberIndex);
|
||||||
|
|
||||||
if (new_count <= 0) {
|
if (new_count <= 0) {
|
||||||
deckModel->removeRow(idx.row(), idx.parent());
|
deckModel->removeRow(idx.row(), idx.parent());
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ void PrintingSelector::selectCard(const int changeBy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nextIndex.isValid()) {
|
if (nextIndex.isValid()) {
|
||||||
deckView->setCurrentIndex(nextIndex);
|
deckEditor->deckDockWidget->setCurrentProxyIndex(nextIndex);
|
||||||
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
|
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ void AbstractTabDeckEditor::addCardHelper(const ExactCard &card, QString zoneNam
|
|||||||
QModelIndex newCardIndex = deckDockWidget->deckModel->addCard(card, zoneName);
|
QModelIndex newCardIndex = deckDockWidget->deckModel->addCard(card, zoneName);
|
||||||
deckDockWidget->expandAll();
|
deckDockWidget->expandAll();
|
||||||
deckDockWidget->deckView->clearSelection();
|
deckDockWidget->deckView->clearSelection();
|
||||||
deckDockWidget->deckView->setCurrentIndex(newCardIndex);
|
deckDockWidget->setCurrentProxyIndex(newCardIndex);
|
||||||
setModified(true);
|
setModified(true);
|
||||||
|
|
||||||
databaseDisplayDockWidget->searchEdit->setSelection(0, databaseDisplayDockWidget->searchEdit->text().length());
|
databaseDisplayDockWidget->searchEdit->setSelection(0, databaseDisplayDockWidget->searchEdit->text().length());
|
||||||
|
|||||||
@@ -232,8 +232,8 @@ void TabDeckEditorVisual::processMainboardCardClick(QMouseEvent *event,
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Normal click = clear selection, select this, set current
|
// Normal click = clear selection, select this, set current
|
||||||
deckDockWidget->deckView->setCurrentIndex(idx);
|
deckDockWidget->setCurrentProxyIndex(idx);
|
||||||
deckDockWidget->deckView->scrollTo(idx);
|
deckDockWidget->scrollToProxyIndex(idx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user