Order cards by name in deck-load screen; fix #247

This commit is contained in:
Fabio Bas 2015-07-07 17:56:11 +02:00
parent 685aa99ad6
commit 1c2ddccb46

View file

@ -241,6 +241,13 @@ QSizeF DeckViewCardContainer::calculateBoundingRect(const QList<QPair<int, int>
return QSizeF(getCardTypeTextWidth() + totalWidth, totalHeight + separatorY + paddingY);
}
bool sortCardsByName(DeckViewCard * c1, DeckViewCard * c2)
{
if (c1 && c2)
return c1->getName() < c2->getName();
return false;
}
void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int> > &rowsAndCols)
{
currentRowsAndCols = rowsAndCols;
@ -257,6 +264,7 @@ void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int> > &rowsAn
QList<QString> cardTypeList = cardsByType.uniqueKeys();
QList<DeckViewCard *> row = cardsByType.values(cardTypeList[i]);
qSort( row.begin(), row.end(), sortCardsByName);
for (int j = 0; j < row.size(); ++j) {
DeckViewCard *card = row[j];
card->setPos(x + (j % tempCols) * CARD_WIDTH, yUntilNow + (j / tempCols) * CARD_HEIGHT);