Rework the way sets selection/importing works; fix #539 (rebased)

This commit is contained in:
Fabio Bas 2015-04-18 18:47:09 +02:00
parent e69ca60164
commit 881cea27f4
13 changed files with 369 additions and 162 deletions

View file

@ -42,7 +42,10 @@ QVariant CardDatabaseModel::data(const QModelIndex &index, int role) const
QStringList setList;
const QList<CardSet *> &sets = card->getSets();
for (int i = 0; i < sets.size(); i++)
setList << sets[i]->getShortName();
{
if(sets[i]->getEnabled())
setList << sets[i]->getShortName();
}
return setList.join(", ");
}
case ManaCostColumn: return role == SortRole ?
@ -77,9 +80,26 @@ void CardDatabaseModel::updateCardList()
for (int i = 0; i < cardList.size(); ++i)
disconnect(cardList[i], 0, this, 0);
cardList = db->getCardList();
for (int i = 0; i < cardList.size(); ++i)
connect(cardList[i], SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
cardList.clear();
foreach(CardInfo * card, db->getCardList())
{
bool hasSet = false;
foreach(CardSet * set, card->getSets())
{
if(set->getEnabled())
{
hasSet = true;
break;
}
}
if(hasSet)
{
cardList.append(card);
connect(card, SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
}
}
endResetModel();
}