[DeckEditor] Reuse the inherited CardDatabaseModel in the visual editor (#7112)

Took 6 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-08-14 07:11:26 +02:00 committed by GitHub
parent 813a3ea034
commit 2eca362e2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 9 deletions

View file

@ -29,8 +29,10 @@
VisualDeckEditorWidget::VisualDeckEditorWidget(QWidget *parent,
DeckListModel *_deckListModel,
QItemSelectionModel *_selectionModel)
: QWidget(parent), deckListModel(_deckListModel), selectionModel(_selectionModel)
QItemSelectionModel *_selectionModel,
CardDatabaseModel *_cardDatabaseModel)
: QWidget(parent), deckListModel(_deckListModel), selectionModel(_selectionModel),
cardDatabaseModel(_cardDatabaseModel)
{
// The Main Widget and Main Layout, which contain a single Widget: The Scroll Area
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@ -94,7 +96,9 @@ void VisualDeckEditorWidget::initializeSearchBarAndCompleter()
setFocusProxy(searchBar);
setFocusPolicy(Qt::ClickFocus);
cardDatabaseModel = new CardDatabaseModel(CardDatabaseManager::getInstance(), false, this);
if (!cardDatabaseModel) {
cardDatabaseModel = new CardDatabaseModel(CardDatabaseManager::getInstance(), false, this);
}
cardDatabaseDisplayModel = new CardDatabaseDisplayModel(this);
cardDatabaseDisplayModel->setSourceModel(cardDatabaseModel);

View file

@ -38,7 +38,10 @@ class VisualDeckEditorWidget : public QWidget
Q_OBJECT
public:
explicit VisualDeckEditorWidget(QWidget *parent, DeckListModel *deckListModel, QItemSelectionModel *selectionModel);
explicit VisualDeckEditorWidget(QWidget *parent,
DeckListModel *deckListModel,
QItemSelectionModel *selectionModel,
CardDatabaseModel *_cardDatabaseModel = nullptr);
void retranslateUi();
void updateCompactMode();
void clearAllDisplayWidgets();