diff options
Diffstat (limited to 'stats/legend.h')
| -rw-r--r-- | stats/legend.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/stats/legend.h b/stats/legend.h index c643a41f3..fb88920bd 100644 --- a/stats/legend.h +++ b/stats/legend.h @@ -3,34 +3,38 @@ #ifndef STATS_LEGEND_H #define STATS_LEGEND_H -#include "backend-shared/roundrectitem.h" +#include "chartitem.h" #include <memory> #include <vector> +#include <QFont> -class QGraphicsScene; -class QGraphicsSceneMouseEvent; +class QFontMetrics; -class Legend : public RoundRectItem { +class Legend : public ChartRectItem { public: - Legend(const std::vector<QString> &names); - void hover(QPointF pos); + Legend(StatsView &view, const std::vector<QString> &names); void resize(); // called when the chart size changes. + void setPos(QPointF pos); // Attention: not virtual - always call on this class. private: // Each entry is a text besides a rectangle showing the color struct Entry { - std::unique_ptr<QGraphicsRectItem> rect; - std::unique_ptr<QGraphicsSimpleTextItem> text; + QString name; + QBrush rectBrush; QPointF pos; double width; - Entry(const QString &name, int idx, int numBins, QGraphicsItem *parent); + Entry(const QString &name, int idx, int numBins, const QFontMetrics &fm); }; int displayedItems; double width; double height; + QFont font; + // The position is specified with respect to the center and in relative terms + // with respect to the canvas. + QPointF centerPos; + bool posInitialized; int fontHeight; std::vector<Entry> entries; - void updatePosition(); void hide(); }; |