diff -r 20ff80421736 -r e4e366013e9a QTfrontend/ui/page/pagegamestats.cpp
--- a/QTfrontend/ui/page/pagegamestats.cpp Sun Jun 16 00:46:11 2013 +0400
+++ b/QTfrontend/ui/page/pagegamestats.cpp Mon Jun 17 16:56:58 2013 +0200
@@ -40,10 +40,15 @@
QLayout * PageGameStats::bodyLayoutDefinition()
{
+ kindOfPoints = QString("");
+ defaultGraphTitle = true;
QGridLayout * pageLayout = new QGridLayout();
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 +66,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 +159,41 @@
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(defaultGraphTitle) {
+ labelGraphTitle->setText("
" + PageGameStats::tr("Health graph") + "
");
+ } else {
+ defaultGraphTitle = true;
+ }
+ // if not health data sent
+ if(healthPoints.size() == 0) {
+ labelGraphTitle->hide();
+ graphic->hide();
+ } else {
+ 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 +235,13 @@
healthPoints[clan].append(hp);
break;
}
+ case 'g' :
+ {
+ // TODO: change default picture or add change pic capability
+ defaultGraphTitle = false;
+ labelGraphTitle->setText("
" + info + "
");
+ break;
+ }
case 'T': // local team stats
{
//AddStatText("local team: " + info + "
");
@@ -232,7 +257,11 @@
}
break;
}
-
+ case 'p' :
+ {
+ kindOfPoints = info;
+ break;
+ }
case 'P' :
{
int i = info.indexOf(' ');
@@ -269,7 +298,13 @@
}
QString message;
- QString killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills);
+ QString killstring;
+ if(kindOfPoints.compare("") == 0) {
+ killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills);
+ } else {
+ killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints);
+ kindOfPoints = QString("");
+ }
message = QString("%1 %2. %3 ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "
";
@@ -300,6 +335,12 @@
AddStatText(message);
break;
}
+ case 'c' :
+ {
+ QString message = " "+info+"
";
+ AddStatText(message);
+ break;
+ }
}
}