Skip to content

Commit

Permalink
Only display warning symbol if the field is not an empty string fix #533
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Nov 30, 2023
1 parent 8aba1b4 commit 1eb06b1
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions lizmap/table_manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,24 +308,27 @@ def _edit_row(self, row, data):
cell.setData(Qt.UserRole, value)
cell.setData(Qt.ToolTipRole, value)

# Get the icon for the field
if self._layer:
index = self._layer.fields().indexFromName(value)
if index >= 0:
cell.setIcon(self._layer.fields().iconForField(index))
# All field inputs are not required, so we might have an empty string
# Only check for icon if the field is defined
if value != '':
# Get the icon for the field
if self._layer:
index = self._layer.fields().indexFromName(value)
if index >= 0:
cell.setIcon(self._layer.fields().iconForField(index))
else:
cell.setIcon(QIcon(":/images/themes/default/mIconWarning.svg"))
cell.setData(Qt.ToolTipRole, tr(
'Field "{}" not found in the layer. You should check this configuration or fix your '
'fields.'
).format(value))
else:
# No layer
cell.setIcon(QIcon(":/images/themes/default/mIconWarning.svg"))
cell.setData(Qt.ToolTipRole, tr(
'Field "{}" not found in the layer. You should check this configuration or fix your '
'fields.'
).format(value))
else:
# No layer
cell.setIcon(QIcon(":/images/themes/default/mIconWarning.svg"))
cell.setData(
Qt.ToolTipRole,
tr("Not possible to check the field type if the layer is not loaded in QGIS").format(value)
)
cell.setData(
Qt.ToolTipRole,
tr("Not possible to check the field type if the layer is not loaded in QGIS").format(value)
)

elif input_type == InputType.Fields:
cell.setText(value)
Expand Down

0 comments on commit 1eb06b1

Please sign in to comment.