@@ -208,27 +208,10 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
208 | 208 | */ |
|
209 | 209 | |
|
210 | 210 | /*! |
|
211 |
\qmlsignal ChartView::on |
|
|
212 |
The |
|
|
213 | related properties of the legend or chart title. | |
|
214 | */ | |
|
215 | ||
|
216 | /*! | |
|
217 | \qmlsignal ChartView::onBottomMarginChanged(real margin) | |
|
218 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
|
219 | related properties of the legend or chart title. | |
|
220 | */ | |
|
221 | ||
|
222 | /*! | |
|
223 | \qmlsignal ChartView::onLeftMarginChanged(real margin) | |
|
224 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
|
225 | related properties of the legend or chart title. | |
|
226 | */ | |
|
227 | ||
|
228 | /*! | |
|
229 | \qmlsignal ChartView::onRightMarginChanged(real margin) | |
|
230 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
|
231 | related properties of the legend or chart title. | |
|
211 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) | |
|
212 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins | |
|
213 | or if you resize the chart, or if you modify font size related properties of the legend or chart | |
|
214 | title. | |
|
232 | 215 | */ |
|
233 | 216 | |
|
234 | 217 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
@@ -237,17 +220,17 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |||
|
237 | 220 | { |
|
238 | 221 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
239 | 222 | m_minMargins = new DeclarativeMargins(this); |
|
240 | connect(m_minMargins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
|
241 | connect(m_minMargins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
|
242 | connect(m_minMargins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
|
243 | connect(m_minMargins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
|
244 | // TODO: connect to plotAreaChanged signal from m_chart | |
|
223 | connect(m_minMargins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
|
224 | connect(m_minMargins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
|
225 | connect(m_minMargins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
|
226 | connect(m_minMargins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
|
245 | 227 | } |
|
246 | 228 | |
|
247 | 229 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) |
|
248 | 230 | { |
|
249 | 231 | m_chart->setMinimumMargins(QMargins(left, top, right, bottom)); |
|
250 | plotAreaChanged(m_chart->plotArea()); | |
|
232 | emit minimumMarginsChanged(); | |
|
233 | emit plotAreaChanged(m_chart->plotArea()); | |
|
251 | 234 | } |
|
252 | 235 | |
|
253 | 236 | DeclarativeChart::~DeclarativeChart() |
@@ -370,6 +353,11 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF & | |||
|
370 | 353 | } |
|
371 | 354 | } |
|
372 | 355 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
356 | ||
|
357 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or | |
|
358 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is | |
|
359 | // to implement it here for the QML API purposes. | |
|
360 | emit plotAreaChanged(m_chart->plotArea()); | |
|
373 | 361 | } |
|
374 | 362 | |
|
375 | 363 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
@@ -41,11 +41,11 class DeclarativeChart : public QDeclarativeItem | |||
|
41 | 41 | Q_PROPERTY(int count READ count) |
|
42 | 42 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
43 | 43 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
44 |
Q_PROPERTY(qreal topMargin READ topMargin |
|
|
45 |
Q_PROPERTY(qreal bottomMargin READ bottomMargin |
|
|
46 |
Q_PROPERTY(qreal leftMargin READ leftMargin |
|
|
47 |
Q_PROPERTY(qreal rightMargin READ rightMargin |
|
|
48 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins REVISION 1) | |
|
44 | Q_PROPERTY(qreal topMargin READ topMargin) | |
|
45 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) | |
|
46 | Q_PROPERTY(qreal leftMargin READ leftMargin) | |
|
47 | Q_PROPERTY(qreal rightMargin READ rightMargin) | |
|
48 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) | |
|
49 | 49 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) |
|
50 | 50 | Q_ENUMS(Animation) |
|
51 | 51 | Q_ENUMS(Theme) |
@@ -139,14 +139,10 Q_SIGNALS: | |||
|
139 | 139 | void titleColorChanged(QColor color); |
|
140 | 140 | void backgroundColorChanged(); |
|
141 | 141 | void dropShadowEnabledChanged(bool enabled); |
|
142 |
void |
|
|
143 | void bottomMarginChanged(qreal margin); | |
|
144 | void leftMarginChanged(qreal margin); | |
|
145 | void rightMarginChanged(qreal margin); | |
|
142 | void minimumMarginsChanged(); | |
|
146 | 143 | void plotAreaChanged(QRectF plotArea); |
|
147 | 144 | |
|
148 | 145 | public Q_SLOTS: |
|
149 | // void handleMarginsChanged(QRectF newMargins); | |
|
150 | 146 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
151 | 147 | void handleAxisXSet(QAbstractAxis *axis); |
|
152 | 148 | void handleAxisYSet(QAbstractAxis *axis); |
@@ -42,22 +42,6 ChartView { | |||
|
42 | 42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); |
|
43 | 43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); |
|
44 | 44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); |
|
45 | onTopMarginChanged: { | |
|
46 | console.log("chart.onTopMarginChanged: " + margin); | |
|
47 | marginVisualizer.opacity = 1.0; | |
|
48 | } | |
|
49 | onBottomMarginChanged: { | |
|
50 | console.log("chart.onBottomMarginChanged: " + margin); | |
|
51 | marginVisualizer.opacity = 1.0; | |
|
52 | } | |
|
53 | onLeftMarginChanged: { | |
|
54 | console.log("chart.onLeftMarginChanged: " + margin); | |
|
55 | marginVisualizer.opacity = 1.0; | |
|
56 | } | |
|
57 | onRightMarginChanged: { | |
|
58 | console.log("chart.onRightMarginChanged: " + margin); | |
|
59 | marginVisualizer.opacity = 1.0; | |
|
60 | } | |
|
61 | 45 | |
|
62 | 46 | legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); |
|
63 | 47 | legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); |
@@ -65,10 +49,16 ChartView { | |||
|
65 | 49 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); |
|
66 | 50 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); |
|
67 | 51 | minimumMargins.onTopChanged: console.log("chart.minimumMargins.onTopChanged: " + top ); |
|
68 |
minimumMargins.onBottomChanged: console.log("chart.minimumMargins.onBottomChanged: " + bottom |
|
|
69 |
minimumMargins.onLeftChanged: console.log("chart.minimumMargins.onLeftChanged: " + left |
|
|
70 |
minimumMargins.onRightChanged: console.log("chart.minimumMargins.onRightChanged: " + right |
|
|
71 | onPlotAreaChanged: console.log("chart.onPlotAreaChanged, width:" + chartView.plotArea.width + " height: " + chartView.plotArea.height + " y: " + chartView.plotArea.y + " x: " + chartView.plotArea.x); | |
|
52 | minimumMargins.onBottomChanged: console.log("chart.minimumMargins.onBottomChanged: " + bottom); | |
|
53 | minimumMargins.onLeftChanged: console.log("chart.minimumMargins.onLeftChanged: " + left); | |
|
54 | minimumMargins.onRightChanged: console.log("chart.minimumMargins.onRightChanged: " + right); | |
|
55 | onPlotAreaChanged: { | |
|
56 | console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width | |
|
57 | + " height: " + chartView.plotArea.height | |
|
58 | + " y: " + chartView.plotArea.y | |
|
59 | + " x: " + chartView.plotArea.x); | |
|
60 | marginVisualizer.opacity = 1.0; | |
|
61 | } | |
|
72 | 62 | |
|
73 | 63 | ValueAxis{ |
|
74 | 64 | onColorChanged: console.log("axisX.onColorChanged: " + color); |
@@ -101,10 +91,10 ChartView { | |||
|
101 | 91 | color: "transparent" |
|
102 | 92 | border.color: "red" |
|
103 | 93 | anchors.fill: parent |
|
104 |
anchors.topMargin: |
|
|
105 |
anchors.bottomMargin: |
|
|
106 |
anchors.leftMargin: |
|
|
107 |
anchors.rightMargin: |
|
|
94 | anchors.topMargin: chartView.minimumMargins.top | |
|
95 | anchors.bottomMargin: chartView.minimumMargins.bottom | |
|
96 | anchors.leftMargin: chartView.minimumMargins.left | |
|
97 | anchors.rightMargin: chartView.minimumMargins.right | |
|
108 | 98 | opacity: 0.0 |
|
109 | 99 | onOpacityChanged: if (opacity > 0.9) opacity = 0.0; |
|
110 | 100 | Behavior on opacity { |
General Comments 0
You need to be logged in to leave comments.
Login now