Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
739ca6a0
Commit
739ca6a0
authored
Jan 27, 2015
by
Gavin Bisesi
Browse files
Merge pull request #607 from poixen/osx_fix
Refactor pileview sorting code
parents
8be659ba
b89535f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/zoneviewzone.cpp
View file @
739ca6a0
...
...
@@ -106,9 +106,30 @@ void ZoneViewZone::reorganizeCards()
int
typeColumn
=
0
;
int
longestRow
=
0
;
if
(
pileView
&&
sortByType
)
// we need sort by type enabled for the feature to work
setPileViewPositions
(
cardCount
,
cardsToDisplay
,
typeColumn
,
longestRow
);
else
{
if
(
pileView
&&
sortByType
)
{
// we need sort by type enabled for the feature to work
int
typeRow
=
0
;
QString
lastCardType
;
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
CardItem
*
c
=
cardsToDisplay
.
at
(
i
);
QString
cardType
=
c
->
getInfo
()
->
getMainCardType
();
if
(
i
){
// if not the first card
if
(
cardType
==
lastCardType
)
typeRow
++
;
// add below current card
else
{
// if no match then move card to next column
typeColumn
++
;
longestRow
=
qMax
(
typeRow
,
longestRow
);
typeRow
=
0
;
}
}
lastCardType
=
cardType
;
qreal
x
=
typeColumn
*
CARD_WIDTH
;
qreal
y
=
typeRow
*
CARD_HEIGHT
/
3
;
c
->
setPos
(
x
+
5
,
y
+
5
);
c
->
setRealZValue
(
i
);
}
}
else
{
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
CardItem
*
c
=
cardsToDisplay
.
at
(
i
);
qreal
x
=
(
i
/
rows
)
*
CARD_WIDTH
;
...
...
@@ -128,31 +149,6 @@ void ZoneViewZone::reorganizeCards()
emit
optimumRectChanged
();
}
void
ZoneViewZone
::
setPileViewPositions
(
int
cardCount
,
CardList
&
cardsToDisplay
,
int
&
typeColumn
,
int
&
longestRow
){
int
typeRow
=
0
;
bool
cardTypeMatch
=
true
;
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
CardItem
*
c
=
cardsToDisplay
.
at
(
i
);
QString
cardType
=
c
->
getInfo
()
->
getMainCardType
();
if
(
i
){
// if not the first card. Last card and this card have a matching main type?
cardTypeMatch
=
cardType
.
compare
(
cardsToDisplay
.
at
(
i
-
1
)
->
getInfo
()
->
getMainCardType
())
==
0
?
true
:
false
;
if
(
!
cardTypeMatch
)
{
// if no match then move card to next column
typeColumn
++
;
longestRow
=
qMax
(
typeRow
,
longestRow
);
typeRow
=
0
;
}
else
// add below current card
typeRow
++
;
}
qreal
x
=
typeColumn
*
CARD_WIDTH
;
qreal
y
=
typeRow
*
CARD_HEIGHT
/
3
;
c
->
setPos
(
x
+
5
,
y
+
5
);
c
->
setRealZValue
(
i
);
}
}
void
ZoneViewZone
::
setSortByName
(
int
_sortByName
)
{
sortByName
=
_sortByName
;
...
...
cockatrice/src/zoneviewzone.h
View file @
739ca6a0
...
...
@@ -26,10 +26,6 @@ public:
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
void
setPileViewPositions
(
int
cardCount
,
CardList
&
cardsToDisplay
,
int
&
typeColumn
,
int
&
longestRow
);
void
initializeCards
(
const
QList
<
const
ServerInfo_Card
*>
&
cardList
=
QList
<
const
ServerInfo_Card
*>
());
void
removeCard
(
int
position
);
int
getNumberCards
()
const
{
return
numberCards
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment