[processing] minor bug fixes

This commit is contained in:
Victor Olaya 2013-10-07 18:40:37 +02:00
parent 503ee57cae
commit 0150fe7c98
6 changed files with 20 additions and 11 deletions

View File

@ -115,14 +115,15 @@ class SaveSelectedFeatures(GeoAlgorithm):
# first available format from the provider is used, and the
# corresponding file extension appended.
provider = vectorLayer.dataProvider()
# vectorLayer.crs() is the layer crs. By default all resulting
# layers are assumed to be in the same crs are the inputs, and
# will be loaded with this assumptions when executed from the
# toolbox. The self.crs variable has to be canged in case this
# toolbox. The self.crs variable has to be changed in case this
# is not true, or in case there are no input layer from which
# the output crs can be infered
provider = vectorLayer.dataProvider()
writer = output.getVectorWriter(provider.fields(),
provider.geometryType(), vectorLayer.crs())
@ -130,14 +131,12 @@ class SaveSelectedFeatures(GeoAlgorithm):
# Now we take the selected features and add them to the output
# layer
features = vector.features(vectorLayer)
total = len(features)
i = 0
total = len(features)
for (i, feat) in enumerate(features):
writer.addFeature(feat)
# We use the progress object to communicate with the user
progress.setPercentage(100 * i / float(total))
i += 1
progress.setPercentage(100 * i / float(total))
del writer
# There is nothing more to do here. We do not have to open the

View File

@ -28,6 +28,9 @@ __revision__ = '$Format:%H$'
class SilentProgress:
def error(self, msg):
print msg
def setText(self, text):
pass

View File

@ -28,6 +28,7 @@ __revision__ = '$Format:%H$'
from PyQt4.QtCore import *
from PyQt4 import QtGui
from processing import interface
from qgis.gui import *
class MessageBarProgress:
@ -42,6 +43,12 @@ class MessageBarProgress:
interface.iface.messageBar().pushWidget(self.progressMessageBar,
interface.iface.messageBar().INFO)
def error(self, msg):
interface.iface.messageBar().clearWidgets()
interface.iface.messageBar().pushMessage("Error", msg,
level = QgsMessageBar.CRITICAL,
duration = 3)
def setText(self, text):
pass

View File

@ -99,7 +99,7 @@ class ProcessingToolbox(QDockWidget, Ui_ProcessingToolbox):
executeAction = QAction(self.tr('Execute'), self.algorithmTree)
executeAction.triggered.connect(self.executeAlgorithm)
popupmenu.addAction(executeAction)
if alg.canRunInBatchMode and not self.allowOnlyOpenedLayers:
if alg.canRunInBatchMode and not alg.allowOnlyOpenedLayers:
executeBatchAction = QAction(
self.tr('Execute as batch process'),
self.algorithmTree)

View File

@ -60,7 +60,7 @@ class UnthreadedAlgorithmExecutor:
msg = 'Uncaught error executing ' + str(alg.name) \
+ '\nSee log for more information'
ProcessingLog.addToLog(sys.exc_info()[0], ProcessingLog.LOG_ERROR)
progress.error(e.msg)
progress.error(msg)
return False
@staticmethod

View File

@ -16,6 +16,7 @@
* *
***************************************************************************
"""
__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@ -119,8 +120,7 @@ class ModelerAlgorithm(GeoAlgorithm):
self.algParameters = []
self.algOutputs = []
self.paramValues = {}
self.dependencies = []
self.dependencies = []
self.descriptionFile = filename
lines = codecs.open(filename, 'r', encoding='utf-8')
line = lines.readline().strip('\n').strip('\r')