1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QLEGENDMARKER_H
5#define QLEGENDMARKER_H
6
7#include <QtCharts/QChartGlobal>
8#include <QtCharts/QLegend>
9#include <QtCore/QObject>
10#include <QtGui/QPen>
11#include <QtGui/QBrush>
12#include <QtGui/QFont>
13
14QT_BEGIN_NAMESPACE
15
16class QLegendMarkerPrivate;
17class QAbstractSeries;
18class QLegend;
19
20class Q_CHARTS_EXPORT QLegendMarker : public QObject
21{
22 Q_OBJECT
23
24public:
25 enum LegendMarkerType {
26 LegendMarkerTypeArea,
27 LegendMarkerTypeBar,
28 LegendMarkerTypePie,
29 LegendMarkerTypeXY,
30 LegendMarkerTypeBoxPlot,
31 LegendMarkerTypeCandlestick
32 };
33
34 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
35 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
36 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
37 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
38 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
39 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
40 Q_PROPERTY(QLegend::MarkerShape shape READ shape WRITE setShape NOTIFY shapeChanged)
41 Q_ENUMS(LegendMarkerType)
42
43public:
44 virtual ~QLegendMarker();
45 virtual LegendMarkerType type() = 0;
46
47 QString label() const;
48 void setLabel(const QString &label);
49
50 QBrush labelBrush() const;
51 void setLabelBrush(const QBrush &brush);
52
53 QFont font() const;
54 void setFont(const QFont &font);
55
56 QPen pen() const;
57 void setPen(const QPen &pen);
58
59 QBrush brush() const;
60 void setBrush(const QBrush &brush);
61
62 bool isVisible() const;
63 void setVisible(bool visible);
64
65 QLegend::MarkerShape shape() const;
66 void setShape(QLegend::MarkerShape shape);
67
68 virtual QAbstractSeries* series() = 0;
69
70Q_SIGNALS:
71 void clicked();
72 void hovered(bool status);
73 void labelChanged();
74 void labelBrushChanged();
75 void fontChanged();
76 void penChanged();
77 void brushChanged();
78 void visibleChanged();
79 void shapeChanged();
80
81protected:
82 explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = nullptr);
83
84 QScopedPointer<QLegendMarkerPrivate> d_ptr;
85 friend class QLegendPrivate;
86 friend class QLegendMarkerPrivate;
87 friend class LegendMarkerItem;
88 friend class LegendLayout;
89 friend class LegendScroller;
90
91private:
92 Q_DISABLE_COPY(QLegendMarker)
93};
94
95QT_END_NAMESPACE
96
97#endif // QLEGENDMARKER_H
98

source code of qtcharts/src/charts/legend/qlegendmarker.h