Skip to content

Commit

Permalink
Enable Qt6 on the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Oct 30, 2024
1 parent 650e147 commit f42fbd9
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 72 deletions.
12 changes: 6 additions & 6 deletions QuickOSM/core/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def add_actions(layer: QgsVectorLayer, keys: list):

title = tr('OpenStreetMap Browser')
osm_browser = QgsAction(
QgsAction.OpenUrl,
QgsAction.ActionType.OpenUrl,
title,
'http://www.openstreetmap.org/browse/[% "osm_type" %]/[% "osm_id" %]',
'',
Expand All @@ -55,7 +55,7 @@ def add_actions(layer: QgsVectorLayer, keys: list):

title = 'JOSM'
josm = QgsAction(
QgsAction.GenericPython,
QgsAction.ActionType.GenericPython,
title,
ACTIONS_PATH + 'Actions.run("josm","[% "full_id" %]")',
resources_path('icons', 'josm_icon.svg'),
Expand All @@ -68,7 +68,7 @@ def add_actions(layer: QgsVectorLayer, keys: list):

title = tr('User default editor')
default_editor = QgsAction(
QgsAction.OpenUrl,
QgsAction.ActionType.OpenUrl,
title,
'http://www.openstreetmap.org/edit?[% "osm_type" %]=[% "osm_id" %]',
'',
Expand All @@ -95,7 +95,7 @@ def add_actions(layer: QgsVectorLayer, keys: list):

link = link.replace(":", "_")
generic = QgsAction(
QgsAction.GenericPython,
QgsAction.ActionType.GenericPython,
link,
(ACTIONS_PATH
+ f'Actions.run("{link}","[% "{link}" %]")'),
Expand All @@ -109,7 +109,7 @@ def add_actions(layer: QgsVectorLayer, keys: list):

if 'network' in keys and 'ref' in keys:
sketch_line = QgsAction(
QgsAction.GenericPython,
QgsAction.ActionType.GenericPython,
tr('Sketchline'),
(
ACTIONS_PATH +
Expand All @@ -130,7 +130,7 @@ def add_relaunch_action(layer: QgsVectorLayer, layer_name: str = ""):

title = tr('Reload the query in a new file')
reload = QgsAction(
QgsAction.GenericPython,
QgsAction.ActionType.GenericPython,
title,
ACTIONS_PATH + f'Actions.run_reload(layer_name="{layer_name}")',
'',
Expand Down
2 changes: 1 addition & 1 deletion QuickOSM/core/api/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ def download(self, get=False):
downloader.downloadCanceled.connect(self.canceled)
downloader.downloadCompleted.connect(self.completed)
downloader.startDownload()
loop.exec_()
loop.exec()
6 changes: 3 additions & 3 deletions QuickOSM/core/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ def open_file(
if str(value) == 'None':
value = ''
if layer in ['lines', 'multilinestrings']:
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.LineGeometry)
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.GeometryType.LineGeometry)
elif layer == "points":
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.PointGeometry)
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.GeometryType.PointGeometry)
elif layer == "multipolygons":
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.PolygonGeometry)
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.GeometryType.PolygonGeometry)
symbol.setColor(QColor(value))
category = QgsRendererCategory(str(value), symbol, str(value))
categories.append(category)
Expand Down
4 changes: 2 additions & 2 deletions QuickOSM/core/utilities/extent_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, canvas):
QgsMapTool.__init__(self, canvas)

self.canvas = canvas
self.rubberBand = QgsRubberBand(self.canvas, QgsWkbTypes.PolygonGeometry)
self.rubberBand = QgsRubberBand(self.canvas, QgsWkbTypes.GeometryType.PolygonGeometry)
color = QColor(30, 230, 30, 65)
self.rubberBand.setColor(color)
self.rubberBand.setWidth(1)
Expand All @@ -49,7 +49,7 @@ def show_extent(self, extent: QgsRectangle):
self.end_point = QgsPointXY(extent.xMaximum(), extent.yMaximum())
self.transform_coordinates()

self.rubberBand.reset(QgsWkbTypes.PolygonGeometry)
self.rubberBand.reset(QgsWkbTypes.GeometryType.PolygonGeometry)

point1 = QgsPointXY(self.start_point.x(), self.start_point.y())
point2 = QgsPointXY(self.start_point.x(), self.end_point.y())
Expand Down
1 change: 1 addition & 0 deletions QuickOSM/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ author=Etienne Trimaille
[email protected]
hasProcessingProvider=yes
server=False
supportsQt6=True

# End of mandatory metadata

Expand Down
11 changes: 6 additions & 5 deletions QuickOSM/quick_osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,15 @@ def open_dialog(self):
# https://github.com/3liz/QuickOSM/issues/422
flag, title, error = check_processing_enable()
if not flag:
error_dialog = QMessageBox(QMessageBox.Critical, title, error, QMessageBox.Ok, self)
error_dialog = QMessageBox(
QMessageBox.Icon.Critical, title, error, QMessageBox.StandardButton.Ok, self)
error_dialog.exec()
return

from QuickOSM.ui.dialog import Dialog
dialog = Dialog()
self.open_copyright_message(dialog)
dialog.exec_()
dialog.exec()

@staticmethod
def open_copyright_message(dialog: QDialog):
Expand Down Expand Up @@ -274,11 +275,11 @@ def know_copyright():
'You should read https://www.openstreetmap.org/copyright'
)
message.setText(text)
message.setIcon(QMessageBox.Question)
message.setIcon(QMessageBox.Icon.Question)
no_button = QPushButton(tr('I understand the copyrights, access to the plugin'), message)
yes_button = QPushButton(tr('I want to read the copyrights'), message)
message.addButton(no_button, QMessageBox.NoRole)
message.addButton(yes_button, QMessageBox.YesRole)
message.addButton(no_button, QMessageBox.ButtonRole.NoRole)
message.addButton(yes_button, QMessageBox.ButtonRole.YesRole)
yes_button.clicked.connect(read_copyright)
no_button.clicked.connect(know_copyright)
message.exec()
Expand Down
6 changes: 3 additions & 3 deletions QuickOSM/quick_osm_processing/advanced/decorate_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ def postProcessLayer(self, layer, context, feedback):
if str(value) == 'None':
value = ''
if layer_type in [self.layer_type_dict['lines'], self.layer_type_dict['multilinestrings']]:
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.LineGeometry)
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.GeometryType.LineGeometry)
elif layer_type == self.layer_type_dict['point']:
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.PointGeometry)
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.GeometryType.PointGeometry)
elif layer_type == self.layer_type_dict['multipolygons']:
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.PolygonGeometry)
symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.GeometryType.PolygonGeometry)
else:
break
symbol.setColor(QColor(value))
Expand Down
4 changes: 2 additions & 2 deletions QuickOSM/test/test_osm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_parser(self):
'barrier'
]
features_expected = 52
geom_type_expected = QgsWkbTypes.Point
geom_type_expected = QgsWkbTypes.Type.Point

self.assertEqual(layers['points']['tags'], tags_expected)
self.assertEqual(layers['points']['featureCount'], features_expected)
Expand All @@ -76,7 +76,7 @@ def test_subset_parser(self):
'shelter', 'covered', 'public_transport', 'name', 'bus'
]
features_expected = 3
geom_type_expected = QgsWkbTypes.Point
geom_type_expected = QgsWkbTypes.Type.Point

self.assertEqual(layers['points']['tags'], tags_expected)
self.assertEqual(layers['points']['featureCount'], features_expected)
Expand Down
10 changes: 5 additions & 5 deletions QuickOSM/test/test_saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_view_bookmark(self):
self.assertEqual(nb_queries, 1)

edit_dialog.preset_name.setText('Test a new name')
edit_dialog.button_box.button(QDialogButtonBox.Cancel).click()
edit_dialog.button_box.button(QDialogButtonBox.StandardButton.Cancel).click()

self.dialog.external_panels[Panels.MapPreset].update_personal_preset_view()

Expand All @@ -157,7 +157,7 @@ def test_edit_rename_bookmark(self):

edit_dialog = EditPreset(self.dialog, data_preset)
edit_dialog.preset_name.setText('Test a new name')
edit_dialog.button_box.button(QDialogButtonBox.Ok).click()
edit_dialog.button_box.button(QDialogButtonBox.StandardButton.Ok).click()

self.dialog.external_panels[Panels.MapPreset].update_personal_preset_view()

Expand All @@ -183,7 +183,7 @@ def test_edited_bookmark_file(self):
index = edit_dialog.combo_output_format.findData(Format.Kml)
edit_dialog.combo_output_format.setCurrentIndex(index)

edit_dialog.button_box.button(QDialogButtonBox.Ok).click()
edit_dialog.button_box.button(QDialogButtonBox.StandardButton.Ok).click()
self.preset = self.dialog.list_personal_preset_mp.item(0)

new_data = self.set_up_preset_data_text()
Expand Down Expand Up @@ -259,7 +259,7 @@ def test_bookmark_several_query(self):
index = edit_dialog.table_keys_values_eb.cellWidget(0, 2).findText('route')
edit_dialog.table_keys_values_eb.cellWidget(0, 2).setCurrentIndex(index)

edit_dialog.button_box.button(QDialogButtonBox.Ok).click()
edit_dialog.button_box.button(QDialogButtonBox.StandardButton.Ok).click()
self.preset = self.dialog.list_personal_preset_mp.item(0)

new_data = self.set_up_preset_data_text()
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_bookmark_several_query(self):
self.assertEqual(
edit_dialog.stacked_parameters_preset.currentWidget(), edit_dialog.advanced_parameters)

edit_dialog.button_box.button(QDialogButtonBox.Ok).click()
edit_dialog.button_box.button(QDialogButtonBox.StandardButton.Ok).click()
self.preset = self.dialog.list_personal_preset_mp.item(0)

new_data = self.set_up_preset_data_text()
Expand Down
2 changes: 1 addition & 1 deletion QuickOSM/ui/base_overpass_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def init_nominatim_autofill(self):
for line_edit in self.dialog.places_edits.values():
line_edit.setCompleter(nominatim_completer)
line_edit.completer().setCompletionMode(
QCompleter.PopupCompletion)
QCompleter.CompletionMode.PopupCompletion)

@staticmethod
def sort_nominatim_places(existing_places: list, place: str) -> list:
Expand Down
12 changes: 6 additions & 6 deletions QuickOSM/ui/custom_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def setup_preset(self):
self.preset_items.append(widget_item)
self.preset.setCompleter(keys_preset_completer)
self.preset.completer().setCompletionMode(
QCompleter.PopupCompletion)
QCompleter.CompletionMode.PopupCompletion)
self.preset.completer().setFilterMode(
Qt.MatchContains
)
Expand All @@ -107,10 +107,10 @@ def setup_table(self):

# Table Keys/Values
header = self.table.horizontalHeader()
header.setSectionResizeMode(QHeaderView.Stretch)
header.setSectionResizeMode(0, QHeaderView.Fixed)
header.setSectionResizeMode(3, QHeaderView.ResizeToContents)
header.setSectionResizeMode(4, QHeaderView.ResizeToContents)
header.setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
header.setSectionResizeMode(0, QHeaderView.ResizeMode.Fixed)
header.setSectionResizeMode(3, QHeaderView.ResizeMode.ResizeToContents)
header.setSectionResizeMode(4, QHeaderView.ResizeMode.ResizeToContents)
header.setMinimumSectionSize(25)
index_type = header.logicalIndexAt(0)
header.resizeSection(index_type, 50)
Expand Down Expand Up @@ -166,7 +166,7 @@ def prepare_key_field(self) -> QComboBox:
key_field.addItems(self.keys)
key_field.setCompleter(keys_completer)
key_field.completer().setCompletionMode(
QCompleter.PopupCompletion)
QCompleter.CompletionMode.PopupCompletion)
key_field.completer().setCaseSensitivity(
Qt.CaseInsensitive
)
Expand Down
2 changes: 1 addition & 1 deletion QuickOSM/ui/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def __init__(self, iface=None, parent=None):
reloader = partial(actions.pre_run_reload)
self.reload_action.triggered.connect(reloader)
self.iface.addCustomActionForLayerType(
self.reload_action, "", QgsMapLayer.VectorLayer, False)
self.reload_action, "", QgsMapLayer.LayerType.VectorLayer, False)

self.feedback_process = QgsFeedback()

Expand Down
14 changes: 7 additions & 7 deletions QuickOSM/ui/edit_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ def __init__(self, parent=None, data_preset: dict = None):
self.tab_widget.setTabIcon(2, QIcon(":images/themes/default/propertyicons/symbology.svg"))

# Buttonbox
self.button_box.button(QDialogButtonBox.Cancel).clicked.connect(self.close)
self.button_box.button(QDialogButtonBox.Ok).clicked.connect(self.validate)
self.button_box.button(QDialogButtonBox.Help).clicked.connect(self.open_help)
self.button_box.button(QDialogButtonBox.StandardButton.Cancel).clicked.connect(self.close)
self.button_box.button(QDialogButtonBox.StandardButton.Ok).clicked.connect(self.validate)
self.button_box.button(QDialogButtonBox.StandardButton.Help).clicked.connect(self.open_help)

def item_context(self, pos: QPoint):
"""Set context submenu to delete item in the list."""
item = self.list_queries.mapToGlobal(pos)
submenu = QMenu()
rename_action = submenu.addAction(tr('Rename'))
delete_action = submenu.addAction(tr('Delete'))
right_click_item = submenu.exec_(item)
right_click_item = submenu.exec(item)
if right_click_item and right_click_item == delete_action:
index = self.list_queries.indexAt(pos).row()
self.verification_delete_query(index)
Expand Down Expand Up @@ -285,13 +285,13 @@ def verification_delete_query(self, row: int):
"""Delete a query in the preset"""
name = self.list_queries.item(row).text()
validate_delete = QMessageBox(
QMessageBox.Warning, tr('Confirm query deletion'),
QMessageBox.Icon.Warning, tr('Confirm query deletion'),
tr(f'Are you sure you want to delete the query \'{name}\'?'),
QMessageBox.Yes | QMessageBox.Cancel, self
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.Cancel, self
)
ok = validate_delete.exec()

if ok == QMessageBox.Yes:
if ok == QMessageBox.StandardButton.Yes:
self.delete_query(row)

def delete_query(self, row: int):
Expand Down
20 changes: 10 additions & 10 deletions QuickOSM/ui/map_preset_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def setup_default_preset(self):
self.dialog.list_default_mp.addItem(item)

widget = QFrame()
widget.setFrameStyle(QFrame.StyledPanel)
widget.setFrameStyle(QFrame.Shape.StyledPanel)
widget.setStyleSheet('QFrame { margin: 3px; };')
widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
widget.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
hbox = QHBoxLayout()
vbox = QVBoxLayout()
picture = QLabel()
Expand All @@ -109,7 +109,7 @@ def setup_default_preset(self):
picture.setStyleSheet('max-height: 150px; max-width: 250px; margin-right: 50px;')
hbox.addWidget(picture)
title = QLabel(data['file_name'])
title.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
title.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
title.setStyleSheet('font: bold 20px; margin-bottom: 25px;')
vbox.addWidget(title)
for label in data['description']:
Expand Down Expand Up @@ -177,8 +177,8 @@ def update_personal_preset_view(self):

preset = QFrame()
preset.setObjectName('FramePreset')
preset.setFrameStyle(QFrame.StyledPanel)
preset.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
preset.setFrameStyle(QFrame.Shape.StyledPanel)
preset.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
hbox = QHBoxLayout()
vbox = QVBoxLayout()
label_name = QLabel(name)
Expand All @@ -196,8 +196,8 @@ def update_personal_preset_view(self):
button_remove = QPushButton()
button_edit.setIcon(QIcon(QgsApplication.iconPath("mActionToggleEditing.svg")))
button_remove.setIcon(QIcon(QgsApplication.iconPath('symbologyRemove.svg')))
button_edit.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
button_remove.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
button_edit.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
button_remove.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
button_edit.setToolTip(tr('Edit the preset'))
button_remove.setToolTip(tr('Delete the preset'))
hbox.addWidget(button_edit)
Expand Down Expand Up @@ -236,13 +236,13 @@ def edit_preset(self, data: dict):
def verification_remove_preset(self, item: QListWidgetItem, name: str):
"""Verification of the removal a preset."""
validate_delete = QMessageBox(
QMessageBox.Warning, tr('Confirm preset deletion'),
QMessageBox.Icon.Warning, tr('Confirm preset deletion'),
tr(f'Are you sure you want to delete the preset \'{name}\'?'),
QMessageBox.Yes | QMessageBox.Cancel, self.dialog
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.Cancel, self.dialog
)
ok = validate_delete.exec()

if ok == QMessageBox.Yes:
if ok == QMessageBox.StandardButton.Yes:
self.remove_preset(item, name)

def remove_preset(self, item: QListWidgetItem, name: str):
Expand Down
2 changes: 1 addition & 1 deletion QuickOSM/ui/query_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def setup_panel(self):

self.dialog.run_buttons[self.panel].clicked.connect(self.run)
self.dialog.button_generate_query.clicked.connect(self.query_language_check)
self.dialog.button_box_q.button(QDialogButtonBox.Reset).clicked.connect(
self.dialog.button_box_q.button(QDialogButtonBox.StandardButton.Reset).clicked.connect(
self.dialog.reset_form)

self.allow_nominatim_or_extent()
Expand Down
Loading

0 comments on commit f42fbd9

Please sign in to comment.