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
8c187eff
Commit
8c187eff
authored
Feb 16, 2015
by
Jeffrey Oliver
Browse files
Use qstring replace.
Iterate through the filter to see if everything matches the card.
parent
65d62b98
Changes
1
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/filtertree.cpp
View file @
8c187eff
...
@@ -162,34 +162,32 @@ bool FilterItem::acceptColor(const CardInfo *info) const
...
@@ -162,34 +162,32 @@ bool FilterItem::acceptColor(const CardInfo *info) const
{
{
QStringList
::
const_iterator
i
;
QStringList
::
const_iterator
i
;
QString
converted_term
;
QString
converted_term
;
bool
status
;
QString
::
const_iterator
it
;
int
match_count
;
status
=
false
;
if
(
term
.
contains
(
"green"
,
Qt
::
CaseInsensitive
)
||
term
.
contains
(
"grn"
,
Qt
::
CaseInsensitive
))
{
converted_term
=
term
;
converted_term
=
'g'
;
converted_term
.
replace
(
QString
(
"green"
),
QString
(
"g"
),
Qt
::
CaseInsensitive
);
}
converted_term
.
replace
(
QString
(
"grn"
),
QString
(
"g"
),
Qt
::
CaseInsensitive
);
else
if
(
term
.
contains
(
"blue"
,
Qt
::
CaseInsensitive
)
||
term
.
contains
(
"blu"
,
Qt
::
CaseInsensitive
))
{
converted_term
.
replace
(
QString
(
"blue"
),
QString
(
"u"
),
Qt
::
CaseInsensitive
);
converted_term
=
'u'
;
converted_term
.
replace
(
QString
(
"blu"
),
QString
(
"u"
),
Qt
::
CaseInsensitive
);
}
converted_term
.
replace
(
QString
(
"black"
),
QString
(
"b"
),
Qt
::
CaseInsensitive
);
else
if
(
term
.
contains
(
"black"
,
Qt
::
CaseInsensitive
)
||
term
.
contains
(
"blk"
,
Qt
::
CaseInsensitive
))
{
converted_term
.
replace
(
QString
(
"blk"
),
QString
(
"b"
),
Qt
::
CaseInsensitive
);
converted_term
=
'b'
;
converted_term
.
replace
(
QString
(
"red"
),
QString
(
"r"
),
Qt
::
CaseInsensitive
);
}
converted_term
.
replace
(
QString
(
"white"
),
QString
(
"w"
),
Qt
::
CaseInsensitive
);
else
if
(
term
.
contains
(
"red"
,
Qt
::
CaseInsensitive
))
{
converted_term
.
replace
(
QString
(
"wht"
),
QString
(
"w"
),
Qt
::
CaseInsensitive
);
converted_term
=
'r'
;
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
++
;
}
}
}
else
if
(
term
.
contains
(
"white"
,
Qt
::
CaseInsensitive
)
||
term
.
contains
(
"wht"
,
Qt
::
CaseInsensitive
))
{
converted_term
=
'w'
;
}
else
{
converted_term
=
term
;
}
for
(
i
=
info
->
getColors
().
constBegin
();
i
!=
info
->
getColors
().
constEnd
();
i
++
)
if
((
*
i
).
contains
(
converted_term
,
Qt
::
CaseInsensitive
))
{
status
=
true
;
break
;
}
return
status
;
return
match_count
==
converted_term
.
length
()
;
}
}
bool
FilterItem
::
acceptText
(
const
CardInfo
*
info
)
const
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