Skip to content
Permalink
Browse files

Changed "save to db" provider capability check

  • Loading branch information
Emilio Loi
Emilio Loi committed Apr 13, 2013
1 parent 4826e28 commit 7aa831d752665291450bbbc5080a1e273767abdd
@@ -127,10 +127,10 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mSaveAsMenu->addAction( tr( "QGIS Layer Style File" ) );
mSaveAsMenu->addAction( tr( "SLD File" ) );

//Only if the provider is PostgresProvider add action to save the style in the DB
if( layer->providerType().compare( tr( "postgres" ) ) == 0 )
//Only if the provider support saving style to db add new choice
if( layer->dataProvider()->isSavingStyleToDBSupported() )
{
mSaveAsMenu->addAction( tr( "Save in Postgres") );
mSaveAsMenu->addAction( tr( "Save on database (%1)" ).arg( layer->providerType() ) );
}

QObject::connect( mSaveAsMenu, SIGNAL( triggered( QAction * ) ), this, SLOT( saveStyleAsMenuTriggered( QAction * ) ) );
@@ -624,7 +624,7 @@ void QgsVectorLayerProperties::saveStyleAs( StyleType styleType )

if( styleType == DB )
{
QString infoWindowTitle = QObject::tr( "Save style to Postgres" );
QString infoWindowTitle = QObject::tr( "Save style to DB (%1)" ).arg( layer->providerType() );
QString msgError;

QgsSaveStyleToDbDialog askToUser;
@@ -328,6 +328,12 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
QStringList errors();

/**
* It returns false by default.
* Must be implemented by providers that support saving style to db returning true
*/
virtual bool isSavingStyleToDBSupported() { return false; }


protected:
QVariant convertValue( QVariant::Type type, QString value );
@@ -163,6 +163,12 @@ class QgsPostgresProvider : public QgsVectorDataProvider
*/
bool isValid();


/**
* It returns true. Saving style to db is supported by this provider
*/
virtual bool isSavingStyleToDBSupported(){ return true; }

QgsAttributeList attributeIndexes();

QgsAttributeList pkAttributeIndexes() { return mPrimaryKeyAttrs; }

0 comments on commit 7aa831d

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