##// END OF EJS Templates
Property notifications: axis minmax, bar properties, xyseries p-visibl and count
Tero Ahola -
r1465:7735835ca38c
parent child
Show More
@@ -29,6 +29,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
29 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
30 QBarSet("", parent)
30 QBarSet("", parent)
31 {
31 {
32 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
33 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
34 }
35
36 void DeclarativeBarSet::handleCountChanged(int index, int count)
37 {
38 Q_UNUSED(index)
39 Q_UNUSED(count)
40 emit countChanged(QBarSet::count());
32 }
41 }
33
42
34 QVariantList DeclarativeBarSet::values()
43 QVariantList DeclarativeBarSet::values()
@@ -50,42 +59,6 void DeclarativeBarSet::setValues(QVariantList values)
50 }
59 }
51 }
60 }
52
61
53 QColor DeclarativeBarSet::color()
54 {
55 return brush().color();
56 }
57
58 void DeclarativeBarSet::setColor(QColor color)
59 {
60 QBrush b = brush();
61 b.setColor(color);
62 setBrush(b);
63 }
64
65 QColor DeclarativeBarSet::borderColor()
66 {
67 return pen().color();
68 }
69
70 void DeclarativeBarSet::setBorderColor(QColor color)
71 {
72 QPen p = pen();
73 p.setColor(color);
74 setPen(p);
75 }
76
77 QColor DeclarativeBarSet::labelColor()
78 {
79 return labelBrush().color();
80 }
81
82 void DeclarativeBarSet::setLabelColor(QColor color)
83 {
84 QBrush b = labelBrush();
85 b.setColor(color);
86 setLabelBrush(b);
87 }
88
89 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
90 QBarSeries(parent)
63 QBarSeries(parent)
91 {
64 {
@@ -37,24 +37,22 class DeclarativeBarSet : public QBarSet
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39 Q_PROPERTY(QVariantList values READ values WRITE setValues)
39 Q_PROPERTY(QVariantList values READ values WRITE setValues)
40 Q_PROPERTY(QColor color READ color WRITE setColor)
40 Q_PROPERTY(int count READ count NOTIFY countChanged)
41 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
42 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
43
41
44 public:
42 public:
45 explicit DeclarativeBarSet(QObject *parent = 0);
43 explicit DeclarativeBarSet(QObject *parent = 0);
46 QVariantList values();
44 QVariantList values();
47 void setValues(QVariantList values);
45 void setValues(QVariantList values);
48 QColor color();
49 void setColor(QColor color);
50 QColor borderColor();
51 void setBorderColor(QColor color);
52 QColor labelColor();
53 void setLabelColor(QColor color);
54
46
55 public: // From QBarSet
47 public: // From QBarSet
56 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
48 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
57 Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); }
49 Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); }
50
51 Q_SIGNALS:
52 void countChanged(int count);
53
54 private Q_SLOTS:
55 void handleCountChanged(int index, int count);
58 };
56 };
59
57
60 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
58 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
@@ -28,6 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
29 QLineSeries(parent)
29 QLineSeries(parent)
30 {
30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 }
33 }
32
34
33 QXYSeries *DeclarativeLineSeries::xySeries()
35 QXYSeries *DeclarativeLineSeries::xySeries()
@@ -35,6 +37,12 QXYSeries *DeclarativeLineSeries::xySeries()
35 return this;
37 return this;
36 }
38 }
37
39
40 void DeclarativeLineSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(points().count());
44 }
45
38 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
46 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
39 {
47 {
40 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
@@ -42,10 +50,9 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
42
50
43 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
51 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 {
52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
53 Q_UNUSED(list)
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
54 Q_UNUSED(element)
47 if (series && point)
55 // Empty implementation, childs are parsed in componentComplete
48 series->append(*point);
49 }
56 }
50
57
51 #include "moc_declarativelineseries.cpp"
58 #include "moc_declarativelineseries.cpp"
@@ -35,6 +35,7 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu
35 Q_OBJECT
35 Q_OBJECT
36 Q_INTERFACES(QDeclarativeParserStatus)
36 Q_INTERFACES(QDeclarativeParserStatus)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
38 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40
41
@@ -53,8 +54,12 public: // from QLineSeries
53 Q_INVOKABLE void clear() { QLineSeries::clear(); }
54 Q_INVOKABLE void clear() { QLineSeries::clear(); }
54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55
56
57 Q_SIGNALS:
58 void countChanged(int count);
59
56 public Q_SLOTS:
60 public Q_SLOTS:
57 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
61 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
62 void handleCountChanged(int index);
58 };
63 };
59
64
60 QTCOMMERCIALCHART_END_NAMESPACE
65 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,6 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
29 QScatterSeries(parent)
29 QScatterSeries(parent)
30 {
30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 }
33 }
32
34
33 QXYSeries *DeclarativeScatterSeries::xySeries()
35 QXYSeries *DeclarativeScatterSeries::xySeries()
@@ -35,6 +37,12 QXYSeries *DeclarativeScatterSeries::xySeries()
35 return this;
37 return this;
36 }
38 }
37
39
40 void DeclarativeScatterSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(QScatterSeries::count());
44 }
45
38 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
46 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
39 {
47 {
40 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
@@ -42,10 +50,9 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren(
42
50
43 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
51 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 {
52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
53 Q_UNUSED(list)
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
54 Q_UNUSED(element)
47 if (series && point)
55 // Empty implementation, childs are parsed in componentComplete
48 series->append(*point);
49 }
56 }
50
57
51 QColor DeclarativeScatterSeries::brushColor()
58 QColor DeclarativeScatterSeries::brushColor()
@@ -35,6 +35,7 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri
35 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_INTERFACES(QDeclarativeParserStatus)
36 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
36 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
37 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
37 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
38 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40
41
@@ -55,8 +56,12 public: // from QScatterSeries
55 Q_INVOKABLE void clear() { QScatterSeries::clear(); }
56 Q_INVOKABLE void clear() { QScatterSeries::clear(); }
56 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
57 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
57
58
59 Q_SIGNALS:
60 void countChanged(int count);
61
58 public Q_SLOTS:
62 public Q_SLOTS:
59 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
63 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
64 void handleCountChanged(int index);
60 };
65 };
61
66
62 QTCOMMERCIALCHART_END_NAMESPACE
67 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,6 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
28 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
29 QSplineSeries(parent)
29 QSplineSeries(parent)
30 {
30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 }
33 }
32
34
33 QXYSeries *DeclarativeSplineSeries::xySeries()
35 QXYSeries *DeclarativeSplineSeries::xySeries()
@@ -35,6 +37,12 QXYSeries *DeclarativeSplineSeries::xySeries()
35 return this;
37 return this;
36 }
38 }
37
39
40 void DeclarativeSplineSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(points().count());
44 }
45
38 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
46 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
39 {
47 {
40 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
@@ -42,10 +50,9 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
42
50
43 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
51 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 {
52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
53 Q_UNUSED(list)
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
54 Q_UNUSED(element)
47 if (series && point)
55 // Empty implementation, childs are parsed in componentComplete
48 series->append(*point);
49 }
56 }
50
57
51 #include "moc_declarativesplineseries.cpp"
58 #include "moc_declarativesplineseries.cpp"
@@ -53,8 +53,12 public: // from QSplineSeries
53 Q_INVOKABLE void clear() { QSplineSeries::clear(); }
53 Q_INVOKABLE void clear() { QSplineSeries::clear(); }
54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55
55
56 Q_SIGNALS:
57 void countChanged(int count);
58
56 public Q_SLOTS:
59 public Q_SLOTS:
57 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
60 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
61 void handleCountChanged(int index);
58 };
62 };
59
63
60 QTCOMMERCIALCHART_END_NAMESPACE
64 QTCOMMERCIALCHART_END_NAMESPACE
@@ -47,8 +47,8 void DeclarativeXySeries::componentComplete()
47
47
48 foreach(QObject *child, series->children()) {
48 foreach(QObject *child, series->children()) {
49 if (qobject_cast<DeclarativeXyPoint *>(child)) {
49 if (qobject_cast<DeclarativeXyPoint *>(child)) {
50 // TODO:
50 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(child);
51 // series->append(qobject_cast<DeclarativeXyPoint *>(child));
51 series->append(point->x(), point->y());
52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
54 mapper->setSeries(series);
54 mapper->setSeries(series);
@@ -69,6 +69,8 public:
69
69
70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
71 QLatin1String("Trying to create uncreatable: Legend."));
71 QLatin1String("Trying to create uncreatable: Legend."));
72 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "QXYSeries",
73 QLatin1String("Trying to create uncreatable: QXYSeries."));
72 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
74 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
73 QLatin1String("Trying to create uncreatable: QScatterSeries."));
75 QLatin1String("Trying to create uncreatable: QScatterSeries."));
74 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
76 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
@@ -42,8 +42,8 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
42 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
42 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
43 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
43 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
44 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
44 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
45 Q_PROPERTY(qreal min READ min WRITE setMin)
45 Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged)
46 Q_PROPERTY(qreal max READ max WRITE setMax)
46 Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged)
47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged)
47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged)
48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged)
48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged)
49
49
@@ -115,8 +115,6 Q_SIGNALS:
115 void visibleChanged(bool visible);
115 void visibleChanged(bool visible);
116 void labelsVisibleChanged(bool visible);
116 void labelsVisibleChanged(bool visible);
117 void gridVisibleChanged(bool visible);
117 void gridVisibleChanged(bool visible);
118 void minChanged(qreal min);
119 void maxChanged(qreal max);
120 void rangeChanged(qreal min, qreal max);
118 void rangeChanged(qreal min, qreal max);
121 void colorChanged(QColor color);
119 void colorChanged(QColor color);
122 void labelsColorChanged(QColor color);
120 void labelsColorChanged(QColor color);
@@ -124,6 +122,8 Q_SIGNALS:
124 void shadesVisibleChanged(bool visible);
122 void shadesVisibleChanged(bool visible);
125 void shadesColorChanged(QColor color);
123 void shadesColorChanged(QColor color);
126 void shadesBorderColorChanged(QColor color);
124 void shadesBorderColorChanged(QColor color);
125 void minChanged(qreal min);
126 void maxChanged(qreal max);
127 void ticksCountChanged(int count);
127 void ticksCountChanged(int count);
128 void niceNumbersEnabledChanged(bool enabled);
128 void niceNumbersEnabledChanged(bool enabled);
129
129
@@ -48,7 +48,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
48
48
49 /*!
49 /*!
50 \property QBarSeries::barWidth
50 \property QBarSeries::barWidth
51 \brief Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
51 \brief The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
52 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
52 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
53 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
53 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
54 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is
54 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is
@@ -82,9 +82,9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
82 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
82 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
83 */
83 */
84 /*!
84 /*!
85 \fn void QBarSeries::barWidthChanged()
85 \fn void QBarSeries::barWidthChanged(qreal)
86
86
87 This signal is emitted when bar width has been changed.
87 This signal is emitted when bar width has been changed to \a width.
88 */
88 */
89
89
90 /*!
90 /*!
@@ -153,25 +153,13 QAbstractSeries::SeriesType QBarSeries::type() const
153 return QAbstractSeries::SeriesTypeBar;
153 return QAbstractSeries::SeriesTypeBar;
154 }
154 }
155
155
156 /*!
157 Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
158 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
159 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
160 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is
161 because with grouped series it is more logical to set widht of whole group and let the chart calculate correct
162 width for bar.
163 \sa QGroupedBarSeries
164 */
165 void QBarSeries::setBarWidth(qreal width)
156 void QBarSeries::setBarWidth(qreal width)
166 {
157 {
167 Q_D(QBarSeries);
158 Q_D(QBarSeries);
168 d->setBarWidth(width);
159 d->setBarWidth(width);
169 emit barWidthChanged();
160 emit barWidthChanged(width);
170 }
161 }
171
162
172 /*!
173 Returns the width of bars.
174 */
175 qreal QBarSeries::barWidth() const
163 qreal QBarSeries::barWidth() const
176 {
164 {
177 Q_D(const QBarSeries);
165 Q_D(const QBarSeries);
@@ -181,7 +169,6 qreal QBarSeries::barWidth() const
181 /*!
169 /*!
182 Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
170 Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
183 Returns true, if appending succeeded.
171 Returns true, if appending succeeded.
184
185 */
172 */
186 bool QBarSeries::append(QBarSet *set)
173 bool QBarSeries::append(QBarSet *set)
187 {
174 {
@@ -63,7 +63,7 protected:
63 Q_SIGNALS:
63 Q_SIGNALS:
64 void clicked(QBarSet *barset, int index);
64 void clicked(QBarSet *barset, int index);
65 void hovered(QBarSet* barset, bool status);
65 void hovered(QBarSet* barset, bool status);
66 void barWidthChanged();
66 void barWidthChanged(qreal width);
67 void countChanged();
67 void countChanged();
68 void labelsVisibleChanged();
68 void labelsVisibleChanged();
69
69
@@ -63,6 +63,21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
63 */
63 */
64
64
65 /*!
65 /*!
66 \property QBarSet::color
67 \brief The fill (brush) color of the bar set.
68 */
69
70 /*!
71 \property QBarSet::borderColor
72 \brief The line (pen) color of the bar set.
73 */
74
75 /*!
76 \property QBarSet::labelColor
77 \brief The text (label) color of the bar set.
78 */
79
80 /*!
66 \fn void QBarSet::labelChanged()
81 \fn void QBarSet::labelChanged()
67
82
68 This signal is emitted when the label of the barSet has changed.
83 This signal is emitted when the label of the barSet has changed.
@@ -103,6 +118,21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
103 */
118 */
104
119
105 /*!
120 /*!
121 \fn void QBarSet::colorChanged(QColor)
122 This signal is emitted when the fill (brush) color of the set has changed to \a color.
123 */
124
125 /*!
126 \fn void QBarSet::borderColorChanged(QColor)
127 This signal is emitted when the line (pen) color of the set has changed to \a color.
128 */
129
130 /*!
131 \fn void QBarSet::labelColorChanged(QColor)
132 This signal is emitted when the text (label) color of the set has changed to \a color.
133 */
134
135 /*!
106 \fn void QBarSet::valuesAdded(int index, int count)
136 \fn void QBarSet::valuesAdded(int index, int count)
107
137
108 This signal is emitted when new values have been added to the set.
138 This signal is emitted when new values have been added to the set.
@@ -413,6 +443,51 QFont QBarSet::labelFont() const
413 return d_ptr->m_labelFont;
443 return d_ptr->m_labelFont;
414 }
444 }
415
445
446 QColor QBarSet::color()
447 {
448 return brush().color();
449 }
450
451 void QBarSet::setColor(QColor color)
452 {
453 QBrush b = brush();
454 if (b.color() != color) {
455 b.setColor(color);
456 setBrush(b);
457 emit colorChanged(color);
458 }
459 }
460
461 QColor QBarSet::borderColor()
462 {
463 return pen().color();
464 }
465
466 void QBarSet::setBorderColor(QColor color)
467 {
468 QPen p = pen();
469 if (p.color() != color) {
470 p.setColor(color);
471 setPen(p);
472 emit borderColorChanged(color);
473 }
474 }
475
476 QColor QBarSet::labelColor()
477 {
478 return labelBrush().color();
479 }
480
481 void QBarSet::setLabelColor(QColor color)
482 {
483 QBrush b = labelBrush();
484 if (b.color() != color) {
485 b.setColor(color);
486 setLabelBrush(b);
487 emit labelColorChanged(color);
488 }
489 }
490
416 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
491 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
417
492
418 QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent),
493 QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent),
@@ -37,6 +37,9 class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject
37 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
37 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
38 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
38 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
39 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
39 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
40 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
41 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
42 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
40
43
41 public:
44 public:
42 explicit QBarSet(const QString label, QObject *parent = 0);
45 explicit QBarSet(const QString label, QObject *parent = 0);
@@ -75,12 +78,24 public:
75 void setLabelFont(const QFont &font);
78 void setLabelFont(const QFont &font);
76 QFont labelFont() const;
79 QFont labelFont() const;
77
80
81 QColor color();
82 void setColor(QColor color);
83
84 QColor borderColor();
85 void setBorderColor(QColor color);
86
87 QColor labelColor();
88 void setLabelColor(QColor color);
89
78 Q_SIGNALS:
90 Q_SIGNALS:
79 void penChanged();
91 void penChanged();
80 void brushChanged();
92 void brushChanged();
81 void labelChanged();
93 void labelChanged();
82 void labelBrushChanged();
94 void labelBrushChanged();
83 void labelFontChanged();
95 void labelFontChanged();
96 void colorChanged(QColor color);
97 void borderColorChanged(QColor color);
98 void labelColorChanged(QColor color);
84
99
85 void valuesAdded(int index, int count);
100 void valuesAdded(int index, int count);
86 void valuesRemoved(int index, int count);
101 void valuesRemoved(int index, int count);
@@ -37,12 +37,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 */
37 */
38
38
39 /*!
39 /*!
40 \property QXYSeries::count
41
42 Number of points in the series.
43 */
44
45 /*!
46 \fn QPen QXYSeries::pen() const
40 \fn QPen QXYSeries::pen() const
47 \brief Returns pen used to draw points for series.
41 \brief Returns pen used to draw points for series.
48 \sa setPen()
42 \sa setPen()
@@ -78,6 +72,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
78 */
72 */
79
73
80 /*!
74 /*!
75 \fn void QXYSeries::pointsVisibleChanged(bool visible)
76 \brief Signal is emitted when the point visibility has changed to \a visible.
77 */
78
79 /*!
81 \fn void QXYSeriesPrivate::updated()
80 \fn void QXYSeriesPrivate::updated()
82 \brief \internal
81 \brief \internal
83 */
82 */
@@ -262,6 +261,7 void QXYSeries::setPointsVisible(bool visible)
262 if (d->m_pointsVisible != visible){
261 if (d->m_pointsVisible != visible){
263 d->m_pointsVisible = visible;
262 d->m_pointsVisible = visible;
264 emit d->updated();
263 emit d->updated();
264 emit pointsVisibleChanged(visible);
265 }
265 }
266 }
266 }
267
267
@@ -36,8 +36,7 class QXYModelMapper;
36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible)
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible NOTIFY pointsVisibleChanged)
40 Q_PROPERTY(int count READ count)
41
40
42 protected:
41 protected:
43 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
42 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
@@ -74,6 +73,8 Q_SIGNALS:
74 void pointReplaced(int index);
73 void pointReplaced(int index);
75 void pointRemoved(int index);
74 void pointRemoved(int index);
76 void pointAdded(int index);
75 void pointAdded(int index);
76 void pointsVisibleChanged(bool visible);
77
77
78
78 private:
79 private:
79 Q_DECLARE_PRIVATE(QXYSeries)
80 Q_DECLARE_PRIVATE(QXYSeries)
@@ -130,7 +130,8 void tst_QBarSet::append()
130 QCOMPARE(m_barset->count(), 0);
130 QCOMPARE(m_barset->count(), 0);
131 QVERIFY(qFuzzyIsNull(m_barset->sum()));
131 QVERIFY(qFuzzyIsNull(m_barset->sum()));
132
132
133 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
133 QSignalSpy valueSpy(m_barset, SIGNAL(valuesAdded(int,int)));
134 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
134
135
135 qreal sum(0.0);
136 qreal sum(0.0);
136 qreal value(0.0);
137 qreal value(0.0);
@@ -145,7 +146,8 void tst_QBarSet::append()
145 QCOMPARE(m_barset->count(), count);
146 QCOMPARE(m_barset->count(), count);
146 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
147 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
147
148
148 QVERIFY(valueSpy.count() == count);
149 QCOMPARE(valueSpy.count(), count);
150 QCOMPARE(countSpy.count(), count);
149 }
151 }
150
152
151 void tst_QBarSet::appendOperator_data()
153 void tst_QBarSet::appendOperator_data()
@@ -161,6 +163,7 void tst_QBarSet::appendOperator()
161 QVERIFY(qFuzzyIsNull(m_barset->sum()));
163 QVERIFY(qFuzzyIsNull(m_barset->sum()));
162
164
163 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
165 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
166 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
164
167
165 qreal sum(0.0);
168 qreal sum(0.0);
166 qreal value(0.0);
169 qreal value(0.0);
@@ -174,8 +177,8 void tst_QBarSet::appendOperator()
174
177
175 QCOMPARE(m_barset->count(), count);
178 QCOMPARE(m_barset->count(), count);
176 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
179 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
177 QVERIFY(valueSpy.count() == count);
180 QCOMPARE(valueSpy.count(), count);
178
181 QCOMPARE(countSpy.count(), count);
179 }
182 }
180
183
181 void tst_QBarSet::insert_data()
184 void tst_QBarSet::insert_data()
@@ -187,6 +190,7 void tst_QBarSet::insert()
187 QCOMPARE(m_barset->count(), 0);
190 QCOMPARE(m_barset->count(), 0);
188 QVERIFY(qFuzzyIsNull(m_barset->sum()));
191 QVERIFY(qFuzzyIsNull(m_barset->sum()));
189 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
192 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
193 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
190
194
191 m_barset->insert(0, 1.0); // 1.0
195 m_barset->insert(0, 1.0); // 1.0
192 QCOMPARE(m_barset->at(0).y(), 1.0);
196 QCOMPARE(m_barset->at(0).y(), 1.0);
@@ -205,7 +209,8 void tst_QBarSet::insert()
205 QCOMPARE(m_barset->at(2).y(), 1.0);
209 QCOMPARE(m_barset->at(2).y(), 1.0);
206 QCOMPARE(m_barset->count(), 3);
210 QCOMPARE(m_barset->count(), 3);
207 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
211 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
208 QVERIFY(valueSpy.count() == 3);
212 QCOMPARE(valueSpy.count(), 3);
213 QCOMPARE(countSpy.count(), 3);
209 }
214 }
210
215
211 void tst_QBarSet::remove_data()
216 void tst_QBarSet::remove_data()
@@ -218,6 +223,7 void tst_QBarSet::remove()
218 QVERIFY(qFuzzyIsNull(m_barset->sum()));
223 QVERIFY(qFuzzyIsNull(m_barset->sum()));
219
224
220 QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int)));
225 QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int)));
226 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
221
227
222 m_barset->append(1.0);
228 m_barset->append(1.0);
223 m_barset->append(2.0);
229 m_barset->append(2.0);
@@ -240,7 +246,8 void tst_QBarSet::remove()
240 QCOMPARE(m_barset->count(), 2);
246 QCOMPARE(m_barset->count(), 2);
241 QCOMPARE(m_barset->sum(), 6.0);
247 QCOMPARE(m_barset->sum(), 6.0);
242
248
243 QVERIFY(valueSpy.count() == 2);
249 QCOMPARE(valueSpy.count(), 2);
250 QCOMPARE(countSpy.count(), 6);
244 }
251 }
245
252
246 void tst_QBarSet::replace_data()
253 void tst_QBarSet::replace_data()
@@ -37,17 +37,18 Flow {
37 ignoreUnknownSignals: true
37 ignoreUnknownSignals: true
38 onNameChanged: console.log("series.onNameChanged: " + series.name);
38 onNameChanged: console.log("series.onNameChanged: " + series.name);
39 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
39 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
40 onBarWidthChanged: console.log("series.onBardWidthChanged: " + width)
40 onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible);
41 onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible);
41 onCountChanged: console.log("series.onCountChanged: " + series.count);
42 onCountChanged: console.log("series.onCountChanged: " + count);
42 }
43 }
43
44
44 Connections {
45 Connections {
45 id: setConnections
46 id: setConnections
46 ignoreUnknownSignals: true
47 ignoreUnknownSignals: true
47 onColorChanged: console.log("series.onColorChanged: " + series.color);
48 onColorChanged: console.log("series.onColorChanged: " + color);
48 onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor);
49 onBorderColorChanged: console.log("series.onBorderColorChanged: " + color);
49 onLabelColorChanged: console.log("series.onLabelColorChanged: " + series.labelColor);
50 onLabelColorChanged: console.log("series.onLabelColorChanged: " + color);
50 onCountChanged: console.log("series.onCountChanged: " + series.count);
51 onCountChanged: console.log("series.onCountChanged: " + count);
51 }
52 }
52
53
53 Button {
54 Button {
@@ -68,8 +68,10 Flow {
68 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
68 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
69 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
69 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
70 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
70 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
71 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
71 onMinChanged: console.log("axisX.onMinChanged: " + min);
72 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
72 onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count);
73 onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count);
74 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
73 }
75 }
74
76
75 Connections {
77 Connections {
@@ -84,8 +86,10 Flow {
84 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
86 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
87 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
88 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
89 onMinChanged: console.log("axisY.onMinChanged: " + min);
90 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
88 onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count);
91 onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count);
92 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
89 }
93 }
90
94
91 Button {
95 Button {
@@ -177,10 +181,6 Flow {
177 onClicked: series.legend.alignment ^= Qt.AlignRight;
181 onClicked: series.legend.alignment ^= Qt.AlignRight;
178 }
182 }
179 Button {
183 Button {
180 text: "axis X nice nmb"
181 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
182 }
183 Button {
184 text: "axis X visible"
184 text: "axis X visible"
185 onClicked: series.axisX.visible = !series.axisX.visible;
185 onClicked: series.axisX.visible = !series.axisX.visible;
186 }
186 }
@@ -221,6 +221,22 Flow {
221 onClicked: series.axisX.shadesBorderColor = main.nextColor();
221 onClicked: series.axisX.shadesBorderColor = main.nextColor();
222 }
222 }
223 Button {
223 Button {
224 text: "axis X max +"
225 onClicked: series.axisX.max += 0.1;
226 }
227 Button {
228 text: "axis X max -"
229 onClicked: series.axisX.max -= 0.1;
230 }
231 Button {
232 text: "axis X min +"
233 onClicked: series.axisX.min += 0.1;
234 }
235 Button {
236 text: "axis X min -"
237 onClicked: series.axisX.min -= 0.1;
238 }
239 Button {
224 text: "axis X ticks count +"
240 text: "axis X ticks count +"
225 onClicked: series.axisX.ticksCount++;
241 onClicked: series.axisX.ticksCount++;
226 }
242 }
@@ -229,8 +245,8 Flow {
229 onClicked: series.axisX.ticksCount--;
245 onClicked: series.axisX.ticksCount--;
230 }
246 }
231 Button {
247 Button {
232 text: "axis Y nice nmb"
248 text: "axis X nice nmb"
233 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
249 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
234 }
250 }
235 Button {
251 Button {
236 text: "axis Y visible"
252 text: "axis Y visible"
@@ -273,6 +289,22 Flow {
273 onClicked: series.axisY.shadesBorderColor = main.nextColor();
289 onClicked: series.axisY.shadesBorderColor = main.nextColor();
274 }
290 }
275 Button {
291 Button {
292 text: "axis Y max +"
293 onClicked: series.axisY.max += 0.1;
294 }
295 Button {
296 text: "axis Y max -"
297 onClicked: series.axisY.max -= 0.1;
298 }
299 Button {
300 text: "axis Y min +"
301 onClicked: series.axisY.min += 0.1;
302 }
303 Button {
304 text: "axis Y min -"
305 onClicked: series.axisY.min -= 0.1;
306 }
307 Button {
276 text: "axis Y ticks count +"
308 text: "axis Y ticks count +"
277 onClicked: series.axisY.ticksCount++;
309 onClicked: series.axisY.ticksCount++;
278 }
310 }
@@ -280,4 +312,8 Flow {
280 text: "axis Y ticks count -"
312 text: "axis Y ticks count -"
281 onClicked: series.axisY.ticksCount--;
313 onClicked: series.axisY.ticksCount--;
282 }
314 }
315 Button {
316 text: "axis Y nice nmb"
317 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
318 }
283 }
319 }
General Comments 0
You need to be logged in to leave comments. Login now