diff --git a/src/barchart/qbarmodelmapper.cpp b/src/barchart/qbarmodelmapper.cpp index b09aaba..5982617 100644 --- a/src/barchart/qbarmodelmapper.cpp +++ b/src/barchart/qbarmodelmapper.cpp @@ -58,6 +58,7 @@ void QBarModelMapper::setModel(QAbstractItemModel *model) connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); + connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); } QAbstractBarSeries* QBarModelMapper::series() const @@ -81,6 +82,7 @@ void QBarModelMapper::setSeries(QAbstractBarSeries *series) // connect the signals from the series connect(d->m_series, SIGNAL(barsetsAdded(QList)), d, SLOT(barSetsAdded(QList))); connect(d->m_series, SIGNAL(barsetsRemoved(QList)), d, SLOT(barSetsRemoved(QList))); + connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); } /*! @@ -247,6 +249,11 @@ QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) return m_model->index(barSection, posInBar + m_first); } +void QBarModelMapperPrivate::handleSeriesDestroyed() +{ + m_series = 0; +} + void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) { Q_UNUSED(topLeft) @@ -360,6 +367,11 @@ void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, blockSeriesSignals(false); } +void QBarModelMapperPrivate::handleModelDestroyed() +{ + m_model = 0; +} + void QBarModelMapperPrivate::insertData(int start, int end) { Q_UNUSED(end) diff --git a/src/barchart/qbarmodelmapper_p.h b/src/barchart/qbarmodelmapper_p.h index f0e4334..e1d931d 100644 --- a/src/barchart/qbarmodelmapper_p.h +++ b/src/barchart/qbarmodelmapper_p.h @@ -54,6 +54,7 @@ public Q_SLOTS: void modelRowsRemoved(QModelIndex parent, int start, int end); void modelColumnsAdded(QModelIndex parent, int start, int end); void modelColumnsRemoved(QModelIndex parent, int start, int end); + void handleModelDestroyed(); // for the series void barSetsAdded(QList sets); @@ -62,6 +63,7 @@ public Q_SLOTS: void valuesRemoved(int index, int count); void barLabelChanged(); void barValueChanged(int index); + void handleSeriesDestroyed(); void initializeBarFromModel(); diff --git a/src/piechart/qpiemodelmapper.cpp b/src/piechart/qpiemodelmapper.cpp index 1d1c06c..14e62fc 100644 --- a/src/piechart/qpiemodelmapper.cpp +++ b/src/piechart/qpiemodelmapper.cpp @@ -56,6 +56,7 @@ void QPieModelMapper::setModel(QAbstractItemModel *model) connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); + connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); } QPieSeries* QPieModelMapper::series() const @@ -79,6 +80,7 @@ void QPieModelMapper::setSeries(QPieSeries *series) // connect the signals from the series connect(d->m_series, SIGNAL(added(QList)), d, SLOT(slicesAdded(QList))); connect(d->m_series, SIGNAL(removed(QList)), d, SLOT(slicesRemoved(QList))); + connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); } /*! @@ -360,6 +362,11 @@ void QPieModelMapperPrivate::sliceValueChanged() blockModelSignals(false); } +void QPieModelMapperPrivate::handleSeriesDestroyed() +{ + m_series = 0; +} + void QPieModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) { if (m_model == 0 || m_series == 0) @@ -443,6 +450,11 @@ void QPieModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, blockSeriesSignals(false); } +void QPieModelMapperPrivate::handleModelDestroyed() +{ + m_model = 0; +} + void QPieModelMapperPrivate::insertData(int start, int end) { if (m_model == 0 || m_series == 0) diff --git a/src/piechart/qpiemodelmapper_p.h b/src/piechart/qpiemodelmapper_p.h index 89242ff..ac32d5b 100644 --- a/src/piechart/qpiemodelmapper_p.h +++ b/src/piechart/qpiemodelmapper_p.h @@ -56,12 +56,14 @@ public Q_SLOTS: void modelRowsRemoved(QModelIndex parent, int start, int end); void modelColumnsAdded(QModelIndex parent, int start, int end); void modelColumnsRemoved(QModelIndex parent, int start, int end); + void handleModelDestroyed(); // for the series void slicesAdded(QList slices); void slicesRemoved(QList slices); void sliceLabelChanged(); void sliceValueChanged(); + void handleSeriesDestroyed(); void initializePieFromModel(); diff --git a/src/xychart/qxymodelmapper.cpp b/src/xychart/qxymodelmapper.cpp index 9db2f8f..5ca618f 100644 --- a/src/xychart/qxymodelmapper.cpp +++ b/src/xychart/qxymodelmapper.cpp @@ -64,6 +64,7 @@ void QXYModelMapper::setModel(QAbstractItemModel *model) connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); + connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); } /*! @@ -94,6 +95,7 @@ void QXYModelMapper::setSeries(QXYSeries *series) connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); + connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); } /*! @@ -291,6 +293,11 @@ void QXYModelMapperPrivate::handlePointReplaced(int pointPos) blockModelSignals(false); } +void QXYModelMapperPrivate::handleSeriesDestroyed() +{ + m_series = 0; +} + void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) { if (m_model == 0 || m_series == 0) @@ -391,6 +398,11 @@ void QXYModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, i blockSeriesSignals(false); } +void QXYModelMapperPrivate::handleModelDestroyed() +{ + m_model = 0; +} + void QXYModelMapperPrivate::insertData(int start, int end) { if (m_model == 0 || m_series == 0) diff --git a/src/xychart/qxymodelmapper_p.h b/src/xychart/qxymodelmapper_p.h index 840b097..506d1dd 100644 --- a/src/xychart/qxymodelmapper_p.h +++ b/src/xychart/qxymodelmapper_p.h @@ -56,11 +56,13 @@ public Q_SLOTS: void modelRowsRemoved(QModelIndex parent, int start, int end); void modelColumnsAdded(QModelIndex parent, int start, int end); void modelColumnsRemoved(QModelIndex parent, int start, int end); + void handleModelDestroyed(); // for the series void handlePointAdded(int pointPos); void handlePointRemoved(int pointPos); void handlePointReplaced(int pointPos); + void handleSeriesDestroyed(); void initializeXYFromModel();