Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save style in database #77

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Save style in database #77

wants to merge 2 commits into from

Conversation

pdrillin
Copy link
Contributor

@pdrillin pdrillin force-pushed the saveStyle branch 5 times, most recently from 21d1f7a to 3a7d0a6 Compare October 14, 2020 09:32
@pdrillin pdrillin force-pushed the saveStyle branch 2 times, most recently from 3963548 to 42123d0 Compare October 14, 2020 14:39
@pdrillin pdrillin marked this pull request as ready for review October 14, 2020 14:58
@pdrillin pdrillin force-pushed the saveStyle branch 3 times, most recently from e249799 to 17b9164 Compare October 14, 2020 17:45
@pdrillin pdrillin requested a review from rldhont October 14, 2020 17:45
@@ -168,12 +190,24 @@ def processAlgorithm(self, parameters, context, feedback):
output_layers.append(result.id())

# add attribute tables
style = self.parameterAsBool(parameters, self.STYLE, context)
save_style = self.parameterAsBool(parameters, self.SAVE_STYLE, context)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que c'est mieux de vérifier ici si not style and save_style, cela évite d'afficher plusieurs fois le message d'erreur qui est dans la boucle (puise que cela sera strictement le même message)
Utiliser feedback.reportError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avec report error le script continue ? @Gustry

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui le script continue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le script ne s'arrête qu'avec une exception QgsProcessingException. Le feedback, c'est juste pour faire du reporting.

output_layers.append(result.id())
if style and save_style:
msg_style = "Style for " + x + " successfully loaded and saved in database"
result.saveStyleToDatabase(result.name(), 'default description', True, '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mettre une meilleure description, comme par ex : "Véloroute - segment"

}
for lay in layers:
layer = QgsProject.instance().mapLayer(lay)
layer.saveStyleToDatabase(layer.name(), 'default description', True, '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Ce code plantera pour une couche qui n'est pas QgsVectorLayer
  • L'utilisateur a potentiellement plusieurs couches dans son projet QGIS, qui n'ont rien à voir avec VVV et qui ne sont pas de la base de données, il faut donc utiliser uniquement les couches VVV
  • Mettre une meilleure description par ex Extension Véloroute - segment ?

@@ -168,12 +190,24 @@ def processAlgorithm(self, parameters, context, feedback):
output_layers.append(result.id())

# add attribute tables
style = self.parameterAsBool(parameters, self.STYLE, context)
save_style = self.parameterAsBool(parameters, self.SAVE_STYLE, context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui le script continue

@pdrillin pdrillin force-pushed the saveStyle branch 8 times, most recently from b1727aa to d63b427 Compare October 16, 2020 07:49
Comment on lines +77 to +79
for lay in layers:
if lay in layers_required:
layer = layers[lay]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici ça ne peut pas marcher, @drillinP as-tu tester cet algo ?

if not style and save_style:
feedback.reportError(
"Le style des couches ne peut pas être chargé en base car aucun "
" style n'est importé"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" style n'est importé"
"style n'est importé"

Sinon il y a un double espace, car il est déjà présent L198

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants