Skip to content

Commit 1bf9688

Browse files
pigrecoclaude
andcommitted
Merge branch 'qgis4-porting': Release v1.6.1 QGIS 4 / Qt6
Porting completo QGIS 4 / Qt6 / PyQt6 (v1.6.0) + fix setShowFeatureCount rimosso in QGIS 4.0.1 (v1.6.1). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 parents 4c16613 + e39e794 commit 1bf9688

4 files changed

Lines changed: 59 additions & 110 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ L'autore declina ogni responsabilità per eventuali usi impropri del plugin o pe
124124

125125
## Changelog
126126

127+
- **[1.6.1](https://github.com/pigreco/wfs_catasto_download_particelle_bbox/releases/tag/v1.6.1)** - Fix QGIS 4.0.1: `QgsLayerTreeLayer.setShowFeatureCount()` rimosso in QGIS 4 — sostituito con `setCustomProperty("showFeatureCount", 1/0)`
128+
- **[1.6.0](https://github.com/pigreco/wfs_catasto_download_particelle_bbox/releases/tag/v1.6.0)** - Porting QGIS 4 / Qt6 / PyQt6: rimossi tutti i blocchi try/except di compatibilità Qt5; enum scoped Qt6 usati direttamente; `QVariant.String/Int` sostituiti con `QMetaType.Type.QString/Int` per `QgsField`; `qgisMinimumVersion` aggiornato a 3.34, `qgisMaximumVersion=4.99` aggiunto
127129
- **[1.5.2](https://github.com/pigreco/wfs_catasto_download_particelle_bbox/releases/tag/v1.5.2)** - Fix: icona SVG — rimosso riferimento `#pattern16` non risolto che causava warning Qt6 "Could not resolve property"; fix GUI tema scuro Win11/Qt6 — rimossi colori testo hardcoded (`#000`, `#333`, `#555`) dai label, il testo segue ora il colore di sistema
128130
- **[1.5.1](https://github.com/pigreco/wfs_catasto_download_particelle_bbox/releases/tag/v1.5.1)** - Fix issue [#9](https://github.com/pigreco/wfs_catasto_download_particelle_bbox/issues/9): rimossa combo "Aggiungi a" locale dalla riga Punti — il controllo OUTPUT globale è ora l'unico punto per scegliere il layer di destinazione; fix compatibilità Qt6 per `QMessageBox.Yes/No`
129131
- **[1.5.0](https://github.com/pigreco/wfs_catasto_download_particelle_bbox/releases/tag/v1.5.0)** - Output Unificato: checkbox + combo globale per accodare i risultati di qualsiasi modalità (BBox, Poligono, Linea, Punti) a un layer Particelle WFS esistente; GUI completamente ridisegnata con layout compatto a lista verticale e separatori; fix crash `KeyError: '-1'` con "Espandi riferimento catastale" in modalità append — avviso con scelta Sì/No prima di procedere

metadata.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
[general]
66
name=WFS Catasto Download Particelle BBox
7-
qgisMinimumVersion=3.0
7+
qgisMinimumVersion=3.34
8+
qgisMaximumVersion=4.99
89
description=Download particelle catastali dal WFS dell'Agenzia delle Entrate tramite BBox, selezione poligono, linea con buffer o layer di punti.
9-
version=1.5.2
10+
version=1.6.1
1011
author=Salvatore Fiandaca
1112
email=pigrecoinfinito@gmail.com
1213

@@ -17,7 +18,7 @@ about=WFS Catasto Download Particelle BBox - Plugin per QGIS che consente di sca
1718
3) Seleziona Linea: clicca su una linea e crea un buffer personalizzabile (0-100m) per scaricare le particelle che lo intersecano.
1819
4) Seleziona Punti: clicca su un layer di punti (o direttamente in mappa) per scaricare le particelle che contengono i punti. Supporta selezione parziale e auto-riproiezione UTM per CRS geografici.
1920
Opzione "Espandi riferimento catastale": estrae dal campo NATIONALCADASTRALREFERENCE i campi sezione, foglio, allegato e sviluppo (formato CCCCZFFFFAS).
20-
Supporta download multi-tile con progress bar, deduplicazione feature e filtro spaziale. Compatibile con QGIS 3 (Qt5) e QGIS 4 (Qt6).
21+
Supporta download multi-tile con progress bar, deduplicazione feature e filtro spaziale. Compatibile con QGIS 4 (Qt6/PyQt6).
2122
---
2223
EN: A QGIS plugin for downloading cadastral parcels from the Italian Revenue Agency (Agenzia delle Entrate) WFS INSPIRE service. Three selection modes: draw BBox, select polygon, select line with customizable buffer (0-100m). Optional expansion of NATIONALCADASTRALREFERENCE into section, sheet, attachment and development fields. Supports multi-tile download with progress bar, feature deduplication and spatial filtering.
2324
DISCLAIMER: Please use this plugin responsibly. Massive or repeated downloads may overload the WFS service of the Italian Revenue Agency, causing disruptions for all users.
@@ -30,6 +31,16 @@ repository=https://github.com/pigreco/wfs_catasto_download_particelle_bbox
3031

3132
hasProcessingProvider=no
3233
changelog=
34+
1.6.1 - Fix QGIS 4.0.1: QgsLayerTreeLayer.setShowFeatureCount() rimosso
35+
in QGIS 4 - sostituito con setCustomProperty("showFeatureCount",
36+
1/0) che e' il meccanismo sottostante compatibile con tutte le
37+
versioni.
38+
1.6.0 - Porting QGIS 4 / Qt6 / PyQt6: rimossi tutti i blocchi try/except di
39+
compatibilita' Qt5. Enum scoped Qt6 usati direttamente
40+
(Qt.WindowModality.WindowModal, Qt.PenStyle.DashLine, ecc.).
41+
QVariant.String/Int sostituiti con QMetaType.Type.QString/Int
42+
per QgsField. QgsMinimumVersion aggiornato a 3.34,
43+
qgisMaximumVersion=4.99 aggiunto.
3344
1.5.2 - Fix: icona SVG - rimosso pattern16 non risolto che causava warning Qt6
3445
"Could not resolve property: #pattern16".
3546
Fix: GUI - rimossi colori testo hardcoded (#000, #333, #555) dai label

wfs_catasto_download_particelle_bbox_d.py

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
==============================================
44
Interfaccia grafica per la scelta della modalità di selezione area.
55
6-
Compatibile con QGIS 3 (Qt5) e QGIS 4 (Qt6).
6+
Compatibile con QGIS 4 (Qt6/PyQt6).
77
"""
88

99
import configparser
@@ -28,42 +28,22 @@
2828
QMessageBox,
2929
)
3030

31-
# Compatibilità Qt5 / Qt6 - enum scoped
32-
try:
33-
_WinHelpHint = Qt.WindowType.WindowContextHelpButtonHint
34-
_WinCloseHint = Qt.WindowType.WindowCloseButtonHint
35-
_AlignCenter = Qt.AlignmentFlag.AlignCenter
36-
_RichText = Qt.TextFormat.RichText
37-
except AttributeError:
38-
_WinHelpHint = Qt.WindowContextHelpButtonHint
39-
_WinCloseHint = Qt.WindowCloseButtonHint
40-
_AlignCenter = Qt.AlignCenter
41-
_RichText = Qt.RichText
42-
43-
try:
44-
_KeepAspectRatio = Qt.AspectRatioMode.KeepAspectRatio
45-
_SmoothTransformation = Qt.TransformationMode.SmoothTransformation
46-
except AttributeError:
47-
_KeepAspectRatio = Qt.KeepAspectRatio
48-
_SmoothTransformation = Qt.SmoothTransformation
31+
from qgis.core import Qgis
32+
33+
_WinHelpHint = Qt.WindowType.WindowContextHelpButtonHint
34+
_WinCloseHint = Qt.WindowType.WindowCloseButtonHint
35+
_AlignCenter = Qt.AlignmentFlag.AlignCenter
36+
_RichText = Qt.TextFormat.RichText
37+
_KeepAspectRatio = Qt.AspectRatioMode.KeepAspectRatio
38+
_SmoothTransformation = Qt.TransformationMode.SmoothTransformation
4939

5040

5141
def _is_point_layer(layer):
52-
"""Verifica se il layer è puntuale (compatibile Qt5/Qt6)."""
53-
try:
54-
from qgis.core import Qgis
55-
return layer.geometryType() == Qgis.GeometryType.Point
56-
except AttributeError:
57-
return layer.geometryType() == 0
42+
return layer.geometryType() == Qgis.GeometryType.Point
5843

5944

6045
def _is_polygon_layer(layer):
61-
"""Verifica se il layer è poligonale (compatibile Qt5/Qt6)."""
62-
try:
63-
from qgis.core import Qgis
64-
return layer.geometryType() == Qgis.GeometryType.Polygon
65-
except AttributeError:
66-
return layer.geometryType() == 2
46+
return layer.geometryType() == Qgis.GeometryType.Polygon
6747

6848

6949
def _plugin_version():
@@ -281,7 +261,7 @@ def _init_ui(self):
281261

282262
# Linea spessa sotto il titolo
283263
sep_title = QFrame()
284-
sep_title.setFrameShape(QFrame.Shape.HLine if hasattr(QFrame, 'Shape') else QFrame.HLine)
264+
sep_title.setFrameShape(QFrame.Shape.HLine)
285265
sep_title.setStyleSheet("border: none; border-top: 2px solid #aaa;")
286266
layout.addWidget(sep_title)
287267

@@ -298,7 +278,7 @@ def _init_ui(self):
298278

299279
# --- Separatore ---
300280
sep = QFrame()
301-
sep.setFrameShape(QFrame.Shape.HLine if hasattr(QFrame, 'Shape') else QFrame.HLine)
281+
sep.setFrameShape(QFrame.Shape.HLine)
302282
sep.setStyleSheet("color: #ccc;")
303283
layout.addWidget(sep)
304284

@@ -314,7 +294,7 @@ def _init_ui(self):
314294

315295
# --- Separatore ---
316296
sep2 = QFrame()
317-
sep2.setFrameShape(QFrame.Shape.HLine if hasattr(QFrame, 'Shape') else QFrame.HLine)
297+
sep2.setFrameShape(QFrame.Shape.HLine)
318298
sep2.setStyleSheet("color: #ccc;")
319299
layout.addWidget(sep2)
320300

@@ -363,7 +343,7 @@ def _make_row(self):
363343
def _make_sep(self):
364344
"""Crea una linea separatrice orizzontale."""
365345
sep = QFrame()
366-
sep.setFrameShape(QFrame.Shape.HLine if hasattr(QFrame, 'Shape') else QFrame.HLine)
346+
sep.setFrameShape(QFrame.Shape.HLine)
367347
sep.setStyleSheet("color: #ddd;")
368348
return sep
369349

wfs_catasto_download_particelle_bbox_p.py

Lines changed: 28 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Logica principale del plugin: classe plugin, map tools, download WFS,
55
tiling, deduplicazione e filtro spaziale.
66
7-
Compatibile con QGIS 3 (Qt5) e QGIS 4 (Qt6).
7+
Compatibile con QGIS 4 (Qt6/PyQt6).
88
99
Autore: Salvatore Fiandaca
1010
Email: pigrecoinfinito@gmail.com
@@ -37,7 +37,7 @@
3737
QgsFillSymbol,
3838
)
3939
from qgis.gui import QgsMapTool, QgsRubberBand
40-
from qgis.PyQt.QtCore import Qt, QVariant, QTimer, QSettings
40+
from qgis.PyQt.QtCore import Qt, QMetaType, QTimer, QSettings
4141
from qgis.PyQt.QtGui import QColor, QIcon, QKeySequence
4242
from qgis.PyQt.QtWidgets import (
4343
QAction,
@@ -54,67 +54,37 @@
5454

5555

5656
# =============================================================================
57-
# COMPATIBILITÀ QGIS 3 / QGIS 4 (Qt5 / Qt6)
57+
# HELPERS QGIS 4 (Qt6/PyQt6)
5858
# =============================================================================
5959

60-
# Tipo geometria per QgsRubberBand e controlli layer
61-
try:
62-
_GEOM_POLYGON = Qgis.GeometryType.Polygon
63-
_GEOM_LINE = Qgis.GeometryType.Line
64-
_GEOM_POINT = Qgis.GeometryType.Point
65-
except AttributeError:
66-
_GEOM_POLYGON = QgsWkbTypes.PolygonGeometry
67-
_GEOM_LINE = QgsWkbTypes.LineGeometry
68-
_GEOM_POINT = QgsWkbTypes.PointGeometry
60+
_GEOM_POLYGON = Qgis.GeometryType.Polygon
61+
_GEOM_LINE = Qgis.GeometryType.Line
62+
_GEOM_POINT = Qgis.GeometryType.Point
6963

7064

7165
def _exec_dialog(dialog):
72-
"""Esegue un dialog in modo compatibile con Qt5 e Qt6."""
73-
try:
74-
return dialog.exec()
75-
except AttributeError:
76-
return dialog.exec_()
66+
return dialog.exec()
7767

7868

7969
def _wkb_display_string(wkb_type):
80-
"""Restituisce il nome del tipo WKB, compatibile QGIS 3/4."""
81-
try:
82-
return QgsWkbTypes.displayString(wkb_type)
83-
except AttributeError:
84-
return str(wkb_type)
70+
return QgsWkbTypes.displayString(wkb_type)
8571

8672

8773
def _is_polygon_layer(layer):
88-
"""Verifica se il layer è poligonale (compatibile QGIS 3/4)."""
89-
try:
90-
return layer.geometryType() == Qgis.GeometryType.Polygon
91-
except AttributeError:
92-
return layer.geometryType() == 2
74+
return layer.geometryType() == Qgis.GeometryType.Polygon
9375

9476

9577
def _is_line_layer(layer):
96-
"""Verifica se il layer è lineare (compatibile QGIS 3/4)."""
97-
try:
98-
return layer.geometryType() == Qgis.GeometryType.Line
99-
except AttributeError:
100-
return layer.geometryType() == 1
78+
return layer.geometryType() == Qgis.GeometryType.Line
10179

10280

10381
def _is_point_layer(layer):
104-
"""Verifica se il layer è puntuale (compatibile QGIS 3/4)."""
105-
try:
106-
return layer.geometryType() == Qgis.GeometryType.Point
107-
except AttributeError:
108-
return layer.geometryType() == 0
82+
return layer.geometryType() == Qgis.GeometryType.Point
10983

11084

11185
def _set_show_feature_count(tree_layer, value):
112-
"""Imposta showFeatureCount compatibile con QGIS 3 (Qt5) e QGIS 4 (Qt6)."""
113-
try:
114-
tree_layer.setShowFeatureCount(bool(value)) # QGIS 3.32+ / QGIS 4 (Qt6)
115-
except AttributeError:
116-
# Fallback QGIS < 3.32: usa int (1/0) per compatibilità QVariant Qt6
117-
tree_layer.setCustomProperty("showFeatureCount", 1 if value else 0)
86+
# setShowFeatureCount() rimosso in QGIS 4; usa la proprietà sottostante
87+
tree_layer.setCustomProperty("showFeatureCount", 1 if value else 0)
11888

11989

12090
def _refresh_feature_counts_deferred(layer_id):
@@ -182,25 +152,14 @@ def _applica_stile_particelle(layer):
182152
layer.setRenderer(renderer)
183153

184154

185-
# Qt enum scoped (Qt6) vs flat (Qt5)
186-
try:
187-
_WindowModal = Qt.WindowModality.WindowModal
188-
_DashLine = Qt.PenStyle.DashLine
189-
_DialogAccepted = QDialog.DialogCode.Accepted
190-
_Key_Escape = Qt.Key.Key_Escape
191-
_LeftButton = Qt.MouseButton.LeftButton
192-
_RightButton = Qt.MouseButton.RightButton
193-
_MB_Yes = QMessageBox.StandardButton.Yes
194-
_MB_No = QMessageBox.StandardButton.No
195-
except AttributeError:
196-
_WindowModal = Qt.WindowModal
197-
_DashLine = Qt.DashLine
198-
_DialogAccepted = QDialog.Accepted
199-
_Key_Escape = Qt.Key_Escape
200-
_LeftButton = Qt.LeftButton
201-
_RightButton = Qt.RightButton
202-
_MB_Yes = QMessageBox.Yes
203-
_MB_No = QMessageBox.No
155+
_WindowModal = Qt.WindowModality.WindowModal
156+
_DashLine = Qt.PenStyle.DashLine
157+
_DialogAccepted = QDialog.DialogCode.Accepted
158+
_Key_Escape = Qt.Key.Key_Escape
159+
_LeftButton = Qt.MouseButton.LeftButton
160+
_RightButton = Qt.MouseButton.RightButton
161+
_MB_Yes = QMessageBox.StandardButton.Yes
162+
_MB_No = QMessageBox.StandardButton.No
204163

205164

206165
# =============================================================================
@@ -859,13 +818,13 @@ def esegui_download_e_caricamento(min_lat, min_lon, max_lat, max_lon, filter_geo
859818

860819
# Copia campi originali + aggiungi campi segnalazione duplicati
861820
original_fields = layer_info["fields"].toList()
862-
original_fields.append(QgsField("geom_duplicata", QVariant.String))
863-
original_fields.append(QgsField("gruppo_duplicato", QVariant.Int))
821+
original_fields.append(QgsField("geom_duplicata", QMetaType.Type.QString))
822+
original_fields.append(QgsField("gruppo_duplicato", QMetaType.Type.Int))
864823
if espandi_catastale:
865-
original_fields.append(QgsField("sezione", QVariant.String))
866-
original_fields.append(QgsField("foglio", QVariant.Int))
867-
original_fields.append(QgsField("allegato", QVariant.String))
868-
original_fields.append(QgsField("sviluppo", QVariant.String))
824+
original_fields.append(QgsField("sezione", QMetaType.Type.QString))
825+
original_fields.append(QgsField("foglio", QMetaType.Type.Int))
826+
original_fields.append(QgsField("allegato", QMetaType.Type.QString))
827+
original_fields.append(QgsField("sviluppo", QMetaType.Type.QString))
869828
mem_provider.addAttributes(original_fields)
870829
mem_layer.updateFields()
871830

@@ -2160,10 +2119,7 @@ def show_about(self):
21602119
"""Mostra il dialog con le informazioni sul plugin."""
21612120
about_dlg = AboutDialog(self.iface.mainWindow())
21622121
# Compatibilità Qt5/Qt6
2163-
try:
2164-
about_dlg.exec() # Qt6
2165-
except AttributeError:
2166-
about_dlg.exec_() # Qt5
2122+
about_dlg.exec()
21672123

21682124
def show_help(self):
21692125
"""Apre la pagina di aiuto del plugin su GitHub Pages."""

0 commit comments

Comments
 (0)