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
25290227
Commit
25290227
authored
Apr 12, 2015
by
Fabio Bas
Browse files
Sort Mana cost using CMC
parent
0e203b3a
Changes
2
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabasemodel.cpp
View file @
25290227
...
...
@@ -32,7 +32,7 @@ QVariant CardDatabaseModel::data(const QModelIndex &index, int role) const
return
QVariant
();
if
((
index
.
row
()
>=
cardList
.
size
())
||
(
index
.
column
()
>=
CARDDBMODEL_COLUMNS
))
return
QVariant
();
if
(
role
!=
Qt
::
DisplayRole
)
if
(
role
!=
Qt
::
DisplayRole
&&
role
!=
SortRole
)
return
QVariant
();
CardInfo
*
card
=
cardList
.
at
(
index
.
row
());
...
...
@@ -45,7 +45,9 @@ QVariant CardDatabaseModel::data(const QModelIndex &index, int role) const
setList
<<
sets
[
i
]
->
getShortName
();
return
setList
.
join
(
", "
);
}
case
ManaCostColumn
:
return
card
->
getManaCost
();
case
ManaCostColumn
:
return
role
==
SortRole
?
QString
(
"%1%2"
).
arg
(
card
->
getCmc
(),
4
,
QChar
(
'0'
)).
arg
(
card
->
getManaCost
())
:
card
->
getManaCost
();
case
CardTypeColumn
:
return
card
->
getCardType
();
case
PTColumn
:
return
card
->
getPowTough
();
default:
return
QVariant
();
...
...
@@ -122,8 +124,8 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
bool
CardDatabaseDisplayModel
::
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
QString
leftString
=
sourceModel
()
->
data
(
left
).
toString
();
QString
rightString
=
sourceModel
()
->
data
(
right
).
toString
();
QString
leftString
=
sourceModel
()
->
data
(
left
,
CardDatabaseModel
::
SortRole
).
toString
();
QString
rightString
=
sourceModel
()
->
data
(
right
,
CardDatabaseModel
::
SortRole
).
toString
();
if
(
!
cardName
.
isEmpty
()
&&
left
.
column
()
==
CardDatabaseModel
::
NameColumn
)
{
...
...
cockatrice/src/carddatabasemodel.h
View file @
25290227
...
...
@@ -13,6 +13,7 @@ class CardDatabaseModel : public QAbstractListModel {
Q_OBJECT
public:
enum
Columns
{
NameColumn
,
SetListColumn
,
ManaCostColumn
,
CardTypeColumn
,
PTColumn
,
CMCColumn
};
enum
Role
{
SortRole
=
Qt
::
UserRole
};
CardDatabaseModel
(
CardDatabase
*
_db
,
QObject
*
parent
=
0
);
~
CardDatabaseModel
();
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
...
...
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