summaryrefslogtreecommitdiff
path: root/src/charts/PieLegend.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/charts/PieLegend.h')
-rw-r--r--src/charts/PieLegend.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/charts/PieLegend.h b/src/charts/PieLegend.h
new file mode 100644
index 0000000..d8e83e5
--- /dev/null
+++ b/src/charts/PieLegend.h
@@ -0,0 +1,34 @@
+#ifndef PIE_LEGEND_H
+#define PIE_LEGEND_H
+
+#include <QtWidgets>
+
+#include "DataPoint.h"
+
+class PieChartScene;
+
+class PieLegend: public QGraphicsItem
+{
+public:
+ static const int Width = 150;
+ static const int SquareSide = 20;
+ static const int LabelSpacing = 10;
+ static const int LabelTextSpacing = 10;
+
+public:
+ PieLegend(const QPointF& pos, const PieChartScene* scene);
+ QRectF boundingRect() const;
+ void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0) {}
+
+private:
+ void addLabels();
+ QPointF getLabelPos(int index) const;
+ void addLabel(int index, const QPointF& pos);
+ QPointF getTextPos(const QPointF& squarePos,
+ const QGraphicsSimpleTextItem* textItem) const;
+
+private:
+ const PieChartScene* scene;
+};
+
+#endif