Skip to content

Commit 338201a

Browse files
committed
Tooltip - Add LWC 3.10 new feature 'Display layer features with QGIS symbology'
1 parent c795f44 commit 338201a

File tree

8 files changed

+85
-25
lines changed

8 files changed

+85
-25
lines changed

lizmap/definitions/tooltip.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ def __init__(self):
4646
'default': '',
4747
'tooltip': tr('The color to use for displaying the geometry.')
4848
}
49+
self._layer_config['displayLayerStyle'] = {
50+
'type': InputType.CheckBox,
51+
'header': tr('Display layer features'),
52+
'default': False,
53+
'tooltip': tr(
54+
'If checked, the layer features will be displayed in the map'
55+
' with a symbology as close as possible to the layer symbology.'
56+
' The conversion from QGIS symbology is not always perfect '
57+
' since it relies on the SLD standard.'
58+
' SVG and PNG files must be embedded in the symbology properties.'
59+
),
60+
'version': LwcVersions.Lizmap_3_10,
61+
}
4962

5063
@staticmethod
5164
def primary_keys() -> tuple:

lizmap/forms/tooltip_edition.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Dialog for tooltip edition."""
22
from typing import Dict, Optional
33

4-
from qgis.core import QgsMapLayerProxyModel
4+
from qgis.core import QgsMapLayerProxyModel, QgsWkbTypes
55
from qgis.PyQt.QtGui import QColor, QIcon
66
from qgis.PyQt.QtWidgets import QMessageBox, QWidget
77

@@ -30,14 +30,14 @@ def __init__(self,
3030
self.config.add_layer_widget('template', self.html_template)
3131
self.config.add_layer_widget('displayGeom', self.display_geometry)
3232
self.config.add_layer_widget('colorGeom', self.color)
33+
self.config.add_layer_widget('displayLayerStyle', self.display_layer_style)
3334

3435
self.config.add_layer_label('layerId', self.label_layer)
3536
self.config.add_layer_label('fields', self.label_fields)
3637
self.config.add_layer_label('template', self.label_html_template)
3738
self.config.add_layer_label('displayGeom', self.label_display_geometry)
3839
self.config.add_layer_label('colorGeom', self.label_color)
39-
40-
# TODO when 3.8 will be the default, change the default tab according to the LWC version
40+
self.config.add_layer_label('displayLayerStyle', self.label_display_layer_style)
4141

4242
self.layer.setFilters(QgsMapLayerProxyModel.Filter.VectorLayer)
4343
self.layer.layerChanged.connect(self.check_layer_wfs)
@@ -51,9 +51,18 @@ def __init__(self,
5151

5252
self.generate_table.clicked.connect(self.generate_table_clicked)
5353

54+
# Make "display" checkbox mutually exclusive
55+
# We cannot use QButtonGroup because it forces at least one button to be checked,
56+
# which is not the case here, so we manage the exclusivity manually in the slot.
57+
self.display_layer_style.toggled.connect(self.toggleDisplayCheckbox)
58+
5459
self.lwc_versions[LwcVersions.Lizmap_3_8] = [
5560
self.label_html_template,
5661
]
62+
self.lwc_versions[LwcVersions.Lizmap_3_10] = [
63+
self.label_display_layer_style,
64+
self.display_layer_style,
65+
]
5766

5867
self.setup_ui()
5968
self.check_layer_wfs()
@@ -104,10 +113,17 @@ def enable_color(self):
104113
if self.display_geometry.isChecked():
105114
self.color.setEnabled(True)
106115
self.color.setColor(QColor('blue'))
116+
if self.display_layer_style.isChecked():
117+
self.display_layer_style.setChecked(False)
107118
else:
108119
self.color.setEnabled(False)
109120
self.color.setToNull()
110121

122+
def toggleDisplayCheckbox(self):
123+
if self.display_layer_style.isChecked():
124+
if self.display_geometry.isChecked():
125+
self.display_geometry.setChecked(False)
126+
111127
def validate(self) -> Optional[str]:
112128
upstream = super().validate()
113129
if upstream:
@@ -124,4 +140,13 @@ def validate(self) -> Optional[str]:
124140
if not self.fields.selection() and not self.html_template.html_content():
125141
return tr('Either an HTML template or a field must be set.')
126142

143+
# Allow display layer style only for point
144+
# LWC 3.10
145+
# Could be changed in future version
146+
if layer.geometryType() != QgsWkbTypes.PointGeometry:
147+
return tr(
148+
"At present, the option 'Display layer feature'"
149+
" is only available for point layers."
150+
)
151+
127152
return None

lizmap/resources/ui/ui_form_tooltip.ui

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@
7979
</widget>
8080
</item>
8181
<item>
82-
<widget class="HtmlEditorWidget" name="html_template" native="true"/>
82+
<widget class="HtmlEditorWidget" name="html_template" native="true">
83+
<property name="minimumSize">
84+
<size>
85+
<width>0</width>
86+
<height>300</height>
87+
</size>
88+
</property>
89+
</widget>
8390
</item>
8491
</layout>
8592
</widget>
@@ -119,13 +126,6 @@
119126
</property>
120127
</widget>
121128
</item>
122-
<item row="3" column="0">
123-
<widget class="QLabel" name="label_color">
124-
<property name="text">
125-
<string>Color</string>
126-
</property>
127-
</widget>
128-
</item>
129129
<item row="3" column="1">
130130
<widget class="QgsColorButton" name="color">
131131
<property name="sizePolicy">
@@ -136,6 +136,27 @@
136136
</property>
137137
</widget>
138138
</item>
139+
<item row="3" column="0">
140+
<widget class="QLabel" name="label_color">
141+
<property name="text">
142+
<string>Color</string>
143+
</property>
144+
</widget>
145+
</item>
146+
<item row="4" column="0">
147+
<widget class="QLabel" name="label_display_layer_style">
148+
<property name="text">
149+
<string>Display layer features</string>
150+
</property>
151+
</widget>
152+
</item>
153+
<item row="4" column="1">
154+
<widget class="QCheckBox" name="display_layer_style">
155+
<property name="text">
156+
<string/>
157+
</property>
158+
</widget>
159+
</item>
139160
</layout>
140161
</item>
141162
<item>
@@ -174,17 +195,17 @@
174195
<extends>QComboBox</extends>
175196
<header>qgis.gui</header>
176197
</customwidget>
177-
<customwidget>
178-
<class>ListFieldsSelection</class>
179-
<extends>QListWidget</extends>
180-
<header>lizmap.widgets.list_fields_selection</header>
181-
</customwidget>
182198
<customwidget>
183199
<class>HtmlEditorWidget</class>
184200
<extends>QWidget</extends>
185201
<header>lizmap.widgets.html_editor</header>
186202
<container>1</container>
187203
</customwidget>
204+
<customwidget>
205+
<class>ListFieldsSelection</class>
206+
<extends>QListWidget</extends>
207+
<header>lizmap.widgets.list_fields_selection</header>
208+
</customwidget>
188209
</customwidgets>
189210
<resources/>
190211
<connections/>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Publish and share your QGIS maps on the Web via Lizmap Web Client
44
authors = [
55
{ name = "3Liz", email = "info@3liz.com" }
66
]
7-
version = "5.0.0-alpha.3-pre"
7+
version = "5.0.0-alpha.3+pre"
88
requires-python = ">= 3.9"
99
license = "GPL-2.0-only"
1010
license-files = ["LICENSE"]

tests/test_dxf_export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from lizmap.table_manager.dxf_export import TableManagerDxfExport
1212
from lizmap.toolbelt.convert import ambiguous_to_bool
13-
from lizmap.widgets.project_tools import is_layer_published_wfs
1413

1514
from .compat import TestCase
1615

@@ -50,8 +49,9 @@ class TestTableManagerDxfExport(TestCase):
5049

5150
def test_initialization(self):
5251
"""Test table manager initialization."""
52+
# Initialize manager
5353
table = QTableWidget()
54-
manager = TableManagerDxfExport(table)
54+
TableManagerDxfExport(table)
5555

5656
# Check table is configured correctly
5757
self.assertEqual(table.columnCount(), 2)

tests/test_table_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ def test_tool_tip(self, layer: QgsVectorLayer):
974974
"template": '<p>[% "nom" %]</p>\n',
975975
"displayGeom": "False",
976976
"colorGeom": "",
977+
"displayLayerStyle": "False",
977978
"layerId": layer.id(),
978979
"order": 0,
979980
}

tests/test_ui.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,8 @@ def test_default_options_values_3_9(self, data: Path):
474474

475475
# map tools
476476
self.assertFalse(output["options"].get("measure"))
477-
self.assertIsNone(output["options"].get("print")) # The checkbox is removed since LWC 3.7.0
478-
self.assertIsNone(output["options"].get("zoomHistory")) # The checkbox is removed since LWC 3.8.0
477+
self.assertIsNone(output["options"].get("print")) # The checkbox is removed since LWC 3.7.0
478+
self.assertIsNone(output["options"].get("zoomHistory")) # The checkbox is removed since LWC 3.8.0
479479
self.assertFalse(output["options"].get("geolocation"))
480480
# self.assertIsNone(output["options"].get("geolocationPrecision")) # Added since LWC 3.10.0
481481
# self.assertIsNone(output["options"].get("geolocationDirection")) # Added since LWC 3.10.0
@@ -526,7 +526,7 @@ def test_default_options_values_3_9(self, data: Path):
526526
self.assertIsNone(output["options"].get("datavizTemplate"))
527527
self.assertIsNone(output["options"].get("dataviz_drag_drop"))
528528
self.assertEqual("dock", output["options"].get("datavizLocation"))
529-
self.assertIsNone(output["options"].get("theme")) # default value "dark" is not set
529+
self.assertIsNone(output["options"].get("theme")) # default value "dark" is not set
530530

531531
# Time manager page
532532
self.assertEqual(10, output["options"].get("tmTimeFrameSize"))
@@ -554,8 +554,8 @@ def test_default_options_latest(self, data: Path):
554554
self.assertIsNone(output["options"].get("print")) # The checkbox is removed since LWC 3.7.0
555555
self.assertIsNone(output["options"].get("zoomHistory")) # The checkbox is removed since LWC 3.8.0
556556
self.assertFalse(output["options"].get("geolocation"))
557-
self.assertTrue(output["options"].get("geolocationPrecision")) # Added since LWC 3.10.0
558-
self.assertFalse(output["options"].get("geolocationDirection")) # Added since LWC 3.10.0
557+
self.assertTrue(output["options"].get("geolocationPrecision")) # Added since LWC 3.10.0
558+
self.assertFalse(output["options"].get("geolocationDirection")) # Added since LWC 3.10.0
559559
self.assertFalse(output["options"].get("draw"))
560560
self.assertIsNone(output["options"].get("externalSearch"))
561561
self.assertEqual(25, output["options"].get("pointTolerance"))

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)