##// END OF EJS Templates
Scatter customization to QML api
Tero Ahola -
r1276:2661cb767b8b
parent child
Show More
@@ -80,6 +80,7 Rectangle {
80 interval = splineSeries.at(__activeIndex).y;
80 interval = splineSeries.at(__activeIndex).y;
81 scatterSeries.append(__activeIndex, interval);
81 scatterSeries.append(__activeIndex, interval);
82 scatterSeries.color = Qt.tint(scatterSeries.color, "#05FF0000");
82 scatterSeries.color = Qt.tint(scatterSeries.color, "#05FF0000");
83 scatterSeries.markerSize += 0.5;
83 } else {
84 } else {
84 // Switch the colors of the slice and the border
85 // Switch the colors of the slice and the border
85 wheelOfFortune.at(index).borderWidth = 2;
86 wheelOfFortune.at(index).borderWidth = 2;
@@ -40,7 +40,6 public:
40 Qt::ItemFlags flags ( const QModelIndex & index ) const;
40 Qt::ItemFlags flags ( const QModelIndex & index ) const;
41 void insertColumn(int column, const QModelIndex &parent = QModelIndex());
41 void insertColumn(int column, const QModelIndex &parent = QModelIndex());
42 void insertRow(int row, const QModelIndex &parent = QModelIndex());
42 void insertRow(int row, const QModelIndex &parent = QModelIndex());
43 /*Q_INVOKABLE*/ //bool removeRow(int row, const QModelIndex &parent = QModelIndex());
44 Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
43 Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
45 Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex());
44 Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex());
46
45
@@ -7,13 +7,13 ChartView::ChartView(QWidget *parent) :
7 //![1]
7 //![1]
8 QScatterSeries *series0 = new QScatterSeries();
8 QScatterSeries *series0 = new QScatterSeries();
9 series0->setName("scatter1");
9 series0->setName("scatter1");
10 series0->setShape(QScatterSeries::MarkerShapeCircle);
10 series0->setMarkerShape(QScatterSeries::MarkerShapeCircle);
11 series0->setSize(15.0);
11 series0->setMarkerSize(15.0);
12
12
13 QScatterSeries *series1 = new QScatterSeries();
13 QScatterSeries *series1 = new QScatterSeries();
14 series1->setName("scatter2");
14 series1->setName("scatter2");
15 series1->setShape(QScatterSeries::MarkerShapeCircle);
15 series1->setMarkerShape(QScatterSeries::MarkerShapeCircle);
16 series1->setSize(20.0);
16 series1->setMarkerSize(20.0);
17 //![1]
17 //![1]
18
18
19 //![2]
19 //![2]
@@ -56,6 +56,9 public:
56 qmlRegisterType<DeclarativePieSlice>(uri, 1, 0, "PieSlice");
56 qmlRegisterType<DeclarativePieSlice>(uri, 1, 0, "PieSlice");
57 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
57 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
58
58
59
60 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
61 QLatin1String("Trying to create uncreatable: QScatterSeries."));
59 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
62 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
60 QLatin1String("Trying to create uncreatable: QPieSeries."));
63 QLatin1String("Trying to create uncreatable: QPieSeries."));
61 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
64 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
@@ -118,4 +118,6 Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter)
118 return line;
118 return line;
119 }
119 }
120
120
121 #include "moc_qlineseries.cpp"
122
121 QTCOMMERCIALCHART_END_NAMESPACE
123 QTCOMMERCIALCHART_END_NAMESPACE
@@ -31,10 +31,11 class QLineSeriesPrivate;
31
31
32 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
32 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
33 {
33 {
34 Q_OBJECT
35
34 public:
36 public:
35 explicit QLineSeries(QObject *parent = 0);
37 explicit QLineSeries(QObject *parent = 0);
36 ~QLineSeries();
38 ~QLineSeries();
37
38 QAbstractSeries::SeriesType type() const;
39 QAbstractSeries::SeriesType type() const;
39
40
40 protected:
41 protected:
@@ -44,7 +45,6 private:
44 Q_DECLARE_PRIVATE(QLineSeries)
45 Q_DECLARE_PRIVATE(QLineSeries)
45 Q_DISABLE_COPY(QLineSeries)
46 Q_DISABLE_COPY(QLineSeries)
46 friend class LineChartItem;
47 friend class LineChartItem;
47
48 };
48 };
49
49
50 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
@@ -89,7 +89,7 QAbstractSeries::SeriesType QScatterSeries::type() const
89 /*!
89 /*!
90 Returns the shape used for drawing markers.
90 Returns the shape used for drawing markers.
91 */
91 */
92 QScatterSeries::MarkerShape QScatterSeries::shape() const
92 QScatterSeries::MarkerShape QScatterSeries::markerShape() const
93 {
93 {
94 Q_D(const QScatterSeries);
94 Q_D(const QScatterSeries);
95 return d->m_shape;
95 return d->m_shape;
@@ -99,7 +99,7 QScatterSeries::MarkerShape QScatterSeries::shape() const
99 Overrides the default shape of the marker items with a user defined \a shape. The default shape
99 Overrides the default shape of the marker items with a user defined \a shape. The default shape
100 is defined by chart theme setting.
100 is defined by chart theme setting.
101 */
101 */
102 void QScatterSeries::setShape(MarkerShape shape)
102 void QScatterSeries::setMarkerShape(MarkerShape shape)
103 {
103 {
104 Q_D(QScatterSeries);
104 Q_D(QScatterSeries);
105 if (d->m_shape != shape) {
105 if (d->m_shape != shape) {
@@ -111,7 +111,7 void QScatterSeries::setShape(MarkerShape shape)
111 /*!
111 /*!
112 Returns the size of the marker items.
112 Returns the size of the marker items.
113 */
113 */
114 qreal QScatterSeries::size() const
114 qreal QScatterSeries::markerSize() const
115 {
115 {
116 Q_D(const QScatterSeries);
116 Q_D(const QScatterSeries);
117 return d->m_size;
117 return d->m_size;
@@ -120,7 +120,7 qreal QScatterSeries::size() const
120 /*!
120 /*!
121 Set the \a size of the marker items. The default size is 15.
121 Set the \a size of the marker items. The default size is 15.
122 */
122 */
123 void QScatterSeries::setSize(qreal size)
123 void QScatterSeries::setMarkerSize(qreal size)
124 {
124 {
125 Q_D(QScatterSeries);
125 Q_D(QScatterSeries);
126
126
@@ -151,5 +151,6 Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter)
151 return scatter;
151 return scatter;
152 }
152 }
153
153
154 #include "moc_qscatterseries.cpp"
154
155
155 QTCOMMERCIALCHART_END_NAMESPACE
156 QTCOMMERCIALCHART_END_NAMESPACE
@@ -30,6 +30,10 class QScatterSeriesPrivate;
30
30
31 class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries
31 class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries
32 {
32 {
33 Q_OBJECT
34 Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape)
35 Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize)
36 Q_ENUMS(MarkerShape)
33
37
34 public:
38 public:
35 enum MarkerShape {
39 enum MarkerShape {
@@ -40,13 +44,11 public:
40 public:
44 public:
41 explicit QScatterSeries(QObject *parent = 0);
45 explicit QScatterSeries(QObject *parent = 0);
42 ~QScatterSeries();
46 ~QScatterSeries();
43
44 QAbstractSeries::SeriesType type() const;
47 QAbstractSeries::SeriesType type() const;
45
48 MarkerShape markerShape() const;
46 MarkerShape shape() const;
49 void setMarkerShape(MarkerShape shape);
47 void setShape(MarkerShape shape);
50 qreal markerSize() const;
48 qreal size() const;
51 void setMarkerSize(qreal size);
49 void setSize(qreal size);
50
52
51 private:
53 private:
52 Q_DECLARE_PRIVATE(QScatterSeries)
54 Q_DECLARE_PRIVATE(QScatterSeries)
@@ -167,21 +167,22 void ScatterChartItem::setBrush(const QBrush& brush)
167
167
168 void ScatterChartItem::handleUpdated()
168 void ScatterChartItem::handleUpdated()
169 {
169 {
170
171 int count = m_items.childItems().count();
170 int count = m_items.childItems().count();
172
171
173 if(count==0) return;
172 if(count==0) return;
174
173
175 bool recreate = m_size != m_series->size() || m_shape != m_series->shape();
174 bool recreate = m_size != m_series->markerSize() || m_shape != m_series->markerShape();
176
177 //TODO: only rewrite on size change
178
175
179 m_size = m_series->size();
176 m_size = m_series->markerSize();
180 m_shape = m_series->shape();
177 m_shape = m_series->markerShape();
181
178
182 if(recreate) {
179 if(recreate) {
180 // TODO: optimize handleUpdate to recreate points only in case shape changed
183 deletePoints(count);
181 deletePoints(count);
184 createPoints(count);
182 createPoints(count);
183
184 // Updating geometry is now safe, because it won't call handleUpdated unless it creates/deletes points
185 updateGeometry();
185 }
186 }
186
187
187 setPen(m_series->pen());
188 setPen(m_series->pen());
@@ -34,8 +34,8 class QSplineSeriesPrivate;
34 class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries
34 class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37 public:
38
37
38 public:
39 explicit QSplineSeries(QObject *parent = 0);
39 explicit QSplineSeries(QObject *parent = 0);
40 ~QSplineSeries();
40 ~QSplineSeries();
41 QAbstractSeries::SeriesType type() const;
41 QAbstractSeries::SeriesType type() const;
@@ -111,6 +111,7 QGroupBox *DataSerieDialog::rowCountSelector()
111 layout->addWidget(radio);
111 layout->addWidget(radio);
112 layout->addWidget(new QRadioButton("50"));
112 layout->addWidget(new QRadioButton("50"));
113 layout->addWidget(new QRadioButton("100"));
113 layout->addWidget(new QRadioButton("100"));
114 layout->addWidget(new QRadioButton("1000"));
114 layout->addWidget(new QRadioButton("10000"));
115 layout->addWidget(new QRadioButton("10000"));
115 layout->addWidget(new QRadioButton("100000"));
116 layout->addWidget(new QRadioButton("100000"));
116 layout->addWidget(new QRadioButton("1000000"));
117 layout->addWidget(new QRadioButton("1000000"));
General Comments 0
You need to be logged in to leave comments. Login now