##// END OF EJS Templates
Added NOTIFY to PieModelMapper class properties
Marek Rosa -
r1474:99b2f41bb95e
parent child
Show More
@@ -70,7 +70,10 int QHPieModelMapper::valuesRow() const
70 */
70 */
71 void QHPieModelMapper::setValuesRow(int valuesRow)
71 void QHPieModelMapper::setValuesRow(int valuesRow)
72 {
72 {
73 QPieModelMapper::setValuesSection(valuesRow);
73 if (valuesRow != valuesSection()) {
74 QPieModelMapper::setValuesSection(valuesRow);
75 emit valuesRowChanged();
76 }
74 }
77 }
75
78
76 /*!
79 /*!
@@ -87,7 +90,10 int QHPieModelMapper::labelsRow() const
87 */
90 */
88 void QHPieModelMapper::setLabelsRow(int labelsRow)
91 void QHPieModelMapper::setLabelsRow(int labelsRow)
89 {
92 {
90 QPieModelMapper::setLabelsSection(labelsRow);
93 if (labelsRow != labelsSection()) {
94 QPieModelMapper::setLabelsSection(labelsRow);
95 emit labelsRowChanged();
96 }
91 }
97 }
92
98
93 #include "moc_qhpiemodelmapper.cpp"
99 #include "moc_qhpiemodelmapper.cpp"
@@ -28,8 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 class QTCOMMERCIALCHART_EXPORT QHPieModelMapper : public QPieModelMapper
28 class QTCOMMERCIALCHART_EXPORT QHPieModelMapper : public QPieModelMapper
29 {
29 {
30 Q_OBJECT
30 Q_OBJECT
31 Q_PROPERTY(int valuesRow READ valuesRow WRITE setValuesRow)
31 Q_PROPERTY(int valuesRow READ valuesRow WRITE setValuesRow NOTIFY valuesRowChanged)
32 Q_PROPERTY(int labelsRow READ labelsRow WRITE setLabelsRow)
32 Q_PROPERTY(int labelsRow READ labelsRow WRITE setLabelsRow NOTIFY labelsRowChanged)
33
33
34 public:
34 public:
35 explicit QHPieModelMapper(QObject *parent = 0);
35 explicit QHPieModelMapper(QObject *parent = 0);
@@ -39,6 +39,10 public:
39
39
40 int labelsRow() const;
40 int labelsRow() const;
41 void setLabelsRow(int labelsRow);
41 void setLabelsRow(int labelsRow);
42
43 Q_SIGNALS:
44 void valuesRowChanged();
45 void labelsRowChanged();
42 };
46 };
43
47
44 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
@@ -97,6 +97,8 void QPieModelMapper::setModel(QAbstractItemModel *model)
97 connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
97 connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
98 connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
98 connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
99 connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
99 connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
100
101 emit modelReplaced();
100 }
102 }
101
103
102 QPieSeries* QPieModelMapper::series() const
104 QPieSeries* QPieModelMapper::series() const
@@ -120,6 +122,8 void QPieModelMapper::setSeries(QPieSeries *series)
120 // connect the signals from the series
122 // connect the signals from the series
121 connect(d->m_series, SIGNAL(added(QList<QPieSlice*>)), d, SLOT(slicesAdded(QList<QPieSlice*>)));
123 connect(d->m_series, SIGNAL(added(QList<QPieSlice*>)), d, SLOT(slicesAdded(QList<QPieSlice*>)));
122 connect(d->m_series, SIGNAL(removed(QList<QPieSlice*>)), d, SLOT(slicesRemoved(QList<QPieSlice*>)));
124 connect(d->m_series, SIGNAL(removed(QList<QPieSlice*>)), d, SLOT(slicesRemoved(QList<QPieSlice*>)));
125
126 emit seriesReplaced();
123 }
127 }
124
128
125 int QPieModelMapper::first() const
129 int QPieModelMapper::first() const
@@ -131,8 +135,12 int QPieModelMapper::first() const
131 void QPieModelMapper::setFirst(int first)
135 void QPieModelMapper::setFirst(int first)
132 {
136 {
133 Q_D(QPieModelMapper);
137 Q_D(QPieModelMapper);
134 d->m_first = qMax(first, 0);
138 if (first != d->m_first) {
135 d->initializePieFromModel();
139 d->m_first = qMax(first, 0);
140 d->initializePieFromModel();
141
142 emit firstChanged();
143 }
136 }
144 }
137
145
138 int QPieModelMapper::count() const
146 int QPieModelMapper::count() const
@@ -144,8 +152,12 int QPieModelMapper::count() const
144 void QPieModelMapper::setCount(int count)
152 void QPieModelMapper::setCount(int count)
145 {
153 {
146 Q_D(QPieModelMapper);
154 Q_D(QPieModelMapper);
147 d->m_count = qMax(count, -1);
155 if (count != d->m_count) {
148 d->initializePieFromModel();
156 d->m_count = qMax(count, -1);
157 d->initializePieFromModel();
158
159 emit countChanged();
160 }
149 }
161 }
150
162
151 /*!
163 /*!
@@ -500,7 +512,7 void QPieModelMapperPrivate::insertData(int start, int end)
500 if (valueIndex.isValid() && labelIndex.isValid()) {
512 if (valueIndex.isValid() && labelIndex.isValid()) {
501 QPieSlice *slice = new QPieSlice;
513 QPieSlice *slice = new QPieSlice;
502 slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble());
514 slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble());
503 slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString());
515 slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString());
504 connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged()));
516 connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged()));
505 connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged()));
517 connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged()));
506 m_series->insert(i - m_first, slice);
518 m_series->insert(i - m_first, slice);
@@ -583,7 +595,7 void QPieModelMapperPrivate::initializePieFromModel()
583 slicePos++;
595 slicePos++;
584 valueIndex = valueModelIndex(slicePos);
596 valueIndex = valueModelIndex(slicePos);
585 labelIndex = labelModelIndex(slicePos);
597 labelIndex = labelModelIndex(slicePos);
586 }
598 }
587 blockSeriesSignals(false);
599 blockSeriesSignals(false);
588 }
600 }
589
601
@@ -34,10 +34,10 class QPieSeries;
34 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
34 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37 Q_PROPERTY(QPieSeries *series READ series WRITE setSeries)
37 Q_PROPERTY(QPieSeries *series READ series WRITE setSeries NOTIFY seriesReplaced)
38 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel)
38 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced)
39 Q_PROPERTY(int first READ first WRITE setFirst)
39 Q_PROPERTY(int first READ first WRITE setFirst NOTIFY firstChanged)
40 Q_PROPERTY(int count READ count WRITE setCount)
40 Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
41 Q_ENUMS(Qt::Orientation)
41 Q_ENUMS(Qt::Orientation)
42
42
43 protected:
43 protected:
@@ -68,6 +68,12 protected:
68 Qt::Orientation orientation() const;
68 Qt::Orientation orientation() const;
69 void setOrientation(Qt::Orientation orientation);
69 void setOrientation(Qt::Orientation orientation);
70
70
71 Q_SIGNALS:
72 void seriesReplaced();
73 void modelReplaced();
74 void firstChanged();
75 void countChanged();
76
71 protected:
77 protected:
72 QPieModelMapperPrivate * const d_ptr;
78 QPieModelMapperPrivate * const d_ptr;
73 Q_DECLARE_PRIVATE(QPieModelMapper)
79 Q_DECLARE_PRIVATE(QPieModelMapper)
@@ -70,7 +70,10 int QVPieModelMapper::valuesColumn() const
70 */
70 */
71 void QVPieModelMapper::setValuesColumn(int valuesColumn)
71 void QVPieModelMapper::setValuesColumn(int valuesColumn)
72 {
72 {
73 QPieModelMapper::setValuesSection(valuesColumn);
73 if (valuesColumn != valuesSection()) {
74 QPieModelMapper::setValuesSection(valuesColumn);
75 emit valuesColumnChanged();
76 }
74 }
77 }
75
78
76 /*!
79 /*!
@@ -87,7 +90,10 int QVPieModelMapper::labelsColumn() const
87 */
90 */
88 void QVPieModelMapper::setLabelsColumn(int labelsColumn)
91 void QVPieModelMapper::setLabelsColumn(int labelsColumn)
89 {
92 {
90 QPieModelMapper::setLabelsSection(labelsColumn);
93 if (labelsColumn != labelsSection()) {
94 QPieModelMapper::setLabelsSection(labelsColumn);
95 emit labelsColumnChanged();
96 }
91 }
97 }
92
98
93 #include "moc_qvpiemodelmapper.cpp"
99 #include "moc_qvpiemodelmapper.cpp"
@@ -28,8 +28,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 class QTCOMMERCIALCHART_EXPORT QVPieModelMapper : public QPieModelMapper
28 class QTCOMMERCIALCHART_EXPORT QVPieModelMapper : public QPieModelMapper
29 {
29 {
30 Q_OBJECT
30 Q_OBJECT
31 Q_PROPERTY(int valuesColumn READ valuesColumn WRITE setValuesColumn)
31 Q_PROPERTY(int valuesColumn READ valuesColumn WRITE setValuesColumn NOTIFY valuesColumnChanged)
32 Q_PROPERTY(int labelsColumn READ labelsColumn WRITE setLabelsColumn)
32 Q_PROPERTY(int labelsColumn READ labelsColumn WRITE setLabelsColumn NOTIFY labelsColumnChanged)
33
33
34 public:
34 public:
35 explicit QVPieModelMapper(QObject *parent = 0);
35 explicit QVPieModelMapper(QObject *parent = 0);
@@ -39,6 +39,10 public:
39
39
40 int labelsColumn() const;
40 int labelsColumn() const;
41 void setLabelsColumn(int labelsColumn);
41 void setLabelsColumn(int labelsColumn);
42
43 Q_SIGNALS:
44 void valuesColumnChanged();
45 void labelsColumnChanged();
42 };
46 };
43
47
44 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now