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
57efffcd
Commit
57efffcd
authored
Aug 08, 2014
by
Gavin Bisesi
Browse files
Merge pull request #273 from ctrlaltca/picurl_handling
Fix #259
parents
e12d66df
765e865a
Changes
1
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
57efffcd
...
@@ -176,7 +176,7 @@ void PictureLoader::processLoadQueue()
...
@@ -176,7 +176,7 @@ void PictureLoader::processLoadQueue()
QString
PictureLoader
::
getPicUrl
(
CardInfo
*
card
)
QString
PictureLoader
::
getPicUrl
(
CardInfo
*
card
)
{
{
if
(
!
picDownload
)
return
0
;
if
(
!
picDownload
)
return
QString
(
""
)
;
CardSet
*
set
=
card
->
getPreferredSet
();
CardSet
*
set
=
card
->
getPreferredSet
();
QString
picUrl
=
QString
(
""
);
QString
picUrl
=
QString
(
""
);
...
@@ -201,9 +201,22 @@ QString PictureLoader::getPicUrl(CardInfo *card)
...
@@ -201,9 +201,22 @@ QString PictureLoader::getPicUrl(CardInfo *card)
// otherwise, fallback to the default url
// otherwise, fallback to the default url
picUrl
=
picDownloadHq
?
settingsCache
->
getPicUrlHq
()
:
settingsCache
->
getPicUrl
();
picUrl
=
picDownloadHq
?
settingsCache
->
getPicUrlHq
()
:
settingsCache
->
getPicUrl
();
picUrl
.
replace
(
"!name!"
,
QUrl
::
toPercentEncoding
(
card
->
getCorrectedName
()));
picUrl
.
replace
(
"!name!"
,
QUrl
::
toPercentEncoding
(
card
->
getCorrectedName
()));
picUrl
.
replace
(
"!setcode!"
,
QUrl
::
toPercentEncoding
(
set
->
getShortName
()));
picUrl
.
replace
(
"!setname!"
,
QUrl
::
toPercentEncoding
(
set
->
getLongName
()));
if
(
set
)
{
picUrl
.
replace
(
"!cardid!"
,
QUrl
::
toPercentEncoding
(
QString
::
number
(
card
->
getPreferredMuId
())));
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
;
return
picUrl
;
}
}
...
@@ -220,8 +233,13 @@ void PictureLoader::startNextPicDownload()
...
@@ -220,8 +233,13 @@ void PictureLoader::startNextPicDownload()
cardBeingDownloaded
=
cardsToDownload
.
takeFirst
();
cardBeingDownloaded
=
cardsToDownload
.
takeFirst
();
// TODO: Do something useful when picUrl is 0 or empty, etc
QString
picUrl
=
getPicUrl
(
cardBeingDownloaded
.
getCard
());
QString
picUrl
=
getPicUrl
(
cardBeingDownloaded
.
getCard
());
if
(
picUrl
.
isEmpty
())
{
qDebug
()
<<
"No url for"
<<
cardBeingDownloaded
.
getCard
()
->
getName
();
cardBeingDownloaded
=
0
;
downloadRunning
=
false
;
return
;
}
QUrl
url
(
picUrl
);
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