@@ -0,0 +1,80 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "qlegendmarker.h" | |
|
22 | //#include "qlegendmarker_p.h" | |
|
23 | #include <QDebug> | |
|
24 | ||
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
26 | ||
|
27 | QLegendMarker::QLegendMarker(QObject *parent) : | |
|
28 | QObject(parent)//, | |
|
29 | // d_ptr(new QLegendMarkerPrivate(this)) | |
|
30 | { | |
|
31 | } | |
|
32 | ||
|
33 | QLegendMarker::~QLegendMarker() | |
|
34 | { | |
|
35 | } | |
|
36 | ||
|
37 | QString QLegendMarker::label() const | |
|
38 | { | |
|
39 | return m_label; | |
|
40 | } | |
|
41 | ||
|
42 | void QLegendMarker::setLabel(const QString &label) | |
|
43 | { | |
|
44 | m_label = label; | |
|
45 | } | |
|
46 | ||
|
47 | QPen QLegendMarker::pen() const | |
|
48 | { | |
|
49 | return m_pen; | |
|
50 | } | |
|
51 | ||
|
52 | void QLegendMarker::setPen(const QPen &pen) | |
|
53 | { | |
|
54 | m_pen = pen; | |
|
55 | } | |
|
56 | ||
|
57 | QBrush QLegendMarker::brush() const | |
|
58 | { | |
|
59 | return m_brush; | |
|
60 | } | |
|
61 | ||
|
62 | void QLegendMarker::setBrush(const QBrush &brush) | |
|
63 | { | |
|
64 | m_brush = brush; | |
|
65 | } | |
|
66 | ||
|
67 | bool QLegendMarker::isVisible() const | |
|
68 | { | |
|
69 | return m_visible; | |
|
70 | } | |
|
71 | ||
|
72 | void QLegendMarker::setVisible(bool visible) | |
|
73 | { | |
|
74 | m_visible = visible; | |
|
75 | } | |
|
76 | ||
|
77 | #include "moc_qlegendmarker.cpp" | |
|
78 | //#include "moc_qlegendmarker_p.cpp" | |
|
79 | ||
|
80 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,81 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #ifndef QLEGENDMARKER_H | |
|
22 | #define QLEGENDMARKER_H | |
|
23 | ||
|
24 | #include <QChartGlobal> | |
|
25 | #include <QObject> | |
|
26 | #include <QPen> | |
|
27 | #include <QBrush> | |
|
28 | ||
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
30 | ||
|
31 | // TODO: | |
|
32 | //class QLegendMarkerPrivate; | |
|
33 | ||
|
34 | // TODO: should this be abstract? | |
|
35 | class QTCOMMERCIALCHART_EXPORT QLegendMarker : public QObject | |
|
36 | { | |
|
37 | Q_OBJECT | |
|
38 | ||
|
39 | // TODO: need for these? | |
|
40 | // Q_PROPERTY(QString label READ label WRITE setlabel NOTIFY labelChanged); | |
|
41 | // Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged); | |
|
42 | // Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged); | |
|
43 | ||
|
44 | public: | |
|
45 | explicit QLegendMarker(QObject *parent = 0); | |
|
46 | virtual ~QLegendMarker(); | |
|
47 | ||
|
48 | QString label() const; | |
|
49 | void setLabel(const QString &label); | |
|
50 | ||
|
51 | QPen pen() const; | |
|
52 | void setPen(const QPen &pen); | |
|
53 | ||
|
54 | QBrush brush() const; | |
|
55 | void setBrush(const QBrush &brush); | |
|
56 | ||
|
57 | bool isVisible() const; | |
|
58 | void setVisible(bool visible); | |
|
59 | ||
|
60 | Q_SIGNALS: | |
|
61 | void clicked(); | |
|
62 | void hovered(bool status); | |
|
63 | ||
|
64 | public Q_SLOTS: | |
|
65 | void markersUpdated(); // TODO: private? Idea is that series signals, when for example pieslices have been added/removed. | |
|
66 | ||
|
67 | public: | |
|
68 | // TODO: | |
|
69 | // QScopedPointer<QLegendMarkerPrivate> d_ptr; | |
|
70 | Q_DISABLE_COPY(QLegendMarker) | |
|
71 | ||
|
72 | // TODO: move to PIMPL | |
|
73 | QString m_label; | |
|
74 | QPen m_pen; | |
|
75 | QBrush m_brush; | |
|
76 | bool m_visible; | |
|
77 | }; | |
|
78 | ||
|
79 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
80 | ||
|
81 | #endif // QLEGENDMARKER_H |
@@ -4,7 +4,8 DEPENDPATH += $$PWD | |||
|
4 | 4 | SOURCES += \ |
|
5 | 5 | $$PWD/qlegend.cpp \ |
|
6 | 6 | $$PWD/legendmarker.cpp \ |
|
7 | $$PWD/legendlayout.cpp | |
|
7 | $$PWD/legendlayout.cpp \ | |
|
8 | $$PWD/qlegendmarker.cpp | |
|
8 | 9 | |
|
9 | 10 | PRIVATE_HEADERS += \ |
|
10 | 11 | $$PWD/legendmarker_p.h \ |
@@ -14,4 +15,5 PRIVATE_HEADERS += \ | |||
|
14 | 15 | |
|
15 | 16 | |
|
16 | 17 | PUBLIC_HEADERS += \ |
|
17 | $$PWD/qlegend.h No newline at end of file | |
|
18 | $$PWD/qlegend.h \ | |
|
19 | $$PWD/qlegendmarker.h |
@@ -392,6 +392,14 bool QLegend::isBackgroundVisible() const | |||
|
392 | 392 | return d_ptr->m_backgroundVisible; |
|
393 | 393 | } |
|
394 | 394 | |
|
395 | ||
|
396 | QList<QLegendMarker*> QLegend::markers() const | |
|
397 | { | |
|
398 | // TODO: name of PIMPL method will change. | |
|
399 | return d_ptr->legendMarkers(); | |
|
400 | } | |
|
401 | ||
|
402 | ||
|
395 | 403 | /*! |
|
396 | 404 | \internal \a event see QGraphicsWidget for details |
|
397 | 405 | */ |
@@ -36,6 +36,7 class QPieSeries; | |||
|
36 | 36 | class QAreaSeries; |
|
37 | 37 | class QChart; |
|
38 | 38 | class QLegendPrivate; |
|
39 | class QLegendMarker; | |
|
39 | 40 | |
|
40 | 41 | class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget |
|
41 | 42 | { |
@@ -83,6 +84,9 public: | |||
|
83 | 84 | void setBackgroundVisible(bool visible = true); |
|
84 | 85 | bool isBackgroundVisible() const; |
|
85 | 86 | |
|
87 | // New stuff: | |
|
88 | QList <QLegendMarker*> markers() const; | |
|
89 | ||
|
86 | 90 | protected: |
|
87 | 91 | void hideEvent(QHideEvent *event); |
|
88 | 92 | void showEvent(QShowEvent *event); |
@@ -52,9 +52,12 public: | |||
|
52 | 52 | QPointF offset() const; |
|
53 | 53 | int roundness(qreal size); |
|
54 | 54 | |
|
55 |
QList<LegendMarker |
|
|
55 | QList<LegendMarker*> markers() { return m_markers; } // TODO: this will be removed | |
|
56 | 56 |
QGraphicsItemGroup |
|
57 | 57 | |
|
58 | // New stuff: | |
|
59 | QList<QLegendMarker*> legendMarkers() { return m_legendMarkers; } // TODO: function name will change | |
|
60 | ||
|
58 | 61 | public Q_SLOTS: |
|
59 | 62 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); |
|
60 | 63 | void handleSeriesRemoved(QAbstractSeries *series); |
@@ -67,7 +70,7 private: | |||
|
67 | 70 | LegendLayout *m_layout; |
|
68 | 71 |
QChart |
|
69 | 72 |
QGraphicsItemGroup |
|
70 |
QList<LegendMarker |
|
|
73 | QList<LegendMarker*> m_markers; // TODO: this will be removed | |
|
71 | 74 | Qt::Alignment m_alignment; |
|
72 | 75 | QBrush m_brush; |
|
73 | 76 | QPen m_pen; |
@@ -80,6 +83,8 private: | |||
|
80 | 83 | |
|
81 | 84 | friend class QLegend; |
|
82 | 85 | friend class LegendLayout; |
|
86 | QList<QLegendMarker*> m_legendMarkers; // TODO: rename to m_markers eventually. | |
|
87 | ||
|
83 | 88 | }; |
|
84 | 89 | |
|
85 | 90 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now