Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering order and add translations #40

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- Feat: Add finnish translations
- Fix: Set annotation rendering order based on priority

## [2.0.7] - 2024-01-17

- Fix: Process modifications in quality error tree correctly when multiple filters are present
Expand Down
12 changes: 12 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ Or run specific tests with:
docker run --rm -it qgis-quality-result-gui pytest test/unit/quality_result_gui/test_quality_data_fetcher.py
```

## Translations

To update or add translations with the wanted language, run the following in the root of the project:

```bash
(.venv) python tools/update-translations.py src/quality_result_gui src/quality_result_gui/resources/i18n <locale>
```

You can then open the *.ts* files you wish to translate with Qt Linguist and make the changes.

Compile the translations to *.qm* files with *File -> Release*

## Release steps

When the branch is in a releasable state, trigger the `Create draft release` workflow from GitHub Actions. Pass the to-be-released version number as an input to the workflow.
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ ban-relative-imports = "all"
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"PLR0913", # Too many arguments to function call (len(args) > 5)
]
"tools*" = [
"T201",
"N999"
]


[tool.flake8]
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pytest==6.2.5
pytest-qt==3.3.0
pytest-cov==2.12.0
pytest-mock==3.7.0
pytest-qgis==1.3.5
pytest-qgis==2.0.0
pytest-timeout==1.4.2
pytest-order==1.0.0
pytest-dotenv==0.5.2
Expand Down
28 changes: 6 additions & 22 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements.in
#

-e file:.
# via -r requirements.in
astor==0.8.1
# via flake8-qgis
atomicwrites==1.4.0
# via
# -r requirements.in
# pytest
# via -r requirements.in
attrs==23.1.0
# via pytest
black==23.7.0
Expand All @@ -25,14 +22,8 @@ charset-normalizer==3.3.0
# via requests
click==8.1.7
# via black
colorama==0.4.6
# via
# click
# pytest
coverage[toml]==7.3.2
# via
# coverage
# pytest-cov
# via pytest-cov
distlib==0.3.7
# via virtualenv
filelock==3.12.4
Expand Down Expand Up @@ -108,7 +99,7 @@ pytest-mock==3.7.0
# via -r requirements.in
pytest-order==1.0.0
# via -r requirements.in
pytest-qgis==1.3.5
pytest-qgis==2.0.0
# via -r requirements.in
pytest-qt==3.3.0
# via -r requirements.in
Expand All @@ -131,16 +122,9 @@ ruff==0.0.292
toml==0.10.2
# via pytest
tomli==2.0.1
# via
# black
# coverage
# flake8-pyproject
# mypy
# qgis-plugin-dev-tools
# via qgis-plugin-dev-tools
typing-extensions==4.8.0
# via
# black
# mypy
# via mypy
urllib3==2.0.6
# via requests
virtualenv==20.24.5
Expand Down
4 changes: 4 additions & 0 deletions src/quality_result_gui/quality_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,8 @@ def _create_annotations( # noqa: C901, PLR0912
else:
raise ValueError(f"Unsupported geom type: {geom_type}")

for annotation in annotations:
# Set z-index based on the priority
annotation.setZIndex(-quality_error.priority.value)

return annotations
Binary file added src/quality_result_gui/resources/i18n/fi.qm
Binary file not shown.
150 changes: 150 additions & 0 deletions src/quality_result_gui/resources/i18n/fi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="fi_FI" sourcelanguage="en">
<context>
<name>@default</name>
<message>
<location filename="../../quality_errors_tree_model.py" line="76"/>
<source>Errors</source>
<translation>Virheet</translation>
</message>
<message>
<location filename="../../quality_errors_tree_model.py" line="80"/>
<source>Error description</source>
<translation>Virheen kuvaus</translation>
</message>
<message>
<location filename="../../quality_layer.py" line="96"/>
<source>Quality errors</source>
<translation>Laatuvirheet</translation>
</message>
<message>
<location filename="../../quality_errors_filters.py" line="116"/>
<source>Select all</source>
<translation>Valitse kaikki</translation>
</message>
<message>
<location filename="../../quality_errors_filters.py" line="119"/>
<source>Deselect all</source>
<translation>Poista valinta kaikilta</translation>
</message>
<message>
<location filename="../../quality_errors_filters.py" line="382"/>
<source>Error type</source>
<translation>Virheen tyyppi</translation>
</message>
<message>
<location filename="../../quality_errors_filters.py" line="410"/>
<source>Feature type</source>
<translation>Kohdeluokka</translation>
</message>
<message>
<location filename="../../quality_errors_filters.py" line="456"/>
<source>Attribute Filter</source>
<translation>Ominaisuustietosuodatin</translation>
</message>
<message>
<location filename="../../quality_error_manager.py" line="178"/>
<source>Status of fetching quality result unknown</source>
<translation>Laatuvirheiden hakemisen tila on tuntematon</translation>
</message>
<message>
<location filename="../../quality_data_fetcher.py" line="49"/>
<source>Quality results are up to date</source>
<translation>Laatuvirheet ovat ajan tasalla</translation>
</message>
<message>
<location filename="../../quality_data_fetcher.py" line="53"/>
<source>Quality check is in progress</source>
<translation>Laatuvirheiden tarkistus on käynnissä</translation>
</message>
<message>
<location filename="../../quality_data_fetcher.py" line="57"/>
<source>Quality result update failed</source>
<translation>Laatuvirheiden päivitys epäonnistui</translation>
</message>
<message>
<location filename="../../quality_data_fetcher.py" line="61"/>
<source>Checking for quality result updates</source>
<translation>Tarkistetaan onko laatuvirhepäivityksiä saatavilla</translation>
</message>
<message>
<location filename="../../api/types/quality_error.py" line="36"/>
<source>Attribute error</source>
<translation>Ominaisuustietovirhe</translation>
</message>
<message>
<location filename="../../api/types/quality_error.py" line="40"/>
<source>Geometry error</source>
<translation>Geometriavirhe</translation>
</message>
<message>
<location filename="../../api/types/quality_error.py" line="44"/>
<source>Topology error</source>
<translation>Topologiavirhe</translation>
</message>
<message>
<location filename="../../api/types/quality_error.py" line="48"/>
<source>Continuity error</source>
<translation>Jatkuvuusvirhe</translation>
</message>
<message>
<location filename="../../api/types/quality_error.py" line="66"/>
<source>Fatal</source>
<translation>Hylkäävä</translation>
</message>
<message>
<location filename="../../api/types/quality_error.py" line="70"/>
<source>Warning</source>
<translation>Vakava</translation>
</message>
<message>
<location filename="../../api/types/quality_error.py" line="74"/>
<source>Info</source>
<translation>Huomautus</translation>
</message>
<message>
<location filename="../../ui/quality_errors_tree_filter_menu.py" line="44"/>
<source>Reset filters</source>
<translation>Nollaa suodattimet</translation>
</message>
<message>
<location filename="../../ui/quality_errors_dock.py" line="76"/>
<source>Toggle show errors on map filter</source>
<translation>Muuta &quot;Näytä vain karttanäkymässä olevat virheet&quot; suodattimen tilaa</translation>
</message>
</context>
<context>
<name>quality_errors_dock</name>
<message>
<location filename="../../ui/quality_errors_dock.ui" line="14"/>
<source>Quality errors</source>
<translation>Laatuvirheet</translation>
</message>
<message>
<location filename="../../ui/quality_errors_dock.ui" line="23"/>
<source>No errors received yet</source>
<translation>Virheitä ei ole vastaanotettu vielä</translation>
</message>
<message>
<location filename="../../ui/quality_errors_dock.ui" line="67"/>
<source>Show already processed errors in list</source>
<translation>Näytä käsitellyt virheet listassa</translation>
</message>
<message>
<location filename="../../ui/quality_errors_dock.ui" line="77"/>
<source>Show only errors within map extent</source>
<translation>Näytä vain karttanäkymässä olevat virheet</translation>
</message>
<message>
<location filename="../../ui/quality_errors_dock.ui" line="87"/>
<source>Visualize errors on map</source>
<translation>Visualisoi virheet karttanäkymässä</translation>
</message>
<message>
<location filename="../../ui/quality_errors_dock.ui" line="104"/>
<source>Close</source>
<translation>Sulje</translation>
</message>
</context>
</TS>
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@
"is_user_processed": false,
"wkt_geom": "PolygonZ ((232237.78700000001117587 6712152.30400000046938658 3.875, 232247.94500000000698492 6712143.11799999978393316 0, 232253.35300000000279397 6712148.50900000054389238 3.81499999999999995, 232248.9370000000053551 6712152.56199999991804361 3.81499999999999995, 232243.10899999999674037 6712158.15400000009685755 3.875, 232237.78700000001117587 6712152.30400000046938658 3.875))"
},
{
"priority": 2,
"feature_type": "chimney_point",
"feature_id": "978d7670-5107-495f-a033-82c22f713c91",
"error_id": 6,
"unique_identifier": "61",
"error_type": 1,
"attribute_name": null,
"error_description": "Self-intersection",
"extra_info": null,
"is_user_processed": false,
"wkt_geom": "PointZ (233041.0456 6711924.7397 0)"
},
{
"priority": 1,
"feature_type": "chimney_point",
"feature_id": "978d7670-5107-495f-a033-82c22f713c91",
"error_id": 6,
"unique_identifier": "62",
"error_type": 1,
"attribute_name": "height_relative",
"error_description": "Invalid value",
"extra_info": null,
"is_user_processed": false,
"wkt_geom": "PointZ (233041.0456 6711924.7397 0)"
},
{
"priority": 1,
"feature_type": "chimney_point",
Expand Down
12 changes: 5 additions & 7 deletions test/unit/quality_result_gui/test_quality_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with quality-result-gui. If not, see <https://www.gnu.org/licenses/>.

from collections.abc import Iterator
from unittest.mock import ANY

import pytest
Expand All @@ -43,14 +42,11 @@ def quality_layer(qgis_new_project: None) -> QualityErrorLayer:
@pytest.fixture()
def quality_layer_created(
quality_layer: QualityErrorLayer,
) -> Iterator[QualityErrorLayer]:
) -> QualityErrorLayer:
annotation_layer = quality_layer.get_annotation_layer()
assert isinstance(annotation_layer, QgsAnnotationLayer)
QgsProject.instance().addMapLayer(annotation_layer)

yield quality_layer

QgsProject.instance().removeMapLayer(annotation_layer.id())
return quality_layer


def test_find_layer_from_project_when_not_added_to_project_should_do_nothing(
Expand Down Expand Up @@ -141,7 +137,9 @@ def test_add_or_replace_annotation_with_new_quality_errors(

for key in annotation_layer.items():
assert key in sum(quality_layer_created._annotation_ids.values(), [])
assert annotation_layer.item(key).geometry().isEmpty() is False
item = annotation_layer.item(key)
assert not item.geometry().isEmpty()
assert item.zIndex() == -priority.value


@pytest.mark.parametrize(
Expand Down
Empty file added tools/__init__.py
Empty file.
Loading
Loading