This commit is contained in:
Lukas Brübach 2025-05-09 04:06:35 +02:00
parent db79534530
commit 3380ee541f
2 changed files with 14 additions and 13 deletions

View file

@ -162,7 +162,7 @@ void DlgGetCardPrices::startCardPriceRequests()
if (excludeLandsCheckBox->isChecked()) { if (excludeLandsCheckBox->isChecked()) {
CardInfoPtr card = CardDatabaseManager::getInstance()->getCard(cardName); CardInfoPtr card = CardDatabaseManager::getInstance()->getCard(cardName);
if (!card || card->getMainCardType() == "Land") if (!card || card->getMainCardType() == "Land")
continue; continue;
} }

View file

@ -10,8 +10,8 @@
#include <QMap> #include <QMap>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QPushButton>
#include <QProgressBar> #include <QProgressBar>
#include <QPushButton>
#include <QStringList> #include <QStringList>
#include <QTableWidget> #include <QTableWidget>
@ -19,20 +19,23 @@ class DeckListModel;
class QLabel; class QLabel;
class QScrollArea; class QScrollArea;
class CardPriceTableWidgetItem : public QTableWidgetItem { class CardPriceTableWidgetItem : public QTableWidgetItem
{
public: public:
// Constructor // Constructor
CardPriceTableWidgetItem(const QString &text) : QTableWidgetItem(text) {} CardPriceTableWidgetItem(const QString &text) : QTableWidgetItem(text)
{
}
bool operator<(const QTableWidgetItem &other) const override bool operator<(const QTableWidgetItem &other) const override
{ {
bool ok1, ok2; bool ok1, ok2;
double val1 = text().remove('%').toDouble(&ok1); // Remove '%' and convert to double double val1 = text().remove('%').toDouble(&ok1); // Remove '%' and convert to double
double val2 = other.text().remove('%').toDouble(&ok2); // Remove '%' and convert to double double val2 = other.text().remove('%').toDouble(&ok2); // Remove '%' and convert to double
// Handle non-numeric cases gracefully // Handle non-numeric cases gracefully
if (ok1 && ok2) { if (ok1 && ok2) {
return val1 < val2; // Compare as double values return val1 < val2; // Compare as double values
} }
// If conversion to double failed, fallback to string comparison // If conversion to double failed, fallback to string comparison
@ -40,7 +43,6 @@ public:
} }
}; };
class DlgGetCardPrices : public QDialog class DlgGetCardPrices : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -48,11 +50,11 @@ class DlgGetCardPrices : public QDialog
public: public:
explicit DlgGetCardPrices(QWidget *parent, DeckListModel *_model); explicit DlgGetCardPrices(QWidget *parent, DeckListModel *_model);
signals: signals:
void allRequestsFinished(); void allRequestsFinished();
private slots: private slots:
void onCardPriceReply(); void onCardPriceReply();
void onAllRequestsFinished(); void onAllRequestsFinished();
void actOK(); void actOK();
void onSelectionChanged(); void onSelectionChanged();
@ -95,7 +97,6 @@ private:
int totalCardsToProcess = 0; int totalCardsToProcess = 0;
int finishedCardCount = 0; int finishedCardCount = 0;
}; };
#endif // DLG_GET_CARD_PRICES_H #endif // DLG_GET_CARD_PRICES_H