##// END OF EJS Templates
legend layouting change
sauimone -
r616:4f2467dfeb41
parent child
Show More
@@ -1,189 +1,189
1 #include "barpresenterbase_p.h"
1 #include "barpresenterbase_p.h"
2 #include "bar_p.h"
2 #include "bar_p.h"
3 #include "barvalue_p.h"
3 #include "barvalue_p.h"
4 #include "separator_p.h"
4 #include "separator_p.h"
5 #include "qbarset.h"
5 #include "qbarset.h"
6 #include "qbarseries.h"
6 #include "qbarseries.h"
7 #include "qchart.h"
7 #include "qchart.h"
8 #include "qchartaxis.h"
8 #include "qchartaxis.h"
9 #include "qchartaxiscategories.h"
9 #include "qchartaxiscategories.h"
10 #include "chartpresenter_p.h"
10 #include "chartpresenter_p.h"
11 #include <QDebug>
11 #include <QDebug>
12 #include <QToolTip>
12 #include <QToolTip>
13
13
14 QTCOMMERCIALCHART_BEGIN_NAMESPACE
14 QTCOMMERCIALCHART_BEGIN_NAMESPACE
15
15
16 BarPresenterBase::BarPresenterBase(QBarSeries *series, QChart *parent) :
16 BarPresenterBase::BarPresenterBase(QBarSeries *series, QChart *parent) :
17 ChartItem(parent),
17 ChartItem(parent),
18 mHeight(0),
18 mHeight(0),
19 mWidth(0),
19 mWidth(0),
20 mLayoutSet(false),
20 mLayoutSet(false),
21 mSeries(series),
21 mSeries(series),
22 mChart(parent)
22 mChart(parent)
23 {
23 {
24 connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString)));
24 connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString)));
25 // connect(series,SIGNAL(enableSeparators(bool)),this,SLOT(enableSeparators(bool)));
25 // connect(series,SIGNAL(enableSeparators(bool)),this,SLOT(enableSeparators(bool)));
26 // enableSeparators(series->separatorsVisible());
26 // enableSeparators(series->separatorsVisible());
27 setZValue(ChartPresenter::BarSeriesZValue);
27 setZValue(ChartPresenter::BarSeriesZValue);
28 initAxisLabels();
28 initAxisLabels();
29 dataChanged();
29 dataChanged();
30 }
30 }
31
31
32 BarPresenterBase::~BarPresenterBase()
32 BarPresenterBase::~BarPresenterBase()
33 {
33 {
34 disconnect(this,SLOT(showToolTip(QPoint,QString)));
34 disconnect(this,SLOT(showToolTip(QPoint,QString)));
35 disconnect(this,SLOT(enableSeparators(bool)));
35 // disconnect(this,SLOT(enableSeparators(bool)));
36 }
36 }
37
37
38 void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
38 void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
39 {
39 {
40 if (!mLayoutSet) {
40 if (!mLayoutSet) {
41 qDebug() << "BarPresenterBase::paint called without layout set. Aborting.";
41 qDebug() << "BarPresenterBase::paint called without layout set. Aborting.";
42 return;
42 return;
43 }
43 }
44 foreach(QGraphicsItem* i, childItems()) {
44 foreach(QGraphicsItem* i, childItems()) {
45 i->paint(painter,option,widget);
45 i->paint(painter,option,widget);
46 }
46 }
47 }
47 }
48
48
49 QRectF BarPresenterBase::boundingRect() const
49 QRectF BarPresenterBase::boundingRect() const
50 {
50 {
51 return QRectF(0, 0, mWidth, mHeight);
51 return QRectF(0, 0, mWidth, mHeight);
52 }
52 }
53
53
54 void BarPresenterBase::dataChanged()
54 void BarPresenterBase::dataChanged()
55 {
55 {
56 // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them?
56 // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them?
57 // Delete old bars
57 // Delete old bars
58 foreach (QGraphicsItem* item, childItems()) {
58 foreach (QGraphicsItem* item, childItems()) {
59 delete item;
59 delete item;
60 }
60 }
61
61
62 mBars.clear();
62 mBars.clear();
63 // mSeparators.clear();
63 // mSeparators.clear();
64 mFloatingValues.clear();
64 mFloatingValues.clear();
65
65
66 // Create new graphic items for bars
66 // Create new graphic items for bars
67 for (int c=0; c<mSeries->categoryCount(); c++) {
67 for (int c=0; c<mSeries->categoryCount(); c++) {
68 QString category = mSeries->categoryName(c);
68 QString category = mSeries->categoryName(c);
69 for (int s=0; s<mSeries->barsetCount(); s++) {
69 for (int s=0; s<mSeries->barsetCount(); s++) {
70 QBarSet *set = mSeries->barsetAt(s);
70 QBarSet *set = mSeries->barsetAt(s);
71 Bar *bar = new Bar(category,this);
71 Bar *bar = new Bar(category,this);
72 childItems().append(bar);
72 childItems().append(bar);
73 mBars.append(bar);
73 mBars.append(bar);
74 connect(bar,SIGNAL(clicked(QString)),set,SIGNAL(clicked(QString)));
74 connect(bar,SIGNAL(clicked(QString)),set,SIGNAL(clicked(QString)));
75 connect(bar,SIGNAL(rightClicked(QString)),set,SIGNAL(rightClicked(QString)));
75 connect(bar,SIGNAL(rightClicked(QString)),set,SIGNAL(rightClicked(QString)));
76 connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEnterEvent(QPoint)));
76 connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEnterEvent(QPoint)));
77 connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaveEvent()));
77 connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaveEvent()));
78 }
78 }
79 }
79 }
80 /*
80 /*
81 // Create separators
81 // Create separators
82 int count = mSeries->categoryCount() - 1; // There is one less separator than columns
82 int count = mSeries->categoryCount() - 1; // There is one less separator than columns
83 for (int i=0; i<count; i++) {
83 for (int i=0; i<count; i++) {
84 Separator* sep = new Separator(this);
84 Separator* sep = new Separator(this);
85 sep->setVisible(mSeries->separatorsVisible());
85 sep->setVisible(mSeries->separatorsVisible());
86 childItems().append(sep);
86 childItems().append(sep);
87 mSeparators.append(sep);
87 mSeparators.append(sep);
88 }
88 }
89 */
89 */
90 // Create floating values
90 // Create floating values
91 for (int category=0; category<mSeries->categoryCount(); category++) {
91 for (int category=0; category<mSeries->categoryCount(); category++) {
92 for (int s=0; s<mSeries->barsetCount(); s++) {
92 for (int s=0; s<mSeries->barsetCount(); s++) {
93 QBarSet *set = mSeries->barsetAt(s);
93 QBarSet *set = mSeries->barsetAt(s);
94 BarValue *value = new BarValue(*set, this);
94 BarValue *value = new BarValue(*set, this);
95 childItems().append(value);
95 childItems().append(value);
96 mFloatingValues.append(value);
96 mFloatingValues.append(value);
97 connect(set,SIGNAL(toggleFloatingValues()),value,SLOT(toggleVisible()));
97 connect(set,SIGNAL(toggleFloatingValues()),value,SLOT(toggleVisible()));
98 }
98 }
99 }
99 }
100 }
100 }
101
101
102 void BarPresenterBase::initAxisLabels()
102 void BarPresenterBase::initAxisLabels()
103 {
103 {
104 int count = mSeries->categoryCount();
104 int count = mSeries->categoryCount();
105 if (0 == count) {
105 if (0 == count) {
106 return;
106 return;
107 }
107 }
108
108
109 mChart->axisX()->setTicksCount(count+2);
109 mChart->axisX()->setTicksCount(count+2);
110
110
111 qreal min = 0;
111 qreal min = 0;
112 qreal max = count+1;
112 qreal max = count+1;
113
113
114 mChart->axisX()->setMin(min);
114 mChart->axisX()->setMin(min);
115 mChart->axisX()->setMax(max);
115 mChart->axisX()->setMax(max);
116
116
117 QChartAxisCategories* categories = mChart->axisX()->categories();
117 QChartAxisCategories* categories = mChart->axisX()->categories();
118 categories->clear();
118 categories->clear();
119 for (int i=0; i<count; i++) {
119 for (int i=0; i<count; i++) {
120 categories->insert(i+1,mSeries->categoryName(i));
120 categories->insert(i+1,mSeries->categoryName(i));
121 }
121 }
122
122
123
123
124
124
125 mChart->axisX()->setLabelsVisible(true);
125 mChart->axisX()->setLabelsVisible(true);
126 }
126 }
127
127
128 //handlers
128 //handlers
129
129
130 void BarPresenterBase::handleModelChanged(int index)
130 void BarPresenterBase::handleModelChanged(int index)
131 {
131 {
132 Q_UNUSED(index)
132 Q_UNUSED(index)
133 dataChanged();
133 dataChanged();
134 }
134 }
135
135
136 void BarPresenterBase::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
136 void BarPresenterBase::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
137 {
137 {
138 // TODO:
138 // TODO:
139 Q_UNUSED(minX)
139 Q_UNUSED(minX)
140 Q_UNUSED(maxX)
140 Q_UNUSED(maxX)
141 Q_UNUSED(minY)
141 Q_UNUSED(minY)
142 Q_UNUSED(maxY)
142 Q_UNUSED(maxY)
143
143
144 /*
144 /*
145 int count = mSeries->categoryCount();
145 int count = mSeries->categoryCount();
146 if (0 == count) {
146 if (0 == count) {
147 return;
147 return;
148 }
148 }
149
149
150 // Position labels to domain
150 // Position labels to domain
151 qreal min = domain.minX();
151 qreal min = domain.minX();
152 qreal max = domain.maxX();
152 qreal max = domain.maxX();
153 qreal step = (max-min)/count;
153 qreal step = (max-min)/count;
154 QChartAxisCategories& categories = mChart->axisX()->categories();
154 QChartAxisCategories& categories = mChart->axisX()->categories();
155 categories.clear();
155 categories.clear();
156 for (int i=0; i<count; i++) {
156 for (int i=0; i<count; i++) {
157 categories.insert(min,mSeries->categoryName(i));
157 categories.insert(min,mSeries->categoryName(i));
158 min += step;
158 min += step;
159 }
159 }
160 */
160 */
161 }
161 }
162
162
163 void BarPresenterBase::handleGeometryChanged(const QRectF& rect)
163 void BarPresenterBase::handleGeometryChanged(const QRectF& rect)
164 {
164 {
165 mWidth = rect.width();
165 mWidth = rect.width();
166 mHeight = rect.height();
166 mHeight = rect.height();
167 layoutChanged();
167 layoutChanged();
168 mLayoutSet = true;
168 mLayoutSet = true;
169 setPos(rect.topLeft());
169 setPos(rect.topLeft());
170 }
170 }
171
171
172 void BarPresenterBase::showToolTip(QPoint pos, QString tip)
172 void BarPresenterBase::showToolTip(QPoint pos, QString tip)
173 {
173 {
174 // TODO: cool tooltip instead of default
174 // TODO: cool tooltip instead of default
175 QToolTip::showText(pos,tip);
175 QToolTip::showText(pos,tip);
176 }
176 }
177
177
178 /*
178 /*
179 void BarPresenterBase::enableSeparators(bool enabled)
179 void BarPresenterBase::enableSeparators(bool enabled)
180 {
180 {
181 for (int i=0; i<mSeparators.count(); i++) {
181 for (int i=0; i<mSeparators.count(); i++) {
182 mSeparators.at(i)->setVisible(enabled);
182 mSeparators.at(i)->setVisible(enabled);
183 }
183 }
184 }
184 }
185 */
185 */
186
186
187 #include "moc_barpresenterbase_p.cpp"
187 #include "moc_barpresenterbase_p.cpp"
188
188
189 QTCOMMERCIALCHART_END_NAMESPACE
189 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,147 +1,151
1 #include "qchartglobal.h"
1 #include "qchartglobal.h"
2 #include "legendmarker_p.h"
2 #include "legendmarker_p.h"
3 #include <qpieslice.h>
3 #include <qpieslice.h>
4 #include <qbarset.h>
4 #include <qbarset.h>
5 #include <qxyseries.h>
5 #include <QPainter>
6 #include <QPainter>
6 #include <QGraphicsSceneEvent>
7 #include <QGraphicsSceneEvent>
7
8
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
10
10 LegendMarker::LegendMarker(QSeries* series, QGraphicsItem *parent)
11 LegendMarker::LegendMarker(QSeries* series, QGraphicsItem *parent)
11 : QGraphicsObject(parent)
12 : QGraphicsObject(parent)
12 ,mBoundingRect(0,0,1,1)
13 ,mBoundingRect(0,0,1,1)
13 ,mMarkerBoundingRect(0,0,1,1)
14 ,mMarkerBoundingRect(0,0,1,1)
14 ,mSeries(series)
15 ,mSeries(series)
15 ,mBarset(0)
16 ,mBarset(0)
16 ,mPieslice(0)
17 ,mPieslice(0)
17 ,mType(LegendMarkerTypeSeries)
18 ,mType(LegendMarkerTypeSeries)
18 ,mTextItem(new QGraphicsSimpleTextItem(this))
19 ,mTextItem(new QGraphicsSimpleTextItem(this))
19 {
20 {
20 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
21 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
21 }
22 }
22
23
23 LegendMarker::LegendMarker(QSeries *series, QBarSet *barset, QGraphicsItem *parent)
24 LegendMarker::LegendMarker(QSeries *series, QBarSet *barset, QGraphicsItem *parent)
24 : QGraphicsObject(parent)
25 : QGraphicsObject(parent)
25 ,mBoundingRect(0,0,1,1)
26 ,mBoundingRect(0,0,1,1)
26 ,mMarkerBoundingRect(0,0,1,1)
27 ,mMarkerBoundingRect(0,0,1,1)
27 ,mSeries(series)
28 ,mSeries(series)
28 ,mBarset(barset)
29 ,mBarset(barset)
29 ,mPieslice(0)
30 ,mPieslice(0)
30 ,mType(LegendMarkerTypeBarset)
31 ,mType(LegendMarkerTypeBarset)
31 ,mTextItem(new QGraphicsSimpleTextItem(this))
32 ,mTextItem(new QGraphicsSimpleTextItem(this))
32 {
33 {
33 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
34 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
34 }
35 }
35
36
36 LegendMarker::LegendMarker(QSeries *series, QPieSlice *pieslice, QGraphicsItem *parent)
37 LegendMarker::LegendMarker(QSeries *series, QPieSlice *pieslice, QGraphicsItem *parent)
37 : QGraphicsObject(parent)
38 : QGraphicsObject(parent)
38 ,mBoundingRect(0,0,1,1)
39 ,mBoundingRect(0,0,1,1)
39 ,mMarkerBoundingRect(0,0,1,1)
40 ,mMarkerBoundingRect(0,0,1,1)
40 ,mSeries(series)
41 ,mSeries(series)
41 ,mBarset(0)
42 ,mBarset(0)
42 ,mPieslice(pieslice)
43 ,mPieslice(pieslice)
43 ,mType(LegendMarkerTypePieslice)
44 ,mType(LegendMarkerTypePieslice)
44 ,mTextItem(new QGraphicsSimpleTextItem(this))
45 ,mTextItem(new QGraphicsSimpleTextItem(this))
45 {
46 {
46 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
47 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
47 }
48 }
48
49
49 void LegendMarker::setBoundingRect(const QRectF rect)
50 void LegendMarker::setBoundingRect(const QRectF rect)
50 {
51 {
51 mBoundingRect = rect;
52 mBoundingRect = rect;
52 // Calculate Marker pos
53 // Calculate Marker pos
53
54
54 // TODO: remove hard coding. 5 is marigin around marker
55 // TODO: remove hard coding. 5 is marigin around marker
55 QSizeF markerSize(10,10);
56 QSizeF markerSize(10,10);
56 qreal x = mBoundingRect.x() + 5;
57 qreal x = mBoundingRect.x() + 5;
57 qreal y = mBoundingRect.y() + (mBoundingRect.height() - markerSize.height())/2;
58 qreal y = mBoundingRect.y() + (mBoundingRect.height() - markerSize.height())/2;
58 mMarkerBoundingRect = QRectF(x,y,markerSize.width(),markerSize.height());
59 mMarkerBoundingRect = QRectF(x,y,markerSize.width(),markerSize.height());
59
60
60 mTextItem.setPos(mBoundingRect.x() + markerSize.width() + 10, y );
61 mTextItem.setPos(mBoundingRect.x() + markerSize.width() + 10, y );
62 qDebug() << "text item bound:" << mTextItem.boundingRect();
61 }
63 }
62
64
63 void LegendMarker::setBrush(const QBrush brush)
65 void LegendMarker::setBrush(const QBrush brush)
64 {
66 {
65 mBrush = brush;
67 mBrush = brush;
66 }
68 }
67
69
68 QBrush LegendMarker::brush() const
70 QBrush LegendMarker::brush() const
69 {
71 {
70 return mBrush;
72 return mBrush;
71 }
73 }
72
74
73 void LegendMarker::setName(const QString name)
75 void LegendMarker::setName(const QString name)
74 {
76 {
75 mTextItem.setText(name);
77 mTextItem.setText(name);
76 }
78 }
77
79
78 QString LegendMarker::name() const
80 QString LegendMarker::name() const
79 {
81 {
80 return mTextItem.text();
82 return mTextItem.text();
81 }
83 }
82
84
83 QSeries* LegendMarker::series() const
85 QSeries* LegendMarker::series() const
84 {
86 {
85 return mSeries;
87 return mSeries;
86 }
88 }
87
89
88 void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
90 void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
89 {
91 {
90 Q_UNUSED(option)
92 Q_UNUSED(option)
91 Q_UNUSED(widget)
93 Q_UNUSED(widget)
92
94
93 painter->setBrush(mBrush);
95 painter->setBrush(mBrush);
94 painter->drawRect(mMarkerBoundingRect);
96 painter->drawRect(mMarkerBoundingRect);
95 }
97 }
96
98
97 QRectF LegendMarker::boundingRect() const
99 QRectF LegendMarker::boundingRect() const
98 {
100 {
99 return mBoundingRect;
101 return mBoundingRect;
100 }
102 }
101
103
102 void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
104 void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
103 {
105 {
104 switch (mType)
106 switch (mType)
105 {
107 {
106 case LegendMarkerTypeSeries: {
108 case LegendMarkerTypeSeries: {
107 emit clicked(mSeries,event->button());
109 emit clicked(mSeries,event->button());
108 break;
110 break;
109 }
111 }
110 case LegendMarkerTypeBarset: {
112 case LegendMarkerTypeBarset: {
111 emit clicked(mBarset,event->button());
113 emit clicked(mBarset,event->button());
112 break;
114 break;
113 }
115 }
114 case LegendMarkerTypePieslice: {
116 case LegendMarkerTypePieslice: {
115 emit clicked(mPieslice,event->button());
117 emit clicked(mPieslice,event->button());
116 break;
118 break;
117 }
119 }
118 default: {
120 default: {
119 break;
121 break;
120 }
122 }
121 }
123 }
122 }
124 }
123
125
124 void LegendMarker::changed()
126 void LegendMarker::changed()
125 {
127 {
126 switch (mType)
128 switch (mType)
127 {
129 {
128 case LegendMarkerTypeSeries: {
130 case LegendMarkerTypeSeries: {
129 // TODO:
131 QXYSeries* s = static_cast<QXYSeries*> (mSeries);
132 setBrush(s->brush());
133 setName(s->name());
130 break;
134 break;
131 }
135 }
132 case LegendMarkerTypeBarset: {
136 case LegendMarkerTypeBarset: {
133 setBrush(mBarset->brush());
137 setBrush(mBarset->brush());
134 setName(mBarset->name());
138 setName(mBarset->name());
135 break;
139 break;
136 }
140 }
137 case LegendMarkerTypePieslice: {
141 case LegendMarkerTypePieslice: {
138 setBrush(mPieslice->sliceBrush());
142 setBrush(mPieslice->sliceBrush());
139 setName(mPieslice->label());
143 setName(mPieslice->label());
140 break;
144 break;
141 }
145 }
142 }
146 }
143 }
147 }
144
148
145 #include "moc_legendmarker_p.cpp"
149 #include "moc_legendmarker_p.cpp"
146
150
147 QTCOMMERCIALCHART_END_NAMESPACE
151 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,360 +1,363
1 #include "qchart.h"
1 #include "qchart.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 #include "qlegend.h"
3 #include "qlegend.h"
4 #include "chartpresenter_p.h"
4 #include "chartpresenter_p.h"
5 #include "chartdataset_p.h"
5 #include "chartdataset_p.h"
6 #include <QGraphicsScene>
6 #include <QGraphicsScene>
7 #include <QGraphicsSceneResizeEvent>
7 #include <QGraphicsSceneResizeEvent>
8 #include <QDebug>
8 #include <QDebug>
9
9
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
11
12 /*!
12 /*!
13 \enum QChart::ChartTheme
13 \enum QChart::ChartTheme
14
14
15 This enum describes the theme used by the chart.
15 This enum describes the theme used by the chart.
16
16
17 \value ChartThemeDefault Follows the GUI style of the Operating System
17 \value ChartThemeDefault Follows the GUI style of the Operating System
18 \value ChartThemeVanilla
18 \value ChartThemeVanilla
19 \value ChartThemeIcy
19 \value ChartThemeIcy
20 \value ChartThemeGrayscale
20 \value ChartThemeGrayscale
21 \value ChartThemeScientific
21 \value ChartThemeScientific
22 \value ChartThemeBlueCerulean
22 \value ChartThemeBlueCerulean
23 \value ChartThemeLight
23 \value ChartThemeLight
24 \value ChartThemeCount Not really a theme; the total count of themes.
24 \value ChartThemeCount Not really a theme; the total count of themes.
25 */
25 */
26
26
27 /*!
27 /*!
28 \enum QChart::AnimationOption
28 \enum QChart::AnimationOption
29
29
30 For enabling/disabling animations. Defaults to NoAnimation.
30 For enabling/disabling animations. Defaults to NoAnimation.
31
31
32 \value NoAnimation
32 \value NoAnimation
33 \value GridAxisAnimations
33 \value GridAxisAnimations
34 \value SeriesAnimations
34 \value SeriesAnimations
35 \value AllAnimations
35 \value AllAnimations
36 */
36 */
37
37
38 /*!
38 /*!
39 \class QChart
39 \class QChart
40 \brief QtCommercial chart API.
40 \brief QtCommercial chart API.
41
41
42 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
42 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
43 representation of different types of QChartSeries and other chart related objects like
43 representation of different types of QChartSeries and other chart related objects like
44 QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
44 QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
45 convenience class QChartView instead of QChart.
45 convenience class QChartView instead of QChart.
46 \sa QChartView
46 \sa QChartView
47 */
47 */
48
48
49 /*!
49 /*!
50 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
50 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
51 */
51 */
52 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
52 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
53 m_backgroundItem(0),
53 m_backgroundItem(0),
54 m_titleItem(0),
54 m_titleItem(0),
55 m_legend(new QLegend(this)),
55 m_legend(new QLegend(this)),
56 m_dataset(new ChartDataSet(this)),
56 m_dataset(new ChartDataSet(this)),
57 m_presenter(new ChartPresenter(this,m_dataset))
57 m_presenter(new ChartPresenter(this,m_dataset))
58 {
58 {
59 connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
59 connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
60 connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
60 connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
61 }
61 }
62
62
63 /*!
63 /*!
64 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
64 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
65 */
65 */
66 QChart::~QChart()
66 QChart::~QChart()
67 {
67 {
68 disconnect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
68 disconnect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
69 disconnect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
69 disconnect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
70 }
70 }
71
71
72 /*!
72 /*!
73 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
73 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
74 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
74 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
75 the y axis).
75 the y axis).
76 */
76 */
77 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
77 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
78 {
78 {
79 m_dataset->addSeries(series, axisY);
79 m_dataset->addSeries(series, axisY);
80 }
80 }
81
81
82 /*!
82 /*!
83 Removes the \a series specified in a perameter from the QChartView.
83 Removes the \a series specified in a perameter from the QChartView.
84 It releses its ownership of the specified QChartSeries object.
84 It releses its ownership of the specified QChartSeries object.
85 It does not delete the pointed QChartSeries data object
85 It does not delete the pointed QChartSeries data object
86 \sa addSeries(), removeAllSeries()
86 \sa addSeries(), removeAllSeries()
87 */
87 */
88 void QChart::removeSeries(QSeries* series)
88 void QChart::removeSeries(QSeries* series)
89 {
89 {
90 m_dataset->removeSeries(series);
90 m_dataset->removeSeries(series);
91 }
91 }
92
92
93 /*!
93 /*!
94 Removes all the QChartSeries that have been added to the QChartView
94 Removes all the QChartSeries that have been added to the QChartView
95 It also deletes the pointed QChartSeries data objects
95 It also deletes the pointed QChartSeries data objects
96 \sa addSeries(), removeSeries()
96 \sa addSeries(), removeSeries()
97 */
97 */
98 void QChart::removeAllSeries()
98 void QChart::removeAllSeries()
99 {
99 {
100 m_dataset->removeAllSeries();
100 m_dataset->removeAllSeries();
101 }
101 }
102
102
103 /*!
103 /*!
104 Sets the \a brush that is used for painting the background of the chart area.
104 Sets the \a brush that is used for painting the background of the chart area.
105 */
105 */
106 void QChart::setChartBackgroundBrush(const QBrush& brush)
106 void QChart::setChartBackgroundBrush(const QBrush& brush)
107 {
107 {
108 createChartBackgroundItem();
108 createChartBackgroundItem();
109 m_backgroundItem->setBrush(brush);
109 m_backgroundItem->setBrush(brush);
110 m_backgroundItem->update();
110 m_backgroundItem->update();
111 }
111 }
112
112
113 /*!
113 /*!
114 Sets the \a pen that is used for painting the background of the chart area.
114 Sets the \a pen that is used for painting the background of the chart area.
115 */
115 */
116 void QChart::setChartBackgroundPen(const QPen& pen)
116 void QChart::setChartBackgroundPen(const QPen& pen)
117 {
117 {
118 createChartBackgroundItem();
118 createChartBackgroundItem();
119 m_backgroundItem->setPen(pen);
119 m_backgroundItem->setPen(pen);
120 m_backgroundItem->update();
120 m_backgroundItem->update();
121 }
121 }
122
122
123 /*!
123 /*!
124 Sets the chart \a title. The description text that is drawn above the chart.
124 Sets the chart \a title. The description text that is drawn above the chart.
125 */
125 */
126 void QChart::setChartTitle(const QString& title)
126 void QChart::setChartTitle(const QString& title)
127 {
127 {
128 createChartTitleItem();
128 createChartTitleItem();
129 m_titleItem->setText(title);
129 m_titleItem->setText(title);
130 updateLayout();
130 updateLayout();
131 }
131 }
132
132
133 /*!
133 /*!
134 Returns the chart title. The description text that is drawn above the chart.
134 Returns the chart title. The description text that is drawn above the chart.
135 */
135 */
136 QString QChart::chartTitle() const
136 QString QChart::chartTitle() const
137 {
137 {
138 if(m_titleItem)
138 if(m_titleItem)
139 return m_titleItem->text();
139 return m_titleItem->text();
140 else
140 else
141 return QString();
141 return QString();
142 }
142 }
143
143
144 /*!
144 /*!
145 Sets the \a font that is used for rendering the description text that is rendered above the chart.
145 Sets the \a font that is used for rendering the description text that is rendered above the chart.
146 */
146 */
147 void QChart::setChartTitleFont(const QFont& font)
147 void QChart::setChartTitleFont(const QFont& font)
148 {
148 {
149 createChartTitleItem();
149 createChartTitleItem();
150 m_titleItem->setFont(font);
150 m_titleItem->setFont(font);
151 updateLayout();
151 updateLayout();
152 }
152 }
153
153
154 /*!
154 /*!
155 Sets the \a brush used for rendering the title text.
155 Sets the \a brush used for rendering the title text.
156 */
156 */
157 void QChart::setChartTitleBrush(const QBrush &brush)
157 void QChart::setChartTitleBrush(const QBrush &brush)
158 {
158 {
159 createChartTitleItem();
159 createChartTitleItem();
160 m_titleItem->setBrush(brush);
160 m_titleItem->setBrush(brush);
161 updateLayout();
161 updateLayout();
162 }
162 }
163
163
164 /*!
164 /*!
165 Returns the brush used for rendering the title text.
165 Returns the brush used for rendering the title text.
166 */
166 */
167 QBrush QChart::chartTitleBrush()
167 QBrush QChart::chartTitleBrush()
168 {
168 {
169 createChartTitleItem();
169 createChartTitleItem();
170 return m_titleItem->brush();
170 return m_titleItem->brush();
171 }
171 }
172
172
173 void QChart::createChartBackgroundItem()
173 void QChart::createChartBackgroundItem()
174 {
174 {
175 if(!m_backgroundItem) {
175 if(!m_backgroundItem) {
176 m_backgroundItem = new QGraphicsRectItem(this);
176 m_backgroundItem = new QGraphicsRectItem(this);
177 m_backgroundItem->setPen(Qt::NoPen);
177 m_backgroundItem->setPen(Qt::NoPen);
178 m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
178 m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
179 }
179 }
180 }
180 }
181
181
182 void QChart::createChartTitleItem()
182 void QChart::createChartTitleItem()
183 {
183 {
184 if(!m_titleItem) {
184 if(!m_titleItem) {
185 m_titleItem = new QGraphicsSimpleTextItem(this);
185 m_titleItem = new QGraphicsSimpleTextItem(this);
186 m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
186 m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
187 }
187 }
188 }
188 }
189
189
190 /*!
190 /*!
191 Returns the chart margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
191 Returns the chart margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
192 \sa setMargin()
192 \sa setMargin()
193 */
193 */
194 int QChart::margin() const
194 int QChart::margin() const
195 {
195 {
196 return m_presenter->margin();
196 return m_presenter->margin();
197 }
197 }
198
198
199 /*!
199 /*!
200 Sets the chart \a margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
200 Sets the chart \a margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
201 \sa margin()
201 \sa margin()
202 */
202 */
203 void QChart::setMargin(int margin)
203 void QChart::setMargin(int margin)
204 {
204 {
205 m_presenter->setMargin(margin);
205 m_presenter->setMargin(margin);
206 updateLayout();
206 updateLayout();
207 }
207 }
208
208
209 /*!
209 /*!
210 Sets the \a theme used by the chart for rendering the graphical representation of the data
210 Sets the \a theme used by the chart for rendering the graphical representation of the data
211 \sa ChartTheme, chartTheme()
211 \sa ChartTheme, chartTheme()
212 */
212 */
213 void QChart::setChartTheme(QChart::ChartTheme theme)
213 void QChart::setChartTheme(QChart::ChartTheme theme)
214 {
214 {
215 m_presenter->setChartTheme(theme);
215 m_presenter->setChartTheme(theme);
216 }
216 }
217
217
218 /*!
218 /*!
219 Returns the theme enum used by the chart.
219 Returns the theme enum used by the chart.
220 \sa ChartTheme, setChartTheme()
220 \sa ChartTheme, setChartTheme()
221 */
221 */
222 QChart::ChartTheme QChart::chartTheme() const
222 QChart::ChartTheme QChart::chartTheme() const
223 {
223 {
224 return m_presenter->chartTheme();
224 return m_presenter->chartTheme();
225 }
225 }
226
226
227 /*!
227 /*!
228 Zooms in the view by a factor of 2
228 Zooms in the view by a factor of 2
229 */
229 */
230 void QChart::zoomIn()
230 void QChart::zoomIn()
231 {
231 {
232 m_presenter->zoomIn();
232 m_presenter->zoomIn();
233 }
233 }
234
234
235 /*!
235 /*!
236 Zooms in the view to a maximum level at which \a rect is still fully visible.
236 Zooms in the view to a maximum level at which \a rect is still fully visible.
237 */
237 */
238 void QChart::zoomIn(const QRectF& rect)
238 void QChart::zoomIn(const QRectF& rect)
239 {
239 {
240
240
241 if(!rect.isValid()) return;
241 if(!rect.isValid()) return;
242 m_presenter->zoomIn(rect);
242 m_presenter->zoomIn(rect);
243 }
243 }
244
244
245 /*!
245 /*!
246 Restores the view zoom level to the previous one.
246 Restores the view zoom level to the previous one.
247 */
247 */
248 void QChart::zoomOut()
248 void QChart::zoomOut()
249 {
249 {
250 m_presenter->zoomOut();
250 m_presenter->zoomOut();
251 }
251 }
252
252
253 /*!
253 /*!
254 Resets to the default view.
254 Resets to the default view.
255 */
255 */
256 void QChart::zoomReset()
256 void QChart::zoomReset()
257 {
257 {
258 m_presenter->zoomReset();
258 m_presenter->zoomReset();
259 }
259 }
260
260
261 /*!
261 /*!
262 Returns the pointer to the x axis object of the chart
262 Returns the pointer to the x axis object of the chart
263 */
263 */
264 QChartAxis* QChart::axisX() const
264 QChartAxis* QChart::axisX() const
265 {
265 {
266 return m_dataset->axisX();
266 return m_dataset->axisX();
267 }
267 }
268
268
269 /*!
269 /*!
270 Returns the pointer to the y axis object of the chart
270 Returns the pointer to the y axis object of the chart
271 */
271 */
272 QChartAxis* QChart::axisY() const
272 QChartAxis* QChart::axisY() const
273 {
273 {
274 return m_dataset->axisY();
274 return m_dataset->axisY();
275 }
275 }
276
276
277 /*!
277 /*!
278 Returns the legend object of the chart
278 Returns the legend object of the chart
279 */
279 */
280 QLegend* QChart::legend()
280 QLegend* QChart::legend()
281 {
281 {
282 return m_legend;
282 return m_legend;
283 }
283 }
284
284
285 /*!
285 /*!
286 Resizes and updates the chart area using the \a event data
286 Resizes and updates the chart area using the \a event data
287 */
287 */
288 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
288 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
289 {
289 {
290
290
291 m_rect = QRectF(QPoint(0,0),event->newSize());
291 m_rect = QRectF(QPoint(0,0),event->newSize());
292 updateLayout();
292 updateLayout();
293 QGraphicsWidget::resizeEvent(event);
293 QGraphicsWidget::resizeEvent(event);
294 update();
294 update();
295 }
295 }
296
296
297 /*!
297 /*!
298 Sets animation \a options for the chart
298 Sets animation \a options for the chart
299 */
299 */
300 void QChart::setAnimationOptions(AnimationOptions options)
300 void QChart::setAnimationOptions(AnimationOptions options)
301 {
301 {
302 m_presenter->setAnimationOptions(options);
302 m_presenter->setAnimationOptions(options);
303 }
303 }
304
304
305 /*!
305 /*!
306 Returns animation options for the chart
306 Returns animation options for the chart
307 */
307 */
308 QChart::AnimationOptions QChart::animationOptions() const
308 QChart::AnimationOptions QChart::animationOptions() const
309 {
309 {
310 return m_presenter->animationOptions();
310 return m_presenter->animationOptions();
311 }
311 }
312
312
313 void QChart::scrollLeft()
313 void QChart::scrollLeft()
314 {
314 {
315 m_presenter->scroll(-m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
315 m_presenter->scroll(-m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
316 }
316 }
317
317
318 void QChart::scrollRight()
318 void QChart::scrollRight()
319 {
319 {
320 m_presenter->scroll(m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
320 m_presenter->scroll(m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
321 }
321 }
322 void QChart::scrollUp()
322 void QChart::scrollUp()
323 {
323 {
324 m_presenter->scroll(0,m_presenter->geometry().width()/(axisY()->ticksCount()-1));
324 m_presenter->scroll(0,m_presenter->geometry().width()/(axisY()->ticksCount()-1));
325 }
325 }
326 void QChart::scrollDown()
326 void QChart::scrollDown()
327 {
327 {
328 m_presenter->scroll(0,-m_presenter->geometry().width()/(axisY()->ticksCount()-1));
328 m_presenter->scroll(0,-m_presenter->geometry().width()/(axisY()->ticksCount()-1));
329 }
329 }
330
330
331 void QChart::updateLayout()
331 void QChart::updateLayout()
332 {
332 {
333 if(!m_rect.isValid()) return;
333 if(!m_rect.isValid()) return;
334
334
335 QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
335 QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
336
336
337 // recalculate title position
337 // recalculate title position
338 if (m_titleItem) {
338 if (m_titleItem) {
339 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
339 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
340 m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
340 m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
341 }
341 }
342
342
343 //recalculate background gradient
343 //recalculate background gradient
344 if (m_backgroundItem) {
344 if (m_backgroundItem) {
345 m_backgroundItem->setRect(rect);
345 m_backgroundItem->setRect(rect);
346 }
346 }
347
347
348 // recalculate legend position
348 // recalculate legend position
349 // TODO: better layout
349 // TODO: better layout
350 if (m_legend) {
350 if (m_legend) {
351 QRectF boundingRect(m_rect.adjusted(margin(),
351 QRectF boundingRect(m_rect.adjusted(margin(),
352 rect.height() + margin() + margin()/2,
352 rect.height() + margin() + margin()/2,
353 -margin(),
353 -margin(),
354 -margin()/2 + m_legend->minimumSize().height()));
354 -margin()/2 + m_legend->minimumSize().height()));
355 m_legend->handleGeometryChanged(boundingRect);
355 // m_legend->handleGeometryChanged(boundingRect);
356 QRectF br(0,0,margin(),m_rect.height());
357 m_legend->handleGeometryChanged(br);
358 m_legend->setPreferredLayout(QLegend::PreferredLayoutVertical);
356 }
359 }
357 }
360 }
358 #include "moc_qchart.cpp"
361 #include "moc_qchart.cpp"
359
362
360 QTCOMMERCIALCHART_END_NAMESPACE
363 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,108 +1,109
1 #ifndef QCHART_H
1 #ifndef QCHART_H
2 #define QCHART_H
2 #define QCHART_H
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <qseries.h>
5 #include <qseries.h>
6 #include <QGraphicsWidget>
6 #include <QGraphicsWidget>
7 #include <QLinearGradient>
7 #include <QLinearGradient>
8 #include <QFont>
8 #include <QFont>
9
9
10 class QGraphicsSceneResizeEvent;
10 class QGraphicsSceneResizeEvent;
11
11
12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
13
13
14 class AxisItem;
14 class AxisItem;
15 class QSeries;
15 class QSeries;
16 class PlotDomain;
16 class PlotDomain;
17 class BarPresenter;
17 class BarPresenter;
18 class QChartAxis;
18 class QChartAxis;
19 class ChartTheme;
19 class ChartTheme;
20 class ChartItem;
20 class ChartItem;
21 class ChartDataSet;
21 class ChartDataSet;
22 class ChartPresenter;
22 class ChartPresenter;
23 class QLegend;
23 class QLegend;
24
24
25 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
25 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
26 {
26 {
27 Q_OBJECT
27 Q_OBJECT
28 public:
28 public:
29 enum ChartTheme {
29 enum ChartTheme {
30 ChartThemeDefault,
30 ChartThemeDefault,
31 ChartThemeVanilla,
31 ChartThemeVanilla,
32 ChartThemeIcy,
32 ChartThemeIcy,
33 ChartThemeGrayscale,
33 ChartThemeGrayscale,
34 ChartThemeScientific,
34 ChartThemeScientific,
35 ChartThemeBlueCerulean,
35 ChartThemeBlueCerulean,
36 ChartThemeLight,
36 ChartThemeLight,
37 ChartThemeCount
37 ChartThemeCount
38 };
38 };
39
39
40 enum AnimationOption {
40 enum AnimationOption {
41 NoAnimation = 0x0,
41 NoAnimation = 0x0,
42 GridAxisAnimations = 0x1,
42 GridAxisAnimations = 0x1,
43 SeriesAnimations =0x2,
43 SeriesAnimations =0x2,
44 AllAnimations = 0x3
44 AllAnimations = 0x3
45 };
45 };
46 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
46 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
47
47
48 public:
48 public:
49 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
49 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
50 ~QChart();
50 ~QChart();
51
51
52 void addSeries(QSeries* series, QChartAxis* axisY = 0);
52 void addSeries(QSeries* series, QChartAxis* axisY = 0);
53 void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached
53 void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached
54 void removeAllSeries(); // deletes series and axis
54 void removeAllSeries(); // deletes series and axis
55
55
56 void setMargin(int margin);
56 void setMargin(int margin);
57 int margin() const;
57 int margin() const;
58 void setChartTheme(QChart::ChartTheme theme);
58 void setChartTheme(QChart::ChartTheme theme);
59 QChart::ChartTheme chartTheme() const;
59 QChart::ChartTheme chartTheme() const;
60
60
61 void setChartTitle(const QString& title);
61 void setChartTitle(const QString& title);
62 QString chartTitle() const;
62 QString chartTitle() const;
63 void setChartTitleFont(const QFont& font);
63 void setChartTitleFont(const QFont& font);
64 void setChartTitleBrush(const QBrush &brush);
64 void setChartTitleBrush(const QBrush &brush);
65 QBrush chartTitleBrush();
65 QBrush chartTitleBrush();
66 void setChartBackgroundBrush(const QBrush& brush);
66 void setChartBackgroundBrush(const QBrush& brush);
67 void setChartBackgroundPen(const QPen& pen);
67 void setChartBackgroundPen(const QPen& pen);
68
68
69 void setAnimationOptions(AnimationOptions options);
69 void setAnimationOptions(AnimationOptions options);
70 AnimationOptions animationOptions() const;
70 AnimationOptions animationOptions() const;
71
71
72 void zoomIn();
72 void zoomIn();
73 void zoomIn(const QRectF& rect);
73 void zoomIn(const QRectF& rect);
74 void zoomOut();
74 void zoomOut();
75 void zoomReset();
75 void zoomReset();
76 void scrollLeft();
76 void scrollLeft();
77 void scrollRight();
77 void scrollRight();
78 void scrollUp();
78 void scrollUp();
79 void scrollDown();
79 void scrollDown();
80
80
81 QChartAxis* axisX() const;
81 QChartAxis* axisX() const;
82 QChartAxis* axisY() const;
82 QChartAxis* axisY() const;
83
83
84 // TODO: take (and give) legend instead of this.
84 QLegend* legend();
85 QLegend* legend();
85
86
86 protected:
87 protected:
87 void resizeEvent(QGraphicsSceneResizeEvent *event);
88 void resizeEvent(QGraphicsSceneResizeEvent *event);
88
89
89 private:
90 private:
90 inline void createChartBackgroundItem();
91 inline void createChartBackgroundItem();
91 inline void createChartTitleItem();
92 inline void createChartTitleItem();
92 void updateLayout();
93 void updateLayout();
93
94
94 private:
95 private:
95 Q_DISABLE_COPY(QChart)
96 Q_DISABLE_COPY(QChart)
96 QGraphicsRectItem* m_backgroundItem;
97 QGraphicsRectItem* m_backgroundItem;
97 QGraphicsSimpleTextItem* m_titleItem;
98 QGraphicsSimpleTextItem* m_titleItem;
98 QRectF m_rect;
99 QRectF m_rect;
99 QLegend* m_legend;
100 QLegend* m_legend;
100 ChartDataSet *m_dataset;
101 ChartDataSet *m_dataset;
101 ChartPresenter *m_presenter;
102 ChartPresenter *m_presenter;
102 };
103 };
103
104
104 QTCOMMERCIALCHART_END_NAMESPACE
105 QTCOMMERCIALCHART_END_NAMESPACE
105
106
106 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
107 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
107
108
108 #endif
109 #endif
@@ -1,222 +1,261
1 #include "qchartglobal.h"
1 #include "qchartglobal.h"
2 #include "qlegend.h"
2 #include "qlegend.h"
3 #include "qseries.h"
3 #include "qseries.h"
4 #include "legendmarker_p.h"
4 #include "legendmarker_p.h"
5 #include "qxyseries.h"
5 #include "qxyseries.h"
6 #include "qlineseries.h"
6 #include "qlineseries.h"
7 #include "qareaseries.h"
7 #include "qareaseries.h"
8 #include "qscatterseries.h"
8 #include "qscatterseries.h"
9 #include "qsplineseries.h"
9 #include "qsplineseries.h"
10 #include "qbarseries.h"
10 #include "qbarseries.h"
11 #include "qstackedbarseries.h"
11 #include "qstackedbarseries.h"
12 #include "qpercentbarseries.h"
12 #include "qpercentbarseries.h"
13 #include "qbarset.h"
13 #include "qbarset.h"
14 #include "qpieseries.h"
14 #include "qpieseries.h"
15 #include "qpieslice.h"
15 #include "qpieslice.h"
16 #include <QPainter>
16 #include <QPainter>
17 #include <QPen>
17 #include <QPen>
18
18
19 #include <QGraphicsSceneEvent>
19 #include <QGraphicsSceneEvent>
20
20
21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
22
22
23 QLegend::QLegend(QGraphicsItem *parent)
23 QLegend::QLegend(QGraphicsItem *parent)
24 : QGraphicsObject(parent)
24 : QGraphicsObject(parent)
25 ,mBoundingRect(0,0,1,1)
25 ,mBoundingRect(0,0,1,1)
26 ,mBackgroundBrush(Qt::darkGray) // TODO: from theme?
26 ,mBackgroundBrush(Qt::darkGray) // TODO: from theme?
27 ,mMinimumSize(50,20) // TODO: magic numbers
27 ,mMinimumSize(50,20) // TODO: magic numbers
28 ,mMaximumSize(150,100)
29 ,mPreferredLayout(QLegend::PreferredLayoutVertical)
28 {
30 {
29 setVisible(false);
31 setVisible(false);
30 }
32 }
31
33
32 void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
34 void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
33 {
35 {
34 Q_UNUSED(option)
36 Q_UNUSED(option)
35 Q_UNUSED(widget)
37 Q_UNUSED(widget)
36
38
37 painter->setBrush(mBackgroundBrush);
39 painter->setBrush(mBackgroundBrush);
38 painter->drawRect(mBoundingRect);
40 painter->drawRect(mBoundingRect);
39 }
41 }
40
42
41 QRectF QLegend::boundingRect() const
43 QRectF QLegend::boundingRect() const
42 {
44 {
43 return mBoundingRect;
45 return mBoundingRect;
44 }
46 }
45
47
46 void QLegend::setBackgroundBrush(const QBrush& brush)
48 void QLegend::setBackgroundBrush(const QBrush& brush)
47 {
49 {
48 mBackgroundBrush = brush;
50 mBackgroundBrush = brush;
49 }
51 }
50
52
51 QBrush QLegend::backgroundBrush() const
53 QBrush QLegend::backgroundBrush() const
52 {
54 {
53 return mBackgroundBrush;
55 return mBackgroundBrush;
54 }
56 }
55
57
58 void QLegend::setPreferredLayout(QLegend::PreferredLayout preferred)
59 {
60 mPreferredLayout = preferred;
61 layoutChanged();
62 }
63
56 QSizeF QLegend::minimumSize() const
64 QSizeF QLegend::minimumSize() const
57 {
65 {
58 return mMinimumSize;
66 return mMinimumSize;
59 }
67 }
60
68
61 void QLegend::setMinimumSize(const QSizeF size)
69 void QLegend::setMinimumSize(const QSizeF size)
62 {
70 {
63 mMinimumSize = size;
71 mMinimumSize = size;
64 }
72 }
65
73
66 void QLegend::handleSeriesAdded(QSeries* series, Domain* domain)
74 void QLegend::handleSeriesAdded(QSeries* series, Domain* domain)
67 {
75 {
68 Q_UNUSED(domain)
76 Q_UNUSED(domain)
69
77
70 mSeriesList.append(series);
78 mSeriesList.append(series);
71 createMarkers(series);
79 createMarkers(series);
72 layoutChanged();
80 layoutChanged();
73 }
81 }
74
82
75 void QLegend::handleSeriesRemoved(QSeries* series)
83 void QLegend::handleSeriesRemoved(QSeries* series)
76 {
84 {
77 if (series->type() == QSeries::SeriesTypeArea)
85 if (series->type() == QSeries::SeriesTypeArea)
78 {
86 {
79 // This is special case. Area series has upper and lower series, which each have markers
87 // This is special case. Area series has upper and lower series, which each have markers
80 QAreaSeries* s = static_cast<QAreaSeries*> (series);
88 QAreaSeries* s = static_cast<QAreaSeries*> (series);
81 deleteMarkers(s->upperSeries());
89 deleteMarkers(s->upperSeries());
82 deleteMarkers(s->lowerSeries());
90 deleteMarkers(s->lowerSeries());
83 } else {
91 } else {
84 deleteMarkers(series);
92 deleteMarkers(series);
85 }
93 }
86
94
87 mSeriesList.removeOne(series);
95 mSeriesList.removeOne(series);
88 layoutChanged();
96 layoutChanged();
89 }
97 }
90
98
91 void QLegend::handleGeometryChanged(const QRectF& size)
99 void QLegend::handleGeometryChanged(const QRectF& size)
92 {
100 {
93 mBoundingRect = size;
101 mBoundingRect = size;
94 layoutChanged();
102 layoutChanged();
95 }
103 }
96
104
97 void QLegend::createMarkers(QSeries *series)
105 void QLegend::createMarkers(QSeries *series)
98 {
106 {
99 switch (series->type())
107 switch (series->type())
100 {
108 {
101 case QSeries::SeriesTypeLine: {
109 case QSeries::SeriesTypeLine: {
102 QLineSeries* lineSeries = static_cast<QLineSeries*>(series);
110 QLineSeries* lineSeries = static_cast<QLineSeries*>(series);
103 appendMarkers(lineSeries);
111 appendMarkers(lineSeries);
104 break;
112 break;
105 }
113 }
106 case QSeries::SeriesTypeArea: {
114 case QSeries::SeriesTypeArea: {
107 QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series);
115 QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series);
108 appendMarkers(areaSeries->upperSeries());
116 appendMarkers(areaSeries->upperSeries());
109 if(areaSeries->lowerSeries())
117 if(areaSeries->lowerSeries())
110 appendMarkers(areaSeries->lowerSeries());
118 appendMarkers(areaSeries->lowerSeries());
111 break;
119 break;
112 }
120 }
113
121
114 case QSeries::SeriesTypeBar: {
122 case QSeries::SeriesTypeBar: {
115 QBarSeries* barSeries = static_cast<QBarSeries*>(series);
123 QBarSeries* barSeries = static_cast<QBarSeries*>(series);
116 appendMarkers(barSeries);
124 appendMarkers(barSeries);
117 break;
125 break;
118 }
126 }
119
127
120 case QSeries::SeriesTypeStackedBar: {
128 case QSeries::SeriesTypeStackedBar: {
121 QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series);
129 QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series);
122 appendMarkers(stackedBarSeries);
130 appendMarkers(stackedBarSeries);
123 break;
131 break;
124 }
132 }
125
133
126 case QSeries::SeriesTypePercentBar: {
134 case QSeries::SeriesTypePercentBar: {
127 QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series);
135 QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series);
128 appendMarkers(percentBarSeries);
136 appendMarkers(percentBarSeries);
129 break;
137 break;
130 }
138 }
131
139
132 case QSeries::SeriesTypeScatter: {
140 case QSeries::SeriesTypeScatter: {
133 QScatterSeries *scatterSeries = static_cast<QScatterSeries *>(series);
141 QScatterSeries *scatterSeries = static_cast<QScatterSeries *>(series);
134 appendMarkers(scatterSeries);
142 appendMarkers(scatterSeries);
135 break;
143 break;
136 }
144 }
137
145
138 case QSeries::SeriesTypePie: {
146 case QSeries::SeriesTypePie: {
139 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
147 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
140 appendMarkers(pieSeries);
148 appendMarkers(pieSeries);
141 break;
149 break;
142 }
150 }
143
151
144 case QSeries::SeriesTypeSpline: {
152 case QSeries::SeriesTypeSpline: {
145 QSplineSeries* splineSeries = static_cast<QSplineSeries*>(series);
153 QSplineSeries* splineSeries = static_cast<QSplineSeries*>(series);
146 appendMarkers(splineSeries);
154 appendMarkers(splineSeries);
147 break;
155 break;
148 }
156 }
149 default: {
157 default: {
150 qDebug()<< "QLegend::createMarkers" << series->type() << "not implemented.";
158 qDebug()<< "QLegend::createMarkers" << series->type() << "not implemented.";
151 break;
159 break;
152 }
160 }
153 }
161 }
154 }
162 }
155
163
156 void QLegend::appendMarkers(QXYSeries* series)
164 void QLegend::appendMarkers(QXYSeries* series)
157 {
165 {
158 LegendMarker* marker = new LegendMarker(series,this);
166 LegendMarker* marker = new LegendMarker(series,this);
159 marker->setName(series->name());
167 marker->setName(series->name());
160 marker->setBrush(series->brush());
168 marker->setBrush(series->brush());
161 connect(marker,SIGNAL(clicked(QSeries*,Qt::MouseButton)),this,SIGNAL(clicked(QSeries*,Qt::MouseButton)));
169 connect(marker,SIGNAL(clicked(QSeries*,Qt::MouseButton)),this,SIGNAL(clicked(QSeries*,Qt::MouseButton)));
162 mMarkers.append(marker);
170 mMarkers.append(marker);
163 childItems().append(marker);
171 childItems().append(marker);
164 }
172 }
165
173
166 void QLegend::appendMarkers(QBarSeries *series)
174 void QLegend::appendMarkers(QBarSeries *series)
167 {
175 {
168 foreach(QBarSet* s, series->barSets()) {
176 foreach(QBarSet* s, series->barSets()) {
169 LegendMarker* marker = new LegendMarker(series,s,this);
177 LegendMarker* marker = new LegendMarker(series,s,this);
170 marker->setName(s->name());
178 marker->setName(s->name());
171 marker->setBrush(s->brush());
179 marker->setBrush(s->brush());
172 connect(marker,SIGNAL(clicked(QBarSet*,Qt::MouseButton)),this,SIGNAL(clicked(QBarSet*,Qt::MouseButton)));
180 connect(marker,SIGNAL(clicked(QBarSet*,Qt::MouseButton)),this,SIGNAL(clicked(QBarSet*,Qt::MouseButton)));
173 connect(s,SIGNAL(changed()),marker,SLOT(changed()));
181 connect(s,SIGNAL(changed()),marker,SLOT(changed()));
174 mMarkers.append(marker);
182 mMarkers.append(marker);
175 childItems().append(marker);
183 childItems().append(marker);
176 }
184 }
177 }
185 }
178
186
179 void QLegend::appendMarkers(QPieSeries *series)
187 void QLegend::appendMarkers(QPieSeries *series)
180 {
188 {
181 foreach(QPieSlice* s, series->slices()) {
189 foreach(QPieSlice* s, series->slices()) {
182 LegendMarker* marker = new LegendMarker(series,s,this);
190 LegendMarker* marker = new LegendMarker(series,s,this);
183 marker->setName(s->label());
191 marker->setName(s->label());
184 marker->setBrush(s->sliceBrush());
192 marker->setBrush(s->sliceBrush());
185 connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)));
193 connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)));
186 connect(s,SIGNAL(changed()),marker,SLOT(changed()));
194 connect(s,SIGNAL(changed()),marker,SLOT(changed()));
187 mMarkers.append(marker);
195 mMarkers.append(marker);
188 childItems().append(marker);
196 childItems().append(marker);
189 }
197 }
190 }
198 }
191
199
192 void QLegend::deleteMarkers(QSeries *series)
200 void QLegend::deleteMarkers(QSeries *series)
193 {
201 {
194 // Search all markers that belong to given series and delete them.
202 // Search all markers that belong to given series and delete them.
195 foreach (LegendMarker *m, mMarkers) {
203 foreach (LegendMarker *m, mMarkers) {
196 if (m->series() == series) {
204 if (m->series() == series) {
197 mMarkers.removeOne(m);
205 mMarkers.removeOne(m);
198 delete m;
206 delete m;
199 }
207 }
200 }
208 }
201 }
209 }
202
210
203 void QLegend::layoutChanged()
211 void QLegend::layoutChanged()
204 {
212 {
205 // Calculate layout for markers and text
213 // Calculate layout for markers and text
206 if (mMarkers.count() <= 0) {
214 if (mMarkers.count() <= 0) {
207 // Nothing to do
215 // Nothing to do
208 return;
216 return;
209 }
217 }
210
218
211 qreal steps = mMarkers.count();
219 // Limit legend size to maximum.
212 qreal xStep = mBoundingRect.width() / steps;
220 QSizeF size = mBoundingRect.size();
213 qreal x=mBoundingRect.x();
221
214 qreal y = mBoundingRect.y() + (mBoundingRect.height()/4);
222
215 foreach (LegendMarker* m, mMarkers) {
223 // TODO: grid layout
216 m->setBoundingRect(QRectF(x,y,xStep,mBoundingRect.height()/2));
224 switch (mPreferredLayout)
217 x += xStep;
225 {
226 case QLegend::PreferredLayoutHorizontal: {
227
228 qreal steps = mMarkers.count();
229 qreal xStep = size.width() / (steps+1);
230 qreal x = mBoundingRect.x() + xStep/2;
231 qreal y = mBoundingRect.y(); // Half of legend marker min size
232 foreach (LegendMarker* m, mMarkers) {
233 m->setBoundingRect(QRectF(x,y,xStep,size.height()/2));
234 x += xStep;
235 }
236 break;
218 }
237 }
238 case QLegend::PreferredLayoutVertical: {
239 // Limit markers to bounding rect size.
240 if (size.width() > mBoundingRect.width()) {
241 size.setWidth(mBoundingRect.width());
242 }
243 qreal steps = mMarkers.count();
244 qreal yStep = size.height() / (steps+1);
245 qreal x = mBoundingRect.x();
246 qreal y = mBoundingRect.y() + yStep/2;
247 foreach (LegendMarker* m, mMarkers) {
248 m->setBoundingRect(QRectF(x,y,size.width(),yStep));
249 y += yStep;
250 }
251 break;
252 }
253 default: {
254 break;
255 }
256 }
257
219 }
258 }
220
259
221 #include "moc_qlegend.cpp"
260 #include "moc_qlegend.cpp"
222 QTCOMMERCIALCHART_END_NAMESPACE
261 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,66 +1,77
1 #ifndef QLEGEND_H
1 #ifndef QLEGEND_H
2 #define QLEGEND_H
2 #define QLEGEND_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qseries.h"
5 #include "qseries.h"
6 #include <QGraphicsObject>
6 #include <QGraphicsObject>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class Domain;
10 class Domain;
11 class LegendMarker;
11 class LegendMarker;
12 class QPieSlice;
12 class QPieSlice;
13 class QXYSeries;
13 class QXYSeries;
14 class QBarSet;
14 class QBarSet;
15 class QBarSeries;
15 class QBarSeries;
16 class QPieSeries;
16 class QPieSeries;
17
17
18 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsObject
18 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsObject
19 {
19 {
20 Q_OBJECT
20 Q_OBJECT
21 public:
21 public:
22
22
23 enum PreferredLayout {
24 PreferredLayoutHorizontal,
25 PreferredLayoutVertical
26 };
27
23 explicit QLegend(QGraphicsItem *parent = 0);
28 explicit QLegend(QGraphicsItem *parent = 0);
24
29
25 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
30 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
26 QRectF boundingRect() const;
31 QRectF boundingRect() const;
27
32
28 void setBackgroundBrush(const QBrush& brush);
33 void setBackgroundBrush(const QBrush& brush);
29 QBrush backgroundBrush() const;
34 QBrush backgroundBrush() const;
30
35
36 void setPreferredLayout(QLegend::PreferredLayout preferred);
37
31 QSizeF minimumSize() const;
38 QSizeF minimumSize() const;
32 void setMinimumSize(const QSizeF size);
39 void setMinimumSize(const QSizeF size);
40 QSizeF maximumSize() const;
41 void setMaximumSize(const QSizeF size);
33
42
34 signals:
43 signals:
35 // for interactions.
44 // for interactions.
36 void clicked(QSeries* series, Qt::MouseButton button);
45 void clicked(QSeries* series, Qt::MouseButton button);
37 void clicked(QBarSet* barset, Qt::MouseButton button);
46 void clicked(QBarSet* barset, Qt::MouseButton button);
38 void clicked(QPieSlice* slice, Qt::MouseButton button);
47 void clicked(QPieSlice* slice, Qt::MouseButton button);
39
48
40 public slots:
49 public slots:
41 void handleSeriesAdded(QSeries* series,Domain* domain);
50 void handleSeriesAdded(QSeries* series,Domain* domain);
42 void handleSeriesRemoved(QSeries* series);
51 void handleSeriesRemoved(QSeries* series);
43 void handleGeometryChanged(const QRectF& size);
52 void handleGeometryChanged(const QRectF& size);
44
53
45 private:
54 private:
46 // PIMPL --->
55 // PIMPL --->
47 void createMarkers(QSeries* series);
56 void createMarkers(QSeries* series);
48 void appendMarkers(QXYSeries* series);
57 void appendMarkers(QXYSeries* series);
49 void appendMarkers(QBarSeries* series);
58 void appendMarkers(QBarSeries* series);
50 void appendMarkers(QPieSeries* series);
59 void appendMarkers(QPieSeries* series);
51 void deleteMarkers(QSeries* series);
60 void deleteMarkers(QSeries* series);
52 void layoutChanged();
61 void layoutChanged(); // TODO: rename this to layoutChanged and remove original layoutChanged, when ready
53 // <--- PIMPL
62 // <--- PIMPL
54
63
55
64
56 QRectF mBoundingRect;
65 QRectF mBoundingRect;
57 QList<QSeries*> mSeriesList;
66 QList<QSeries*> mSeriesList;
58 QList<LegendMarker*> mMarkers;
67 QList<LegendMarker*> mMarkers;
59
68
60 QBrush mBackgroundBrush;
69 QBrush mBackgroundBrush;
61 QSizeF mMinimumSize;
70 QSizeF mMinimumSize;
71 QSizeF mMaximumSize;
72 QLegend::PreferredLayout mPreferredLayout;
62 };
73 };
63
74
64 QTCOMMERCIALCHART_END_NAMESPACE
75 QTCOMMERCIALCHART_END_NAMESPACE
65
76
66 #endif // QLEGEND_H
77 #endif // QLEGEND_H
@@ -1,56 +1,48
1 #ifndef QSERIES_H
1 #ifndef QSERIES_H
2 #define QSERIES_H
2 #define QSERIES_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include <QObject>
5 #include <QObject>
6 #include <QAbstractItemModel>
6 #include <QAbstractItemModel>
7 #include <QPen>
7 #include <QPen>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class QTCOMMERCIALCHART_EXPORT QSeries : public QObject
11 class QTCOMMERCIALCHART_EXPORT QSeries : public QObject
12 {
12 {
13 Q_OBJECT
13 Q_OBJECT
14 public:
14 public:
15 enum QSeriesType {
15 enum QSeriesType {
16 SeriesTypeLine,
16 SeriesTypeLine,
17 SeriesTypeArea,
17 SeriesTypeArea,
18 SeriesTypeBar,
18 SeriesTypeBar,
19 SeriesTypeStackedBar,
19 SeriesTypeStackedBar,
20 SeriesTypePercentBar,
20 SeriesTypePercentBar,
21 SeriesTypePie,
21 SeriesTypePie,
22 SeriesTypeScatter,
22 SeriesTypeScatter,
23 SeriesTypeSpline
23 SeriesTypeSpline
24 };
24 };
25
25
26 // Helper class to contain legend and color for it
27 // TODO: This is actually quite close to current LegendMarker.. combine them?
28 /* class LegendEntry {
29 public:
30 QString mName;
31 /QBrush mBrush;
32 };*/
33
34 protected:
26 protected:
35 QSeries(QObject *parent = 0) : QObject(parent) {m_model = NULL;}
27 QSeries(QObject *parent = 0) : QObject(parent) {m_model = NULL;}
36
28
37 public:
29 public:
38 virtual ~QSeries() {}
30 virtual ~QSeries() {}
39 virtual QSeriesType type() const = 0;
31 virtual QSeriesType type() const = 0;
40 QString name() { return QString("TODO: Name QSeries"); }
32 QString name() { return QString("TODO: Name QSeries"); }
41 // TODO
33 // TODO
42 virtual bool setModel(QAbstractItemModel* /*model*/) { return false; }
34 virtual bool setModel(QAbstractItemModel* /*model*/) { return false; }
43
35
44 void setTitle(QString title) { m_title = title; }
36 void setTitle(QString title) { m_title = title; }
45 QString title() { return m_title; }
37 QString title() { return m_title; }
46
38
47 protected:
39 protected:
48 QAbstractItemModel* m_model;
40 QAbstractItemModel* m_model;
49
41
50 private:
42 private:
51 QString m_title;
43 QString m_title;
52 };
44 };
53
45
54 QTCOMMERCIALCHART_END_NAMESPACE
46 QTCOMMERCIALCHART_END_NAMESPACE
55
47
56 #endif
48 #endif
General Comments 0
You need to be logged in to leave comments. Login now