diff --git a/ohsomeTools/gui/OhsomeToolsDialog.py b/ohsomeTools/gui/OhsomeToolsDialog.py index 46fe215..05645cc 100644 --- a/ohsomeTools/gui/OhsomeToolsDialog.py +++ b/ohsomeTools/gui/OhsomeToolsDialog.py @@ -328,22 +328,10 @@ def run_gui_control(self): return # if there are no centroids or layers, throw an error message - tab_index = self.dlg.request_types_widget.currentIndex() - if tab_index == 0: - self.dlg.global_buttons.button(QDialogButtonBox.Ok).setDisabled( - True - ) - globals()[task_name] = ExtractionTaskFunction( - iface=self.iface, - dlg=self.dlg, - description=f"OHSOME task", - provider=provider, - request_url=preferences.get_request_url(), - preferences=preferences.get_bcircles_request_preferences(), - activate_temporal=preferences.activate_temporal_feature, - ) - QgsApplication.taskManager().addTask(globals()[task_name]) - elif tab_index == 1: + layer_name = self.dlg.comboBox_inputLayer.currentText() + layer = QgsProject.instance().mapLayersByName(layer_name)[0] + wkbType = layer.wkbType() + if wkbType in (QgsWkbTypes.Point, QgsWkbTypes.MultiPoint): self.dlg.global_buttons.button(QDialogButtonBox.Ok).setDisabled( True ) @@ -382,7 +370,7 @@ def run_gui_control(self): last_task = task self.dlg.debug_text.append(f'> cURL: {preferences.cURL(provider)}') QgsApplication.taskManager().addTask(globals()[task_name]) - elif tab_index == 2: + elif wkbType in (QgsWkbTypes.Polygon, QgsWkbTypes.MultiPolygon): self.dlg.global_buttons.button(QDialogButtonBox.Ok).setDisabled( True ) @@ -433,7 +421,7 @@ def run_gui_control(self): ) self.dlg.global_buttons.button(QDialogButtonBox.Ok).setEnabled(True) except Exception as e: - msg = [e.__class__.__name__, str(e)] + msg = f'{e.__class__.__name__} {str(e)}' logger.log("{}: {}".format(*msg), 2) self.dlg.debug_text.append(msg) self.iface.messageBar().pushMessage( @@ -749,44 +737,3 @@ def _on_linetool_map_deactivate(self): QApplication.restoreOverrideCursor() self._iface.mapCanvas().setMapTool(self.last_maptool) self.show() - - def _add_point_layer(self) -> bool: - layer = self.point_layer_input.currentLayer() - list_name = ( - f"{layer.name()} | Radius: {self.point_layer_radius_input.value()}" - ) - if layer and not check_list_duplicates( - self.point_layer_list, list_name - ): - self.point_layer_list.addItem(list_name) - self.point_layer_input.setCurrentIndex(0) - else: - return False - return True - - def _remove_point_layer(self): - layers: QListWidget = self.point_layer_list - selected_layers: [QListWidgetItem] = layers.selectedItems() - if not selected_layers: - return - element: QListWidgetItem - for element in selected_layers: - self.point_layer_list.takeItem(self.point_layer_list.row(element)) - - def _add_polygon_layer(self) -> bool: - layer = self.layer_input.currentLayer() - if layer and not check_list_duplicates(self.layer_list, layer.name()): - self.layer_list.addItem(layer.name()) - self.layer_input.setCurrentIndex(0) - else: - return False - return True - - def _remove_polygon_layer(self): - layers: QListWidget = self.layer_list - selected_layers: [QListWidgetItem] = layers.selectedItems() - if not selected_layers: - return - element: QListWidgetItem - for element in selected_layers: - self.layer_list.takeItem(self.layer_list.row(element)) diff --git a/ohsomeTools/gui/OhsomeToolsDialogUI.py b/ohsomeTools/gui/OhsomeToolsDialogUI.py index e91b1ef..7730799 100644 --- a/ohsomeTools/gui/OhsomeToolsDialogUI.py +++ b/ohsomeTools/gui/OhsomeToolsDialogUI.py @@ -27,6 +27,34 @@ def setupUi(self, OhsomeToolsDialogBase): self.gridLayout_17 = QtWidgets.QGridLayout(OhsomeToolsDialogBase) self.gridLayout_17.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize) self.gridLayout_17.setObjectName("gridLayout_17") + self.global_buttons = QtWidgets.QDialogButtonBox(OhsomeToolsDialogBase) + self.global_buttons.setEnabled(True) + self.global_buttons.setOrientation(QtCore.Qt.Horizontal) + self.global_buttons.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) + self.global_buttons.setObjectName("global_buttons") + self.gridLayout_17.addWidget(self.global_buttons, 2, 1, 1, 1) + self.control_widget = QtWidgets.QWidget(OhsomeToolsDialogBase) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.control_widget.sizePolicy().hasHeightForWidth()) + self.control_widget.setSizePolicy(sizePolicy) + self.control_widget.setMaximumSize(QtCore.QSize(150, 16777215)) + self.control_widget.setObjectName("control_widget") + self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.control_widget) + self.horizontalLayout_8.setObjectName("horizontalLayout_8") + self.help_button = QtWidgets.QPushButton(self.control_widget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.help_button.sizePolicy().hasHeightForWidth()) + self.help_button.setSizePolicy(sizePolicy) + self.help_button.setObjectName("help_button") + self.horizontalLayout_8.addWidget(self.help_button) + self.about_button = QtWidgets.QPushButton(self.control_widget) + self.about_button.setObjectName("about_button") + self.horizontalLayout_8.addWidget(self.about_button) + self.gridLayout_17.addWidget(self.control_widget, 2, 0, 1, 1) self.tabWidget_main = QtWidgets.QTabWidget(OhsomeToolsDialogBase) self.tabWidget_main.setMinimumSize(QtCore.QSize(550, 0)) self.tabWidget_main.setObjectName("tabWidget_main") @@ -39,12 +67,30 @@ def setupUi(self, OhsomeToolsDialogBase): self.scrollArea_2.setWidgetResizable(True) self.scrollArea_2.setObjectName("scrollArea_2") self.scrollAreaWidgetContents_4 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 511, 708)) + self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 511, 733)) self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4") self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_4) self.verticalLayout_8.setObjectName("verticalLayout_8") self.verticalLayout_5 = QtWidgets.QVBoxLayout() self.verticalLayout_5.setObjectName("verticalLayout_5") + self.gridLayout = QtWidgets.QGridLayout() + self.gridLayout.setContentsMargins(5, 5, 5, 5) + self.gridLayout.setObjectName("gridLayout") + self.label_7 = QtWidgets.QLabel(self.scrollAreaWidgetContents_4) + self.label_7.setMaximumSize(QtCore.QSize(60, 16777215)) + self.label_7.setObjectName("label_7") + self.gridLayout.addWidget(self.label_7, 0, 0, 1, 1) + self.comboBox_inputLayer = QtWidgets.QComboBox(self.scrollAreaWidgetContents_4) + self.comboBox_inputLayer.setObjectName("comboBox_inputLayer") + self.gridLayout.addWidget(self.comboBox_inputLayer, 0, 1, 1, 1) + self.lineEdit_radius = QtWidgets.QLineEdit(self.scrollAreaWidgetContents_4) + self.lineEdit_radius.setClearButtonEnabled(False) + self.lineEdit_radius.setObjectName("lineEdit_radius") + self.gridLayout.addWidget(self.lineEdit_radius, 1, 1, 1, 1) + self.label_8 = QtWidgets.QLabel(self.scrollAreaWidgetContents_4) + self.label_8.setObjectName("label_8") + self.gridLayout.addWidget(self.label_8, 1, 0, 1, 1) + self.verticalLayout_5.addLayout(self.gridLayout) self.tabWidget_simple_advanced = QtWidgets.QTabWidget(self.scrollAreaWidgetContents_4) self.tabWidget_simple_advanced.setTabPosition(QtWidgets.QTabWidget.North) self.tabWidget_simple_advanced.setObjectName("tabWidget_simple_advanced") @@ -126,17 +172,6 @@ def setupUi(self, OhsomeToolsDialogBase): self.horizontalLayout_17.addItem(spacerItem1) self.verticalLayout_2.addLayout(self.horizontalLayout_17) self.gridLayout_16.addLayout(self.verticalLayout_2, 4, 0, 1, 1) - self.horizontalLayout_2 = QtWidgets.QHBoxLayout() - self.horizontalLayout_2.setContentsMargins(5, 5, 5, 5) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.label_7 = QtWidgets.QLabel(self.tab_simple) - self.label_7.setMaximumSize(QtCore.QSize(60, 16777215)) - self.label_7.setObjectName("label_7") - self.horizontalLayout_2.addWidget(self.label_7) - self.comboBox_inputLayer = QtWidgets.QComboBox(self.tab_simple) - self.comboBox_inputLayer.setObjectName("comboBox_inputLayer") - self.horizontalLayout_2.addWidget(self.comboBox_inputLayer) - self.gridLayout_16.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) self.tabWidget_simple_advanced.addTab(self.tab_simple, "") self.tab_advanced = QtWidgets.QWidget() self.tab_advanced.setObjectName("tab_advanced") @@ -446,35 +481,7 @@ def setupUi(self, OhsomeToolsDialogBase): self.debug_text.setObjectName("debug_text") self.gridLayout_15.addWidget(self.debug_text, 0, 0, 1, 1) self.tabWidget_main.addTab(self.tab_2, "") - self.gridLayout_17.addWidget(self.tabWidget_main, 0, 0, 1, 2) - self.global_buttons = QtWidgets.QDialogButtonBox(OhsomeToolsDialogBase) - self.global_buttons.setEnabled(True) - self.global_buttons.setOrientation(QtCore.Qt.Horizontal) - self.global_buttons.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) - self.global_buttons.setObjectName("global_buttons") - self.gridLayout_17.addWidget(self.global_buttons, 2, 1, 1, 1) - self.control_widget = QtWidgets.QWidget(OhsomeToolsDialogBase) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.control_widget.sizePolicy().hasHeightForWidth()) - self.control_widget.setSizePolicy(sizePolicy) - self.control_widget.setMaximumSize(QtCore.QSize(150, 16777215)) - self.control_widget.setObjectName("control_widget") - self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.control_widget) - self.horizontalLayout_8.setObjectName("horizontalLayout_8") - self.help_button = QtWidgets.QPushButton(self.control_widget) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.help_button.sizePolicy().hasHeightForWidth()) - self.help_button.setSizePolicy(sizePolicy) - self.help_button.setObjectName("help_button") - self.horizontalLayout_8.addWidget(self.help_button) - self.about_button = QtWidgets.QPushButton(self.control_widget) - self.about_button.setObjectName("about_button") - self.horizontalLayout_8.addWidget(self.about_button) - self.gridLayout_17.addWidget(self.control_widget, 2, 0, 1, 1) + self.gridLayout_17.addWidget(self.tabWidget_main, 1, 0, 1, 1) self.retranslateUi(OhsomeToolsDialogBase) self.tabWidget_main.setCurrentIndex(0) @@ -507,6 +514,11 @@ def setupUi(self, OhsomeToolsDialogBase): def retranslateUi(self, OhsomeToolsDialogBase): _translate = QtCore.QCoreApplication.translate OhsomeToolsDialogBase.setWindowTitle(_translate("OhsomeToolsDialogBase", "ohsomeTools")) + self.help_button.setText(_translate("OhsomeToolsDialogBase", "Help")) + self.about_button.setText(_translate("OhsomeToolsDialogBase", "About")) + self.label_7.setText(_translate("OhsomeToolsDialogBase", "Input Layer:")) + self.lineEdit_radius.setPlaceholderText(_translate("OhsomeToolsDialogBase", "1000")) + self.label_8.setText(_translate("OhsomeToolsDialogBase", "Radius:")) self.label_6.setText(_translate("OhsomeToolsDialogBase", "OSM tag")) self.label_2.setText(_translate("OhsomeToolsDialogBase", "Key")) self.label_3.setText(_translate("OhsomeToolsDialogBase", "Value")) @@ -520,7 +532,6 @@ def retranslateUi(self, OhsomeToolsDialogBase): self.mcomboBox_osm_type.setItemText(0, _translate("OhsomeToolsDialogBase", "Node")) self.mcomboBox_osm_type.setItemText(1, _translate("OhsomeToolsDialogBase", "Way")) self.mcomboBox_osm_type.setItemText(2, _translate("OhsomeToolsDialogBase", "Relation")) - self.label_7.setText(_translate("OhsomeToolsDialogBase", "Input Layer:")) self.tabWidget_simple_advanced.setTabText(self.tabWidget_simple_advanced.indexOf(self.tab_simple), _translate("OhsomeToolsDialogBase", "Simple")) self.filter_label.setToolTip(_translate("OhsomeToolsDialogBase", "
Combines several attributive filters, e.g. OSM type, the geometry (simple feature) type, as well as the OSM tag.
For more information see: https://docs.ohsome.org/ohsome-api/v1/filter.html
")) self.filter_label.setText(_translate("OhsomeToolsDialogBase", "Filter ")) @@ -571,8 +582,6 @@ def retranslateUi(self, OhsomeToolsDialogBase): self.tabWidget_main.setTabText(self.tabWidget_main.indexOf(self.tab), _translate("OhsomeToolsDialogBase", "Parameter")) self.debug_text.setPlaceholderText(_translate("OhsomeToolsDialogBase", "Queries and errors will be printed here.")) self.tabWidget_main.setTabText(self.tabWidget_main.indexOf(self.tab_2), _translate("OhsomeToolsDialogBase", "Log")) - self.help_button.setText(_translate("OhsomeToolsDialogBase", "Help")) - self.about_button.setText(_translate("OhsomeToolsDialogBase", "About")) from qgscheckablecombobox import QgsCheckableComboBox from qgscollapsiblegroupbox import QgsCollapsibleGroupBox # import resources_rc diff --git a/ohsomeTools/gui/OhsomeToolsDialogUI.ui b/ohsomeTools/gui/OhsomeToolsDialogUI.ui index 1b81616..bfce2cb 100644 --- a/ohsomeTools/gui/OhsomeToolsDialogUI.ui +++ b/ohsomeTools/gui/OhsomeToolsDialogUI.ui @@ -41,7 +41,58 @@