mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 06:52:15 -07:00
Sensible deckListModel handling.
This commit is contained in:
parent
57bbbec206
commit
f52903a94d
7 changed files with 30 additions and 25 deletions
|
|
@ -6,7 +6,7 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListModel *_deckLi
|
|||
mainLayout = new QVBoxLayout();
|
||||
setLayout(mainLayout);
|
||||
|
||||
manaCurveWidget = new ManaCurveWidget(this);
|
||||
manaCurveWidget = new ManaCurveWidget(this, deckListModel);
|
||||
mainLayout->addWidget(manaCurveWidget);
|
||||
|
||||
manaDevotionWidget = new ManaDevotionWidget(this, deckListModel);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
#include <regex>
|
||||
#include <unordered_map>
|
||||
|
||||
ManaBaseWidget::ManaBaseWidget(QWidget *parent, DeckListModel *_deck_list_model)
|
||||
: QWidget(parent), deck_list_model(_deck_list_model)
|
||||
ManaBaseWidget::ManaBaseWidget(QWidget *parent, DeckListModel *_deckListModel)
|
||||
: QWidget(parent), deckListModel(_deckListModel)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
|
@ -25,20 +25,20 @@ ManaBaseWidget::ManaBaseWidget(QWidget *parent, DeckListModel *_deck_list_model)
|
|||
barLayout = new QHBoxLayout();
|
||||
layout->addLayout(barLayout);
|
||||
|
||||
connect(deck_list_model, &DeckListModel::dataChanged, this, &ManaBaseWidget::analyzeManaBase);
|
||||
connect(deckListModel, &DeckListModel::dataChanged, this, &ManaBaseWidget::analyzeManaBase);
|
||||
}
|
||||
|
||||
void ManaBaseWidget::setDeckModel(DeckListModel *deckModel)
|
||||
{
|
||||
deck_list_model = deckModel;
|
||||
connect(deck_list_model, &DeckListModel::dataChanged, this, &ManaBaseWidget::analyzeManaBase);
|
||||
deckListModel = deckModel;
|
||||
connect(deckListModel, &DeckListModel::dataChanged, this, &ManaBaseWidget::analyzeManaBase);
|
||||
analyzeManaBase();
|
||||
}
|
||||
|
||||
std::unordered_map<char, int> ManaBaseWidget::analyzeManaBase()
|
||||
{
|
||||
manaBaseMap.clear();
|
||||
InnerDecklistNode *listRoot = deck_list_model->getDeckList()->getRoot();
|
||||
InnerDecklistNode *listRoot = deckListModel->getDeckList()->getRoot();
|
||||
for (int i = 0; i < listRoot->size(); i++) {
|
||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
||||
for (int j = 0; j < currentZone->size(); j++) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ManaBaseWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ManaBaseWidget(QWidget *parent = nullptr, DeckListModel *deck_list_model = nullptr);
|
||||
explicit ManaBaseWidget(QWidget *parent, DeckListModel *deckListModel);
|
||||
std::unordered_map<char, int> analyzeManaBase();
|
||||
void updateDisplay();
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ public slots:
|
|||
void setDeckModel(DeckListModel *deckModel);
|
||||
|
||||
private:
|
||||
DeckListModel *deck_list_model;
|
||||
DeckListModel *deckListModel;
|
||||
BannerWidget *bannerWidget;
|
||||
std::unordered_map<char, int> manaBaseMap;
|
||||
QVBoxLayout *layout;
|
||||
|
|
|
|||
|
|
@ -10,28 +10,33 @@
|
|||
#include <decklist.h>
|
||||
#include <unordered_map>
|
||||
|
||||
ManaCurveWidget::ManaCurveWidget(QWidget *parent, DeckListModel *_deck_list_model)
|
||||
: QWidget(parent), deck_list_model(_deck_list_model)
|
||||
ManaCurveWidget::ManaCurveWidget(QWidget *parent, DeckListModel *_deckListModel)
|
||||
: QWidget(parent), deckListModel(_deckListModel)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
bannerWidget = new BannerWidget(this, "Mana Curve", Qt::Vertical, 100);
|
||||
bannerWidget->setMaximumHeight(100);
|
||||
layout->addWidget(bannerWidget);
|
||||
connect(deck_list_model, &DeckListModel::dataChanged, this, &ManaCurveWidget::analyzeManaCurve);
|
||||
|
||||
barLayout = new QHBoxLayout(this);
|
||||
layout->addLayout(barLayout);
|
||||
|
||||
connect(deckListModel, &DeckListModel::dataChanged, this, &ManaCurveWidget::analyzeManaCurve);
|
||||
}
|
||||
|
||||
void ManaCurveWidget::setDeckModel(DeckListModel *deckModel)
|
||||
{
|
||||
deck_list_model = deckModel;
|
||||
connect(deck_list_model, &DeckListModel::dataChanged, this, &ManaCurveWidget::analyzeManaCurve);
|
||||
deckListModel = deckModel;
|
||||
connect(deckListModel, &DeckListModel::dataChanged, this, &ManaCurveWidget::analyzeManaCurve);
|
||||
analyzeManaCurve();
|
||||
}
|
||||
|
||||
std::unordered_map<int, int> ManaCurveWidget::analyzeManaCurve()
|
||||
{
|
||||
manaCurveMap.clear();
|
||||
InnerDecklistNode *listRoot = deck_list_model->getDeckList()->getRoot();
|
||||
InnerDecklistNode *listRoot = deckListModel->getDeckList()->getRoot();
|
||||
for (int i = 0; i < listRoot->size(); i++) {
|
||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
||||
for (int j = 0; j < currentZone->size(); j++) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ManaCurveWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ManaCurveWidget(QWidget *parent = nullptr, DeckListModel *deck_list_model = nullptr);
|
||||
explicit ManaCurveWidget(QWidget *parent, DeckListModel *deckListModel);
|
||||
void updateDisplay();
|
||||
|
||||
public slots:
|
||||
|
|
@ -21,7 +21,7 @@ public slots:
|
|||
std::unordered_map<int, int> analyzeManaCurve();
|
||||
|
||||
private:
|
||||
DeckListModel *deck_list_model = nullptr;
|
||||
DeckListModel *deckListModel;
|
||||
std::unordered_map<int, int> manaCurveMap;
|
||||
QVBoxLayout *layout;
|
||||
QHBoxLayout *barLayout;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
ManaDevotionWidget::ManaDevotionWidget(QWidget *parent, DeckListModel *_deck_list_model)
|
||||
: QWidget(parent), deck_list_model(_deck_list_model)
|
||||
ManaDevotionWidget::ManaDevotionWidget(QWidget *parent, DeckListModel *_deckListModel)
|
||||
: QWidget(parent), deckListModel(_deckListModel)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
|
@ -26,20 +26,20 @@ ManaDevotionWidget::ManaDevotionWidget(QWidget *parent, DeckListModel *_deck_lis
|
|||
barLayout = new QHBoxLayout();
|
||||
layout->addLayout(barLayout);
|
||||
|
||||
connect(deck_list_model, &DeckListModel::dataChanged, this, &ManaDevotionWidget::analyzeManaDevotion);
|
||||
connect(deckListModel, &DeckListModel::dataChanged, this, &ManaDevotionWidget::analyzeManaDevotion);
|
||||
}
|
||||
|
||||
void ManaDevotionWidget::setDeckModel(DeckListModel *deckModel)
|
||||
{
|
||||
deck_list_model = deckModel;
|
||||
connect(deck_list_model, &DeckListModel::dataChanged, this, &ManaDevotionWidget::analyzeManaDevotion);
|
||||
deckListModel = deckModel;
|
||||
connect(deckListModel, &DeckListModel::dataChanged, this, &ManaDevotionWidget::analyzeManaDevotion);
|
||||
analyzeManaDevotion();
|
||||
}
|
||||
|
||||
std::unordered_map<char, int> ManaDevotionWidget::analyzeManaDevotion()
|
||||
{
|
||||
manaDevotionMap.clear();
|
||||
InnerDecklistNode *listRoot = deck_list_model->getDeckList()->getRoot();
|
||||
InnerDecklistNode *listRoot = deckListModel->getDeckList()->getRoot();
|
||||
for (int i = 0; i < listRoot->size(); i++) {
|
||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
||||
for (int j = 0; j < currentZone->size(); j++) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ManaDevotionWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ManaDevotionWidget(QWidget *parent = nullptr, DeckListModel *deck_list_model = nullptr);
|
||||
explicit ManaDevotionWidget(QWidget *parent, DeckListModel *deckListModel);
|
||||
void updateDisplay();
|
||||
|
||||
std::unordered_map<char, int> countManaSymbols(const QString &manaString);
|
||||
|
|
@ -24,7 +24,7 @@ public slots:
|
|||
std::unordered_map<char, int> analyzeManaDevotion();
|
||||
|
||||
private:
|
||||
DeckListModel *deck_list_model;
|
||||
DeckListModel *deckListModel;
|
||||
BannerWidget *bannerWidget;
|
||||
std::unordered_map<char, int> manaDevotionMap;
|
||||
QVBoxLayout *layout;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue