321 lines
11 KiB
C++
321 lines
11 KiB
C++
#include "Odds.h"
|
|||
|
|
#include <QIcon>
|
||
|
|
#include "Global.h"
|
||
|
|
#include "Utils.h"
|
||
|
|
|
||
|
|
Odds::Odds(QWidget *parent)
|
||
|
|
: QWidget(parent)
|
||
|
|
{
|
||
|
|
ui.setupUi(this);
|
||
|
|
|
||
|
|
// 设置窗口图标
|
||
|
|
this->setWindowIcon(QIcon(":/images/Images/client.ico"));
|
||
|
|
// 设置窗口标题
|
||
|
|
this->setWindowTitle("注单赔率判断处理");
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
ui.tableWidget->setColumnCount(15);
|
||
|
|
ui.tableWidget->setHorizontalHeaderLabels({"注单项目","让球","受让","大","小","独赢主","独赢客","独赢和","单","双","主队大","主队小","客队大","客队小","补单" });
|
||
|
|
|
||
|
|
|
||
|
|
ui.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||
|
|
ui.tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||
|
|
ui.tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||
|
|
ui.tableWidget->horizontalHeader()->resizeSection(0, 50);
|
||
|
|
|
||
|
|
|
||
|
|
for (int i = 0; i < 9; i++)
|
||
|
|
{
|
||
|
|
ui.tableWidget->insertRow(i);
|
||
|
|
ui.tableWidget->setItem(i, 0, new QTableWidgetItem(g_gameTypes[i]));
|
||
|
|
|
||
|
|
for (int j = 0; j < 15; j++)
|
||
|
|
{
|
||
|
|
if (j == 0)
|
||
|
|
{
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (j == 14)
|
||
|
|
{
|
||
|
|
QWidget* widget = new QWidget;
|
||
|
|
QHBoxLayout* layout = new QHBoxLayout;
|
||
|
|
QCheckBox* box = new QCheckBox;
|
||
|
|
layout->addWidget(box);
|
||
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
||
|
|
layout->setAlignment(box, Qt::AlignCenter);
|
||
|
|
widget->setLayout(layout);
|
||
|
|
ui.tableWidget->setCellWidget(i, j, widget);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
QGridLayout* gridLayout = new QGridLayout();
|
||
|
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||
|
|
|
||
|
|
QLabel* highLabel = new QLabel("0");
|
||
|
|
QLabel* lowLabel = new QLabel("1");
|
||
|
|
QLabel* upLabel = new QLabel("2");
|
||
|
|
QLabel* downLabel = new QLabel("3");
|
||
|
|
gridLayout->addWidget(highLabel, 0, 0, Qt::AlignCenter);
|
||
|
|
gridLayout->addWidget(upLabel, 0, 1, Qt::AlignCenter);
|
||
|
|
gridLayout->addWidget(lowLabel, 1, 0, Qt::AlignCenter);
|
||
|
|
gridLayout->addWidget(downLabel, 1, 1, Qt::AlignCenter);
|
||
|
|
|
||
|
|
gridLayout->setAlignment(highLabel, Qt::AlignCenter);
|
||
|
|
gridLayout->setAlignment(upLabel, Qt::AlignCenter);
|
||
|
|
gridLayout->setAlignment(lowLabel, Qt::AlignCenter);
|
||
|
|
gridLayout->setAlignment(downLabel, Qt::AlignCenter);
|
||
|
|
|
||
|
|
QWidget* widget = new QWidget();
|
||
|
|
widget->setLayout(gridLayout);
|
||
|
|
ui.tableWidget->setCellWidget(i, j, widget);
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
QList<QMap<QString, QString>> odds = g_config->odds();
|
||
|
|
for (int i = 0; i < odds.count(); i++)
|
||
|
|
{
|
||
|
|
QMap<QString, QString> map = odds[i];
|
||
|
|
//qDebug() << map;
|
||
|
|
if (map["COLUMN"]!="14")
|
||
|
|
{
|
||
|
|
QLabel* high = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(map["ROW"].toInt(), map["COLUMN"].toInt())->layout()->itemAt(0)->widget());
|
||
|
|
QLabel* up = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(map["ROW"].toInt(), map["COLUMN"].toInt())->layout()->itemAt(1)->widget());
|
||
|
|
QLabel* low = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(map["ROW"].toInt(), map["COLUMN"].toInt())->layout()->itemAt(2)->widget());
|
||
|
|
QLabel* down = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(map["ROW"].toInt(), map["COLUMN"].toInt())->layout()->itemAt(3)->widget());
|
||
|
|
|
||
|
|
high->setText(map["HIGH"]);
|
||
|
|
up->setText(map["UP"]);
|
||
|
|
low->setText(map["LOW"]);
|
||
|
|
down->setText(map["DOWN"]);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
QCheckBox* checkBox = reinterpret_cast<QCheckBox*>(ui.tableWidget->cellWidget(map["ROW"].toInt(), map["COLUMN"].toInt())->layout()->itemAt(0)->widget());
|
||
|
|
if (map["REBET"] == "TRUE")
|
||
|
|
{
|
||
|
|
checkBox->setChecked(true);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
checkBox->setChecked(false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 读取配置
|
||
|
|
ui.projectCheckBox->setChecked(g_config->oddsProject());
|
||
|
|
ui.projectCombo->setCurrentIndex(g_config->oddsProjectIndex());
|
||
|
|
ui.typeCheckBox->setChecked(g_config->oddsType());
|
||
|
|
ui.typeCombo->setCurrentIndex(g_config->oddsTypeIndex());
|
||
|
|
ui.highEdit->setText(QString::number(g_config->oddsHigh()));
|
||
|
|
ui.lowEdit->setText(QString::number(g_config->oddsLow()));
|
||
|
|
ui.upEdit->setText(QString::number(g_config->oddsUp()));
|
||
|
|
ui.downEdit->setText(QString::number(g_config->oddsDown()));
|
||
|
|
|
||
|
|
connect(ui.setOddsButton, &QPushButton::clicked, this, &Odds::slotSetOdds);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
Odds::~Odds()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void Odds::slotSetOdds()
|
||
|
|
{
|
||
|
|
QString project = ui.projectCombo->currentText();
|
||
|
|
QString type = ui.typeCombo->currentText();
|
||
|
|
|
||
|
|
// 单个
|
||
|
|
if (ui.projectCheckBox->isChecked() && ui.typeCheckBox->isChecked())
|
||
|
|
{
|
||
|
|
int row = 0, column = 0;
|
||
|
|
for (row; row < ui.tableWidget->rowCount(); row++)
|
||
|
|
{
|
||
|
|
QString rowText = ui.tableWidget->item(row, 0)->text();
|
||
|
|
if (rowText == project)
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for (column; column < ui.tableWidget->columnCount(); column++)
|
||
|
|
{
|
||
|
|
QString columnText = ui.tableWidget->horizontalHeaderItem(column)->text();
|
||
|
|
if (columnText == type)
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
QLabel* high = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(0)->widget());
|
||
|
|
QLabel* up = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(1)->widget());
|
||
|
|
QLabel* low = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(2)->widget());
|
||
|
|
QLabel* down = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(3)->widget());
|
||
|
|
|
||
|
|
high->setText(ui.highEdit->text());
|
||
|
|
up->setText(ui.upEdit->text());
|
||
|
|
low->setText(ui.lowEdit->text());
|
||
|
|
down->setText(ui.downEdit->text());
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
else if (ui.projectCheckBox->isChecked() && !ui.typeCheckBox->isChecked())
|
||
|
|
{
|
||
|
|
int row = 0, column = 0;
|
||
|
|
for (row; row < ui.tableWidget->rowCount(); row++)
|
||
|
|
{
|
||
|
|
QString rowText = ui.tableWidget->item(row, 0)->text();
|
||
|
|
if (rowText == project)
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for (column; column < ui.tableWidget->columnCount(); column++)
|
||
|
|
{
|
||
|
|
// 第一列 最后一列跳过
|
||
|
|
if (column == 0 || column == ui.tableWidget->columnCount() - 1)
|
||
|
|
{
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
QLabel* high = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(0)->widget());
|
||
|
|
QLabel* up = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(1)->widget());
|
||
|
|
QLabel* low = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(2)->widget());
|
||
|
|
QLabel* down = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(3)->widget());
|
||
|
|
high->setText(ui.highEdit->text());
|
||
|
|
up->setText(ui.upEdit->text());
|
||
|
|
low->setText(ui.lowEdit->text());
|
||
|
|
down->setText(ui.downEdit->text());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (!ui.projectCheckBox->isChecked() && ui.typeCheckBox->isChecked())
|
||
|
|
{
|
||
|
|
int row = 0, column = 0;
|
||
|
|
for (column; column < ui.tableWidget->columnCount(); column++)
|
||
|
|
{
|
||
|
|
QString columnText = ui.tableWidget->horizontalHeaderItem(column)->text();
|
||
|
|
if (columnText == type)
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for (row; row < ui.tableWidget->rowCount(); row++)
|
||
|
|
{
|
||
|
|
QLabel* high = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(0)->widget());
|
||
|
|
QLabel* up = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(1)->widget());
|
||
|
|
QLabel* low = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(2)->widget());
|
||
|
|
QLabel* down = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(3)->widget());
|
||
|
|
high->setText(ui.highEdit->text());
|
||
|
|
up->setText(ui.upEdit->text());
|
||
|
|
low->setText(ui.lowEdit->text());
|
||
|
|
down->setText(ui.downEdit->text());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
for (int row = 0; row < ui.tableWidget->rowCount(); row++)
|
||
|
|
{
|
||
|
|
for (int column = 0; column < ui.tableWidget->columnCount(); column++)
|
||
|
|
{
|
||
|
|
// 第一列 最后一列跳过
|
||
|
|
if (column == 0 || column == ui.tableWidget->columnCount() - 1)
|
||
|
|
{
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
QLabel* high = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(0)->widget());
|
||
|
|
QLabel* up = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(1)->widget());
|
||
|
|
QLabel* low = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(2)->widget());
|
||
|
|
QLabel* down = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(3)->widget());
|
||
|
|
high->setText(ui.highEdit->text());
|
||
|
|
up->setText(ui.upEdit->text());
|
||
|
|
low->setText(ui.lowEdit->text());
|
||
|
|
down->setText(ui.downEdit->text());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void Odds::closeEvent(QCloseEvent * event)
|
||
|
|
{
|
||
|
|
QList<QMap<QString, QString>> list;
|
||
|
|
for (int row = 0; row < ui.tableWidget->rowCount(); row++)
|
||
|
|
{
|
||
|
|
QString rowText = ui.tableWidget->item(row, 0)->text();
|
||
|
|
for (int column = 0; column < ui.tableWidget->columnCount(); column++)
|
||
|
|
{
|
||
|
|
if (column == 0)
|
||
|
|
{
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
QString columnText = ui.tableWidget->horizontalHeaderItem(column)->text();
|
||
|
|
|
||
|
|
// 判断是否勾选补单
|
||
|
|
QCheckBox* rebet_checkbox = reinterpret_cast<QCheckBox*>(ui.tableWidget->cellWidget(row, ui.tableWidget->columnCount() - 1)->layout()->itemAt(0)->widget());
|
||
|
|
bool rebet = rebet_checkbox->isChecked();
|
||
|
|
if (column == ui.tableWidget->columnCount() - 1)
|
||
|
|
{
|
||
|
|
QMap<QString, QString> map;
|
||
|
|
map["ROW"] = QString::number(row);
|
||
|
|
map["COLUMN"] = QString::number(column);
|
||
|
|
QCheckBox* checkBox = reinterpret_cast<QCheckBox*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(0)->widget());
|
||
|
|
if (checkBox->isChecked())
|
||
|
|
{
|
||
|
|
map["REBET"] = "TRUE";
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
map["REBET"] = "FALSE";
|
||
|
|
}
|
||
|
|
map["project"] = rowText;
|
||
|
|
list.append(map);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
QMap<QString, QString> map = Utils::instance().type(rowText, columnText);
|
||
|
|
map["ROW"] = QString::number(row);
|
||
|
|
map["COLUMN"] = QString::number(column);
|
||
|
|
|
||
|
|
QLabel* high = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(0)->widget());
|
||
|
|
QLabel* up = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(1)->widget());
|
||
|
|
QLabel* low = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(2)->widget());
|
||
|
|
QLabel* down = reinterpret_cast<QLabel*>(ui.tableWidget->cellWidget(row, column)->layout()->itemAt(3)->widget());
|
||
|
|
|
||
|
|
map["HIGH"] = high->text();
|
||
|
|
map["UP"] = up->text();
|
||
|
|
map["LOW"] = low->text();
|
||
|
|
map["DOWN"] = down->text();
|
||
|
|
map["project"] = rowText;
|
||
|
|
|
||
|
|
if (rebet)
|
||
|
|
{
|
||
|
|
map["REBET"] = "TRUE";
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
map["REBET"] = "FALSE";
|
||
|
|
}
|
||
|
|
//map["type"] = columnText;
|
||
|
|
list.append(map);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
g_config->setOdds(list);
|
||
|
|
|
||
|
|
g_config->setOddsProject(ui.projectCheckBox->isChecked());
|
||
|
|
g_config->setOddsProjectIndex(ui.projectCombo->currentIndex());
|
||
|
|
g_config->setOddsType(ui.typeCheckBox->isChecked());
|
||
|
|
g_config->setOddsTypeIndex(ui.typeCombo->currentIndex());
|
||
|
|
|
||
|
|
g_config->setOddsHigh(ui.highEdit->text().toInt());
|
||
|
|
g_config->setOddsLow(ui.lowEdit->text().toInt());
|
||
|
|
g_config->setOddsUp(ui.upEdit->text().toInt());
|
||
|
|
g_config->setOddsDown(ui.downEdit->text().toInt());
|
||
|
|
|
||
|
|
}
|
||
|
|
|