def installLayer( self, id, schema, table, key, estimated, where, displayname ): layer = self.findLayer(id) if layer: legend = self._iface.legendInterface() if not legend.isLayerVisible(layer): legend.setLayerVisible(layer, True) return layer self._statusBar.showMessage("Loading layer " + displayname ) layer = None try: uri = QgsDataSourceURI() uri.setConnection(Database.host(),Database.port(),Database.database(),Database.user(),Database.password()) uri.setDataSource(schema,table,'shape',where) uri.setKeyColumn( key ) uri.setUseEstimatedMetadata( estimated ) layer = QgsVectorLayer(uri.uri(),displayname,"postgres") self.setLayerId( layer, id ) try: layer.loadNamedStyle(join(self._styledir,id+'_style.qml')) except: pass QgsMapLayerRegistry.instance().addMapLayer(layer) finally: self._statusBar.showMessage("") return layer
def __init__( self, parent=None ): QDialog.__init__( self, parent ) self.setupUi( self ) self.uHost.setText( Database.host() ) self.uPort.setText( Database.port() ) self.uDatabase.setText( Database.database() ) self.uUser.setText( Database.user() ) self.uPassword.setText( Database.password() ) self.uBdeSchema.setText( Database.bdeSchema() ) self.uAddressSchema.setText( Database.addressSchema() ) self.uDialogButtons.clicked.connect( self.buttonClicked )