diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index ae7e4cc28..8760ee41b 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -573,11 +573,8 @@ DeckEditorSettingsPage::DeckEditorSettingsPage() switch(settingsCache->getPriceTagSource()) { case AbstractPriceUpdater::DBPriceSource: - priceTagSource1->setChecked(true); - break; - case AbstractPriceUpdater::BLPPriceSource: default: - priceTagSource0->setChecked(true); + priceTagSource1->setChecked(true); break; } @@ -603,8 +600,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage() void DeckEditorSettingsPage::retranslateUi() { priceTagsCheckBox->setText(tr("Enable &price tag feature")); - priceTagSource0->setText(tr("using data from blacklotusproject.com")); - priceTagSource1->setText(tr("using data from deckbrew.com")); + priceTagSource1->setText(tr("Get prices from deckbrew.com")); generalGroupBox->setTitle(tr("General")); } @@ -613,11 +609,7 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked) if(!checked) return; - int source=AbstractPriceUpdater::BLPPriceSource; - if(priceTagSource0->isChecked()) - source=AbstractPriceUpdater::BLPPriceSource; - if(priceTagSource1->isChecked()) - source=AbstractPriceUpdater::DBPriceSource; + int source=AbstractPriceUpdater::DBPriceSource; emit priceTagSourceChanged(source); } diff --git a/cockatrice/src/priceupdater.cpp b/cockatrice/src/priceupdater.cpp index 89ff66c08..5029324e8 100644 --- a/cockatrice/src/priceupdater.cpp +++ b/cockatrice/src/priceupdater.cpp @@ -28,82 +28,6 @@ AbstractPriceUpdater::AbstractPriceUpdater(const DeckList *_deck) deck = _deck; } -// blacklotusproject.com - -/** - * Constructor. - * - * @param _deck deck. - */ -BLPPriceUpdater::BLPPriceUpdater(const DeckList *_deck) -: AbstractPriceUpdater(_deck) -{ -} - -/** - * Update the prices of the cards in deckList. - */ -void BLPPriceUpdater::updatePrices() -{ - QString q = "http://blacklotusproject.com/json/?cards="; - QStringList cards = deck->getCardList(); - for (int i = 0; i < cards.size(); ++i) { - q += cards[i].toLower() + "|"; - } - QUrl url(q.replace(' ', '+')); - - QNetworkReply *reply = nam->get(QNetworkRequest(url)); - connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished())); -} - -/** - * Called when the download of the json file with the prices is finished. - */ -void BLPPriceUpdater::downloadFinished() -{ - QNetworkReply *reply = static_cast(sender()); - bool ok; - QVariantMap resultMap = QtJson::Json::parse(QString(reply->readAll()), ok).toMap(); - if (!ok) { - reply->deleteLater(); - deleteLater(); - return; - } - - QMap cardsPrice; - - QListIterator it(resultMap.value("cards").toList()); - while (it.hasNext()) { - QVariantMap map = it.next().toMap(); - QString name = map.value("name").toString().toLower(); - float price = map.value("price").toString().toFloat(); - QString set = map.value("set_code").toString(); - - /** - * Make sure Masters Edition (MED) isn't the set, as it doesn't - * physically exist. Also check the price to see that the cheapest set - * ends up as the final price. - */ - if (set != "MED" && (!cardsPrice.contains(name) || cardsPrice.value(name) > price)) - cardsPrice.insert(name, price); - } - - InnerDecklistNode *listRoot = deck->getRoot(); - for (int i = 0; i < listRoot->size(); i++) { - InnerDecklistNode *currentZone = dynamic_cast(listRoot->at(i)); - for (int j = 0; j < currentZone->size(); j++) { - DecklistCardNode *currentCard = dynamic_cast(currentZone->at(j)); - if (!currentCard) - continue; - currentCard->setPrice(cardsPrice[currentCard->getName().toLower()]); - } - } - - reply->deleteLater(); - deleteLater(); - emit finishedUpdate(); -} - // deckbrew.com /** diff --git a/cockatrice/src/priceupdater.h b/cockatrice/src/priceupdater.h index afe582b65..a6fd7496b 100644 --- a/cockatrice/src/priceupdater.h +++ b/cockatrice/src/priceupdater.h @@ -31,16 +31,6 @@ public: virtual void updatePrices() = 0; }; -class BLPPriceUpdater : public AbstractPriceUpdater -{ - Q_OBJECT -protected: - virtual void downloadFinished(); -public: - BLPPriceUpdater(const DeckList *deck); - virtual void updatePrices(); -}; - class DBPriceUpdater : public AbstractPriceUpdater { Q_OBJECT diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 7d9b34d83..7cfbff554 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -680,11 +680,8 @@ void TabDeckEditor::actUpdatePrices() switch(settingsCache->getPriceTagSource()) { case AbstractPriceUpdater::DBPriceSource: - up = new DBPriceUpdater(deckModel->getDeckList()); - break; - case AbstractPriceUpdater::BLPPriceSource: default: - up = new BLPPriceUpdater(deckModel->getDeckList()); + up = new DBPriceUpdater(deckModel->getDeckList()); break; }