##// END OF EJS Templates
added QAreaLegendMarker
sauimone -
r2176:e6d9fe9b5eee
parent child
Show More
@@ -0,0 +1,85
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 "qarealegendmarker.h"
22 #include "qarealegendmarker_p.h"
23 #include "qareaseries_p.h"
24 #include <QAreaSeries>
25 #include <QDebug>
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
29 QAreaLegendMarker::QAreaLegendMarker(QAreaSeries* series, QLegend *legend, QObject *parent) :
30 QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent)
31 {
32 }
33
34 QAreaLegendMarker::~QAreaLegendMarker()
35 {
36 // qDebug() << "deleting Area marker" << this;
37 }
38
39 /*!
40 \internal
41 */
42 QAreaLegendMarker::QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent) :
43 QLegendMarker(d, parent)
44 {
45 }
46
47 QAreaSeries* QAreaLegendMarker::series()
48 {
49 Q_D(QAreaLegendMarker);
50 return d->m_series;
51 }
52
53 QAreaSeries* QAreaLegendMarker::peerObject()
54 {
55 Q_D(QAreaLegendMarker);
56 return d->m_series;
57 }
58
59 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60
61 QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend) :
62 QLegendMarkerPrivate(q,legend),
63 m_series(series)
64 {
65 QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
66 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
67 updated();
68 }
69
70 QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate()
71 {
72 QObject::disconnect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
73 QObject::disconnect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
74 }
75
76 void QAreaLegendMarkerPrivate::updated()
77 {
78 m_item->setBrush(m_series->brush());
79 m_item->setLabel(m_series->name());
80 }
81
82 #include "moc_qarealegendmarker.cpp"
83 #include "moc_qarealegendmarker_p.cpp"
84
85 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,59
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 QAREALEGENDMARKER_H
22 #define QAREALEGENDMARKER_H
23
24 #include <QChartGlobal>
25 #include <QLegendMarker>
26 #include <QAreaSeries>
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
30 class QAreaLegendMarkerPrivate;
31
32 // TODO: No export? make this private. QLegendMarker should be enough for user of the api (why expose the details?)
33 class QTCOMMERCIALCHART_EXPORT QAreaLegendMarker : public QLegendMarker
34 {
35 Q_OBJECT
36
37 public:
38 explicit QAreaLegendMarker(QAreaSeries* series, QLegend *legend, QObject *parent = 0);
39 virtual ~QAreaLegendMarker();
40
41 virtual QAreaSeries* series();
42 virtual QAreaSeries* peerObject(); // TODO: rename to slice and remove these virtuals from base class?
43
44 protected:
45 QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = 0);
46
47 //Q_SIGNALS:
48
49 //public Q_SLOTS:
50
51 private:
52 Q_DECLARE_PRIVATE(QAreaLegendMarker)
53 Q_DISABLE_COPY(QAreaLegendMarker)
54
55 };
56
57 QTCOMMERCIALCHART_END_NAMESPACE
58
59 #endif // QAREALEGENDMARKER_H
@@ -0,0 +1,65
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 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
27 //
28 // We mean it.
29
30 #ifndef QAREALEGENDMARKER_P_H
31 #define QAREALEGENDMARKER_P_H
32
33 #include "qchartglobal.h"
34 #include "qlegendmarker_p.h"
35 #include "legendmarkeritem_p.h"
36 #include <QAreaSeries>
37
38 #include <QDebug>
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
42 class QAreaLegendMarker;
43
44 class QAreaLegendMarkerPrivate : public QLegendMarkerPrivate
45 {
46 Q_OBJECT
47 public:
48 explicit QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend);
49 virtual ~QAreaLegendMarkerPrivate();
50
51 public Q_SLOTS:
52 virtual void updated();
53
54 private:
55 QAreaLegendMarker *q_ptr;
56
57 QAreaSeries* m_series;
58
59 friend class QLegendPrivate; // TODO: Is this needed?
60 Q_DECLARE_PUBLIC(QAreaLegendMarker)
61 };
62
63 QTCOMMERCIALCHART_END_NAMESPACE
64
65 #endif // QAREALEGENDMARKER_P_H
@@ -1,84 +1,85
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QAREASERIES_H
21 #ifndef QAREASERIES_H
22 #define QAREASERIES_H
22 #define QAREASERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qabstractseries.h>
25 #include <qabstractseries.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 class QLineSeries;
30 class QLineSeries;
31 class QAreaSeriesPrivate;
31 class QAreaSeriesPrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries
33 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(QLineSeries *upperSeries READ upperSeries)
36 Q_PROPERTY(QLineSeries *upperSeries READ upperSeries)
37 Q_PROPERTY(QLineSeries *lowerSeries READ lowerSeries)
37 Q_PROPERTY(QLineSeries *lowerSeries READ lowerSeries)
38 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
38 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
39 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
39 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
40
40
41 public:
41 public:
42 explicit QAreaSeries(QObject *parent = 0);
42 explicit QAreaSeries(QObject *parent = 0);
43 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
43 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
44 ~QAreaSeries();
44 ~QAreaSeries();
45
45
46 public:
46 public:
47 QAbstractSeries::SeriesType type() const;
47 QAbstractSeries::SeriesType type() const;
48
48
49 void setUpperSeries(QLineSeries *series);
49 void setUpperSeries(QLineSeries *series);
50 QLineSeries *upperSeries() const;
50 QLineSeries *upperSeries() const;
51 void setLowerSeries(QLineSeries *series);
51 void setLowerSeries(QLineSeries *series);
52 QLineSeries *lowerSeries() const;
52 QLineSeries *lowerSeries() const;
53
53
54 void setPen(const QPen &pen);
54 void setPen(const QPen &pen);
55 QPen pen() const;
55 QPen pen() const;
56
56
57 void setBrush(const QBrush &brush);
57 void setBrush(const QBrush &brush);
58 QBrush brush() const;
58 QBrush brush() const;
59
59
60 void setColor(const QColor &color);
60 void setColor(const QColor &color);
61 QColor color() const;
61 QColor color() const;
62
62
63 void setBorderColor(const QColor &color);
63 void setBorderColor(const QColor &color);
64 QColor borderColor() const;
64 QColor borderColor() const;
65
65
66 void setPointsVisible(bool visible = true);
66 void setPointsVisible(bool visible = true);
67 bool pointsVisible() const;
67 bool pointsVisible() const;
68
68
69 Q_SIGNALS:
69 Q_SIGNALS:
70 void clicked(const QPointF &point);
70 void clicked(const QPointF &point);
71 void selected();
71 void selected();
72 void colorChanged(QColor color);
72 void colorChanged(QColor color);
73 void borderColorChanged(QColor color);
73 void borderColorChanged(QColor color);
74
74
75 private:
75 private:
76 Q_DECLARE_PRIVATE(QAreaSeries)
76 Q_DECLARE_PRIVATE(QAreaSeries)
77 Q_DISABLE_COPY(QAreaSeries)
77 Q_DISABLE_COPY(QAreaSeries)
78 friend class AreaLegendMarker;
78 friend class AreaLegendMarker;
79 friend class AreaChartItem;
79 friend class AreaChartItem;
80 friend class QAreaLegendMarkerPrivate;
80 };
81 };
81
82
82 QTCOMMERCIALCHART_END_NAMESPACE
83 QTCOMMERCIALCHART_END_NAMESPACE
83
84
84 #endif // QAREASERIES_H
85 #endif // QAREASERIES_H
@@ -1,31 +1,34
1 INCLUDEPATH += $$PWD
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
2 DEPENDPATH += $$PWD
3
3
4 SOURCES += \
4 SOURCES += \
5 $$PWD/qlegend.cpp \
5 $$PWD/qlegend.cpp \
6 $$PWD/legendmarker.cpp \
6 $$PWD/legendmarker.cpp \
7 $$PWD/legendlayout.cpp \
7 $$PWD/legendlayout.cpp \
8 $$PWD/qlegendmarker.cpp \
8 $$PWD/qlegendmarker.cpp \
9 $$PWD/qpielegendmarker.cpp \
9 $$PWD/qpielegendmarker.cpp \
10 $$PWD/legendmarkeritem.cpp \
10 $$PWD/legendmarkeritem.cpp \
11 $$PWD/qbarlegendmarker.cpp \
11 $$PWD/qbarlegendmarker.cpp \
12 $$PWD/qxylegendmarker.cpp
12 $$PWD/qxylegendmarker.cpp \
13 $$PWD/qarealegendmarker.cpp
13
14
14 PRIVATE_HEADERS += \
15 PRIVATE_HEADERS += \
15 $$PWD/legendmarker_p.h \
16 $$PWD/legendmarker_p.h \
16 $$PWD/legendscroller_p.h \
17 $$PWD/legendscroller_p.h \
17 $$PWD/qlegend_p.h \
18 $$PWD/qlegend_p.h \
18 $$PWD/legendlayout_p.h \
19 $$PWD/legendlayout_p.h \
19 $$PWD/qlegendmarker_p.h \
20 $$PWD/qlegendmarker_p.h \
20 $$PWD/legendmarkeritem_p.h \
21 $$PWD/legendmarkeritem_p.h \
21 $$PWD/qpielegendmarker_p.h \
22 $$PWD/qpielegendmarker_p.h \
22 $$PWD/qbarlegendmarker_p.h \
23 $$PWD/qbarlegendmarker_p.h \
23 $$PWD/qxylegendmarker_p.h
24 $$PWD/qxylegendmarker_p.h \
25 $$PWD/qarealegendmarker_p.h
24
26
25
27
26 PUBLIC_HEADERS += \
28 PUBLIC_HEADERS += \
27 $$PWD/qlegend.h \
29 $$PWD/qlegend.h \
28 $$PWD/qlegendmarker.h \
30 $$PWD/qlegendmarker.h \
29 $$PWD/qpielegendmarker.h \
31 $$PWD/qpielegendmarker.h \
30 $$PWD/qbarlegendmarker.h \
32 $$PWD/qbarlegendmarker.h \
31 $$PWD/qxylegendmarker.h
33 $$PWD/qxylegendmarker.h \
34 $$PWD/qarealegendmarker.h
General Comments 0
You need to be logged in to leave comments. Login now