[DeckList] Refactor: Create class to RAII underlying tree (#6412)

* [DeckList] Create class to RAII underlying tree

* Update usages

* fixes after rebase

* update docs
This commit is contained in:
RickyRister 2025-12-14 15:56:58 -08:00 committed by GitHub
parent 589e9a15a6
commit b29909bdbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 325 additions and 168 deletions

View file

@ -41,7 +41,7 @@ void DeckListModel::rebuildTree()
beginResetModel();
root->clearTree();
InnerDecklistNode *listRoot = deckList->getRoot();
InnerDecklistNode *listRoot = deckList->getTree()->getRoot();
for (int i = 0; i < listRoot->size(); i++) {
auto *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
@ -313,7 +313,7 @@ bool DeckListModel::removeRows(int row, int count, const QModelIndex &parent)
for (int i = 0; i < count; i++) {
AbstractDecklistNode *toDelete = node->takeAt(row);
if (auto *temp = dynamic_cast<DecklistModelCardNode *>(toDelete)) {
deckList->deleteNode(temp->getDataNode());
deckList->getTree()->deleteNode(temp->getDataNode());
}
delete toDelete;
}
@ -668,7 +668,7 @@ bool DeckListModel::isCardQuantityLegalForCurrentFormat(const CardInfoPtr cardIn
void DeckListModel::refreshCardFormatLegalities()
{
InnerDecklistNode *listRoot = deckList->getRoot();
InnerDecklistNode *listRoot = deckList->getTree()->getRoot();
for (int i = 0; i < listRoot->size(); i++) {
auto *currentZone = static_cast<InnerDecklistNode *>(listRoot->at(i));

View file

@ -202,7 +202,7 @@ public:
* affects its hash.
*
* Slots:
* - rebuildTree(): rebuilds the model structure from the underlying DeckLoader.
* - rebuildTree(): rebuilds the model structure from the underlying node tree.
*/
class DeckListModel : public QAbstractItemModel
{
@ -210,7 +210,7 @@ class DeckListModel : public QAbstractItemModel
public slots:
/**
* @brief Rebuilds the model tree from the underlying DeckLoader.
* @brief Rebuilds the model tree from the underlying node tree.
*
* This updates all indices and ensures the model reflects the current
* state of the deck.