mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
First draft of better pic url error handling
This commit is contained in:
parent
4d6f46b06e
commit
b9cb61abd0
2 changed files with 24 additions and 7 deletions
|
|
@ -151,14 +151,28 @@ void PictureLoader::processLoadQueue()
|
|||
|
||||
QString PictureLoader::getPicUrl(CardInfo *card)
|
||||
{
|
||||
if (!picDownload) return 0;
|
||||
if (!picDownload) return QString("");
|
||||
|
||||
QString picUrl = picDownloadHq ? settingsCache->getPicUrlHq() : settingsCache->getPicUrl();
|
||||
|
||||
picUrl.replace("!name!", QUrl::toPercentEncoding(card->getCorrectedName()));
|
||||
|
||||
CardSet *set = card->getPreferredSet();
|
||||
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(card->getPreferredMuId())));
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -175,8 +189,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);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,11 +70,11 @@ void CardDatabaseModel::updateCardList()
|
|||
{
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
disconnect(cardList[i], 0, this, 0);
|
||||
|
||||
|
||||
cardList = db->getCardList();
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
connect(cardList[i], SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
|
||||
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue