-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Conversation
21d1f7a
to
3a7d0a6
Compare
3963548
to
42123d0
Compare
e249799
to
17b9164
Compare
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oui le script continue
There was a problem hiding this comment.
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, '') |
There was a problem hiding this comment.
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"
veloroutes_voies_vertes/processing/config/save_style_database.py
Outdated
Show resolved
Hide resolved
veloroutes_voies_vertes/processing/structure/create_database_structure.py
Outdated
Show resolved
Hide resolved
veloroutes_voies_vertes/processing/structure/upgrade_database_structure.py
Outdated
Show resolved
Hide resolved
veloroutes_voies_vertes/processing/config/save_style_database.py
Outdated
Show resolved
Hide resolved
} | ||
for lay in layers: | ||
layer = QgsProject.instance().mapLayer(lay) | ||
layer.saveStyleToDatabase(layer.name(), 'default description', True, '') |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oui le script continue
b1727aa
to
d63b427
Compare
for lay in layers: | ||
if lay in layers_required: | ||
layer = layers[lay] |
There was a problem hiding this comment.
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é" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" style n'est importé" | |
"style n'est importé" |
Sinon il y a un double espace, car il est déjà présent L198
Description