def __init__(self, parent=None):
        qtBaseClass.__init__(self, parent)
        self.setupUi(self)

        self.conn = None

        self.buttonBox.button(QDialogButtonBox.Help).clicked.connect(
            self.show_help)

        settings = QSettings()
        settings.beginGroup("/Discovery")

        # connections

        self.cboConnection.addItem('')
        for conn in dbutils.get_postgres_connections():
            self.cboConnection.addItem(conn)

        self.init_combo_from_settings(self.cboConnection, "connection")
        self.cboConnection.currentIndexChanged.connect(self.connect_db)
        self.connect_db()

        # schemas
        self.init_combo_from_settings(self.cboSchema, "schema")
        self.cboSchema.currentIndexChanged.connect(self.populate_tables)
        self.populate_tables()

        # tables
        self.init_combo_from_settings(self.cboTable, "table")
        self.cboTable.currentIndexChanged.connect(self.populate_columns)
        self.populate_columns()

        # columns
        self.init_combo_from_settings(self.cboSearchColumn, "search_column")
        self.init_combo_from_settings(self.cboGeomColumn, "geom_column")

        echo_search_col = settings.value("echo_search_column", True, type=bool)
        if echo_search_col:
            self.cbEchoSearchColumn.setCheckState(Qt.Checked)
        else:
            self.cbEchoSearchColumn.setCheckState(Qt.Unchecked)

        columns = settings.value("display_columns", "", type=str)
        if len(columns) != 0:
            lst = columns.split(",")
            self.set_combo_current_text(self.cboDisplayColumn1, lst[0])
            if len(lst) > 1:
                self.set_combo_current_text(self.cboDisplayColumn2, lst[1])
            if len(lst) > 2:
                self.set_combo_current_text(self.cboDisplayColumn3, lst[2])
            if len(lst) > 3:
                self.set_combo_current_text(self.cboDisplayColumn4, lst[3])
            if len(lst) > 4:
                self.set_combo_current_text(self.cboDisplayColumn5, lst[4])

        self.editScaleExpr.setText(settings.value("scale_expr", "", type=str))
        self.editBboxExpr.setText(settings.value("bbox_expr", "", type=str))

        self.timeCB.stateChanged.connect(self.disable_display_time)
        self.disable_display_time()
Exemplo n.º 2
0
    def __init__(self, parent=None):
        """Constructor."""
        super(GeoCatConfigDialog, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        self.setupUi(self)

        self.postGisConnectionComboBox.addItems(get_postgres_connections())

        # See if we can put back the old config
        s = QSettings()

        req_con = s.value('GeoCat/connection', '', type=str)
        req_met_tab_sc = s.value('GeoCat/metadataTableSchema', '', type=str)
        req_met_tab_ta = s.value('GeoCat/metadataTableName', '', type=str)
        req_title = s.value('GeoCat/titleColumn', '', type=str)
        req_abs = s.value('GeoCat/abstractColumn', '', type=str)
        req_lay_sch = s.value('GeoCat/gisLayerSchemaCol', '', type=str)
        req_lay_tab = s.value('GeoCat/gisLayerTableCol', '', type=str)

        self.postGisConnectionComboBox.blockSignals(True)
        self.metadataTableSchemaComboBox.blockSignals(True)
        self.metadataTableNameComboBox.blockSignals(True)
        self.titleColumnComboBox.blockSignals(True)
        self.abstractColumnComboBox.blockSignals(True)
        self.layerSchemaNameComboBox.blockSignals(True)
        self.layerTableNameComboBox.blockSignals(True)

        self.postGisConnectionComboBox.setCurrentIndex(
            self.postGisConnectionComboBox.findText(req_con))

        if self.postGisConnectionComboBox.currentIndex() >= 0:

            self.refresh_schemas()

            self.metadataTableSchemaComboBox.setCurrentIndex(
                self.metadataTableSchemaComboBox.findText(req_met_tab_sc))

            self.refresh_tables()

            self.metadataTableNameComboBox.setCurrentIndex(
                self.metadataTableNameComboBox.findText(req_met_tab_ta))

            self.refresh_columns()

            self.titleColumnComboBox.setCurrentIndex(
                self.titleColumnComboBox.findText(req_title))
            self.abstractColumnComboBox.setCurrentIndex(
                self.abstractColumnComboBox.findText(req_abs))
            self.layerSchemaNameComboBox.setCurrentIndex(
                self.layerSchemaNameComboBox.findText(req_lay_sch))
            self.layerTableNameComboBox.setCurrentIndex(
                self.layerTableNameComboBox.findText(req_lay_tab))

        self.postGisConnectionComboBox.blockSignals(False)
        self.metadataTableSchemaComboBox.blockSignals(False)
        self.metadataTableNameComboBox.blockSignals(False)
        self.titleColumnComboBox.blockSignals(False)
        self.abstractColumnComboBox.blockSignals(False)
        self.layerSchemaNameComboBox.blockSignals(False)
        self.layerTableNameComboBox.blockSignals(False)