Index: python/plugins/fTools/tools/doJoinAttributes.py =================================================================== --- python/plugins/fTools/tools/doJoinAttributes.py (revision 13315) +++ python/plugins/fTools/tools/doJoinAttributes.py (working copy) @@ -53,6 +53,7 @@ QObject.connect(self.rdoTable, SIGNAL("clicked()"), self.updateTableFields) QObject.connect(self.rdoVector, SIGNAL("clicked()"), self.jupdate) self.setWindowTitle( self.tr("Join attributes") ) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() @@ -77,6 +78,7 @@ self.joinField.addItem(unicode(changedField[i].name())) def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Join Attributes"), self.tr("Please specify target vector layer")) elif self.outShape.text() == "": @@ -112,6 +114,7 @@ QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ) .arg( unicode( outPath ) )) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() Index: python/plugins/fTools/tools/doGeoprocessing.py =================================================================== --- python/plugins/fTools/tools/doGeoprocessing.py (revision 13315) +++ python/plugins/fTools/tools/doGeoprocessing.py (working copy) @@ -22,6 +22,7 @@ self.manageGui() self.success = False self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close ) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) self.progressBar.setValue (0 ) def checkA( self ): @@ -180,6 +181,7 @@ if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ): QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Unable to delete existing shapefile." ) ) return + self.buttonOk.setEnabled( False ) self.testThread = geoprocessingThread( self.iface.mainWindow(), self, self.myFunction, myLayerA, myLayerB, myParam, myMerge, mySelectionA, mySelectionB, self.shapefileName, self.encoding ) QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread ) @@ -192,9 +194,11 @@ def cancelThread( self ): self.testThread.stop() + self.buttonOk.setEnabled( True ) def runFinishedFromThread( self, results ): self.testThread.stop() + self.buttonOk.setEnabled( True ) self.cancel_close.setText( self.tr("Close") ) QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread ) out_text = "" Index: python/plugins/fTools/tools/doSpatialJoin.py =================================================================== --- python/plugins/fTools/tools/doSpatialJoin.py (revision 13315) +++ python/plugins/fTools/tools/doSpatialJoin.py (working copy) @@ -48,6 +48,7 @@ self.setupUi(self) QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile) self.setWindowTitle( self.tr("Join attributes by location") ) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() @@ -56,6 +57,7 @@ self.joinShape.addItems(layers) def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Spatial Join"), self.tr("Please specify target vector layer") ) elif self.outShape.text() == "": @@ -96,6 +98,7 @@ self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() Index: python/plugins/fTools/tools/doVectorSplit.py =================================================================== --- python/plugins/fTools/tools/doVectorSplit.py (revision 13315) +++ python/plugins/fTools/tools/doVectorSplit.py (working copy) @@ -45,6 +45,7 @@ QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile) QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update) self.setWindowTitle(self.tr("Split vector layer")) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() @@ -59,6 +60,7 @@ self.inField.addItem(unicode(changedField[i].name())) def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Vector Split"), self.tr("No input shapefile specified")) elif self.outShape.text() == "": @@ -77,70 +79,15 @@ self.progressBar.setValue(100) self.outShape.clear() QMessageBox.information(self, self.tr("Vector Split"), self.tr("Created output shapefiles in folder:\n%1").arg( outPath)) - self.progressBar.setValue(0) + self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): - fileDialog = QFileDialog() - settings = QSettings() - dirName = settings.value("/UI/lastShapefileDir").toString() - fileDialog.setDirectory(dirName) - encodingBox = QComboBox() - l = QLabel("Encoding:",fileDialog) - fileDialog.layout().addWidget(l) - fileDialog.layout().addWidget(encodingBox) - encodingBox.addItem("BIG5") - encodingBox.addItem("BIG5-HKSCS") - encodingBox.addItem("EUCJP") - encodingBox.addItem("EUCKR") - encodingBox.addItem("GB2312") - encodingBox.addItem("GBK") - encodingBox.addItem("GB18030") - encodingBox.addItem("JIS7") - encodingBox.addItem("SHIFT-JIS") - encodingBox.addItem("TSCII") - encodingBox.addItem("UTF-8") - encodingBox.addItem("UTF-16") - encodingBox.addItem("KOI8-R") - encodingBox.addItem("KOI8-U") - encodingBox.addItem("ISO8859-1") - encodingBox.addItem("ISO8859-2") - encodingBox.addItem("ISO8859-3") - encodingBox.addItem("ISO8859-4") - encodingBox.addItem("ISO8859-5") - encodingBox.addItem("ISO8859-6") - encodingBox.addItem("ISO8859-7") - encodingBox.addItem("ISO8859-8") - encodingBox.addItem("ISO8859-8-I") - encodingBox.addItem("ISO8859-9") - encodingBox.addItem("ISO8859-10") - encodingBox.addItem("ISO8859-13") - encodingBox.addItem("ISO8859-14") - encodingBox.addItem("ISO8859-15") - encodingBox.addItem("IBM 850") - encodingBox.addItem("IBM 866") - encodingBox.addItem("CP874") - encodingBox.addItem("CP1250") - encodingBox.addItem("CP1251") - encodingBox.addItem("CP1252") - encodingBox.addItem("CP1253") - encodingBox.addItem("CP1254") - encodingBox.addItem("CP1255") - encodingBox.addItem("CP1256") - encodingBox.addItem("CP1257") - encodingBox.addItem("CP1258") - encodingBox.addItem("Apple Roman") - encodingBox.addItem("TIS-620") - encodingBox.setItemText(encodingBox.currentIndex(), QString(QTextCodec.codecForLocale().name())) - fileDialog.setAcceptMode(QFileDialog.AcceptSave) - fileDialog.setFileMode(QFileDialog.DirectoryOnly) - fileDialog.setConfirmOverwrite(False) - if not fileDialog.exec_() == 1: - return - folders = fileDialog.selectedFiles() - self.folderName = unicode(folders.first()) - self.encoding = unicode(encodingBox.currentText()) self.outShape.clear() - self.outShape.insert(self.folderName) + ( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self ) + if self.shapefileName is None or self.encoding is None: + return + self.outShape.setText( QString( self.shapefileName ) ) def split(self, vlayer, outPath, inField, progressBar): provider = vlayer.dataProvider() Index: python/plugins/fTools/tools/doDefineProj.py =================================================================== --- python/plugins/fTools/tools/doDefineProj.py (revision 13315) +++ python/plugins/fTools/tools/doDefineProj.py (working copy) @@ -19,6 +19,7 @@ self.label_2.setVisible(False) self.label_2.setEnabled(False) self.setWindowTitle(self.tr("Define current projection")) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) QObject.connect(self.btnProjection, SIGNAL("clicked()"), self.outProjFile) QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1) QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2) @@ -42,6 +43,7 @@ self.outRef.insert(unicode(crs)) def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Define current projection"), self.tr("No input shapefile specified")) elif self.txtProjection.text() == "" and self.rdoProjection.isChecked(): @@ -103,6 +105,7 @@ self.progressBar.setValue(100) QMessageBox.information(self, self.tr("Define current projection"), self.tr("Defined Projection For:\n%1.shp").arg( inPath ) ) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outProjFile(self): format = QString( "

%1

%2
%3" ) Index: python/plugins/fTools/tools/doMeanCoords.py =================================================================== --- python/plugins/fTools/tools/doMeanCoords.py (revision 13315) +++ python/plugins/fTools/tools/doMeanCoords.py (working copy) @@ -15,6 +15,7 @@ self.updateUi() QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile) QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) @@ -44,6 +45,7 @@ self.uniqueField.addItem(unicode(changedField[i].name())) def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Coordinate statistics"), self.tr("No input vector layer specified")) elif self.outShape.text() == "": @@ -74,7 +76,8 @@ render.addSymbol(symbol) self.vlayer.setRenderer(render) QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) - self.progressBar.setValue(0) + self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() @@ -137,7 +140,7 @@ else: weight = float(feat.attributeMap()[weightIndex].toDouble()[0]) geom = QgsGeometry(feat.geometry()) - geom = self.extract(geom) + geom = ftools_utils.extractPoints(geom) for i in geom: cx += i.x() cy += i.y() @@ -180,31 +183,3 @@ if single: break del writer - - def extract(self, geom): - multi_geom = QgsGeometry() - temp_geom = [] - if geom.type() == 0: # it's a point - if geom.isMultipart(): - temp_geom = geom.asMultiPoint() - else: - temp_geom.append(geom.asPoint()) - if geom.type() == 1: # it's a line - if geom.isMultipart(): - multi_geom = geom.asMultiPolyline() #multi_geog is a multiline - for i in multi_geom: #i is a line - temp_geom.extend(i) - else: - temp_geom = geom.asPolyline() - elif geom.type() == 2: # it's a polygon - if geom.isMultipart(): - multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon - for i in multi_geom: #i is a polygon - for j in i: #j is a line - temp_geom.extend(j) - else: - multi_geom = geom.asPolygon() #multi_geom is a polygon - for i in multi_geom: #i is a line - temp_geom.extend(i) - return temp_geom - Index: python/plugins/fTools/tools/doSelectByLocation.py =================================================================== --- python/plugins/fTools/tools/doSelectByLocation.py (revision 13315) +++ python/plugins/fTools/tools/doSelectByLocation.py (working copy) @@ -12,6 +12,7 @@ self.iface = iface # Set up the user interface from Designer. self.setupUi(self) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) @@ -41,6 +42,7 @@ self.resize(381, 100) def accept(self): + self.buttonOk.setEnabled( False ) if self.inPolygon.currentText() == "": QMessageBox.information(self, self.tr("Select by location"), self.tr( "Please specify input layer")) elif self.inPoint.currentText() == "": @@ -50,6 +52,7 @@ inPts = self.inPoint.currentText() self.compute(inPoly, inPts, self.cmbModify.currentText()) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def compute(self, inPoly, inPts, modify): inputLayer = ftools_utils.getVectorLayerByName(inPoly) Index: python/plugins/fTools/tools/doSubsetSelect.py =================================================================== --- python/plugins/fTools/tools/doSubsetSelect.py (revision 13315) +++ python/plugins/fTools/tools/doSubsetSelect.py (working copy) @@ -45,6 +45,7 @@ self.setupUi(self) QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update) self.setWindowTitle(self.tr("Random selection within subsets")) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() @@ -61,6 +62,7 @@ self.spnNumber.setMaximum( maxFeatures ) def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Please specify input vector layer")) elif self.inField.currentText() == "": @@ -77,26 +79,12 @@ self.compute(inVect, uidField, value, perc, self.progressBar) self.progressBar.setValue(100) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) - def outFile(self): - self.outShape.clear() - fileDialog = QFileDialog() - fileDialog.setConfirmOverwrite(False) - outName = fileDialog.getSaveFileName(self, self.tr("Output Shapefile"),".", self.tr("Shapefiles (*.shp)")) - fileCheck = QFile(outName) - if fileCheck.exists(): - QMessageBox.warning(self, self.tr("Random selection within subsets"), self.tr("Cannot overwrite existing shapefile...")) - else: - filePath = QFileInfo(outName).absoluteFilePath() - if filePath.right(4) != ".shp": filePath = filePath + ".shp" - if not outName.isEmpty(): - self.outShape.clear() - self.outShape.insert(filePath) - def compute(self, inVect, inField, value, perc, progressBar): vlayer = ftools_utils.getVectorLayerByName(inVect) vprovider = vlayer.dataProvider() - mlayer = self.getMapLayerByName(inVect) + mlayer = ftools_utils.getMapLayerByName(inVect) allAttrs = vprovider.attributeIndexes() vprovider.select(allAttrs) index = vprovider.fieldNameIndex(inField) @@ -129,11 +117,3 @@ mlayer.setSelectedFeatures(selran) else: mlayer.setSelectedFeatures(range(0, mlayer.featureCount())) - - def getMapLayerByName(self, myName): - mc = self.iface.mapCanvas() - nLayers = mc.layerCount() - for l in range(nLayers): - layer = mc.layer(l) - if layer.name() == unicode(myName,'latin1'): - return layer Index: python/plugins/fTools/tools/doVectorGrid.py =================================================================== --- python/plugins/fTools/tools/doVectorGrid.py (revision 13315) +++ python/plugins/fTools/tools/doVectorGrid.py (working copy) @@ -46,6 +46,7 @@ #QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateInput) QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateLayer) QObject.connect(self.btnCanvas, SIGNAL("clicked()"), self.updateCanvas) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) self.setWindowTitle(self.tr("Vector grid")) self.xMin.setValidator(QDoubleValidator(self.xMin)) self.xMax.setValidator(QDoubleValidator(self.xMax)) @@ -78,6 +79,7 @@ self.yMax.setText( unicode( boundBox.yMaximum() ) ) def accept(self): + self.buttonOk.setEnabled( False ) if self.xMin.text() == "" or self.xMax.text() == "" or self.yMin.text() == "" or self.yMax.text() == "": QMessageBox.information(self, self.tr("Vector grid"), self.tr("Please specify valid extent coordinates")) elif self.outShape.text() == "": @@ -100,7 +102,8 @@ addToTOC = QMessageBox.question(self, self.tr("Generate Vector Grid"), self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg(unicode(self.shapefileName)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton) if addToTOC == QMessageBox.Yes: ftools_utils.addShapeToCanvas( self.shapefileName ) - self.progressBar.setValue( 0 ) + self.progressBar.setValue( 0 ) + self.buttonOk.setEnabled( True ) def compute( self, bound, xOffset, yOffset, polygon ): crs = self.iface.mapCanvas().mapRenderer().destinationSrs() Index: python/plugins/fTools/tools/doRegPoints.py =================================================================== --- python/plugins/fTools/tools/doRegPoints.py (revision 13315) +++ python/plugins/fTools/tools/doRegPoints.py (working copy) @@ -50,12 +50,14 @@ self.yMax.setValidator(QDoubleValidator(self.yMax)) QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile) self.setWindowTitle( self.tr("Regular points") ) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) self.progressBar.setValue(0) self.mapCanvas = self.iface.mapCanvas() layers = ftools_utils.getLayerNames("all") self.inShape.addItems(layers) def accept(self): + self.buttonOk.setEnabled( False ) if not self.rdoCoordinates.isChecked() and self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Generate Regular Points"), self.tr("Please specify input layer")) elif self.rdoCoordinates.isChecked() and (self.xMin.text() == "" or self.xMax.text() == "" or self.yMin.text() == "" or self.yMax.text() == ""): @@ -90,7 +92,8 @@ if addToTOC == QMessageBox.Yes: self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) - self.progressBar.setValue(0) + self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() @@ -99,7 +102,7 @@ return self.outShape.setText( QString( self.shapefileName ) ) -# Generate list of random points +# Generate list of random points def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax): seed() points = [] Index: python/plugins/fTools/tools/doPointsInPolygon.py =================================================================== --- python/plugins/fTools/tools/doPointsInPolygon.py (revision 13315) +++ python/plugins/fTools/tools/doPointsInPolygon.py (working copy) @@ -46,6 +46,7 @@ self.setupUi(self) QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile) self.setWindowTitle(self.tr("Count Points in Polygon")) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() @@ -55,6 +56,7 @@ self.inPoint.addItems(layers) def accept(self): + self.buttonOk.setEnabled( False ) if self.inPolygon.currentText() == "": QMessageBox.information(self, self.tr("Count Points In Polygon"), self.tr("Please specify input polygon vector layer")) elif self.outShape.text() == "": @@ -81,6 +83,7 @@ self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() Index: python/plugins/fTools/tools/doRandom.py =================================================================== --- python/plugins/fTools/tools/doRandom.py (revision 13315) +++ python/plugins/fTools/tools/doRandom.py (working copy) @@ -21,32 +21,34 @@ self.inShape.addItems(layers) def changed(self, inputLayer): - changedLayer = ftools_utils.getVectorLayerByName(inputLayer) - changedProvider = changedLayer.dataProvider() - upperVal = changedProvider.featureCount() - self.spnNumber.setMaximum(upperVal) + changedLayer = ftools_utils.getVectorLayerByName(inputLayer) + changedProvider = changedLayer.dataProvider() + upperVal = changedProvider.featureCount() + self.spnNumber.setMaximum(upperVal) def accept(self): - if self.inShape.currentText() == "": - QMessageBox.information(self, self.tr("Random Selection Tool"), self.tr("No input shapefile specified")) - else: + self.buttonOk.setEnabled( False ) + if self.inShape.currentText() == "": + QMessageBox.information(self, self.tr("Random Selection Tool"), self.tr("No input shapefile specified")) + else: self.progressBar.setValue(10) inName = self.inShape.currentText() - self.progressBar.setValue(20) - layer = ftools_utils.getVectorLayerByName(inName) - self.progressBar.setValue(30) - if self.rdoNumber.isChecked(): - value = self.spnNumber.value() - self.progressBar.setValue(60) - else: - value = self.spnPercent.value() - self.progressBar.setValue(50) - value = int(round((value / 100.0000), 4) * layer.featureCount()) - self.progressBar.setValue(60) - selran = random.sample(xrange(0, layer.featureCount()), value) - self.progressBar.setValue(70) - self.progressBar.setValue(80) - self.progressBar.setValue(90) - self.progressBar.setValue(100) - layer.setSelectedFeatures(selran) - self.progressBar.setValue(0) + self.progressBar.setValue(20) + layer = ftools_utils.getVectorLayerByName(inName) + self.progressBar.setValue(30) + if self.rdoNumber.isChecked(): + value = self.spnNumber.value() + self.progressBar.setValue(60) + else: + value = self.spnPercent.value() + self.progressBar.setValue(50) + value = int(round((value / 100.0000), 4) * layer.featureCount()) + self.progressBar.setValue(60) + selran = random.sample(xrange(0, layer.featureCount()), value) + self.progressBar.setValue(70) + self.progressBar.setValue(80) + self.progressBar.setValue(90) + self.progressBar.setValue(100) + layer.setSelectedFeatures(selran) + self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) Index: python/plugins/fTools/tools/doRandPoints.py =================================================================== --- python/plugins/fTools/tools/doRandPoints.py (revision 13315) +++ python/plugins/fTools/tools/doRandPoints.py (working copy) @@ -48,11 +48,12 @@ QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update) self.progressBar.setValue(0) self.setWindowTitle(self.tr("Random Points")) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) self.mapCanvas = self.iface.mapCanvas() layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"]) self.inShape.addItems(layers) -# If input layer is changed, update field list +# If input layer is changed, update field list def update(self, inputLayer): self.cmbField.clear() changedLayer = ftools_utils.getMapLayerByName(unicode(inputLayer)) @@ -75,8 +76,9 @@ self.cmbField.setEnabled(False) self.label_4.setEnabled(False) -# when 'OK' button is pressed, gather required inputs, and initiate random points generation +# when 'OK' button is pressed, gather required inputs, and initiate random points generation def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Random Points"), self.tr("No input layer specified")) elif self.outShape.text() == "": @@ -127,7 +129,8 @@ if addToTOC == QMessageBox.Yes: self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) - self.progressBar.setValue(0) + self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() @@ -136,7 +139,7 @@ return self.outShape.setText( QString( self.shapefileName ) ) -# combine all polygons in layer to create single polygon (slow for complex polygons) +# combine all polygons in layer to create single polygon (slow for complex polygons) def createSinglePolygon(self, vlayer): provider = vlayer.dataProvider() allAttrs = provider.attributeIndexes() @@ -157,7 +160,7 @@ self.progressBar.setValue(count) return geom -# Generate list of random points +# Generate list of random points def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax): seed() points = [] Index: python/plugins/fTools/tools/doIntersectLines.py =================================================================== --- python/plugins/fTools/tools/doIntersectLines.py (revision 13315) +++ python/plugins/fTools/tools/doIntersectLines.py (working copy) @@ -48,6 +48,7 @@ QObject.connect(self.inLine1, SIGNAL("currentIndexChanged(QString)"), self.update1) QObject.connect(self.inLine2, SIGNAL("currentIndexChanged(QString)"), self.update2) self.setWindowTitle( self.tr("Line intersections") ) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() @@ -70,6 +71,7 @@ self.inField2.addItem(unicode(changedField[i].name())) def accept(self): + self.buttonOk.setEnabled( False ) if self.inLine1.currentText() == "": QMessageBox.information(self, self.tr("Locate Line Intersections"), self.tr("Please specify input line layer") ) elif self.outShape.text() == "": @@ -94,6 +96,7 @@ if not ftools_utils.addShapeToCanvas( unicode( outPath ) ): QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( outPath ) )) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() Index: python/plugins/fTools/tools/doGeometry.py =================================================================== --- python/plugins/fTools/tools/doGeometry.py (revision 13315) +++ python/plugins/fTools/tools/doGeometry.py (working copy) @@ -14,6 +14,7 @@ self.iface = iface self.setupUi(self) self.myFunction = function + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile) if self.myFunction == 1: QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update) @@ -126,7 +127,7 @@ elif self.myFunction == 9: myList = ftools_utils.getLayerNames( "all" ) else: - myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] ) + myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] ) self.inShape.addItems( myList ) return @@ -151,6 +152,7 @@ if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ): QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Unable to delete existing shapefile." ) ) return + self.buttonOk.setEnabled( False ) self.testThread = geometryThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myParam, myField, self.shapefileName, self.encoding ) QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread ) @@ -162,9 +164,11 @@ def cancelThread( self ): self.testThread.stop() + self.buttonOk.setEnabled( True ) def runFinishedFromThread( self, success ): self.testThread.stop() + self.buttonOk.setEnabled( True ) if success == "math_error": QMessageBox.warning( self, self.tr("Geometry"), self.tr("Error processing specified tolerance!\nPlease choose larger tolerance...") ) if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ): Index: python/plugins/fTools/tools/doReProject.py =================================================================== --- python/plugins/fTools/tools/doReProject.py (revision 13315) +++ python/plugins/fTools/tools/doReProject.py (working copy) @@ -18,6 +18,7 @@ QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1) QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2) self.setWindowTitle( self.tr("Export to new projection") ) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon]) @@ -37,6 +38,7 @@ self.outRef.insert(unicode(crs)) def accept(self): + self.buttonOk.setEnabled( False ) if self.inShape.currentText() == "": QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No input layer specified")) elif self.outShape.text() == "": @@ -64,6 +66,7 @@ self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outProjFile(self): format = QString( "

%1

%2
%3" ) Index: python/plugins/fTools/tools/doSumLines.py =================================================================== --- python/plugins/fTools/tools/doSumLines.py (revision 13315) +++ python/plugins/fTools/tools/doSumLines.py (working copy) @@ -46,6 +46,7 @@ self.setupUi(self) QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile) self.setWindowTitle(self.tr("Sum line lengths")) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.progressBar.setValue(0) mapCanvas = self.iface.mapCanvas() @@ -55,6 +56,7 @@ self.inPolygon.addItems(layers) def accept(self): + self.buttonOk.setEnabled( False ) if self.inPolygon.currentText() == "": QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input polygon vector layer")) elif self.outShape.text() == "": @@ -81,6 +83,7 @@ self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def outFile(self): self.outShape.clear() Index: python/plugins/fTools/tools/doVisual.py =================================================================== --- python/plugins/fTools/tools/doVisual.py (revision 13315) +++ python/plugins/fTools/tools/doVisual.py (working copy) @@ -16,6 +16,7 @@ QObject.connect( self.inShape, SIGNAL( "currentIndexChanged(QString)" ), self.update ) self.manageGui() self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close ) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) self.progressBar.setValue( 0 ) self.partProgressBar.setValue( 0 ) self.partProgressBar.setVisible( False ) @@ -110,6 +111,7 @@ self.tblUnique.clearContents() self.tblUnique.setRowCount( 0 ) self.lstCount.clear() + self.buttonOk.setEnabled( False ) self.testThread = visualThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myField, mySelection ) QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread ) QObject.connect( self.testThread, SIGNAL( "runStatus(PyQt_PyObject)" ), self.runStatusFromThread ) @@ -123,9 +125,11 @@ def cancelThread( self ): self.testThread.stop() + self.buttonOk.setEnabled( True ) def runFinishedFromThread( self, output ): self.testThread.stop() + self.buttonOk.setEnabled( True ) result = output[ 0 ] numRows = len( result ) self.tblUnique.setRowCount( numRows ) @@ -195,7 +199,7 @@ self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 ) def stop(self): - self.running = False + self.running = False def list_unique_values( self, vlayer, myField ): vprovider = vlayer.dataProvider() Index: python/plugins/fTools/tools/doPointDistance.py =================================================================== --- python/plugins/fTools/tools/doPointDistance.py (revision 13315) +++ python/plugins/fTools/tools/doPointDistance.py (working copy) @@ -85,6 +85,7 @@ QObject.connect(self.btnFile, SIGNAL("clicked()"), self.saveFile) QObject.connect(self.inPoint1, SIGNAL("currentIndexChanged(QString)"), self.update1) QObject.connect(self.inPoint2, SIGNAL("currentIndexChanged(QString)"), self.update2) + self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) # populate layer list self.setWindowTitle(self.tr("Distance matrix")) self.progressBar.setValue(0) @@ -112,6 +113,7 @@ self.inField2.addItem(unicode(changedField[i].name())) def accept(self): + self.buttonOk.setEnabled( False ) if self.inPoint1.currentText() == "": QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify input point layer")) elif self.outFile.text() == "": @@ -144,6 +146,7 @@ self.progressBar.setValue(100) addToTOC = QMessageBox.information(self, "Create Point Distance Matrix", self.tr("Created output matrix:\n") + outPath) self.progressBar.setValue(0) + self.buttonOk.setEnabled( True ) def saveFile(self): self.outFile.clear()