Skip to content

Commit

Permalink
Missing Widgets
Browse files Browse the repository at this point in the history
Fixes #620
  • Loading branch information
timlinux committed Nov 29, 2024
1 parent 6cb742d commit a6126b5
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions geest/gui/dialogs/factor_aggregation_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ 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
and the configuration are conistent with each other.
"""
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()
Expand Down
6 changes: 4 additions & 2 deletions geest/gui/factor_configuration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -180,13 +178,14 @@ 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.
Only needed in cases where a) there are internal widgets and b)
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()
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a6126b5

Please sign in to comment.