def _refresh_services(self): # fill the FDSN listWidget with the dictionary keys self.fdsn_event_list.clear() self.fdsn_event_list.addItems(SERVICE_MANAGER.available_services(SERVICE_MANAGER.FDSNEVENT)) self.fdsn_event_list.setCurrentRow(0) # fill the FDSN listWidget with the dictionary keys self.fdsn_macro_list.clear() self.fdsn_macro_list.addItems(SERVICE_MANAGER.available_services(SERVICE_MANAGER.MACROSEISMIC)) self.fdsn_macro_list.setCurrentRow(0) # fill the FDSN listWidget with the dictionary keys self.fdsn_station_list.clear() self.fdsn_station_list.addItems(SERVICE_MANAGER.available_services(SERVICE_MANAGER.FDSNSTATION)) self.fdsn_station_list.setCurrentRow(0) self.refreshOgcWidgets()
def refreshOgcWidgets(self): """ read the ogc_combo and fill it with the services """ self.ogc_list_model.clear() ogc_selection = self.ogc_combo.currentData() services = SERVICE_MANAGER.available_services(ogc_selection) group_items = {} for service in services: service_config = SERVICE_MANAGER.service_details( ogc_selection, service) group = service_config.get('group') if not group or group in group_items: continue group_item = QStandardItem(group) group_item.setFlags(Qt.ItemIsEnabled) self.ogc_list_model.appendRow([group_item]) group_items[group] = group_item first_item = None for service in services: item = QStandardItem(service) item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) item.setData(service, role=Qt.UserRole) if not first_item: first_item = item service_config = SERVICE_MANAGER.service_details( ogc_selection, service) group = service_config.get('group') if group: parent = group_items[group] parent.appendRow([item]) else: self.ogc_list_model.appendRow([item]) self.ogc_list.expandAll() first_item_index = self.ogc_list_model.indexFromItem(first_item) self.ogc_list.selectionModel().select( first_item_index, QItemSelectionModel.ClearAndSelect) service_config = SERVICE_MANAGER.service_details( ogc_selection, self.get_current_service_id(ogc_selection)) self.button_ogc_edit_service.setEnabled( not service_config['read_only']) self.button_ogc_rename_service.setEnabled( not service_config['read_only']) self.button_ogc_remove_service.setEnabled( not service_config['read_only'])
def refreshOgcWidgets(self): """ read the ogc_combo and fill it with the services """ self.ogc_list.clear() ogc_selection = self.ogc_combo.currentData() self.ogc_list.addItems(SERVICE_MANAGER.available_services(ogc_selection)) self.ogc_list.setCurrentRow(0) service_config = SERVICE_MANAGER.service_details(ogc_selection, self.get_current_service_id(ogc_selection)) self.button_ogc_edit_service.setEnabled(not service_config['read_only']) self.button_ogc_rename_service.setEnabled(not service_config['read_only']) self.button_ogc_remove_service.setEnabled(not service_config['read_only'])
def _create_configuration(self): service_type = self.get_current_service_type() dlg = QgsNewNameDialog('', '', [], existing=SERVICE_MANAGER.available_services(service_type)) dlg.setHintString(self.tr('Create a new service configuration named')) dlg.setWindowTitle(self.tr('New Service Configuration')) dlg.setOverwriteEnabled(False) dlg.setConflictingNameWarning(self.tr('A configuration with this name already exists')) if not dlg.exec_(): return name = dlg.name() config_dialog = ServiceConfigurationDialog(self.iface, service_type, name, self) if config_dialog.exec_(): self.set_current_service(service_type, name)
def _rename_service(self): service_type = self.get_current_service_type() service_id = self.get_current_service_id(service_type) dlg = QgsNewNameDialog(service_id, service_id, [], existing=SERVICE_MANAGER.available_services(service_type)) dlg.setHintString(self.tr('Rename service configuration to')) dlg.setWindowTitle(self.tr('Rename Service Configuration')) dlg.setOverwriteEnabled(False) dlg.setConflictingNameWarning(self.tr('A configuration with this name already exists')) if not dlg.exec_(): return new_name = dlg.name() SERVICE_MANAGER.rename_service(service_type, service_id, new_name) self.set_current_service(service_type, new_name)
def __init__( self, iface, # pylint: disable=unused-argument,too-many-branches service_type: str, service_id: str, parent: Optional[QWidget] = None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.qml_style_name_combo.addItem('') self.qml_style_name_combo_mdp.addItem('') for name, props in SERVICE_MANAGER.PRESET_STYLES.items(): if props['type'] in ('events', 'stations'): self.qml_style_name_combo.addItem(name) elif props['type'] == 'macroseismic': self.qml_style_name_combo_mdp.addItem(name) self.service_type = service_type self.service_id = service_id self.start_date_edit.setDisplayFormat("yyyy-MM-dd HH:mm:ss") self.end_date_edit.setDisplayFormat("yyyy-MM-dd HH:mm:ss") if service_id in SERVICE_MANAGER.available_services(service_type): config = SERVICE_MANAGER.service_details(service_type, service_id) else: config = {} self.set_state_from_config(config) self.title_edit.textChanged.connect(self._changed) self.web_service_url_edit.textChanged.connect(self._changed) self.combo_http_code_nodata.addItem('204', '204') for _, w in self.WIDGET_MAP.items(): widget = getattr(self, w) if isinstance(widget, QCheckBox): widget.toggled.connect(self._changed) elif isinstance(widget, QSpinBox): widget.valueChanged.connect(self._changed) self.check_http_code_nodata.toggled.connect(self._changed) self.combo_http_code_nodata.currentIndexChanged.connect(self._changed) if self.service_type in (SERVICE_MANAGER.WMS, SERVICE_MANAGER.WFS): for w in [self.group_capabilities, self.group_bounding_box]: w.setEnabled(False) w.hide() else: self.group_ogc_layers.setEnabled(False) self.group_ogc_layers.hide() self.group_label.hide() self.group_edit.hide() if self.service_type == SERVICE_MANAGER.FDSNSTATION: for w in [ self.check_filter_by_eventid, self.check_filter_by_originid, self.check_filter_by_magnitudeid, self.check_filter_by_focalmechanismid, self.check_filter_by_catalog, self.check_filter_by_contributor, self.check_filter_by_contributorid, self.check_filter_by_event_type, self.check_filter_by_magnitude_type, self.check_can_include_all_origins, self.check_can_include_all_magnitudes, self.check_can_include_arrivals, self.check_can_include_all_stations_magnitudes, self.check_has_limit_of_entries, self.spin_has_limit_of_entries, self.check_can_filter_by_depth ]: w.setEnabled(False) self._changed()
def get_config(self) -> dict: # pylint: disable=too-many-branches """ Returns the configuration of the service defined in the widget """ if self.service_id in SERVICE_MANAGER.available_services( self.service_type): config = deepcopy( SERVICE_MANAGER.service_details(self.service_type, self.service_id)) else: config = {'default': {}, 'settings': {}} config['title'] = self.title_edit.text() config['group'] = self.group_edit.text() config['servicedescription'] = self.service_description_edit.text() config[ 'servicedescriptionurl'] = self.service_description_url_edit.text( ) config['datadescription'] = self.data_description_edit.text() config['datadescriptionurl'] = self.data_description_url_edit.text() config[ 'publications'] = [] if not self.publications_text_edit.toPlainText( ) else self.publications_text_edit.toPlainText().split('\n') config['manualurl'] = self.webservice_manual_url_edit.text() config['datalicense'] = self.data_license_edit.text() config['datalicenseurl'] = self.data_license_url_edit.text() config['dataprovider'] = self.data_provider_edit.text() config['dataproviderurl'] = self.data_provider_url_edit.text() config['endpointurl'] = self.web_service_url_edit.text() config['styleurl'] = self.qml_style_url_edit.text() config['default']['style'] = self.qml_style_name_combo.currentText() config['mdpstyleurl'] = self.qml_style_url_edit_mdp.text() config['default'][ 'mdp_style'] = self.qml_style_name_combo_mdp.currentText() if self.start_date_edit.dateTime().isValid(): config['datestart'] = self.start_date_edit.dateTime().toString( Qt.ISODate) else: config['datestart'] = '' if self.end_date_edit.dateTime().isValid(): config['dateend'] = self.end_date_edit.dateTime().toString( Qt.ISODate) else: config['dateend'] = '' if self.group_bounding_box.isEnabled(): bounding_box = [ self.min_long_spin.value(), self.min_lat_spin.value(), self.max_long_spin.value(), self.max_lat_spin.value() ] config['boundingbox'] = bounding_box if self.group_capabilities.isEnabled(): settings = {} for key, w in self.WIDGET_MAP.items(): widget = getattr(self, w) if not widget.isEnabled(): continue if isinstance(widget, QCheckBox): settings[key] = widget.isChecked() elif isinstance(widget, QSpinBox): settings[key] = widget.value() if self.check_http_code_nodata.isChecked(): settings[ 'httpcodenodata'] = self.combo_http_code_nodata.currentData( ) config['settings'] = settings if self.group_ogc_layers.isEnabled(): config['default']['layers'] = json.loads( self.ogc_layers_edit.text()) return config
def __init__( self, iface, # pylint: disable=unused-argument,too-many-branches,too-many-statements service_type: str, service_id: str, parent: Optional[QWidget] = None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.qml_style_name_combo_events.addItem('') self.qml_style_name_combo_mdp.addItem('') self.qml_style_name_combo_stations.addItem('') self.label_qml_events.setVisible( service_type in (SERVICE_MANAGER.FDSNEVENT, SERVICE_MANAGER.MACROSEISMIC)) self.qml_style_url_edit_events.setVisible( service_type in (SERVICE_MANAGER.FDSNEVENT, SERVICE_MANAGER.MACROSEISMIC)) self.label_preset_style_events.setVisible( service_type in (SERVICE_MANAGER.FDSNEVENT, SERVICE_MANAGER.MACROSEISMIC)) self.qml_style_name_combo_events.setVisible( service_type in (SERVICE_MANAGER.FDSNEVENT, SERVICE_MANAGER.MACROSEISMIC)) self.label_mdp_url.setVisible( service_type == SERVICE_MANAGER.MACROSEISMIC) self.qml_style_url_edit_mdp.setVisible( service_type == SERVICE_MANAGER.MACROSEISMIC) self.qml_style_name_combo_mdp.setVisible( service_type == SERVICE_MANAGER.MACROSEISMIC) self.mdp_preset_label.setVisible( service_type == SERVICE_MANAGER.MACROSEISMIC) self.label_stations_url.setVisible( service_type == SERVICE_MANAGER.FDSNSTATION) self.qml_style_url_edit_stations.setVisible( service_type == SERVICE_MANAGER.FDSNSTATION) self.label_preset_name_stations.setVisible( service_type == SERVICE_MANAGER.FDSNSTATION) self.qml_style_name_combo_stations.setVisible( service_type == SERVICE_MANAGER.FDSNSTATION) for name in SERVICE_MANAGER.styles_for_service_type( SERVICE_MANAGER.FDSNEVENT): self.qml_style_name_combo_events.addItem( SERVICE_MANAGER.get_style(name)['label'], name) for name in SERVICE_MANAGER.styles_for_service_type( SERVICE_MANAGER.MACROSEISMIC): self.qml_style_name_combo_mdp.addItem( SERVICE_MANAGER.get_style(name)['label'], name) for name in SERVICE_MANAGER.styles_for_service_type( SERVICE_MANAGER.FDSNSTATION): self.qml_style_name_combo_stations.addItem( SERVICE_MANAGER.get_style(name)['label'], name) self.service_type = service_type self.service_id = service_id self.start_date_edit.setDisplayFormat("yyyy-MM-dd HH:mm:ss") self.end_date_edit.setDisplayFormat("yyyy-MM-dd HH:mm:ss") if service_id in SERVICE_MANAGER.available_services(service_type): config = SERVICE_MANAGER.service_details(service_type, service_id) else: # this is the default configuration for a newly created service! config = {'settings': {'outputxml': True, 'httpcodenodata': True}} self.set_state_from_config(config) self.title_edit.textChanged.connect(self._changed) self.web_service_url_edit.textChanged.connect(self._changed) self.combo_http_code_nodata.addItem('204', '204') for _, w in self.WIDGET_MAP.items(): widget = getattr(self, w) if isinstance(widget, QCheckBox): widget.toggled.connect(self._changed) elif isinstance(widget, QSpinBox): widget.valueChanged.connect(self._changed) self.check_http_code_nodata.toggled.connect(self._changed) self.combo_http_code_nodata.currentIndexChanged.connect(self._changed) if self.service_type in (SERVICE_MANAGER.WMS, SERVICE_MANAGER.WFS, SERVICE_MANAGER.WCS): for w in [self.group_capabilities, self.group_bounding_box]: w.setEnabled(False) w.hide() else: self.group_ogc_layers.setEnabled(False) self.group_ogc_layers.hide() self.group_label.hide() self.group_edit.hide() if self.service_type == SERVICE_MANAGER.FDSNSTATION: for w in [ self.check_filter_by_eventid, self.check_filter_by_originid, self.check_filter_by_magnitudeid, self.check_filter_by_focalmechanismid, self.check_filter_by_catalog, self.check_filter_by_contributor, self.check_filter_by_contributorid, self.check_filter_by_event_type, self.check_filter_by_magnitude_type, self.check_can_include_all_origins, self.check_can_include_all_magnitudes, self.check_can_include_all_origins_multiple, self.check_can_include_all_magnitudes_multiple, self.check_can_include_arrivals, self.check_can_include_all_stations_magnitudes, self.check_has_limit_of_entries, self.spin_has_limit_of_entries, self.check_can_filter_by_depth ]: w.setEnabled(False) self.button_load_service.clicked.connect(self._load_service) self._changed()