diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 186687e0..f969d612 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -97,8 +97,7 @@ SET(cockatrice_SOURCES src/thememanager.cpp src/localserver.cpp src/localserverinterface.cpp - src/localclient.cpp - src/priceupdater.cpp + src/localclient.cpp src/qt-json/json.cpp src/soundengine.cpp src/pending_command.cpp diff --git a/cockatrice/src/decklistmodel.cpp b/cockatrice/src/decklistmodel.cpp index e550352a..7b4d775a 100644 --- a/cockatrice/src/decklistmodel.cpp +++ b/cockatrice/src/decklistmodel.cpp @@ -68,9 +68,6 @@ int DeckListModel::rowCount(const QModelIndex &parent) const int DeckListModel::columnCount(const QModelIndex &/*parent*/) const { - if (settingsCache->getPriceTagFeature()) - return 3; - else return 2; } @@ -97,7 +94,6 @@ QVariant DeckListModel::data(const QModelIndex &index, int role) const switch (index.column()) { case 0: return node->recursiveCount(true); case 1: return node->getVisibleName(); - case 2: return QString().sprintf("$%.2f", node->recursivePrice(true)); default: return QVariant(); } case Qt::BackgroundRole: { @@ -116,7 +112,6 @@ QVariant DeckListModel::data(const QModelIndex &index, int role) const switch (index.column()) { case 0: return card->getNumber(); case 1: return card->getName(); - case 2: return QString().sprintf("$%.2f", card->getTotalPrice()); default: return QVariant(); } } @@ -141,7 +136,6 @@ QVariant DeckListModel::headerData(int section, Qt::Orientation orientation, int switch (section) { case 0: return tr("Number"); case 1: return tr("Card"); - case 2: return tr("Price"); default: return QVariant(); } } @@ -195,7 +189,6 @@ bool DeckListModel::setData(const QModelIndex &index, const QVariant &value, int switch (index.column()) { case 0: node->setNumber(value.toInt()); break; case 1: node->setName(value.toString()); break; - case 2: node->setPrice(value.toFloat()); break; default: return false; } emitRecursiveUpdates(index); @@ -347,9 +340,6 @@ void DeckListModel::sort(int column, Qt::SortOrder order) case 1: sortMethod = ByName; break; - case 2: - sortMethod = ByPrice; - break; default: sortMethod = ByName; } @@ -374,7 +364,7 @@ void DeckListModel::setDeckList(DeckLoader *_deck) void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *node) { - const int totalColumns = settingsCache->getPriceTagFeature() ? 3 : 2; + const int totalColumns = 2; if (node->height() == 1) { QTextBlockFormat blockFormat; @@ -382,10 +372,6 @@ void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *no charFormat.setFontPointSize(11); charFormat.setFontWeight(QFont::Bold); cursor->insertBlock(blockFormat, charFormat); - QString priceStr; - if (settingsCache->getPriceTagFeature()) - priceStr = QString().sprintf(": $%.2f", node->recursivePrice(true)); - cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)).append(priceStr)); QTextTableFormat tableFormat; tableFormat.setCellPadding(0); @@ -408,12 +394,6 @@ void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *no cellCursor = cell.firstCursorPosition(); cellCursor.insertText(card->getName()); - if (settingsCache->getPriceTagFeature()) { - cell = table->cellAt(i, 2); - cell.setFormat(cellCharFormat); - cellCursor = cell.firstCursorPosition(); - cellCursor.insertText(QString().sprintf("$%.2f ", card->getTotalPrice())); - } } } else if (node->height() == 2) { QTextBlockFormat blockFormat; @@ -422,10 +402,6 @@ void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *no charFormat.setFontWeight(QFont::Bold); cursor->insertBlock(blockFormat, charFormat); - QString priceStr; - if (settingsCache->getPriceTagFeature()) - priceStr = QString().sprintf(": $%.2f", node->recursivePrice(true)); - cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)).append(priceStr)); QTextTableFormat tableFormat; tableFormat.setCellPadding(10); @@ -477,9 +453,4 @@ void DeckListModel::printDeckList(QPrinter *printer) } doc.print(printer); -} - -void DeckListModel::pricesUpdated() -{ - emit layoutChanged(); -} +} \ No newline at end of file diff --git a/cockatrice/src/decklistmodel.h b/cockatrice/src/decklistmodel.h index f4e93e3b..7fcf5377 100644 --- a/cockatrice/src/decklistmodel.h +++ b/cockatrice/src/decklistmodel.h @@ -18,8 +18,6 @@ public: DecklistModelCardNode(DecklistCardNode *_dataNode, InnerDecklistNode *_parent) : AbstractDecklistCardNode(_parent), dataNode(_dataNode) { } int getNumber() const { return dataNode->getNumber(); } void setNumber(int _number) { dataNode->setNumber(_number); } - float getPrice() const { return dataNode->getPrice(); } - void setPrice(const float _price) { dataNode->setPrice(_price); } QString getName() const { return dataNode->getName(); } void setName(const QString &_name) { dataNode->setName(_name); } DecklistCardNode *getDataNode() const { return dataNode; } @@ -51,7 +49,6 @@ public: void cleanList(); DeckLoader *getDeckList() const { return deckList; } void setDeckList(DeckLoader *_deck); - void pricesUpdated(); private: DeckLoader *deckList; InnerDecklistNode *root; diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index a7b01783..75d8f30e 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -27,7 +27,6 @@ #include "main.h" #include "settingscache.h" #include "thememanager.h" -#include "priceupdater.h" #include "releasechannel.h" #include "soundengine.h" #include "sequenceEdit/shortcutstab.h" @@ -468,13 +467,7 @@ void UserInterfaceSettingsPage::retranslateUi() DeckEditorSettingsPage::DeckEditorSettingsPage() { - //priceTagsCheckBox.setChecked(settingsCache->getPriceTagFeature()); - //connect(&priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int))); - - //connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int))); - QGridLayout *generalGrid = new QGridLayout; - //generalGrid->addWidget(&priceTagsCheckBox, 0, 0); generalGrid->addWidget(new QLabel(tr("Nothing is here... yet")), 0, 0); @@ -489,21 +482,9 @@ DeckEditorSettingsPage::DeckEditorSettingsPage() void DeckEditorSettingsPage::retranslateUi() { - //priceTagsCheckBox.setText(tr("Enable &price tag feature from deckbrew.com")); generalGroupBox->setTitle(tr("General")); } -/* -void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked) -{ - if(!checked) - return; - - int source=AbstractPriceUpdater::DBPriceSource; - emit priceTagSourceChanged(source); -} -*/ - MessagesSettingsPage::MessagesSettingsPage() { chatMentionCheckBox.setChecked(settingsCache->getChatMention()); diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index 03dba7bd..19cae38f 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -130,11 +130,8 @@ public: DeckEditorSettingsPage(); void retranslateUi(); private slots: - //void radioPriceTagSourceClicked(bool checked); signals: - //void priceTagSourceChanged(int _priceTagSource); private: - //QCheckBox priceTagsCheckBox; QGroupBox *generalGroupBox; }; diff --git a/cockatrice/src/priceupdater.cpp b/cockatrice/src/priceupdater.cpp deleted file mode 100644 index 649becc6..00000000 --- a/cockatrice/src/priceupdater.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/** - * @author Marcio Ribeiro , Max-Wilhelm Bruker - * @version 1.1 - */ -#include -#include -#include - -#include "qt-json/json.h" -#include "priceupdater.h" - -#include "main.h" -#include "carddatabase.h" - -/** - * Constructor. - * - * @param _deck deck. - */ -AbstractPriceUpdater::AbstractPriceUpdater(const DeckList *_deck) -{ - nam = new QNetworkAccessManager(this); - deck = _deck; -} - -// deckbrew.com - -/** - * Constructor. - * - * @param _deck deck. - */ - -/* -DBPriceUpdater::DBPriceUpdater(const DeckList *_deck) -: AbstractPriceUpdater(_deck) -{ -} -*/ - -/** - * Update the prices of the cards in deckList. - */ - -/* -void DBPriceUpdater::updatePrices() -{ - QString base = "https://api.deckbrew.com/mtg/cards", q = ""; - QStringList cards = deck->getCardList(); - muidMap.clear(); - urls.clear(); - CardInfo * card; - int muid; - SetList sets; - bool bNotFirst=false; - - for (int i = 0; i < cards.size(); ++i) { - card = db->getCard(cards[i]); - if(!card) - continue; - sets = card->getSets(); - for(int j = 0; j < sets.size(); ++j) - { - muid=card->getMuId(sets[j]->getShortName()); - - if (!muid) { - continue; - } - - //qDebug() << "muid " << muid << " card: " << cards[i] << endl; - if(bNotFirst) - { - q += QString("&m=%1").arg(muid); - } else { - q += QString("?m=%1").arg(muid); - bNotFirst = true; - } - muidMap.insert(muid, cards[i]); - - if(q.length() > 240) - { - urls.append(base + q); - bNotFirst=false; - q = ""; - } - } - } - if(q.length() > 0) - urls.append(base + q); - - requestNext(); -} -*/ - -/* -void DBPriceUpdater::requestNext() -{ - if(urls.empty()) - return; - - QUrl url(urls.takeFirst(), QUrl::TolerantMode); - //qDebug() << "request prices from: " << url.toString() << endl; - 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 DBPriceUpdater::downloadFinished() -{ - QNetworkReply *reply = static_cast(sender()); - bool ok; - QString tmp = QString(reply->readAll()); - - // Errors are incapsulated in an object, check for them first - QVariantMap resultMap = QtJson::Json::parse(tmp, ok).toMap(); - if (!ok) { - QMessageBox::critical(this, tr("Error"), tr("A problem has occured while fetching card prices.")); - reply->deleteLater(); - if(urls.isEmpty()) - { - deleteLater(); - emit finishedUpdate(); - } else { - requestNext(); - } - } - - if(resultMap.contains("errors")) - { - QMessageBox::critical(this, tr("Error"), tr("A problem has occured while fetching card prices:") + - "
" + resultMap["errors"].toList().first().toString().toHtmlEscaped() - ); - reply->deleteLater(); - if(urls.isEmpty()) - { - deleteLater(); - emit finishedUpdate(); - } else { - requestNext(); - } - } - - // Good results are a list - QVariantList resultList = QtJson::Json::parse(tmp, ok).toList(); - if (!ok) { - QMessageBox::critical(this, tr("Error"), tr("A problem has occured while fetching card prices.")); - reply->deleteLater(); - if(urls.isEmpty()) - { - deleteLater(); - emit finishedUpdate(); - } else { - requestNext(); - } - } - - QMap cardsPrice; - QListIterator it(resultList); - while (it.hasNext()) { - QVariantMap cardMap = it.next().toMap(); - - - // get sets list - QList editions = cardMap.value("editions").toList(); - foreach (QVariant ed, editions) - { - // retrieve card name "as we know it" from the muid - QVariantMap edition = ed.toMap(); - QString set = edition.value("set_id").toString(); - - int muid = edition.value("multiverse_id").toString().toInt(); - if(!muidMap.contains(muid)) - continue; - - QString name=muidMap.value(muid); - // Prices are in USD cents - float price = edition.value("price").toMap().value("median").toString().toFloat() / 100; - //qDebug() << "card " << name << " set " << set << " price " << price << endl; - - - * 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" && price > 0 && (!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; - float price = cardsPrice[currentCard->getName()]; - if(price > 0) - currentCard->setPrice(price); - } - } - - reply->deleteLater(); - if(urls.isEmpty()) - { - deleteLater(); - emit finishedUpdate(); - } else { - requestNext(); - } -} -*/ diff --git a/cockatrice/src/priceupdater.h b/cockatrice/src/priceupdater.h deleted file mode 100644 index 9acb1dc9..00000000 --- a/cockatrice/src/priceupdater.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef PRICEUPDATER_H -#define PRICEUPDATER_H - -#include -#include "decklist.h" - -class QNetworkAccessManager; - -// If we don't typedef this, won't compile on OS X < 10.9 -typedef QMap MuidStringMap; - -/** - * Price Updater. - * - * @author Marcio Ribeiro - */ -class AbstractPriceUpdater : public QWidget -{ - Q_OBJECT -public: - enum PriceSource { DBPriceSource }; -protected: - const DeckList *deck; - QNetworkAccessManager *nam; -signals: - void finishedUpdate(); -protected slots: - virtual void downloadFinished() = 0; -public: - AbstractPriceUpdater(const DeckList *deck); - virtual void updatePrices() = 0; -}; - -/* -class DBPriceUpdater : public AbstractPriceUpdater -{ - Q_OBJECT -protected: - MuidStringMap muidMap; - QList urls; -protected: - virtual void downloadFinished(); - void requestNext(); -public: - DBPriceUpdater(const DeckList *deck); - virtual void updatePrices(); -}; -*/ -#endif diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index b1fae89d..dd2b91f7 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -236,9 +236,6 @@ SettingsCache::SettingsCache() maxFontSize = settings->value("game/maxfontsize", DEFAULT_FONT_SIZE).toInt(); - priceTagFeature = settings->value("deckeditor/pricetags", false).toBool(); - priceTagSource = settings->value("deckeditor/pricetagsource", 0).toInt(); - ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool(); ignoreUnregisteredUserMessages = settings->value("chat/ignore_unregistered_messages", false).toBool(); @@ -514,19 +511,6 @@ void SettingsCache::setSoundThemeName(const QString &_soundThemeName) emit soundThemeChanged(); } -void SettingsCache::setPriceTagFeature(int _priceTagFeature) -{ - priceTagFeature = _priceTagFeature; - settings->setValue("deckeditor/pricetags", priceTagFeature); - emit priceTagFeatureChanged(priceTagFeature); -} - -void SettingsCache::setPriceTagSource(int _priceTagSource) -{ - priceTagSource = _priceTagSource; - settings->setValue("deckeditor/pricetagsource", priceTagSource); -} - void SettingsCache::setIgnoreUnregisteredUsers(int _ignoreUnregisteredUsers) { ignoreUnregisteredUsers = _ignoreUnregisteredUsers; diff --git a/cockatrice/src/settingscache.h b/cockatrice/src/settingscache.h index 818e357b..6d6029b8 100644 --- a/cockatrice/src/settingscache.h +++ b/cockatrice/src/settingscache.h @@ -43,7 +43,6 @@ signals: void minPlayersForMultiColumnLayoutChanged(); void soundEnabledChanged(); void soundThemeChanged(); - void priceTagFeatureChanged(int enabled); void ignoreUnregisteredUsersChanged(); void ignoreUnregisteredUserMessagesChanged(); void pixmapCacheSizeChanged(int newSizeInMBs); @@ -86,8 +85,6 @@ private: bool zoneViewSortByName, zoneViewSortByType, zoneViewPileView; bool soundEnabled; QString soundThemeName; - bool priceTagFeature; - int priceTagSource; bool ignoreUnregisteredUsers; bool ignoreUnregisteredUserMessages; QString picUrl; @@ -165,8 +162,6 @@ public: bool getZoneViewPileView() const { return zoneViewPileView; } bool getSoundEnabled() const { return soundEnabled; } QString getSoundThemeName() const { return soundThemeName; } - bool getPriceTagFeature() const { return false; /* #859; priceTagFeature;*/ } - int getPriceTagSource() const { return priceTagSource; } bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; } bool getIgnoreUnregisteredUserMessages() const { return ignoreUnregisteredUserMessages; } QString getPicUrl() const { return picUrl; } @@ -236,8 +231,6 @@ public slots: void setZoneViewPileView(int _zoneViewPileView); void setSoundEnabled(int _soundEnabled); void setSoundThemeName(const QString &_soundThemeName); - void setPriceTagFeature(int _priceTagFeature); - void setPriceTagSource(int _priceTagSource); void setIgnoreUnregisteredUsers(int _ignoreUnregisteredUsers); void setIgnoreUnregisteredUserMessages(int _ignoreUnregisteredUserMessages); void setPicUrl(const QString &_picUrl); diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index de9503f3..661a5a7a 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -31,7 +31,6 @@ #include "dlg_load_deck_from_clipboard.h" #include "main.h" #include "settingscache.h" -#include "priceupdater.h" #include "tab_supervisor.h" #include "deckstats_interface.h" #include "tappedout_interface.h" @@ -536,9 +535,6 @@ void TabDeckEditor::retranslateUi() nameLabel->setText(tr("Deck &name:")); commentsLabel->setText(tr("&Comments:")); hashLabel1->setText(tr("Hash:")); - - //aUpdatePrices->setText(tr("&Update prices")); - //aUpdatePrices->setShortcut(QKeySequence("Ctrl+U")); aNewDeck->setText(tr("&New deck")); aLoadDeck->setText(tr("&Load deck...")); @@ -926,38 +922,6 @@ void TabDeckEditor::actDecrement() offsetCountAtIndex(currentIndex, -1); } -void TabDeckEditor::setPriceTagFeatureEnabled(int /* enabled */) -{ - //aUpdatePrices->setVisible(enabled); - deckModel->pricesUpdated(); -} - -/* -void TabDeckEditor::actUpdatePrices() -{ - aUpdatePrices->setDisabled(true); - AbstractPriceUpdater *up; - - switch(settingsCache->getPriceTagSource()) - { - case AbstractPriceUpdater::DBPriceSource: - default: - up = new DBPriceUpdater(deckModel->getDeckList()); - break; - } - - connect(up, SIGNAL(finishedUpdate()), this, SLOT(finishedUpdatingPrices())); - up->updatePrices(); -} -*/ - - -void TabDeckEditor::finishedUpdatingPrices() -{ - //deckModel->pricesUpdated(); - //setModified(true); - //aUpdatePrices->setDisabled(false); -} void TabDeckEditor::setDeck(DeckLoader *_deck) { diff --git a/cockatrice/src/tab_deck_editor.h b/cockatrice/src/tab_deck_editor.h index 5bd9d5bc..22211b41 100644 --- a/cockatrice/src/tab_deck_editor.h +++ b/cockatrice/src/tab_deck_editor.h @@ -67,13 +67,9 @@ class TabDeckEditor : public Tab { void actDecrementCard(); void actDecrementCardFromSideboard(); - //void actUpdatePrices(); - - void finishedUpdatingPrices(); void saveDeckRemoteFinished(const Response &r); void filterViewCustomContextMenu(const QPoint &point); void filterRemove(QAction *action); - void setPriceTagFeatureEnabled(int enabled); void loadLayout(); void restartLayout(); @@ -116,7 +112,7 @@ private: QMenu *deckMenu, *viewMenu, *cardInfoDockMenu, *deckDockMenu, *filterDockMenu, *analyzeDeckMenu; QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeckDeckstats, *aAnalyzeDeckTappedout, *aClose; QAction *aClearFilterAll, *aClearFilterOne; - QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement;// *aUpdatePrices; + QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement; QAction *aResetLayout; QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aDeckDockVisible, *aDeckDockFloating, *aFilterDockVisible, *aFilterDockFloating; diff --git a/common/decklist.cpp b/common/decklist.cpp index cb1ff98f..e9521028 100644 --- a/common/decklist.cpp +++ b/common/decklist.cpp @@ -125,7 +125,7 @@ void InnerDecklistNode::clearTree() } DecklistCardNode::DecklistCardNode(DecklistCardNode *other, InnerDecklistNode *_parent) - : AbstractDecklistCardNode(_parent), name(other->getName()), number(other->getNumber()), price(other->getPrice()) + : AbstractDecklistCardNode(_parent), name(other->getName()), number(other->getNumber()) { } @@ -157,19 +157,6 @@ int InnerDecklistNode::recursiveCount(bool countTotalCards) const return result; } -float InnerDecklistNode::recursivePrice(bool countTotalCards) const -{ - float result = 0; - for (int i = 0; i < size(); i++) { - InnerDecklistNode *node = dynamic_cast(at(i)); - if (node) - result += node->recursivePrice(countTotalCards); - else if (countTotalCards) - result += dynamic_cast(at(i))->getTotalPrice(); - } - return result; -} - bool InnerDecklistNode::compare(AbstractDecklistNode *other) const { switch (sortMethod) { @@ -177,8 +164,6 @@ bool InnerDecklistNode::compare(AbstractDecklistNode *other) const return compareNumber(other); case ByName: return compareName(other); - case ByPrice: - return comparePrice(other); } return 0; } @@ -205,18 +190,6 @@ bool InnerDecklistNode::compareName(AbstractDecklistNode *other) const } } -bool InnerDecklistNode::comparePrice(AbstractDecklistNode *other) const -{ - InnerDecklistNode *other2 = dynamic_cast(other); - if (other2) { - int p1 = 100*recursivePrice(true); - int p2 = 100*other2->recursivePrice(true); - return (p1 != p2) ? (p1 > p2) : compareName(other); - } else { - return false; - } -} - bool AbstractDecklistCardNode::compare(AbstractDecklistNode *other) const { switch (sortMethod) { @@ -224,8 +197,6 @@ bool AbstractDecklistCardNode::compare(AbstractDecklistNode *other) const return compareNumber(other); case ByName: return compareName(other); - case ByPrice: - return compareTotalPrice(other); } return 0; } @@ -252,18 +223,6 @@ bool AbstractDecklistCardNode::compareName(AbstractDecklistNode *other) const } } -bool AbstractDecklistCardNode::compareTotalPrice(AbstractDecklistNode *other) const -{ - AbstractDecklistCardNode *other2 = dynamic_cast(other); - if (other2) { - int p1 = 100*getTotalPrice(); - int p2 = 100*other2->getTotalPrice(); - return (p1 != p2) ? (p1 > p2) : compareName(other); - } else { - return true; - } -} - class InnerDecklistNode::compareFunctor { private: Qt::SortOrder order; @@ -285,8 +244,7 @@ bool InnerDecklistNode::readElement(QXmlStreamReader *xml) InnerDecklistNode *newZone = new InnerDecklistNode(xml->attributes().value("name").toString(), this); newZone->readElement(xml); } else if (childName == "card") { - float price = (xml->attributes().value("price") != NULL) ? xml->attributes().value("price").toString().toFloat() : 0; - DecklistCardNode *newCard = new DecklistCardNode(xml->attributes().value("name").toString(), xml->attributes().value("number").toString().toInt(), price, this); + DecklistCardNode *newCard = new DecklistCardNode(xml->attributes().value("name").toString(), xml->attributes().value("number").toString().toInt(), this); newCard->readElement(xml); } } else if (xml->isEndElement() && (childName == "zone")) @@ -318,7 +276,6 @@ void AbstractDecklistCardNode::writeElement(QXmlStreamWriter *xml) { xml->writeEmptyElement("card"); xml->writeAttribute("number", QString::number(getNumber())); - xml->writeAttribute("price", QString::number(getPrice())); xml->writeAttribute("name", getName()); } @@ -592,7 +549,7 @@ bool DeckList::loadFromStream_Plain(QTextStream &in) QString zoneName = getCardZoneFromName(cardName, isSideboard ? DECK_ZONE_SIDE: DECK_ZONE_MAIN); ++okRows; - new DecklistCardNode(cardName, number, 0, getZoneObjFromName(zoneName)); + new DecklistCardNode(cardName, number, getZoneObjFromName(zoneName)); } updateDeckHash(); return (okRows > 0); @@ -705,7 +662,7 @@ DecklistCardNode *DeckList::addCard(const QString &cardName, const QString &zone if (!zoneNode) zoneNode = new InnerDecklistNode(zoneName, root); - DecklistCardNode *node = new DecklistCardNode(cardName, 1, 0, zoneNode); + DecklistCardNode *node = new DecklistCardNode(cardName, 1, zoneNode); updateDeckHash(); return node; } diff --git a/common/decklist.h b/common/decklist.h index 8aac2dca..01d41c2b 100644 --- a/common/decklist.h +++ b/common/decklist.h @@ -39,7 +39,7 @@ public: void setMoveList(const QList &_moveList); }; -enum DeckSortMethod { ByNumber, ByName, ByPrice }; +enum DeckSortMethod { ByNumber, ByName }; class AbstractDecklistNode { protected: @@ -76,11 +76,9 @@ public: AbstractDecklistNode *findChild(const QString &name); int height() const; int recursiveCount(bool countTotalCards = false) const; - float recursivePrice(bool countTotalCards = false) const; bool compare(AbstractDecklistNode *other) const; bool compareNumber(AbstractDecklistNode *other) const; bool compareName(AbstractDecklistNode *other) const; - bool comparePrice(AbstractDecklistNode *other) const; QVector > sort(Qt::SortOrder order = Qt::AscendingOrder); bool readElement(QXmlStreamReader *xml); @@ -94,14 +92,10 @@ public: virtual void setNumber(int _number) = 0; virtual QString getName() const = 0; virtual void setName(const QString &_name) = 0; - virtual float getPrice() const = 0; - virtual void setPrice(const float _price) = 0; - float getTotalPrice() const { return getNumber() * getPrice(); } int height() const { return 0; } bool compare(AbstractDecklistNode *other) const; bool compareNumber(AbstractDecklistNode *other) const; bool compareName(AbstractDecklistNode *other) const; - bool compareTotalPrice(AbstractDecklistNode *other) const; bool readElement(QXmlStreamReader *xml); void writeElement(QXmlStreamWriter *xml); @@ -111,16 +105,13 @@ class DecklistCardNode : public AbstractDecklistCardNode { private: QString name; int number; - float price; public: - DecklistCardNode(const QString &_name = QString(), int _number = 1, float _price = 0, InnerDecklistNode *_parent = 0) : AbstractDecklistCardNode(_parent), name(_name), number(_number), price(_price) { } + DecklistCardNode(const QString &_name = QString(), int _number = 1, InnerDecklistNode *_parent = 0) : AbstractDecklistCardNode(_parent), name(_name), number(_number) { } DecklistCardNode(DecklistCardNode *other, InnerDecklistNode *_parent); int getNumber() const { return number; } void setNumber(int _number) { number = _number; } QString getName() const { return name; } void setName(const QString &_name) { name = _name; } - float getPrice() const { return price; } - void setPrice(const float _price) { price = _price; } }; class DeckList : public QObject {