def accept(self): self.selectedoptions = [] model = self.lstLayers.model() for i in xrange(model.rowCount()): item = model.item(i) self.selectedoptions.append(item.text()) QDialog.accept(self)
def accept(self): styles = {} for key in self.valueItems.keys(): styles[key] = unicode(self.valueItems[key].getValue()) RenderingStyles.addAlgStylesAndSave(self.alg.commandLineName(), styles) QDialog.accept(self)
def accept(self): self.selectedoptions = [] model = self.lstLayers.model() for i in xrange(model.rowCount()): item = model.item(i) if item.checkState() == Qt.Checked: self.selectedoptions.append(i) QDialog.accept(self)
def accept(self): cols = self.tblView.model().columnCount() rows = self.tblView.model().rowCount() self.rettable = [] for i in xrange(rows): self.rettable.append(list()) for j in xrange(cols): self.rettable[i].append(unicode(self.tblView.model().item(i, j).text())) QDialog.accept(self)
def accept(self): try: self.value = float(eval(unicode(self.leFormula.text()))) if self.isInteger: self.value = int(round(self.value)) QDialog.accept(self) except: QMessageBox.critical(self, self.tr('Wrong expression'), self.tr('The expression entered is not correct'))
def accept(self): try: self.value = float(eval(unicode(self.leFormula.text()))) if self.isInteger: self.value = int(round(self.value)) QDialog.accept(self) except: QMessageBox.critical( self, self.tr('Wrong expression'), self.tr('The expression entered is not correct'))
def accept(self): cols = self.tblView.model().columnCount() rows = self.tblView.model().rowCount() self.rettable = [] for i in xrange(rows): self.rettable.append(list()) for j in xrange(cols): self.rettable[i].append( unicode(self.tblView.model().item(i, j).text())) QDialog.accept(self)
def accept(self): if not self.preloadAPI.isChecked() and \ not self.groupBoxPreparedAPI.isChecked(): if self.tableWidget.rowCount() == 0: QMessageBox.information(self, self.tr("Warning!"), self.tr('Please specify API file or check "Use preloaded API files"')) return if self.groupBoxPreparedAPI.isChecked() and \ not self.lineEdit.text(): QMessageBox.information(self, self.tr("Warning!"), self.tr('The APIs file was not compiled, click on "Compile APIs..."')) return self.saveSettings() self.listPath = [] QDialog.accept(self)
def accept(self): for setting in self.items.keys(): if isinstance(setting.value, bool): setting.setValue(self.items[setting].checkState() == Qt.Checked) else: try: setting.setValue(unicode(self.items[setting].text())) except ValueError as e: QMessageBox.warning(self, self.tr('Wrong value'), self.tr('Wrong value for parameter "%s":\n\n%s' % (setting.description, unicode(e)))) return setting.save() Processing.updateAlgsList() updateMenus() QDialog.accept(self)
def accept(self): """add CSW entry""" conn_name = self.leName.text().strip() conn_url = self.leURL.text().strip() if any([conn_name == '', conn_url == '']): QMessageBox.warning(self, self.tr('Save connection'), self.tr('Both Name and URL must be provided')) return if '/' in conn_name: QMessageBox.warning(self, self.tr('Save connection'), self.tr('Name cannot contain \'/\'')) return if conn_name is not None: key = '/MetaSearch/%s' % conn_name keyurl = '%s/url' % key key_orig = '/MetaSearch/%s' % self.conn_name_orig # warn if entry was renamed to an existing connection if all([ self.conn_name_orig != conn_name, self.settings.contains(keyurl) ]): res = QMessageBox.warning(self, self.tr('Save connection'), self.tr('Overwrite %s?') % conn_name, QMessageBox.Ok | QMessageBox.Cancel) if res == QMessageBox.Cancel: return # on rename delete original entry first if all([ self.conn_name_orig is not None, self.conn_name_orig != conn_name ]): self.settings.remove(key_orig) self.settings.setValue(keyurl, conn_url) self.settings.setValue('/MetaSearch/selected', conn_name) QDialog.accept(self)
def accept(self): for setting in self.items.keys(): if isinstance(setting.value, bool): setting.setValue( self.items[setting].checkState() == Qt.Checked) else: try: setting.setValue(unicode(self.items[setting].text())) except ValueError as e: QMessageBox.warning( self, self.tr('Wrong value'), self.tr('Wrong value for parameter "%s":\n\n%s' % (setting.description, unicode(e)))) return setting.save() Processing.updateAlgsList() updateMenus() QDialog.accept(self)
def accept(self): """add CSW entry""" conn_name = self.leName.text().strip() conn_url = self.leURL.text().strip() if any([conn_name == '', conn_url == '']): QMessageBox.warning(self, self.tr('Save connection'), self.tr('Both Name and URL must be provided')) return if '/' in conn_name: QMessageBox.warning(self, self.tr('Save connection'), self.tr('Name cannot contain \'/\'')) return if conn_name is not None: key = '/MetaSearch/%s' % conn_name keyurl = '%s/url' % key key_orig = '/MetaSearch/%s' % self.conn_name_orig # warn if entry was renamed to an existing connection if all([self.conn_name_orig != conn_name, self.settings.contains(keyurl)]): res = QMessageBox.warning(self, self.tr('Save connection'), self.tr('Overwrite %s?') % conn_name, QMessageBox.Ok | QMessageBox.Cancel) if res == QMessageBox.Cancel: return # on rename delete original entry first if all([self.conn_name_orig is not None, self.conn_name_orig != conn_name]): self.settings.remove(key_orig) self.settings.setValue(keyurl, conn_url) self.settings.setValue('/MetaSearch/selected', conn_name) QDialog.accept(self)
def accept(self): self.mode = self.cmbFillType.currentIndex() self.param = self.cmbParameters.currentIndex() QDialog.accept(self)
def accept(self): # sanity checks if self.editOutputFile.text() == "": QMessageBox.information(self, self.tr("Export to file"), self.tr("Output file name is required")) return if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked(): try: sourceSrid = int(self.editSourceSrid.text()) except ValueError: QMessageBox.information( self, self.tr("Export to file"), self.tr("Invalid source srid: must be an integer")) return if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked(): try: targetSrid = int(self.editTargetSrid.text()) except ValueError: QMessageBox.information( self, self.tr("Export to file"), self.tr("Invalid target srid: must be an integer")) return # override cursor QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) # store current input layer crs, so I can restore it later prevInCrs = self.inLayer.crs() try: uri = self.editOutputFile.text() providerName = "ogr" options = {} # set the OGR driver will be used driverName = self.cboFileFormat.itemData( self.cboFileFormat.currentIndex()) options['driverName'] = driverName # set the output file encoding if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked(): enc = self.cboEncoding.currentText() options['fileEncoding'] = enc if self.chkDropTable.isChecked(): options['overwrite'] = True outCrs = None if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked( ): targetSrid = int(self.editTargetSrid.text()) outCrs = qgis.core.QgsCoordinateReferenceSystem(targetSrid) # update input layer crs if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked( ): sourceSrid = int(self.editSourceSrid.text()) inCrs = qgis.core.QgsCoordinateReferenceSystem(sourceSrid) self.inLayer.setCrs(inCrs) # do the export! ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer( self.inLayer, uri, providerName, outCrs, False, False, options) except Exception as e: ret = -1 errMsg = unicode(e) finally: # restore input layer crs and encoding self.inLayer.setCrs(prevInCrs) # restore cursor QApplication.restoreOverrideCursor() if ret != 0: QMessageBox.warning(self, self.tr("Export to file"), self.tr("Error %d\n%s") % (ret, errMsg)) return # create spatial index # if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked(): # self.db.connector.createSpatialIndex( (schema, table), geom ) QMessageBox.information(self, self.tr("Export to file"), self.tr("Export finished.")) return QDialog.accept(self)
def accept(self): Utils.setGdalBinPath(self.leGdalBinPath.text()) Utils.setGdalPymodPath(self.leGdalPymodPath.text()) Utils.setHelpPath(self.leGdalHelpPath.text()) QDialog.accept(self)
def accept(self): self.descriptions[self.currentName] = unicode(self.text.toPlainText()) QDialog.accept(self)
def accept(self): if self.mode == self.ASK_FOR_INPUT_MODE: # create the input layer (if not already done) and # update available options self.reloadInputLayer() # sanity checks if self.inLayer is None: QMessageBox.information(self, self.tr("Import to database"), self.tr("Input layer missing or not valid")) return if self.cboTable.currentText() == "": QMessageBox.information(self, self.tr("Import to database"), self.tr("Output table name is required")) return if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked(): try: sourceSrid = self.editSourceSrid.text() except ValueError: QMessageBox.information(self, self.tr("Import to database"), self.tr("Invalid source srid: must be an integer")) return if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked(): try: targetSrid = self.editTargetSrid.text() except ValueError: QMessageBox.information(self, self.tr("Import to database"), self.tr("Invalid target srid: must be an integer")) return # override cursor QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) # store current input layer crs and encoding, so I can restore it prevInCrs = self.inLayer.crs() prevInEncoding = self.inLayer.dataProvider().encoding() try: schema = self.outUri.schema() if not self.cboSchema.isEnabled() else self.cboSchema.currentText() table = self.cboTable.currentText() # get pk and geom field names from the source layer or use the # ones defined by the user srcUri = qgis.core.QgsDataSourceURI(self.inLayer.source()) pk = srcUri.keyColumn() if not self.chkPrimaryKey.isChecked() else self.editPrimaryKey.text() if not pk: pk = self.default_pk if self.inLayer.hasGeometryType() and self.chkGeomColumn.isEnabled(): geom = srcUri.geometryColumn() if not self.chkGeomColumn.isChecked() else self.editGeomColumn.text() if not geom: geom = self.default_geom else: geom = None # get output params, update output URI self.outUri.setDataSource(schema, table, geom, "", pk) uri = self.outUri.uri(False) providerName = self.db.dbplugin().providerName() options = {} if self.chkDropTable.isChecked(): options['overwrite'] = True if self.chkSinglePart.isEnabled() and self.chkSinglePart.isChecked(): options['forceSinglePartGeometryType'] = True outCrs = None if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked(): targetSrid = int(self.editTargetSrid.text()) outCrs = qgis.core.QgsCoordinateReferenceSystem(targetSrid) # update input layer crs and encoding if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked(): sourceSrid = int(self.editSourceSrid.text()) inCrs = qgis.core.QgsCoordinateReferenceSystem(sourceSrid) self.inLayer.setCrs(inCrs) if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked(): enc = self.cboEncoding.currentText() self.inLayer.setProviderEncoding(enc) onlySelected = self.chkSelectedFeatures.isChecked() # do the import! ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer(self.inLayer, uri, providerName, outCrs, onlySelected, False, options) except Exception as e: ret = -1 errMsg = unicode(e) finally: # restore input layer crs and encoding self.inLayer.setCrs(prevInCrs) self.inLayer.setProviderEncoding(prevInEncoding) # restore cursor QApplication.restoreOverrideCursor() if ret != 0: output = qgis.gui.QgsMessageViewer() output.setTitle(self.tr("Import to database")) output.setMessageAsPlainText(self.tr("Error %d\n%s") % (ret, errMsg)) output.showMessage() return # create spatial index if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked(): self.db.connector.createSpatialIndex((schema, table), geom) QMessageBox.information(self, self.tr("Import to database"), self.tr("Import was successful.")) return QDialog.accept(self)
def accept(self): # sanity checks if self.editOutputFile.text() == "": QMessageBox.information(self, self.tr("Export to file"), self.tr("Output file name is required")) return if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked(): try: sourceSrid = int(self.editSourceSrid.text()) except ValueError: QMessageBox.information(self, self.tr("Export to file"), self.tr("Invalid source srid: must be an integer")) return if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked(): try: targetSrid = int(self.editTargetSrid.text()) except ValueError: QMessageBox.information(self, self.tr("Export to file"), self.tr("Invalid target srid: must be an integer")) return # override cursor QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) # store current input layer crs, so I can restore it later prevInCrs = self.inLayer.crs() try: uri = self.editOutputFile.text() providerName = "ogr" options = {} # set the OGR driver will be used driverName = self.cboFileFormat.itemData(self.cboFileFormat.currentIndex()) options['driverName'] = driverName # set the output file encoding if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked(): enc = self.cboEncoding.currentText() options['fileEncoding'] = enc if self.chkDropTable.isChecked(): options['overwrite'] = True outCrs = None if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked(): targetSrid = int(self.editTargetSrid.text()) outCrs = qgis.core.QgsCoordinateReferenceSystem(targetSrid) # update input layer crs if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked(): sourceSrid = int(self.editSourceSrid.text()) inCrs = qgis.core.QgsCoordinateReferenceSystem(sourceSrid) self.inLayer.setCrs(inCrs) # do the export! ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer(self.inLayer, uri, providerName, outCrs, False, False, options) except Exception as e: ret = -1 errMsg = unicode(e) finally: # restore input layer crs and encoding self.inLayer.setCrs(prevInCrs) # restore cursor QApplication.restoreOverrideCursor() if ret != 0: QMessageBox.warning(self, self.tr("Export to file"), self.tr("Error %d\n%s") % (ret, errMsg)) return # create spatial index # if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked(): # self.db.connector.createSpatialIndex( (schema, table), geom ) QMessageBox.information(self, self.tr("Export to file"), self.tr("Export finished.")) return QDialog.accept(self)
def accept(self): if self.mode == self.ASK_FOR_INPUT_MODE: # create the input layer (if not already done) and # update available options self.reloadInputLayer() # sanity checks if self.inLayer is None: QMessageBox.information( self, self.tr("Import to database"), self.tr("Input layer missing or not valid")) return if self.cboTable.currentText() == "": QMessageBox.information(self, self.tr("Import to database"), self.tr("Output table name is required")) return if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked(): try: sourceSrid = self.editSourceSrid.text() except ValueError: QMessageBox.information( self, self.tr("Import to database"), self.tr("Invalid source srid: must be an integer")) return if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked(): try: targetSrid = self.editTargetSrid.text() except ValueError: QMessageBox.information( self, self.tr("Import to database"), self.tr("Invalid target srid: must be an integer")) return # override cursor QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) # store current input layer crs and encoding, so I can restore it prevInCrs = self.inLayer.crs() prevInEncoding = self.inLayer.dataProvider().encoding() try: schema = self.outUri.schema() if not self.cboSchema.isEnabled( ) else self.cboSchema.currentText() table = self.cboTable.currentText() # get pk and geom field names from the source layer or use the # ones defined by the user srcUri = qgis.core.QgsDataSourceURI(self.inLayer.source()) pk = srcUri.keyColumn() if not self.chkPrimaryKey.isChecked( ) else self.editPrimaryKey.text() if not pk: pk = self.default_pk if self.inLayer.hasGeometryType() and self.chkGeomColumn.isEnabled( ): geom = srcUri.geometryColumn( ) if not self.chkGeomColumn.isChecked( ) else self.editGeomColumn.text() if not geom: geom = self.default_geom else: geom = None # get output params, update output URI self.outUri.setDataSource(schema, table, geom, "", pk) uri = self.outUri.uri(False) providerName = self.db.dbplugin().providerName() options = {} if self.chkDropTable.isChecked(): options['overwrite'] = True if self.chkSinglePart.isEnabled() and self.chkSinglePart.isChecked( ): options['forceSinglePartGeometryType'] = True outCrs = None if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked( ): targetSrid = int(self.editTargetSrid.text()) outCrs = qgis.core.QgsCoordinateReferenceSystem(targetSrid) # update input layer crs and encoding if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked( ): sourceSrid = int(self.editSourceSrid.text()) inCrs = qgis.core.QgsCoordinateReferenceSystem(sourceSrid) self.inLayer.setCrs(inCrs) if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked(): enc = self.cboEncoding.currentText() self.inLayer.setProviderEncoding(enc) onlySelected = self.chkSelectedFeatures.isChecked() # do the import! ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer( self.inLayer, uri, providerName, outCrs, onlySelected, False, options) except Exception as e: ret = -1 errMsg = unicode(e) finally: # restore input layer crs and encoding self.inLayer.setCrs(prevInCrs) self.inLayer.setProviderEncoding(prevInEncoding) # restore cursor QApplication.restoreOverrideCursor() if ret != 0: output = qgis.gui.QgsMessageViewer() output.setTitle(self.tr("Import to database")) output.setMessageAsPlainText( self.tr("Error %d\n%s") % (ret, errMsg)) output.showMessage() return # create spatial index if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked( ): self.db.connector.createSpatialIndex((schema, table), geom) QMessageBox.information(self, self.tr("Import to database"), self.tr("Import was successful.")) return QDialog.accept(self)