def add_flatten_dataset_table(self): """ Add a flatten dataset table with all links and contacts. """ connections, message = connections_list() if not connections: LOGGER.critical(message) self.set_html_content('PgMetadata', message) return if len(connections) > 1: dialog = QInputDialog() dialog.setComboBoxItems(connections) dialog.setWindowTitle(tr("Database")) dialog.setLabelText(tr("Choose the database to add the catalog")) if not dialog.exec_(): return connection_name = dialog.textValue() else: connection_name = connections[0] metadata = QgsProviderRegistry.instance().providerMetadata('postgres') connection = metadata.findConnection(connection_name) locale = QgsSettings().value("locale/userLocale", QLocale().name()) locale = locale.split('_')[0].lower() uri = QgsDataSourceUri(connection.uri()) uri.setTable(f'(SELECT * FROM pgmetadata.export_datasets_as_flat_table(\'{locale}\'))') uri.setKeyColumn('uid') layer = QgsVectorLayer(uri.uri(), '{} - {}'.format(tr("Catalog"), connection_name), 'postgres') QgsProject.instance().addMapLayer(layer)
def changeLayerForFeature(self, currLayer, currFeature): status = False sameGeomTypeLayerList = self.getSameGeomTypeLayerList( currLayer, currFeature) TOMsMessageLog.logMessage( "In setNewLayerForFeature: sameGeomTypeLayerList: {}".format( sameGeomTypeLayerList), level=Qgis.Info) surveyDialog = QInputDialog() surveyDialog.setLabelText("Please confirm new layer for this feature ") surveyDialog.setComboBoxItems(sameGeomTypeLayerList) surveyDialog.setTextValue(currLayer.name()) if surveyDialog.exec_() == QDialog.Accepted: newLayerName = surveyDialog.textValue() TOMsMessageLog.logMessage( "In setNewLayerForFeature: {}".format(newLayerName), level=Qgis.Info) if currLayer.name() != newLayerName: newLayer = QgsProject.instance().mapLayersByName( newLayerName)[0] reply = QMessageBox.information( None, "Information", "Setting {} to layer {}".format( currFeature.attribute("GeometryID"), newLayer.name()), QMessageBox.Ok) status = self.moveFeatureToNewLayer(currLayer, currFeature, newLayer) return status
def updDescrSelectedDimStyle(self): if self.selectedDimStyle is None: return Title = QadMsg.translate( "DimStyle_Dialog", "QAD - Editing dimension style description: " ) + self.selectedDimStyle.name inputDlg = QInputDialog(self) inputDlg.setWindowTitle(Title) inputDlg.setInputMode(QInputDialog.TextInput) inputDlg.setLabelText( QadMsg.translate("DimStyle_Dialog", "New description:")) inputDlg.setTextValue(self.selectedDimStyle.description) inputDlg.resize(600, 100) if inputDlg.exec_(): self.selectedDimStyle.description = inputDlg.textValue() self.selectedDimStyle.save() self.init()