- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
void AddMatchDialog::doAction(QListWidget *list, QListWidget *playersList)
{
//prepare
MatchStatistics *stats;
QLabel *score;
QStringList *s, *ch;
static QStringList homeStart, homeChanges, awayStart, awayChanges;
if (list == m_ui->lstHome) {
stats = &m.home;
s = &homeStart;
ch = &homeChanges;
score = m_ui->lblHomeScore;
}
else if (list == m_ui->lstAway) {
stats = &m.away;
s = &awayStart;
ch = &awayChanges;
score = m_ui->lblAwayScore;
}
else {return;}
if (s->isEmpty() && ch->isEmpty()) {
stats->goals = 0;
foreach (Player p, stats->club.players) {
if (stats->start.contains(p))
s->append(p.name);
else
ch->append(p.name);
}
}
//счетчик желтых карточек
static QStringList yellowCarders;
EventDialog *dlg = new EventDialog(this, *s, *ch);
if (dlg->exec() == QDialog::Accepted) {
QStringList data = dlg->getData();
QListWidgetItem *it = new QListWidgetItem(0);
switch (QVariant (data.at(1)).toInt()) {
qDebug() << data.at(1);
case 5:
stats->golaedors.append(stats->club.getPlayer(data.at(0)));
it->setIcon(QIcon(":/images/images/ball.png"));
it->setText(data.at(0));
list->addItem(it);
stats->goals ++;
score->setText(QVariant(stats->goals).toString());
break;
case 1:
if (!yellowCarders.contains(data.at(0))) {
stats->yellowCards.append(stats->club.getPlayer(data.at(0)));
it->setIcon(QIcon(":/images/images/whistle.png"));
it->setText(data.at(0));
list->addItem(it);
yellowCarders.append(data.at(0));}
else {
stats->yellowCards.append(stats->club.getPlayer(data.at(0)));
stats->redCards.append(stats->club.getPlayer(data.at(0)));
it->setIcon(QIcon(":/images/images/cards.png"));
it->setText(data.at(0));
list->addItem(it);
s->removeAt(s->indexOf(data.at(0)));
playersList->clear();
playersList->addItems(*s);
yellowCarders.removeAt(yellowCarders.indexOf(data.at(0)));
}
break;
case 2:
stats->redCards.append(stats->club.getPlayer(data.at(0)));
it->setIcon(QIcon(":/images/images/cards.png"));
it->setText(data.at(0));
list->addItem(it);
s->removeAt(s->indexOf(data.at(0)));
playersList->clear();
playersList->addItems(*s);
break;
case 3:
stats->traumas.append(stats->club.getPlayer(data.at(0)));
it->setIcon(QIcon(":/images/images/boots.png"));
it->setText(data.at(0));
list->addItem(it);
break;
case 4:
{
Change change;
change.first = stats->club.getPlayer(data.at(0));
change.second = stats->club.getPlayer(data.at(2));
stats->changes.append(change);
//item
it->setIcon(QIcon (":/images/images/change.png"));
it->setText(data.at(0) + " ? " + data.at(2));
list->addItem(it);
//change!
s->removeAt(s->indexOf(data.at(0)));
ch->removeAt (ch->indexOf(data.at(2)));
s->append(data.at(2));
playersList->clear();
playersList->addItems(*s);
// ...
Я сейчас пишу систему сбора статистики футбольных матчей.
Немного кода :). ВНИМАНИЕ: это Qt
Комментарии (0) RSS
Добавить комментарий