Skip to content

Commit

Permalink
We need to fix the widget factory
Browse files Browse the repository at this point in the history
Basic index score widget renders now
WIP for #331
  • Loading branch information
timlinux committed Sep 28, 2024
1 parent 452260e commit a3592fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions geest/gui/indicator_widget_factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qgis.core import QgsMessageLog
from qgis.core import QgsMessageLog, Qgis
from .widgets.indicator_index_score_widget import IndexScoreRadioButton
from .widgets.widget_radio_button import WidgetRadioButton

Expand All @@ -12,12 +12,19 @@ def create_radio_button(key: str, value: int):
"""
Factory method to create a radio button based on key-value pairs.
"""
QgsMessageLog.logMessage("Dialog widget factory called", tag="Geest", level=Qgis.Info)
QgsMessageLog.logMessage("----------------------------", tag="Geest", level=Qgis.Info)
QgsMessageLog.logMessage(f"Key: {key}", tag="Geest", level=Qgis.Info)
QgsMessageLog.logMessage(f"Value: {key}", tag="Geest", level=Qgis.Info)
QgsMessageLog.logMessage("----------------------------", tag="Geest", level=Qgis.Info)

try:
if key == "UseIndexScore" and value == 1:
if key == "Use Default Index Score" and value == 1:
return IndexScoreRadioButton("IndexScore")
elif key == "UseWidget" and value == 1:
return WidgetRadioButton("Widget")
else:
QgsMessageLog.logMessage(f"Factory did not match any widgets", tag="Geest", level=Qgis.Critical)
return None
except Exception as e:
QgsMessageLog.logMessage(f"Error in create_radio_button: {e}", "Geest")
Expand Down
4 changes: 2 additions & 2 deletions geest/gui/layer_detail_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ def get_widget_for_value(self, key, value):

def add_config_widgets(self, layout):
config_widget = IndicatorConfigWidget(self.layer_data)
#if config_widget.widgets:
# layout.addWidget(config_widget)
if config_widget:
layout.addWidget(config_widget)
# # connect to the stateChanged signal
# #config_widget.stateChanged.connect(self.handle_config_change)
#else:
Expand Down

0 comments on commit a3592fc

Please sign in to comment.