PnGuadeloupe / db-style-manager

Improve the workflow for managing styles in PostgreSQL
1 stars 2 forks source link

Save all layer styles to database as default #4

Open timlinux opened 5 years ago

timlinux commented 5 years ago

Hey @Gustry! I just found your plugin. I was kinda hoping it would do what the title of this ticket suggests - iterate over all my project layers, saving the style of each layer as the default in the PostgreSQL database.

Gustry commented 5 years ago

Hey @timlinux !

A new button can be added in the toolbar. I guess it should be very easy:

layers = QgsProject.instance().mapLayers()

for layer in layers.values():
    if layer.type() == QgsMapLayerType.VectorLayer:
        layer.saveStyleToDatabase('name of style', 'description or None', True, '')

I didn't try, but it should more or less that.