diff -r d328fe17b195 -r dc3c0e44f7f3 QTfrontend/ui/page/pagegamestats.cpp --- a/QTfrontend/ui/page/pagegamestats.cpp Thu Jun 06 03:52:32 2013 +0300 +++ b/QTfrontend/ui/page/pagegamestats.cpp Sat Jun 08 23:24:52 2013 +0300 @@ -44,6 +44,9 @@ pageLayout->setSpacing(20); pageLayout->setColumnStretch(0, 1); pageLayout->setColumnStretch(1, 1); + pageLayout->setRowStretch(0, 1); + pageLayout->setRowStretch(1, 20); + //pageLayout->setRowStretch(1, -1); this should work but there is unnecessary empty space betwin lines if used pageLayout->setContentsMargins(7, 7, 7, 0); QGroupBox * gb = new QGroupBox(this); @@ -61,15 +64,15 @@ gbl->addWidget(l); gbl->addWidget(labelGameStats); gb->setLayout(gbl); - pageLayout->addWidget(gb, 1, 1, 1, 2); + pageLayout->addWidget(gb, 1, 1); // graph graphic = new FitGraphicsView(gb); - l = new QLabel(this); - l->setTextFormat(Qt::RichText); - l->setText("

" + PageGameStats::tr("Health graph") + "

"); - l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - gbl->addWidget(l); + labelGraphTitle = new QLabel(this); + labelGraphTitle->setTextFormat(Qt::RichText); + labelGraphTitle->setText("

" + PageGameStats::tr("Health graph") + "

"); + labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + gbl->addWidget(labelGraphTitle); gbl->addWidget(graphic); graphic->scale(1.0, -1.0); graphic->setBackgroundBrush(QBrush(Qt::black)); @@ -154,28 +157,37 @@ void PageGameStats::renderStats() { - QGraphicsScene * scene = new QGraphicsScene(); - - QMap >::const_iterator i = healthPoints.constBegin(); - while (i != healthPoints.constEnd()) - { - quint32 c = i.key(); - //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); - QVector hps = i.value(); + graphic->show(); + labelGraphTitle-> show(); + // if not health data sent + if(healthPoints.size() == 0) { + labelGraphTitle->hide(); + graphic->hide(); + } else { + labelGraphTitle->setText("

" + PageGameStats::tr("Health graph") + "

"); + QGraphicsScene * scene = new QGraphicsScene(); - QPainterPath path; - if (hps.size()) - path.moveTo(0, hps[0]); + QMap >::const_iterator i = healthPoints.constBegin(); + while (i != healthPoints.constEnd()) + { + quint32 c = i.key(); + //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); + QVector hps = i.value(); - for(int t = 1; t < hps.size(); ++t) - path.lineTo(t, hps[t]); + QPainterPath path; + if (hps.size()) + path.moveTo(0, hps[0]); - scene->addPath(path, QPen(c)); - ++i; - } + for(int t = 1; t < hps.size(); ++t) + path.lineTo(t, hps[t]); - graphic->setScene(scene); - graphic->fitInView(graphic->sceneRect()); + scene->addPath(path, QPen(c)); + ++i; + } + + graphic->setScene(scene); + graphic->fitInView(graphic->sceneRect()); + } } void PageGameStats::GameStats(char type, const QString & info) @@ -217,6 +229,12 @@ healthPoints[clan].append(hp); break; } + case 'g' : + { + // TODO: change default picture or add change pic capability + labelGraphTitle->setText("

" + info + "

"); + break; + } case 'T': // local team stats { //AddStatText("

local team: " + info + "

");