almost finished pre-game deck loading

This commit is contained in:
Max-Wilhelm Bruker 2009-11-22 01:30:16 +01:00
parent 8dcf81654e
commit cf21528a69
16 changed files with 140 additions and 64 deletions

View file

@ -0,0 +1,29 @@
#include <QProgressDialog>
#include "deck_picturecacher.h"
#include "decklist.h"
#include "carddatabase.h"
#include "main.h"
void Deck_PictureCacher::cacheHelper(InnerDecklistNode *item, QProgressDialog *progress)
{
for (int i = 0; i < item->size(); i++) {
DecklistCardNode *node = dynamic_cast<DecklistCardNode *>(item->at(i));
if (node) {
db->getCard(node->getName())->loadPixmap();
progress->setValue(progress->value() + 1);
} else
cacheHelper(dynamic_cast<InnerDecklistNode *>(item->at(i)), progress);
}
}
void Deck_PictureCacher::cachePictures(DeckList *deck, QWidget *parent)
{
int totalCards = deck->getRoot()->recursiveCount();
QProgressDialog progress(tr("Caching card pictures..."), QString(), 0, totalCards, parent);
progress.setMinimumDuration(1000);
progress.setWindowModality(Qt::WindowModal);
cacheHelper(deck->getRoot(), &progress);
}