def load_parametric_values(self, dialog, function):
        """ Load QGIS settings related with parametric toolbox options """

        function_name = function[0]['functionname']
        layout = dialog.findChild(QWidget, 'grb_parameters')
        widgets = layout.findChildren(QWidget)

        for widget in widgets:
            if type(widget) not in (QCheckBox, QComboBox, QLineEdit,
                                    QRadioButton):
                continue
            if type(widget) in (QCheckBox, QRadioButton):
                value = get_parser_value(
                    'toolbox',
                    f"parametric_{function_name}_{widget.objectName()}")
                qt_tools.setChecked(dialog, widget, value)

            elif type(widget) is QComboBox:
                if widget.property('selectedId') in (None, '', 'NULL'):
                    value = get_parser_value(
                        'toolbox',
                        f"parametric_{function_name}_{widget.objectName()}")
                else:
                    value = widget.property('selectedId')
                qt_tools.set_combo_itemData(widget, value, 0)
            elif type(widget) in (QLineEdit, QSpinBox):
                value = get_parser_value(
                    'toolbox',
                    f"parametric_{function_name}_{widget.objectName()}")
                qt_tools.setWidgetText(dialog, widget, value)
예제 #2
0
    def go2epa(self):
        """ Button 23: Open form to set INP, RPT and project """

        # Show form in docker?
        self.controller.init_docker('qgis_form_docker')

        # Create dialog
        self.dlg_go2epa = Go2EpaUI()
        load_settings(self.dlg_go2epa)
        self.load_user_values()
        if self.project_type in 'ws':
            self.dlg_go2epa.chk_export_subcatch.setVisible(False)

        # Set signals
        self.set_signals()

        if self.project_type == 'ws':
            self.dlg_go2epa.btn_hs_ds.setText("Dscenario Selector")
            tableleft = "cat_dscenario"
            tableright = "selector_inp_demand"
            field_id_left = "dscenario_id"
            field_id_right = "dscenario_id"
            self.dlg_go2epa.btn_hs_ds.clicked.connect(
                partial(self.sector_selection,
                        tableleft,
                        tableright,
                        field_id_left,
                        field_id_right,
                        aql=""))

        elif self.project_type == 'ud':
            self.dlg_go2epa.btn_hs_ds.setText("Hydrology selector")
            self.dlg_go2epa.btn_hs_ds.clicked.connect(
                self.ud_hydrology_selector)

        # Check OS and enable/disable checkbox execute EPA software
        if sys.platform != "win32":
            qt_tools.setChecked(self.dlg_go2epa, self.dlg_go2epa.chk_exec,
                                False)
            self.dlg_go2epa.chk_exec.setEnabled(False)
            self.dlg_go2epa.chk_exec.setText(
                'Execute EPA software (Runs only on Windows)')

        self.set_completer_result(self.dlg_go2epa.txt_result_name,
                                  'v_ui_rpt_cat_result', 'result_id')

        if self.controller.dlg_docker:
            self.controller.manage_translation('go2epa', self.dlg_go2epa)
            self.controller.dock_dialog(self.dlg_go2epa)
            self.dlg_go2epa.btn_cancel.clicked.disconnect()
            self.dlg_go2epa.btn_cancel.clicked.connect(
                self.controller.close_docker)
        else:
            open_dialog(self.dlg_go2epa, dlg_name='go2epa')
    def load_user_values(self):
        """ Load last selected user values
        :return: Dictionary with values
        """

        host = get_parser_value('i18n_generator', 'qm_lang_host')
        port = get_parser_value('i18n_generator', 'qm_lang_port')
        db = get_parser_value('i18n_generator', 'qm_lang_db')
        user = get_parser_value('i18n_generator', 'qm_lang_user')
        py_msg = get_parser_value('i18n_generator', 'qm_lang_py_msg')
        db_msg = get_parser_value('i18n_generator', 'qm_lang_db_msg')
        qt_tools.setWidgetText(self.dlg_qm, 'txt_host', host)
        qt_tools.setWidgetText(self.dlg_qm, 'txt_port', port)
        qt_tools.setWidgetText(self.dlg_qm, 'txt_db', db)
        qt_tools.setWidgetText(self.dlg_qm, 'txt_user', user)
        qt_tools.setChecked(self.dlg_qm, self.dlg_qm.chk_py_msg, py_msg)
        qt_tools.setChecked(self.dlg_qm, self.dlg_qm.chk_db_msg, db_msg)
예제 #4
0
    def go2epa_options_get_data(self, tablename, dialog):
        """ Get data from selected table """

        sql = f"SELECT * FROM {tablename}"
        row = self.controller.get_row(sql)
        if not row:
            message = "Any data found in table"
            self.controller.show_warning(message, parameter=tablename)
            return None

        # Iterate over all columns and populate its corresponding widget
        columns = []
        for i in range(0, len(row)):
            column_name = self.controller.dao.get_column_name(i)
            widget = dialog.findChild(QWidget, column_name)
            widget_type = qt_tools.getWidgetType(dialog, widget)
            if row[column_name] is not None:
                if widget_type is QCheckBox:
                    qt_tools.setChecked(dialog, widget, row[column_name])
                elif widget_type is QComboBox:
                    qt_tools.set_combo_itemData(widget, row[column_name], 0)
                elif widget_type is QDateEdit:
                    dateaux = row[column_name].replace('/', '-')
                    date = QDate.fromString(dateaux, 'dd-MM-yyyy')
                    qt_tools.setCalendarDate(dialog, widget, date)
                elif widget_type is QTimeEdit:
                    timeparts = str(row[column_name]).split(':')
                    if len(timeparts) < 3:
                        timeparts.append("0")
                    days = int(timeparts[0]) / 24
                    hours = int(timeparts[0]) % 24
                    minuts = int(timeparts[1])
                    seconds = int(timeparts[2])
                    time = QTime(hours, minuts, seconds)
                    qt_tools.setTimeEdit(dialog, widget, time)
                    qt_tools.setText(dialog, column_name + "_day", days)
                else:
                    qt_tools.setWidgetText(dialog, widget,
                                           str(row[column_name]))

            columns.append(column_name)

        return columns
예제 #5
0
    def load_user_values(self):
        """ Load QGIS settings related with file_manager """

        cur_user = self.controller.get_current_user()

        self.dlg_go2epa.txt_result_name.setMaxLength(16)
        self.result_name = self.controller.plugin_settings_value(
            'go2epa_RESULT_NAME' + cur_user)
        self.dlg_go2epa.txt_result_name.setText(self.result_name)
        self.file_inp = self.controller.plugin_settings_value(
            'go2epa_FILE_INP' + cur_user)
        self.dlg_go2epa.txt_file_inp.setText(self.file_inp)
        self.file_rpt = self.controller.plugin_settings_value(
            'go2epa_FILE_RPT' + cur_user)
        self.dlg_go2epa.txt_file_rpt.setText(self.file_rpt)

        value = self.controller.plugin_settings_value(
            'go2epa_chk_NETWORK_GEOM' + cur_user)
        if str(value) == 'true':
            qt_tools.setChecked(self.dlg_go2epa,
                                self.dlg_go2epa.chk_only_check, True)
        value = self.controller.plugin_settings_value('go2epa_chk_INP' +
                                                      cur_user)
        if str(value) == 'true':
            qt_tools.setChecked(self.dlg_go2epa, self.dlg_go2epa.chk_export,
                                True)
        value = self.controller.plugin_settings_value('go2epa_chk_UD' +
                                                      cur_user)
        if str(value) == 'true':
            qt_tools.setChecked(self.dlg_go2epa,
                                self.dlg_go2epa.chk_export_subcatch, True)
        value = self.controller.plugin_settings_value('go2epa_chk_EPA' +
                                                      cur_user)
        if str(value) == 'true':
            qt_tools.setChecked(self.dlg_go2epa, self.dlg_go2epa.chk_exec,
                                True)
        value = self.controller.plugin_settings_value('go2epa_chk_RPT' +
                                                      cur_user)
        if str(value) == 'true':
            qt_tools.setChecked(self.dlg_go2epa,
                                self.dlg_go2epa.chk_import_result, True)
    def load_settings_values(self, dialog, function):
        """ Load QGIS settings related with toolbox options """

        function_name = function[0]['functionname']
        if dialog.cmb_geom_type.property('selectedId') in (None, '', 'NULL'):
            geom_type = get_parser_value('toolbox',
                                         f"{function_name}_cmb_geom_type")
        else:
            geom_type = dialog.cmb_geom_type.property('selectedId')
        qt_tools.set_combo_itemData(dialog.cmb_geom_type, geom_type, 0)
        if dialog.cmb_layers.property('selectedId') in (None, '', 'NULL'):
            layer = get_parser_value('toolbox', f"{function_name}_cmb_layers")
        else:
            layer = dialog.cmb_layers.property('selectedId')
        qt_tools.set_combo_itemData(dialog.cmb_layers, layer, 0)

        if get_parser_value('toolbox',
                            f"{function_name}_rbt_previous") == 'True':
            qt_tools.setChecked(dialog, 'rbt_previous', True)
        else:
            qt_tools.setChecked(dialog, 'rbt_layer', True)
예제 #7
0
    def load_user_values(self):
        """ Load QGIS settings related with file_manager """

        self.dlg_go2epa.txt_result_name.setMaxLength(16)
        self.result_name = get_parser_value('go2epa', 'go2epa_RESULT_NAME')
        self.dlg_go2epa.txt_result_name.setText(self.result_name)
        self.file_inp = get_parser_value('go2epa', 'go2epa_FILE_INP')
        self.dlg_go2epa.txt_file_inp.setText(self.file_inp)
        self.file_rpt = get_parser_value('go2epa', 'go2epa_FILE_RPT')
        self.dlg_go2epa.txt_file_rpt.setText(self.file_rpt)

        value = get_parser_value('go2epa', 'go2epa_chk_NETWORK_GEOM')
        qt_tools.setChecked(self.dlg_go2epa, self.dlg_go2epa.chk_only_check,
                            value)
        value = get_parser_value('go2epa', 'go2epa_chk_INP')
        qt_tools.setChecked(self.dlg_go2epa, self.dlg_go2epa.chk_export, value)
        value = get_parser_value('go2epa', 'go2epa_chk_UD')
        qt_tools.setChecked(self.dlg_go2epa,
                            self.dlg_go2epa.chk_export_subcatch, value)
        value = get_parser_value('go2epa', 'go2epa_chk_EPA')
        qt_tools.setChecked(self.dlg_go2epa, self.dlg_go2epa.chk_exec, value)
        value = get_parser_value('go2epa', 'go2epa_chk_RPT')
        qt_tools.setChecked(self.dlg_go2epa, self.dlg_go2epa.chk_import_result,
                            value)