Skip to content
Permalink
Browse files

Merge pull request #3665 from rouault/save_style_gpkg

 [FEATURE] [OGR provider] Load/save style in database for GPKG and Spatialite
  • Loading branch information
rouault committed Oct 26, 2016
2 parents 469f07c + 3bb7d5c commit 2d2ce00341a976a856be24e6981cb2c5ea031679
@@ -1438,6 +1438,9 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.</li>
<li>Removed fieldNameIndex(), use fields().lookupField() or fields().indexFromName() instead
<li>Renamed addAttributeAlias() to setFieldAlias()
<li>Renamed remAttributeAlias() to removeFieldAlias()
<li>saveStyleToDatabase(): msgError argument is correctly declared as output argument
<li>getStyleFromDatabase(): msgError argument is correctly declared as output argument
<li>loadNamedStyle(): theResultFlag argument is correctly declared as output argument
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayerEditBuffer QgsVectorLayerEditBuffer
@@ -662,11 +662,11 @@ class QgsVectorLayer : QgsMapLayer
* @param description
* @param useAsDefault
* @param uiFileContent
* @param msgError
* @param msgError (out)
*/
virtual void saveStyleToDatabase( const QString& name, const QString& description,
bool useAsDefault, const QString& uiFileContent,
QString &msgError );
QString &msgError /Out/ );

/**
* Lists all the style in db split into related to the layer and not related to
@@ -682,21 +682,21 @@ class QgsVectorLayer : QgsMapLayer
/**
* Will return the named style corresponding to style id provided
*/
virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError /Out/ );

/**
* Load a named style from file/local db/datasource db
* @param theURI the URI of the style or the URI of the layer
* @param theResultFlag will be set to true if a named style is correctly loaded
* @param loadFromLocalDb if true forces to load from local db instead of datasource one
*/
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag /Out/, bool loadFromLocalDb );

/**
* Calls loadNamedStyle( theURI, theResultFlag, false );
* Retained for backward compatibility
*/
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag );
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag /Out/ );

/** Read the symbology for the current layer from the Dom node supplied.
* @param node node that will contain the symbology definition for this layer.
@@ -1947,7 +1947,14 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
mConditionalStyles->writeXml( node, doc );

// save expression fields
mExpressionFieldBuffer->writeXml( node, doc );
if ( !mExpressionFieldBuffer )
{
// can happen when saving style on a invalid layer
QgsExpressionFieldBuffer dummy;
dummy.writeXml( node, doc );
}
else
mExpressionFieldBuffer->writeXml( node, doc );

// save readonly state
node.toElement().setAttribute( QStringLiteral( "readOnly" ), mReadOnly );
@@ -4107,7 +4114,7 @@ QString QgsVectorLayer::loadNamedStyle( const QString &theURI, bool &theResultFl
QString QgsVectorLayer::loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDB )
{
QgsDataSourceUri dsUri( theURI );
if ( !loadFromLocalDB && !dsUri.database().isEmpty() )
if ( !loadFromLocalDB && mDataProvider && mDataProvider->isSaveAndLoadStyleToDBSupported() )
{
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
QLibrary *myLib = pReg->providerLibrary( mProviderKey );

0 comments on commit 2d2ce00

Please sign in to comment.
You can’t perform that action at this time.