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