Index: python/plugins/fTools/tools/doVisual.py =================================================================== --- python/plugins/fTools/tools/doVisual.py (revision 13010) +++ python/plugins/fTools/tools/doVisual.py (working copy) @@ -18,7 +18,7 @@ self.progressBar.setValue( 0 ) self.partProgressBar.setValue( 0 ) self.partProgressBar.setEnabled( False ) - + def keyPressEvent( self, e ): ''' Reimplemented key press event: @@ -53,15 +53,17 @@ # add all fields in combobox because now we can work with text fields too for i in changedField: self.cmbField.addItem( unicode( changedField[i].name() ) ) - + def accept( self ): if self.inShape.currentText() == "": QMessageBox.information( self, self.tr("Error!"), self.tr( "Please specify input vector layer" ) ) elif self.cmbField.isVisible() and self.cmbField.currentText() == "": QMessageBox.information( self, self.tr("Error!"), self.tr( "Please specify input field" ) ) + elif self.useSelected.isChecked() and len( ftools_utils.getVectorLayerByName( self.inShape.currentText() ).selectedFeatures() ) == 0: + QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "No features selected, please uncheck 'Use selected' or make a selection" ) ) else: self.visual( self.inShape.currentText(), self.cmbField.currentText(), self.useSelected.checkState() ) - + def manageGui( self ): if self.myFunction == 1: # Check geometry validity self.setWindowTitle( self.tr( "Check geometry validity" ) ) @@ -96,7 +98,7 @@ elif self.myFunction == 4: myList = ftools_utils.getLayerNames( [ QGis.Point ] ) 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 @@ -122,10 +124,10 @@ def cancelThread( self ): self.testThread.stop() - + def runFinishedFromThread( self, output ): self.testThread.stop() - + result = output[ 0 ] numRows = len( result ) self.tblUnique.setRowCount( numRows ) @@ -147,15 +149,15 @@ self.tblUnique.horizontalHeader().show() self.tblUnique.horizontalHeader().setResizeMode( 0, QHeaderView.Stretch ) self.tblUnique.resizeRowsToContents() - + self.lstCount.insert( unicode( output[ 1 ] ) ) self.cancel_close.setText( "Close" ) QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread ) return True - + def runStatusFromThread( self, status ): self.progressBar.setValue( status ) - + def runRangeFromThread( self, range_vals ): self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] ) @@ -163,12 +165,12 @@ self.partProgressBar.setValue( status ) if status >= self.part_max: self.partProgressBar.setEnabled( False ) - + def runPartRangeFromThread( self, range_vals ): self.part_max = range_vals[ 1 ] self.partProgressBar.setEnabled( True ) self.partProgressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] ) - + class visualThread( QThread ): def __init__( self, parentThread, parentObject, function, vlayer, myField, mySelection ): QThread.__init__( self, parentThread ) @@ -195,7 +197,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() @@ -297,7 +299,7 @@ if self.mySelection: # only selected features selection = vlayer.selectedFeatures() nFeat = vlayer.selectedFeatureCount() - uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, True ) + uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, True ) self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 ) self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) ) for f in selection: @@ -316,7 +318,7 @@ self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement ) else: # there is no selection, process the whole layer nFeat = vprovider.featureCount() - uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, False ) + uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, False ) self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 ) self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) ) while vprovider.nextFeature( feat ): @@ -430,7 +432,7 @@ if not self.isCorrectOrientation( polygon ): lstErrors.append( self.tr( "Feature %1 has incorrect node ordering" ).arg( unicode( feat.id() ) ) ) count += 1 - + else: geom = geom.asPolygon() if not self.isHoleNested( geom ):