Skip to content

Commit

Permalink
Merge branch 'dev-3.6' into master-3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfuste committed Jul 8, 2024
2 parents 7e06370 + 8a6d781 commit 9c123da
Show file tree
Hide file tree
Showing 60 changed files with 69,442 additions and 68,794 deletions.
24 changes: 12 additions & 12 deletions core/admin/admin_btn.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def execute_import_inp_data(self, project_name, project_type):
""" Executed when option 'Import INP data' has been selected """

# Create dialog
self.dlg_import_inp = GwAdminImportUi()
self.dlg_import_inp = GwAdminImportUi(self)
tools_gw.load_settings(self.dlg_import_inp)

# Hide widgets
Expand Down Expand Up @@ -391,7 +391,7 @@ def load_updates(self, project_type=None, update_changelog=False, schema_name=No
def init_dialog_create_project(self, project_type=None):
""" Initialize dialog (only once) """

self.dlg_readsql_create_project = GwAdminDbProjectUi()
self.dlg_readsql_create_project = GwAdminDbProjectUi(self)
tools_gw.load_settings(self.dlg_readsql_create_project)
self.dlg_readsql_create_project.btn_cancel_task.hide()

Expand Down Expand Up @@ -681,7 +681,7 @@ def _init_show_database(self):
self.dev_commit = global_vars.gw_dev_mode

# Create dialog object
self.dlg_readsql = GwAdminUi()
self.dlg_readsql = GwAdminUi(self)
tools_gw.load_settings(self.dlg_readsql)
self.cmb_project_type = self.dlg_readsql.findChild(QComboBox, 'cmb_project_type')

Expand Down Expand Up @@ -1035,7 +1035,7 @@ def _open_form_create_gis_project(self):
return

# Create GIS project dialog
self.dlg_create_gis_project = GwAdminGisProjectUi()
self.dlg_create_gis_project = GwAdminGisProjectUi(self)
tools_gw.load_settings(self.dlg_create_gis_project)

# Set default values
Expand Down Expand Up @@ -1433,7 +1433,7 @@ def _open_update_info(self):
""""""

# Create dialog
self.dlg_readsql_show_info = GwAdminProjectInfoUi()
self.dlg_readsql_show_info = GwAdminProjectInfoUi(self)
tools_gw.load_settings(self.dlg_readsql_show_info)

info_updates = self.dlg_readsql_show_info.findChild(QTextEdit, 'info_updates')
Expand Down Expand Up @@ -1742,7 +1742,7 @@ def _open_rename(self):
return

# Create dialog
self.dlg_readsql_rename = GwAdminRenameProjUi()
self.dlg_readsql_rename = GwAdminRenameProjUi(self)
tools_gw.load_settings(self.dlg_readsql_rename)

schema = tools_qt.get_text(self.dlg_readsql, self.dlg_readsql.project_schema_name)
Expand Down Expand Up @@ -1897,7 +1897,7 @@ def _copy_schema(self):
""""""

# Create dialog
self.dlg_readsql_copy = GwAdminRenameProjUi()
self.dlg_readsql_copy = GwAdminRenameProjUi(self)
tools_gw.load_settings(self.dlg_readsql_copy)

schema = tools_qt.get_text(self.dlg_readsql, self.dlg_readsql.project_schema_name)
Expand Down Expand Up @@ -2065,7 +2065,7 @@ def _execute_import_inp(self, accepted, project_name, project_type):
def _build_replace_dlg(self, replace_json):

# Build the dialog
self.dlg_replace = GwReplaceInFileUi()
self.dlg_replace = GwReplaceInFileUi(self)
self.dlg_replace.setWindowFlags(Qt.WindowStaysOnTopHint)
tools_gw.load_settings(self.dlg_replace)

Expand Down Expand Up @@ -2312,7 +2312,7 @@ def _open_manage_field(self, action):
""""""

# Create the dialog and signals
self.dlg_manage_fields = GwAdminFieldsUi()
self.dlg_manage_fields = GwAdminFieldsUi(self)
tools_gw.load_settings(self.dlg_manage_fields)
self.model_update_table = None

Expand Down Expand Up @@ -2369,7 +2369,7 @@ def _update_selected_addfild(self, widget, is_multi_addfield):

# Create the dialog and signals
self._close_dialog_admin(self.dlg_manage_fields)
self.dlg_manage_fields = GwAdminFieldsUi()
self.dlg_manage_fields = GwAdminFieldsUi(self)
tools_gw.load_settings(self.dlg_manage_fields)
self.model_update_table = None

Expand Down Expand Up @@ -2894,7 +2894,7 @@ def _save_selection(self):
def _create_credentials_form(self, set_connection):
""""""

self.dlg_credentials = GwCredentialsUi()
self.dlg_credentials = GwCredentialsUi(self)
tools_gw.load_settings(self.dlg_credentials)
if str(self.list_connections) != '[]':
tools_qt.fill_combo_values(self.dlg_credentials.cmb_connection, self.list_connections)
Expand Down Expand Up @@ -2952,7 +2952,7 @@ def _manage_docker(self):
try:
tools_gw.close_docker('admin_position')
lib_vars.session_vars['docker_type'] = 'qgis_form_docker'
lib_vars.session_vars['dialog_docker'] = GwDocker()
lib_vars.session_vars['dialog_docker'] = GwDocker(self)
lib_vars.session_vars['dialog_docker'].dlg_closed.connect(partial(tools_gw.close_docker, 'admin_position'))
tools_gw.manage_docker_options('admin_position')
tools_gw.docker_dialog(self.dlg_readsql)
Expand Down
2 changes: 1 addition & 1 deletion core/admin/i18n_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self):
def init_dialog(self):
""" Constructor """

self.dlg_qm = GwAdminTranslationUi()
self.dlg_qm = GwAdminTranslationUi(self)
tools_gw.load_settings(self.dlg_qm)
self._load_user_values()

Expand Down
2 changes: 1 addition & 1 deletion core/load_project_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _open_manage_file(self):
""" Manage files dialog:: """

tools_qgis.set_cursor_wait()
self.dlg_manage_menu = GwLoadMenuUi()
self.dlg_manage_menu = GwLoadMenuUi(self)
tools_gw.load_settings(self.dlg_manage_menu)

# Manage widgets
Expand Down
2 changes: 1 addition & 1 deletion core/shared/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def open_catalog(self, previous_dialog, widget_name, feature_type, child_type):
group_box_1 = QGroupBox("Filter")
self.filter_form = QGridLayout()

self.dlg_catalog = GwInfoCatalogUi()
self.dlg_catalog = GwInfoCatalogUi(self)
tools_gw.load_settings(self.dlg_catalog)
self.dlg_catalog.btn_cancel.clicked.connect(partial(tools_gw.close_dialog, self.dlg_catalog))
self.dlg_catalog.btn_accept.clicked.connect(partial(self._fill_geomcat_id, previous_dialog, widget_name))
Expand Down
4 changes: 2 additions & 2 deletions core/shared/dimensioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self):

def open_dimensioning_form(self, qgis_feature=None, layer=None, db_return=None, fid=None, rubber_band=None):

self.dlg_dim = GwDimensioningUi()
self.dlg_dim = GwDimensioningUi(self)
tools_gw.load_settings(self.dlg_dim)

self.user_current_layer = self.iface.activeLayer()
Expand All @@ -57,7 +57,7 @@ def open_dimensioning_form(self, qgis_feature=None, layer=None, db_return=None,

# when function is called from new feature
if db_return is None:
rubber_band = tools_gw.create_rubberband(self.canvas, QgsWkbTypes.PointGeometry)
rubber_band = tools_gw.create_rubberband(self.canvas, "point")
extras = f'"coordinates":{{{self.points}}}'
body = tools_gw.create_body(extras=extras)
json_result = tools_gw.execute_procedure('gw_fct_getdimensioning', body)
Expand Down
4 changes: 2 additions & 2 deletions core/shared/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_document(self, tablename=None, qtable=None, item_id=None, feature=None,

self.rubber_band = tools_gw.create_rubberband(self.canvas)
# Create the dialog and signals
self.dlg_add_doc = GwDocUi()
self.dlg_add_doc = GwDocUi(self)
tools_gw.load_settings(self.dlg_add_doc)
self.doc_id = None
self.files_path = []
Expand Down Expand Up @@ -174,7 +174,7 @@ def manage_documents(self):
""" Button 66: Edit document """

# Create the dialog
self.dlg_man = GwDocManagerUi()
self.dlg_man = GwDocManagerUi(self)
self.dlg_man.setProperty('class_obj', self)
tools_gw.load_settings(self.dlg_man)
self.dlg_man.tbl_document.setSelectionBehavior(QAbstractItemView.SelectRows)
Expand Down
4 changes: 2 additions & 2 deletions core/shared/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_element(self, new_element_id=True, feature=None, feature_type=None, sele
self.new_element_id = new_element_id

# Create the dialog and signals
self.dlg_add_element = GwElementUi()
self.dlg_add_element = GwElementUi(self)
tools_gw.load_settings(self.dlg_add_element)
self.element_id = None

Expand Down Expand Up @@ -273,7 +273,7 @@ def manage_elements(self):
""" Button 67: Edit element """

# Create the dialog
self.dlg_man = GwElementManagerUi()
self.dlg_man = GwElementManagerUi(self)
tools_gw.load_settings(self.dlg_man)
self.dlg_man.tbl_element.setSelectionBehavior(QAbstractItemView.SelectRows)

Expand Down
95 changes: 95 additions & 0 deletions core/shared/flow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""
This file is part of Giswater 3
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
"""
# -*- coding: utf-8 -*-
import sys
import os

from qgis.PyQt.QtCore import Qt
from ..toolbars.maptool import GwMaptool
from ..utils import tools_gw
from ...libs import tools_qgis

class GwFlow(GwMaptool):
""" Base class for flow buttons """

def __init__(self, icon_path, action_name, text, toolbar, action_group):
super().__init__(icon_path, action_name, text, toolbar, action_group)
self.layers_added = []

""" QgsMapTools inherited event functions """

def clicked_event(self):
# Deactivate maptool if already active
if self == self.iface.mapCanvas().mapTool():
return self.cancel_map_tool()
super().clicked_event()

def canvasMoveEvent(self, event):
# Hide marker and get coordinates
self.vertex_marker.hide()
event_point = self.snapper_manager.get_event_point(event)

# Snapping
result = self.snapper_manager.snap_to_current_layer(event_point)
if result.isValid():
self.snapper_manager.add_marker(result, self.vertex_marker)
# Data for function
self.snapped_feat = self.snapper_manager.get_snapped_feature(result)
else:
self.snapped_feat = None

def activate(self):
# set active and current layer
self.layer_node = tools_qgis.get_layer_by_tablename("v_edit_node")
self.iface.setActiveLayer(self.layer_node)
self.current_layer = self.layer_node

# Check action. It works if is selected from toolbar. Not working if is selected from menu or shortcut keys
if hasattr(self.action, "setChecked"):
self.action.setChecked(True)

# Store user snapping configuration
self.previous_snapping = self.snapper_manager.get_snapping_options()

# Set snapping layers
self.snapper_manager.set_snapping_layers()

# Change cursor
self.canvas.setCursor(self.cursor)

# Show help message when action is activated
if self.show_help:
tools_qgis.show_info(self.help_message)

# Control current layer (due to QGIS bug in snapping system)
if self.canvas.currentLayer() is None:
layer = tools_qgis.get_layer_by_tablename('v_edit_node')
if layer:
self.iface.setActiveLayer(layer)

def deactivate(self):
super().deactivate()

def _set_flow(self, event, procedure_name):
if event.button() == Qt.RightButton:
return self.cancel_map_tool()

if event.button() == Qt.LeftButton and self.current_layer:
if self.snapped_feat is None:
elem_id = 'null'
else:
elem_id = f"""{self.snapped_feat.attribute('node_id')}"""
feature_id = f'"id":[{elem_id}]'
point = tools_qgis.create_point(self.canvas, self.iface, event)
scale_zoom = self.iface.mapCanvas().scale()
extras = f' "coordinates":{{"xcoord":{point.x()},"ycoord":{point.y()}, "zoomRatio":{scale_zoom}}}'
body = tools_gw.create_body(feature=feature_id, extras=extras)
result = tools_gw.execute_procedure(procedure_name, body)
if not result or result['status'] == 'Failed':
return

self.refresh_map_canvas()
Loading

0 comments on commit 9c123da

Please sign in to comment.