From a6126b5832deaf7ede88cb027aa89dde65009bab Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 29 Nov 2024 13:17:58 +0000 Subject: [PATCH] Missing Widgets Fixes #620 --- geest/gui/dialogs/factor_aggregation_dialog.py | 4 ++-- geest/gui/factor_configuration_widget.py | 6 ++++-- .../configuration_widgets/acled_csv_configuration_widget.py | 2 +- .../configuration_widgets/base_configuration_widget.py | 2 +- .../classified_polygon_configuration_widget.py | 2 +- .../configuration_widgets/dont_use_configuration_widget.py | 2 +- .../feature_per_cell_configuration_widget.py | 2 +- .../index_score_configuration_widget.py | 2 +- .../multi_buffer_configuration_widget.py | 2 +- .../raster_reclassification_configuration_widget.py | 2 +- .../safety_polygon_configuration_widget.py | 5 ++--- .../safety_raster_configuration_widget.py | 2 +- .../single_buffer_configuration_widget.py | 2 +- .../street_lights_configuration_widget.py | 2 +- .../vector_and_field_datasource_widget.py | 2 +- 15 files changed, 20 insertions(+), 19 deletions(-) diff --git a/geest/gui/dialogs/factor_aggregation_dialog.py b/geest/gui/dialogs/factor_aggregation_dialog.py index 8b03e777..a2819bb4 100644 --- a/geest/gui/dialogs/factor_aggregation_dialog.py +++ b/geest/gui/dialogs/factor_aggregation_dialog.py @@ -204,7 +204,7 @@ def switch_page(self): current_index = self.stacked_widget.currentIndex() self.stacked_widget.setCurrentIndex(1 - current_index) # Toggle between 0 and 1 - def refresh_configuration(self): + def refresh_configuration(self, attributes: dict): """Refresh the configuration widget and table. We call this when any data source widget changes to ensure the data source @@ -212,7 +212,7 @@ def refresh_configuration(self): """ log_message("data_changed signal received, refreshing configuration") - self.configuration_widget.refresh_radio_buttons() + self.configuration_widget.refresh_radio_buttons(attributes) def create_checkbox_widget(self, row: int, weighting_value: float) -> QWidget: checkbox = QCheckBox() diff --git a/geest/gui/factor_configuration_widget.py b/geest/gui/factor_configuration_widget.py index f29c62e7..ae760b05 100644 --- a/geest/gui/factor_configuration_widget.py +++ b/geest/gui/factor_configuration_widget.py @@ -87,14 +87,16 @@ def create_radio_buttons(self, attributes: dict) -> None: default_radio = self.button_group.buttons()[0] default_radio.setChecked(True) - def refresh_radio_buttons(self) -> None: + def refresh_radio_buttons(self, attributes: dict) -> None: """ Refreshes the radio buttons. """ log_message("Refreshing radio buttons") + for key, value in attributes.items(): + log_message(f"Key: {key}, Value: {value}") for key, widget in self.widgets.items(): log_message(f"Updating widget for key: {key}") - widget.update_widgets() + widget.update_widgets(attributes) def on_selection_changed(self, button) -> None: """ diff --git a/geest/gui/widgets/configuration_widgets/acled_csv_configuration_widget.py b/geest/gui/widgets/configuration_widgets/acled_csv_configuration_widget.py index eaad87ec..e04f359c 100644 --- a/geest/gui/widgets/configuration_widgets/acled_csv_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/acled_csv_configuration_widget.py @@ -86,7 +86,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/base_configuration_widget.py b/geest/gui/widgets/configuration_widgets/base_configuration_widget.py index 7e80c765..e3038df0 100644 --- a/geest/gui/widgets/configuration_widgets/base_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/base_configuration_widget.py @@ -97,7 +97,7 @@ def get_data(self) -> dict: raise NotImplementedError("Subclasses must implement get_data.") @abstractmethod - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. To be implemented by subclasses. diff --git a/geest/gui/widgets/configuration_widgets/classified_polygon_configuration_widget.py b/geest/gui/widgets/configuration_widgets/classified_polygon_configuration_widget.py index 43ac4b94..4bb3076d 100644 --- a/geest/gui/widgets/configuration_widgets/classified_polygon_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/classified_polygon_configuration_widget.py @@ -67,7 +67,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/dont_use_configuration_widget.py b/geest/gui/widgets/configuration_widgets/dont_use_configuration_widget.py index 21c1fa15..3c93f9dc 100644 --- a/geest/gui/widgets/configuration_widgets/dont_use_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/dont_use_configuration_widget.py @@ -24,7 +24,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: """ pass - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/feature_per_cell_configuration_widget.py b/geest/gui/widgets/configuration_widgets/feature_per_cell_configuration_widget.py index 857e4d90..1ffd28ce 100644 --- a/geest/gui/widgets/configuration_widgets/feature_per_cell_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/feature_per_cell_configuration_widget.py @@ -66,7 +66,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py b/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py index 7732f237..e058fcbd 100644 --- a/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/index_score_configuration_widget.py @@ -40,7 +40,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/multi_buffer_configuration_widget.py b/geest/gui/widgets/configuration_widgets/multi_buffer_configuration_widget.py index 4ddb41ab..d6c17f91 100644 --- a/geest/gui/widgets/configuration_widgets/multi_buffer_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/multi_buffer_configuration_widget.py @@ -190,7 +190,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/raster_reclassification_configuration_widget.py b/geest/gui/widgets/configuration_widgets/raster_reclassification_configuration_widget.py index 92370772..7c5d7b46 100644 --- a/geest/gui/widgets/configuration_widgets/raster_reclassification_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/raster_reclassification_configuration_widget.py @@ -55,7 +55,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py b/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py index 8f01af96..79e24e39 100644 --- a/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/safety_polygon_configuration_widget.py @@ -108,8 +108,6 @@ def on_value_changed(value): # Call update_cell_colors after all rows are created self.update_cell_colors() - value_item.valueChanged.connect(on_value_changed) - def update_cell_colors(self): # Check if all values are zero all_zeros = True @@ -180,7 +178,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. @@ -188,5 +186,6 @@ def update_widgets(self) -> None: the attributes may change externally e.g. in the datasource widget. """ log_message("Updating widgets for SafetyPolygonConfigurationWidget") + self.attributes = attributes self.table_widget.clear() self.populate_table() diff --git a/geest/gui/widgets/configuration_widgets/safety_raster_configuration_widget.py b/geest/gui/widgets/configuration_widgets/safety_raster_configuration_widget.py index f7baa903..417f1c57 100644 --- a/geest/gui/widgets/configuration_widgets/safety_raster_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/safety_raster_configuration_widget.py @@ -53,7 +53,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/single_buffer_configuration_widget.py b/geest/gui/widgets/configuration_widgets/single_buffer_configuration_widget.py index b0a364ff..f1de4cf1 100644 --- a/geest/gui/widgets/configuration_widgets/single_buffer_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/single_buffer_configuration_widget.py @@ -74,7 +74,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/configuration_widgets/street_lights_configuration_widget.py b/geest/gui/widgets/configuration_widgets/street_lights_configuration_widget.py index 26ee872b..a60a2785 100644 --- a/geest/gui/widgets/configuration_widgets/street_lights_configuration_widget.py +++ b/geest/gui/widgets/configuration_widgets/street_lights_configuration_widget.py @@ -51,7 +51,7 @@ def set_internal_widgets_enabled(self, enabled: bool) -> None: level=Qgis.Critical, ) - def update_widgets(self) -> None: + def update_widgets(self, attributes: dict) -> None: """ Updates the internal widgets with the current attributes. diff --git a/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py b/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py index 0b21e8c7..844a4af9 100644 --- a/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py +++ b/geest/gui/widgets/datasource_widgets/vector_and_field_datasource_widget.py @@ -210,7 +210,7 @@ def update_selected_field(self) -> None: values_dict[key] = None else: values_dict[key] = existing_values[key] - log_message(f"Existing values: {values_dict}") + log_message(f"Existing values: {existing_values}") log_message(f"New values: {values_dict}") # will drop any keys in the json item that are not in values_dict self.attributes[f"{self.widget_key}_unique_values"] = values_dict