diff include/gui/widgets/graph.h @ 94:2f373d48f889

*: etc changes to graph stuff
author Paper <mrpapersonic@gmail.com>
date Wed, 01 Nov 2023 14:30:26 -0400
parents d5efb81540b3
children bd68e4393e6f
line wrap: on
line diff
--- a/include/gui/widgets/graph.h	Wed Nov 01 13:52:34 2023 -0400
+++ b/include/gui/widgets/graph.h	Wed Nov 01 14:30:26 2023 -0400
@@ -1,5 +1,6 @@
 #ifndef __gui__widgets__graph_h
 #define __gui__widgets__graph_h
+
 #include <QWidget>
 #include <QSize>
 #include <QPaintEvent>
@@ -9,7 +10,7 @@
 #include <QPainterPath>
 #include <QPen>
 
-template <typename T> /* does this even work?? */
+template <typename T>
 class Graph final : public QWidget {
 public:
 	Graph(QWidget* parent = nullptr) : QWidget(parent) {};
@@ -36,7 +37,7 @@
 
 		int i = 0;
 		for (const auto& item : map) {
-			painter.drawText(QRect(0, i*ITEM_HEIGHT, TEXT_WIDTH, ITEM_HEIGHT), Qt::AlignRight | Qt::AlignVCenter, QString::number(item.first));
+			painter.drawText(QRect(rect.x(), rect.y() + i * ITEM_HEIGHT, TEXT_WIDTH, ITEM_HEIGHT), Qt::AlignRight | Qt::AlignVCenter, QString::number(item.first));
 
 			if (size) {
 				painter.save();
@@ -45,7 +46,7 @@
 				painter.setPen(pen);
 
 				QPainterPath path;
-				path.addRect(rect.x()+35, rect.y()+(i*ITEM_HEIGHT), (static_cast<double>(item.second)/size)*(rect.width()-35), ITEM_HEIGHT);
+				path.addRect(rect.x()+35, rect.y() + i * ITEM_HEIGHT, (static_cast<double>(item.second)/size)*(rect.width()-35), ITEM_HEIGHT);
 				painter.fillPath(path, Qt::blue);
 				painter.drawPath(path);