Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior qt5transition
authorunc0rr
Tue, 13 Mar 2018 22:57:49 +0100
branchqt5transition
changeset 13191 07c93d864bc2
parent 13187 d2f8dafdb080
child 13193 16b375b21af1
Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
QTfrontend/ui/page/pagegamestats.cpp
--- a/QTfrontend/ui/page/pagegamestats.cpp	Tue Mar 13 18:25:37 2018 +0100
+++ b/QTfrontend/ui/page/pagegamestats.cpp	Tue Mar 13 22:57:49 2018 +0100
@@ -176,19 +176,32 @@
         graphic->setScene(Q_NULLPTR);
         m_scene.reset(new QGraphicsScene(this));
 
+        quint32 maxValue = 0;
+        int maxSize = 0;
+        for(QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin(); i != healthPoints.constEnd(); ++i)
+        {
+          maxSize = qMax(maxSize, i.value().size());
+
+          foreach (quint32 v, i.value())
+            maxValue = qMax(maxValue, v);
+        }
+
+        if(maxSize < 2)
+          return;
+
         QMap<quint32, QVector<quint32> >::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<quint32> hps = i.value();
+            const QVector<quint32>& hps = i.value();
 
             QPainterPath path;
             if (hps.size())
                 path.moveTo(0, hps[0]);
 
             for(int t = 1; t < hps.size(); ++t)
-                path.lineTo(t, hps[t]);
+                path.lineTo(t * maxValue / (maxSize - 1), hps[t]);
 
             QPen pen(c);
             pen.setWidth(2);