##// END OF EJS Templates
Enabled legend again; it is now created before presenter
Tero Ahola -
r550:c0a0231bdee1
parent child
Show More
@@ -68,7 +68,7 void ChartTheme::decorate(QChart* chart)
68
68
69 void ChartTheme::decorate(QLegend* legend)
69 void ChartTheme::decorate(QLegend* legend)
70 {
70 {
71 //legend->setBackgroundBrush(m_backgroundGradient);
71 legend->setBackgroundBrush(m_backgroundGradient);
72 }
72 }
73
73
74 void ChartTheme::decorate(AreaChartItem* item, QAreaSeries* series, int index)
74 void ChartTheme::decorate(AreaChartItem* item, QAreaSeries* series, int index)
@@ -49,12 +49,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
49 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
49 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
50 m_backgroundItem(0),
50 m_backgroundItem(0),
51 m_titleItem(0),
51 m_titleItem(0),
52 m_legend(new QLegend(this)),
52 m_dataset(new ChartDataSet(this)),
53 m_dataset(new ChartDataSet(this)),
53 m_presenter(new ChartPresenter(this,m_dataset))
54 m_presenter(new ChartPresenter(this,m_dataset))
54 {
55 {
55 createLegend();
56 connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
56 // connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
57 connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
57 // connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
58 }
58 }
59
59
60 /*!
60 /*!
@@ -62,8 +62,8 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(
62 */
62 */
63 QChart::~QChart()
63 QChart::~QChart()
64 {
64 {
65 // disconnect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
65 disconnect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
66 // disconnect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
66 disconnect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
67 }
67 }
68
68
69 /*!
69 /*!
@@ -181,16 +181,6 void QChart::createChartTitleItem()
181 }
181 }
182 }
182 }
183
183
184 void QChart::createLegend()
185 {
186 // TODO: Why we have null pointer, even if this is created in constructor?
187 if(!m_legend) {
188 m_legend = new QLegend(this);
189 m_legend->setZValue(ChartPresenter::LegendZValue);
190 }
191 }
192
193
194 /*!
184 /*!
195 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.
185 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.
196 \sa setMargin()
186 \sa setMargin()
@@ -282,7 +272,6 QChartAxis* QChart::axisY() const
282 */
272 */
283 QLegend* QChart::legend()
273 QLegend* QChart::legend()
284 {
274 {
285 createLegend();
286 return m_legend;
275 return m_legend;
287 }
276 }
288
277
@@ -85,16 +85,15 protected:
85 private:
85 private:
86 inline void createChartBackgroundItem();
86 inline void createChartBackgroundItem();
87 inline void createChartTitleItem();
87 inline void createChartTitleItem();
88 inline void createLegend();
89
88
90 private:
89 private:
91 Q_DISABLE_COPY(QChart)
90 Q_DISABLE_COPY(QChart)
92 QGraphicsRectItem* m_backgroundItem;
91 QGraphicsRectItem* m_backgroundItem;
93 QGraphicsSimpleTextItem* m_titleItem;
92 QGraphicsSimpleTextItem* m_titleItem;
94 QRectF m_rect;
93 QRectF m_rect;
94 QLegend* m_legend;
95 ChartDataSet *m_dataset;
95 ChartDataSet *m_dataset;
96 ChartPresenter *m_presenter;
96 ChartPresenter *m_presenter;
97 QLegend* m_legend;
98 };
97 };
99
98
100 QTCOMMERCIALCHART_END_NAMESPACE
99 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now