mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Move reponsibility for saving/restoring temporal properties
to QgsMapLayer::read/writeCommonStyle Correctly stores these settings in QML files and when duplicating layers Fixes #36531, fixes #36530
This commit is contained in:
parent
8499e09e28
commit
79f8fd9892
@ -96,6 +96,7 @@ This is the base class for all map layer types (vector, raster).
|
||||
CustomProperties,
|
||||
GeometryOptions,
|
||||
Relations,
|
||||
Temporal,
|
||||
AllStyleCategories
|
||||
};
|
||||
typedef QFlags<QgsMapLayer::StyleCategory> StyleCategories;
|
||||
|
@ -1033,8 +1033,6 @@ bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &con
|
||||
QString errorMsg;
|
||||
readSymbology( layer_node, errorMsg, context );
|
||||
|
||||
// read temporal
|
||||
temporalProperties()->readXml( layer_node.toElement(), context );
|
||||
if ( !mTemporalProperties->timeExtent().begin().isValid() )
|
||||
temporalProperties()->setDefaultsFromDataProviderTemporalCapabilities( dataProvider()->temporalCapabilities() );
|
||||
|
||||
@ -1089,8 +1087,6 @@ bool QgsMeshLayer::writeXml( QDomNode &layer_node, QDomDocument &document, const
|
||||
}
|
||||
layer_node.appendChild( elemExtraDatasets );
|
||||
}
|
||||
// write temporal
|
||||
mTemporalProperties->writeXml( mapLayerNode, document, context );
|
||||
|
||||
QDomElement elemStaticDataset = document.createElement( QStringLiteral( "static-active-dataset" ) );
|
||||
if ( mStaticScalarDatasetIndex.isValid() )
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsxmlutils.h"
|
||||
#include "qgsstringutils.h"
|
||||
#include "qgsmaplayertemporalproperties.h"
|
||||
|
||||
QString QgsMapLayer::extensionPropertyType( QgsMapLayer::PropertyType type )
|
||||
{
|
||||
@ -579,6 +580,11 @@ void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &doc
|
||||
layerElement.appendChild( layerFlagsElem );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( Temporal ) && const_cast< QgsMapLayer * >( this )->temporalProperties() )
|
||||
{
|
||||
const_cast< QgsMapLayer * >( this )->temporalProperties()->writeXml( layerElement, document, context );
|
||||
}
|
||||
|
||||
// custom properties
|
||||
if ( categories.testFlag( CustomProperties ) )
|
||||
{
|
||||
@ -1672,6 +1678,11 @@ void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsRea
|
||||
}
|
||||
setFlags( flags );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( Temporal ) && temporalProperties() )
|
||||
{
|
||||
temporalProperties()->readXml( layerElement.toElement(), context );
|
||||
}
|
||||
}
|
||||
|
||||
QUndoStack *QgsMapLayer::undoStack()
|
||||
|
@ -167,8 +167,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
CustomProperties = 1 << 11, //!< Custom properties (by plugins for instance)
|
||||
GeometryOptions = 1 << 12, //!< Geometry validation configuration
|
||||
Relations = 1 << 13, //!< Relations
|
||||
Temporal = 1 << 14, //!< Temporal properties
|
||||
AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
|
||||
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations,
|
||||
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations | Temporal,
|
||||
};
|
||||
Q_ENUM( StyleCategory )
|
||||
Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
|
||||
|
@ -1561,8 +1561,6 @@ bool QgsVectorLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &c
|
||||
return false;
|
||||
}
|
||||
|
||||
mTemporalProperties->readXml( layer_node.toElement(), context );
|
||||
|
||||
readStyleManager( layer_node );
|
||||
|
||||
QDomNode depsNode = layer_node.namedItem( QStringLiteral( "dataDependencies" ) );
|
||||
@ -1877,9 +1875,6 @@ bool QgsVectorLayer::writeXml( QDomNode &layer_node,
|
||||
// save expression fields
|
||||
mExpressionFieldBuffer->writeXml( layer_node, document );
|
||||
|
||||
// write temporal properties
|
||||
mTemporalProperties->writeXml( mapLayerNode, document, context );
|
||||
|
||||
writeStyleManager( layer_node, document );
|
||||
|
||||
// auxiliary layer
|
||||
|
@ -1965,8 +1965,6 @@ bool QgsRasterLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &c
|
||||
}
|
||||
}
|
||||
|
||||
mTemporalProperties->readXml( layer_node.toElement(), context );
|
||||
|
||||
readStyleManager( layer_node );
|
||||
|
||||
return res;
|
||||
@ -2069,9 +2067,6 @@ bool QgsRasterLayer::writeXml( QDomNode &layer_node,
|
||||
layer_node.appendChild( noData );
|
||||
}
|
||||
|
||||
// write temporal properties
|
||||
mTemporalProperties->writeXml( mapLayerNode, document, context );
|
||||
|
||||
writeStyleManager( layer_node, document );
|
||||
|
||||
//write out the symbology
|
||||
|
@ -231,6 +231,19 @@ QVariant QgsMapLayerStyleCategoriesModel::data( const QModelIndex &index, int ro
|
||||
return QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/relations.svg" ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case QgsMapLayer::StyleCategory::Temporal:
|
||||
switch ( role )
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return tr( "Temporal Properties" );
|
||||
case Qt::ToolTipRole:
|
||||
return tr( "Temporal properties" );
|
||||
case Qt::DecorationRole:
|
||||
return QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/temporal.svg" ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case QgsMapLayer::StyleCategory::AllStyleCategories:
|
||||
switch ( role )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user