Skip to content

Commit

Permalink
Rm iface from forms
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Feb 24, 2025
1 parent d0f8d9a commit 74c9f96
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
8 changes: 2 additions & 6 deletions ee_plugin/ee_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,13 @@ def initGui(self):
text=self.tr("Add Feature Collection"),
parent=self.iface.mainWindow(),
triggered=lambda: add_feature_collection.form(
self.iface,
accepted=add_feature_collection.callback,
accepted=add_feature_collection.callback
),
)
add_ee_image_button = QtWidgets.QAction(
text=self.tr("Add Image"),
parent=self.iface.mainWindow(),
triggered=lambda: add_ee_image.form(
self.iface,
accepted=add_ee_image.callback,
),
triggered=lambda: add_ee_image.form(accepted=add_ee_image.callback),
)

# Initialize plugin menu
Expand Down
7 changes: 2 additions & 5 deletions ee_plugin/ui/forms/add_ee_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Callable, Optional

import ee
from qgis import gui
from qgis.PyQt import QtWidgets
from qgis.core import QgsMessageLog, Qgis

Expand All @@ -11,10 +10,7 @@
from ..utils import call_func_with_values


# TODO: iface is not used
def form(
iface: gui.QgisInterface, accepted: Optional[Callable] = None, **dialog_kwargs
) -> QtWidgets.QDialog:
def form(accepted: Optional[Callable] = None, **dialog_kwargs) -> QtWidgets.QDialog:
"""Display a dialog to add a GEE dataset to the QGIS map."""
dialog = build_vbox_dialog(
windowTitle="Add Google Earth Engine Image",
Expand Down Expand Up @@ -49,6 +45,7 @@ def form(
],
),
],
**dialog_kwargs,
)

if accepted:
Expand Down
2 changes: 0 additions & 2 deletions ee_plugin/ui/forms/add_feature_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


def form(
iface: gui.QgisInterface,
accepted: Optional[Callable] = None,
**dialog_kwargs,
) -> QtWidgets.QDialog:
Expand Down Expand Up @@ -100,7 +99,6 @@ def form(
],
),
],
parent=iface.mainWindow(),
**dialog_kwargs,
)

Expand Down
10 changes: 5 additions & 5 deletions test/test_form_add_ee_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def test_add_gee_layer_dialog(clean_qgis_iface):
dialog = form(clean_qgis_iface)
dialog = form()
dialog.findChild(QtWidgets.QLineEdit, "image_id").setText("COPERNICUS/S2")

dialog.findChild(QtWidgets.QTextEdit, "viz_params").setText(
Expand All @@ -19,7 +19,7 @@ def test_add_gee_layer_dialog(clean_qgis_iface):


def test_load_gee_layer_srtm(clean_qgis_iface):
dialog = form(clean_qgis_iface)
dialog = form()
dialog.findChild(QtWidgets.QLineEdit, "image_id").setText("USGS/SRTMGL1_003")

dialog.findChild(QtWidgets.QTextEdit, "viz_params").setText(
Expand All @@ -39,7 +39,7 @@ def test_load_gee_layer_srtm(clean_qgis_iface):


def test_converting_viz_params_json(clean_qgis_iface):
dialog = form(clean_qgis_iface)
dialog = form()
dialog.findChild(QtWidgets.QLineEdit, "image_id").setText("USGS/SRTMGL1_003")

# single quotes should get replaced to double quotes
Expand All @@ -56,7 +56,7 @@ def test_converting_viz_params_json(clean_qgis_iface):


def test_invalid_viz_params(clean_qgis_iface):
dialog = form(clean_qgis_iface)
dialog = form()
dialog.findChild(QtWidgets.QLineEdit, "image_id").setText("USGS/SRTMGL1_003")

dialog.findChild(QtWidgets.QTextEdit, "viz_params").setText(
Expand All @@ -69,7 +69,7 @@ def test_invalid_viz_params(clean_qgis_iface):


def test_empty_viz_params(clean_qgis_iface):
dialog = form(clean_qgis_iface)
dialog = form()
dialog.findChild(QtWidgets.QLineEdit, "image_id").setText("USGS/SRTMGL1_003")

dialog.findChild(QtWidgets.QTextEdit, "viz_params").setText("")
Expand Down

0 comments on commit 74c9f96

Please sign in to comment.