@@ -83,8 +83,8 m_index(-1),m_chart(chart) | |||
|
83 | 83 | QObject::connect(series,SIGNAL(clicked(const QPointF&)),this,SLOT(handlePointClicked(const QPointF&))); |
|
84 | 84 | } |
|
85 | 85 | //![4] |
|
86 | QTimer::singleShot(0,this,SLOT(handleTimeout())); | |
|
87 | 86 | m_timer.start(); |
|
87 | handleTimeout(); | |
|
88 | 88 | } |
|
89 | 89 | |
|
90 | 90 | ChartView::~ChartView() |
@@ -64,7 +64,6 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(char | |||
|
64 | 64 | m_marginTiny(10), |
|
65 | 65 | m_chartMargins(QRect(m_marginBig,m_marginBig,0,0)) |
|
66 | 66 | { |
|
67 | createConnections(); | |
|
68 | 67 | } |
|
69 | 68 | |
|
70 | 69 | ChartPresenter::~ChartPresenter() |
@@ -72,14 +71,6 ChartPresenter::~ChartPresenter() | |||
|
72 | 71 | delete m_chartTheme; |
|
73 | 72 | } |
|
74 | 73 | |
|
75 | void ChartPresenter::createConnections() | |
|
76 | { | |
|
77 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),this,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
|
78 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),this,SLOT(handleSeriesRemoved(QSeries*))); | |
|
79 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),this,SLOT(handleAxisAdded(QChartAxis*,Domain*))); | |
|
80 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*))); | |
|
81 | } | |
|
82 | ||
|
83 | 74 | void ChartPresenter::setGeometry(const QRectF& rect) |
|
84 | 75 | { |
|
85 | 76 | m_rect = rect; |
@@ -506,12 +497,14 void ChartPresenter::updateLayout() | |||
|
506 | 497 | |
|
507 | 498 | QRectF chartRect = m_rect.adjusted(m_chartMargins.left(),m_chartMargins.top(),-m_chartMargins.right(),-m_chartMargins.bottom()); |
|
508 | 499 | |
|
500 | legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom())); | |
|
501 | ||
|
509 | 502 | if(m_chartRect!=chartRect){ |
|
510 | 503 | m_chartRect=chartRect; |
|
511 | 504 | emit geometryChanged(m_chartRect); |
|
512 | 505 | } |
|
513 | 506 | |
|
514 | legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom())); | |
|
507 | ||
|
515 | 508 | } |
|
516 | 509 | |
|
517 | 510 | void ChartPresenter::createChartBackgroundItem() |
@@ -81,7 +81,6 public: | |||
|
81 | 81 | qreal minimumBottomMargin() const { return m_minBottomMargin; } |
|
82 | 82 | |
|
83 | 83 | public: //TODO: fix me |
|
84 | void createConnections(); | |
|
85 | 84 | void resetAllElements(); |
|
86 | 85 | void createChartBackgroundItem(); |
|
87 | 86 | void createChartTitleItem(); |
@@ -72,9 +72,8 d_ptr(new QChartPrivate()) | |||
|
72 | 72 | d_ptr->m_dataset = new ChartDataSet(this); |
|
73 | 73 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); |
|
74 | 74 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
75 | d_ptr->createConnections(); | |
|
75 | 76 | //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3); |
|
76 | connect(d_ptr->m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),d_ptr->m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
|
77 | connect(d_ptr->m_dataset,SIGNAL(seriesRemoved(QSeries*)),d_ptr->m_legend,SLOT(handleSeriesRemoved(QSeries*))); | |
|
78 | 77 | } |
|
79 | 78 | |
|
80 | 79 | /*! |
@@ -346,6 +345,16 QChartPrivate::~QChartPrivate() | |||
|
346 | 345 | |
|
347 | 346 | } |
|
348 | 347 | |
|
348 | void QChartPrivate::createConnections() | |
|
349 | { | |
|
350 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
|
351 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*))); | |
|
352 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
|
353 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*))); | |
|
354 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*))); | |
|
355 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*))); | |
|
356 | } | |
|
357 | ||
|
349 | 358 | #include "moc_qchart.cpp" |
|
350 | 359 | |
|
351 | 360 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -47,6 +47,8 struct QChartPrivate | |||
|
47 | 47 | ChartDataSet *m_dataset; |
|
48 | 48 | ChartPresenter *m_presenter; |
|
49 | 49 | |
|
50 | void createConnections(); | |
|
51 | ||
|
50 | 52 | }; |
|
51 | 53 | |
|
52 | 54 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -100,8 +100,7 QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), | |||
|
100 | 100 | m_minHeight(0), |
|
101 | 101 | m_width(0), |
|
102 | 102 | m_height(0), |
|
103 |
m_visible(false) |
|
|
104 | m_dirty(false) | |
|
103 | m_visible(false) | |
|
105 | 104 | { |
|
106 | 105 | setZValue(ChartPresenter::LegendZValue); |
|
107 | 106 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
@@ -247,11 +246,7 void QLegend::handleSeriesAdded(QSeries *series, Domain *domain) | |||
|
247 | 246 | } |
|
248 | 247 | } |
|
249 | 248 | |
|
250 | // wait for all series added | |
|
251 | if(!m_dirty){ | |
|
252 | QTimer::singleShot(0,this,SLOT(updateLayout())); | |
|
253 | m_dirty=true; | |
|
254 | } | |
|
249 | updateLayout(); | |
|
255 | 250 | } |
|
256 | 251 | |
|
257 | 252 | /*! |
@@ -428,7 +423,6 QPointF QLegend::offset() const | |||
|
428 | 423 | // this function runs first to set min max values |
|
429 | 424 | void QLegend::updateLayout() |
|
430 | 425 | { |
|
431 | m_dirty=false; | |
|
432 | 426 | m_offsetX=0; |
|
433 | 427 | QList<QGraphicsItem *> items = m_markers->childItems(); |
|
434 | 428 |
@@ -106,11 +106,6 private: | |||
|
106 | 106 | void appendMarkers(QBarSeries *series); |
|
107 | 107 | void appendMarkers(QPieSeries *series); |
|
108 | 108 | void deleteMarkers(QSeries *series); |
|
109 | ||
|
110 | ||
|
111 | ||
|
112 | ||
|
113 | private Q_SLOTS: | |
|
114 | 109 | void updateLayout(); |
|
115 | 110 | |
|
116 | 111 | private: |
@@ -136,7 +131,6 private: | |||
|
136 | 131 | qreal m_width; |
|
137 | 132 | qreal m_height; |
|
138 | 133 | bool m_visible; |
|
139 | bool m_dirty; | |
|
140 | 134 | friend class ScrolledQLegend; |
|
141 | 135 | // <--- PIMPL |
|
142 | 136 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now