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
06e53275
Commit
06e53275
authored
Feb 19, 2015
by
Gavin Bisesi
Browse files
Merge pull request #748 from kaiserfro/jo-full-word-card-color-filter
Add full and short name for card color filters.
parents
648c5c48
8c187eff
Changes
1
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/filtertree.cpp
View file @
06e53275
...
...
@@ -161,16 +161,33 @@ bool FilterItem::acceptType(const CardInfo *info) const
bool
FilterItem
::
acceptColor
(
const
CardInfo
*
info
)
const
{
QStringList
::
const_iterator
i
;
bool
status
;
status
=
false
;
for
(
i
=
info
->
getColors
().
constBegin
();
i
!=
info
->
getColors
().
constEnd
();
i
++
)
if
((
*
i
).
contains
(
term
,
Qt
::
CaseInsensitive
))
{
status
=
true
;
break
;
}
QString
converted_term
;
QString
::
const_iterator
it
;
int
match_count
;
converted_term
=
term
;
converted_term
.
replace
(
QString
(
"green"
),
QString
(
"g"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"grn"
),
QString
(
"g"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"blue"
),
QString
(
"u"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"blu"
),
QString
(
"u"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"black"
),
QString
(
"b"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"blk"
),
QString
(
"b"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"red"
),
QString
(
"r"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"white"
),
QString
(
"w"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
"wht"
),
QString
(
"w"
),
Qt
::
CaseInsensitive
);
converted_term
.
replace
(
QString
(
" "
),
QString
(
""
),
Qt
::
CaseInsensitive
);
/* This is a tricky part, if the filter has multiple colors in it, like UGW,
then we should match all of them to the card's colors */
match_count
=
0
;
for
(
it
=
converted_term
.
begin
();
it
!=
converted_term
.
end
();
it
++
)
{
for
(
i
=
info
->
getColors
().
constBegin
();
i
!=
info
->
getColors
().
constEnd
();
i
++
)
if
((
*
i
).
contains
((
*
it
),
Qt
::
CaseInsensitive
))
{
match_count
++
;
}
}
return
status
;
return
match_count
==
converted_term
.
length
()
;
}
bool
FilterItem
::
acceptText
(
const
CardInfo
*
info
)
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