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
42f1c693
Commit
42f1c693
authored
Jun 29, 2014
by
Daenyth
Committed by
Fabio Bas
Aug 08, 2014
Browse files
Merged: First draft of better pic url error handling
Cherry-picked b9cb61abd05f83c67740aafa5e1e6939143547e4
parent
bba8184d
Changes
1
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
42f1c693
...
...
@@ -176,7 +176,7 @@ void PictureLoader::processLoadQueue()
QString
PictureLoader
::
getPicUrl
(
CardInfo
*
card
)
{
if
(
!
picDownload
)
return
0
;
if
(
!
picDownload
)
return
QString
(
""
)
;
CardSet
*
set
=
card
->
getPreferredSet
();
QString
picUrl
=
QString
(
""
);
...
...
@@ -201,9 +201,22 @@ QString PictureLoader::getPicUrl(CardInfo *card)
// otherwise, fallback to the default url
picUrl
=
picDownloadHq
?
settingsCache
->
getPicUrlHq
()
:
settingsCache
->
getPicUrl
();
picUrl
.
replace
(
"!name!"
,
QUrl
::
toPercentEncoding
(
card
->
getCorrectedName
()));
picUrl
.
replace
(
"!setcode!"
,
QUrl
::
toPercentEncoding
(
set
->
getShortName
()));
picUrl
.
replace
(
"!setname!"
,
QUrl
::
toPercentEncoding
(
set
->
getLongName
()));
picUrl
.
replace
(
"!cardid!"
,
QUrl
::
toPercentEncoding
(
QString
::
number
(
card
->
getPreferredMuId
())));
if
(
set
)
{
picUrl
.
replace
(
"!setcode!"
,
QUrl
::
toPercentEncoding
(
set
->
getShortName
()));
picUrl
.
replace
(
"!setname!"
,
QUrl
::
toPercentEncoding
(
set
->
getLongName
()));
}
int
muid
=
card
->
getPreferredMuId
();
if
(
muid
)
picUrl
.
replace
(
"!cardid!"
,
QUrl
::
toPercentEncoding
(
QString
::
number
(
muid
)));
if
(
picUrl
.
contains
(
"!name!"
)
||
picUrl
.
contains
(
"!setcode!"
)
||
picUrl
.
contains
(
"!setname!"
)
||
picUrl
.
contains
(
"!cardid!"
))
{
qDebug
()
<<
"Insufficient card data to download"
<<
card
->
getName
()
<<
"Url:"
<<
picUrl
;
return
QString
(
""
);
}
return
picUrl
;
}
...
...
@@ -220,8 +233,11 @@ void PictureLoader::startNextPicDownload()
cardBeingDownloaded
=
cardsToDownload
.
takeFirst
();
// TODO: Do something useful when picUrl is 0 or empty, etc
QString
picUrl
=
getPicUrl
(
cardBeingDownloaded
.
getCard
());
if
(
picUrl
.
isEmpty
())
{
qDebug
()
<<
"No url for"
<<
cardBeingDownloaded
.
getCard
()
->
getName
();
return
;
}
QUrl
url
(
picUrl
);
...
...
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