Refactor local batch variables to be class variables/defines.

This commit is contained in:
Lukas Brübach 2024-11-25 15:58:58 +01:00 committed by ZeldaZach
parent f8ce97d598
commit 929789bcf9
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View file

@ -300,11 +300,10 @@ void PrintingSelector::getAllSetsForCurrentCard()
const QList<CardInfoPerSet> prependedSets = prependPrintingsInDeck(filteredSets);
// Defer widget creation
int batchSize = 10;
int currentIndex = 0;
currentIndex = 0;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, [=]() mutable {
for (int i = 0; i < batchSize && currentIndex < prependedSets.size(); ++i, ++currentIndex) {
for (int i = 0; i < BATCH_SIZE && currentIndex < prependedSets.size(); ++i, ++currentIndex) {
auto *cardDisplayWidget =
new PrintingSelectorCardDisplayWidget(this, deckEditor, deckModel, deckView, cardSizeSlider,
selectedCard, prependedSets[currentIndex], currentZone);
@ -317,5 +316,6 @@ void PrintingSelector::getAllSetsForCurrentCard()
timer->deleteLater();
}
});
currentIndex = 0;
timer->start(0); // Process as soon as possible
}

View file

@ -13,6 +13,8 @@
#include <QVBoxLayout>
#include <QWidget>
#define BATCH_SIZE 10
class TabDeckEditor;
class PrintingSelector : public QWidget
{
@ -61,6 +63,7 @@ private:
QTreeView *deckView;
CardInfoPtr selectedCard;
QString currentZone;
int currentIndex = 0;
void selectCard(int changeBy);
};