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