Merge pull request #1225 from ctrlaltca/fix_247
Order cards by name in deck-load screen
This commit is contained in:
commit
9b87f9e7e7
1 changed files with 8 additions and 0 deletions
|
@ -241,6 +241,13 @@ QSizeF DeckViewCardContainer::calculateBoundingRect(const QList<QPair<int, int>
|
||||||
return QSizeF(getCardTypeTextWidth() + totalWidth, totalHeight + separatorY + paddingY);
|
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)
|
void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int> > &rowsAndCols)
|
||||||
{
|
{
|
||||||
currentRowsAndCols = rowsAndCols;
|
currentRowsAndCols = rowsAndCols;
|
||||||
|
@ -257,6 +264,7 @@ void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int> > &rowsAn
|
||||||
|
|
||||||
QList<QString> cardTypeList = cardsByType.uniqueKeys();
|
QList<QString> cardTypeList = cardsByType.uniqueKeys();
|
||||||
QList<DeckViewCard *> row = cardsByType.values(cardTypeList[i]);
|
QList<DeckViewCard *> row = cardsByType.values(cardTypeList[i]);
|
||||||
|
qSort( row.begin(), row.end(), sortCardsByName);
|
||||||
for (int j = 0; j < row.size(); ++j) {
|
for (int j = 0; j < row.size(); ++j) {
|
||||||
DeckViewCard *card = row[j];
|
DeckViewCard *card = row[j];
|
||||||
card->setPos(x + (j % tempCols) * CARD_WIDTH, yUntilNow + (j / tempCols) * CARD_HEIGHT);
|
card->setPos(x + (j % tempCols) * CARD_WIDTH, yUntilNow + (j / tempCols) * CARD_HEIGHT);
|
||||||
|
|
Loading…
Reference in a new issue