Ejemplo 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)
    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
Ejemplo n.º 3
0
 def rename_query(self, query: QListWidgetItem):
     """Rename a query in the preset"""
     input_dialog = QInputDialog(self)
     new_name = input_dialog.getText(
         self, tr("Rename the query"),
         tr("New name:"), text=query.text())
     if new_name[1] and new_name[0]:
         query.setText(new_name[0].replace(' ', '_'))
         self.update_qml_format()
Ejemplo n.º 4
0
 def on_clone_btn_clicked(self):
     title = (self.selected_proj_def['title'] +
              ' (copy)' if 'title' in self.selected_proj_def else '(copy)')
     title, ok = QInputDialog().getText(self,
                                        tr('Assign a title'),
                                        tr('Project definition title'),
                                        text=title)
     if ok:
         self.add_proj_def(title, self.selected_proj_def)
Ejemplo n.º 5
0
 def create_project(self):
     """Creates a new project."""
     name, ok = QInputDialog().getText(self.dlg, "Create project",
                                       "Name of the new project:",
                                       QLineEdit.Normal)
     if ok and name:
         self.set_busy_cursor()
         try:
             self.cloudqube.create_project(name, self.project_created,
                                           self.show_error)
         except Exception as err:
             self.iface.messageBar().pushCritical(
                 'Failure', "Couldn't create project: {0}".format(err))
Ejemplo n.º 6
0
 def create_signature_callback(self, hiperqube_id, pixels):
     """Creates a signature for the given hiperqube_id."""
     try:
         name, ok = QInputDialog().getText(self.dlg, "Create signature",
                                           "Name of the new signature:",
                                           QLineEdit.Normal)
         if ok and name:
             self.set_busy_cursor()
             self.cloudqube.create_signature(hiperqube_id, name, pixels,
                                             self.signature_created,
                                             self.show_error)
     except Exception as err:
         self.iface.messageBar().pushCritical(
             'Failure', "Couldn't create signature: {0}".format(err))
         self.restore_cursor()
Ejemplo n.º 7
0
 def run_config(self):
     question = "Geef het wachtwoord:"
     qid = QInputDialog()
     password, ok = QInputDialog.getText(
         qid,
         "Password:"******"01v":
         self.configwidget = oivConfigWidget()
         self.iface.addDockWidget(Qt.RightDockWidgetArea, self.configwidget)
         self.configwidget.show()
     else:
         QMessageBox.information(None, "DEBUG:", "Verkeerd password!")
Ejemplo n.º 8
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()
Ejemplo n.º 9
0
def user_input_label(label_req, question):
    label = ''
    qid = QInputDialog()
    #communiceer met de gebruiker voor input, waarbij question de vraag is die wordt gesteld
    if label_req < '2':
        while True:
            label, ok = QInputDialog.getText(
                qid,
                "Label:",
                question,
                QLineEdit.Normal,
            )
            if ok:
                if label != '' or label_req == '0':
                    return label
                    break
            else:
                label = 'Cancel'
                return label
                break
Ejemplo n.º 10
0
 def on_add_proj_def_btn_clicked(self):
     title, ok = QInputDialog().getText(self, tr('Assign a title'),
                                        tr('Project definition title'))
     if ok:
         self.add_proj_def(title)