mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
Fix conditional styles in feature list view do not update when
the layer's conditional styles are changed
This commit is contained in:
parent
5f7264d4d1
commit
bccd5a4610
@ -31,10 +31,15 @@ QgsFeatureListModel::QgsFeatureListModel( QgsAttributeTableFilterModel *sourceMo
|
|||||||
|
|
||||||
void QgsFeatureListModel::setSourceModel( QgsAttributeTableFilterModel *sourceModel )
|
void QgsFeatureListModel::setSourceModel( QgsAttributeTableFilterModel *sourceModel )
|
||||||
{
|
{
|
||||||
|
if ( mSourceLayer )
|
||||||
|
disconnect( mSourceLayer->conditionalStyles(), &QgsConditionalLayerStyles::changed, this, &QgsFeatureListModel::conditionalStylesChanged );
|
||||||
|
|
||||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||||
mExpressionContext = sourceModel->layer()->createExpressionContext();
|
mExpressionContext = sourceModel->layer()->createExpressionContext();
|
||||||
mFilterModel = sourceModel;
|
mFilterModel = sourceModel;
|
||||||
|
|
||||||
|
mSourceLayer = sourceModel->layer();
|
||||||
|
connect( mSourceLayer->conditionalStyles(), &QgsConditionalLayerStyles::changed, this, &QgsFeatureListModel::conditionalStylesChanged );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsVectorLayerCache *QgsFeatureListModel::layerCache()
|
QgsVectorLayerCache *QgsFeatureListModel::layerCache()
|
||||||
@ -265,6 +270,12 @@ void QgsFeatureListModel::onEndInsertRows( const QModelIndex &parent, int first,
|
|||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsFeatureListModel::conditionalStylesChanged()
|
||||||
|
{
|
||||||
|
mRowStylesMap.clear();
|
||||||
|
emit dataChanged( index( 0, 0 ), index( rowCount() - 1, columnCount() - 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsFeatureListModel::sortByDisplayExpression() const
|
bool QgsFeatureListModel::sortByDisplayExpression() const
|
||||||
{
|
{
|
||||||
return mSortByDisplayExpression;
|
return mSortByDisplayExpression;
|
||||||
|
@ -185,6 +185,10 @@ class GUI_EXPORT QgsFeatureListModel : public QSortFilterProxyModel, public QgsF
|
|||||||
*/
|
*/
|
||||||
Q_DECL_DEPRECATED void onEndInsertRows( const QModelIndex &parent, int first, int last );
|
Q_DECL_DEPRECATED void onEndInsertRows( const QModelIndex &parent, int first, int last );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void conditionalStylesChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QgsExpression mDisplayExpression;
|
mutable QgsExpression mDisplayExpression;
|
||||||
QgsAttributeTableFilterModel *mFilterModel = nullptr;
|
QgsAttributeTableFilterModel *mFilterModel = nullptr;
|
||||||
@ -193,6 +197,7 @@ class GUI_EXPORT QgsFeatureListModel : public QSortFilterProxyModel, public QgsF
|
|||||||
mutable QgsExpressionContext mExpressionContext;
|
mutable QgsExpressionContext mExpressionContext;
|
||||||
mutable QMap< QgsFeatureId, QList<QgsConditionalStyle> > mRowStylesMap;
|
mutable QMap< QgsFeatureId, QList<QgsConditionalStyle> > mRowStylesMap;
|
||||||
bool mSortByDisplayExpression = false;
|
bool mSortByDisplayExpression = false;
|
||||||
|
QPointer< QgsVectorLayer > mSourceLayer;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QgsFeatureListModel::FeatureInfo )
|
Q_DECLARE_METATYPE( QgsFeatureListModel::FeatureInfo )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user