Esempio n. 1
0
    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)
Esempio n. 2
0
 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()