14 changes: 7 additions & 7 deletions python/plugins/sextante/algs/ftools/Intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Intersection(GeoAlgorithm):
def processAlgorithm(self, progress):
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(Intersection.INPUT))
vlayerB = QGisLayers.getObjectFromUri(self.getParameterValue(Intersection.INPUT2))
vproviderA = vlayerA.dataProvider()
vproviderA = vlayerA.dataProvider()

fields = utils.combineVectorFields(vlayerA, vlayerB)
writer = self.getOutputFromName(Intersection.OUTPUT).getVectorWriter(fields, vproviderA.geometryType(), vproviderA.crs() )
inFeatA = QgsFeature()
Expand All @@ -57,7 +57,7 @@ def processAlgorithm(self, progress):
index = utils.createSpatialIndex(vlayerB)
nElement = 0
selectionA = QGisLayers.features(vlayerA)
nFeat = len(selectionA)
nFeat = len(selectionA)
for inFeatA in selectionA:
nElement += 1
progress.setPercentage(nElement/float(nFeat) * 100)
Expand All @@ -79,17 +79,17 @@ def processAlgorithm(self, progress):
outFeat.setGeometry( int_geom )
attrs = []
attrs.extend(atMapA)
attrs.extend(atMapB)
attrs.extend(atMapB)
outFeat.setAttributes(attrs)
writer.addFeature( outFeat )
except:
raise GeoAlgorithmExecutionException("Feature exception while computing intersection")
raise GeoAlgorithmExecutionException("Feature exception while computing intersection")
except:
raise GeoAlgorithmExecutionException("Geometry exception while computing intersection")


del writer


def defineCharacteristics(self):
self.name = "Intersection"
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/algs/ftools/MeanCoords.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ def processAlgorithm(self, progress):

current = 0
total = 100.0 / float(provider.featureCount() * len(uniqueValues))

outFeat = QgsFeature()

for j in uniqueValues:
for j in uniqueValues:
cx = 0.00
cy = 0.00
points = []
weights = []
features = QGisLayers.features(layer)
features = QGisLayers.features(layer)
for feat in features:
current += 1
progress.setPercentage(current * total)
Expand Down Expand Up @@ -132,7 +132,7 @@ def processAlgorithm(self, progress):
meanPoint = QgsPoint(cx, cy)

outFeat.setGeometry(QgsGeometry.fromPoint(meanPoint))
outFeat.setAttributes([QVariant(cx), QVariant(cy), QVariant(j)])
outFeat.setAttributes([QVariant(cx), QVariant(cy), QVariant(j)])
writer.addFeature(outFeat)

if single:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

provider = layer.dataProvider()
provider = layer.dataProvider()

geomType = self.multiToSingleGeom(provider.geometryType())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def processAlgorithm(self, progress):

current += 1
progress.setPercentage(int(current * total))

do = float(sumDist) / count
de = float(0.5 / math.sqrt(count / A))
d = float(do / de)
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/sextante/algs/ftools/PointDistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def linearMatrix(self, inLayer, inField, targetLayer, targetField, matType, nPoi
self.writer.writerow(["InputID", "TargetID", "Distance"])
else:
self.writer.writerow(["InputID", "MEAN", "STDDEV", "MIN", "MAX"])

index = utils.createSpatialIndex(targetLayer);

inIdx = inLayer.fieldNameIndex(inField)
Expand All @@ -114,7 +114,7 @@ def linearMatrix(self, inLayer, inField, targetLayer, targetField, matType, nPoi
inGeom = QgsGeometry()
outGeom = QgsGeometry()
distArea = QgsDistanceArea()

features = QGisLayers.features(inLayer)
current = 0
total = 100.0 / float(len(features))
Expand Down Expand Up @@ -144,12 +144,12 @@ def linearMatrix(self, inLayer, inField, targetLayer, targetField, matType, nPoi
current += 1
progress.setPercentage(int(current * total))

def regularMatrix(self, inLayer, inField, targetLayer, targetField, nPoints, progress):
def regularMatrix(self, inLayer, inField, targetLayer, targetField, nPoints, progress):

index = utils.createSpatialIndex(targetLayer)
inIdx = inLayer.fieldNameIndex(inField)
outIdx = targetLayer.fieldNameIndex(inField)

inIdx = inLayer.fieldNameIndex(inField)
outIdx = targetLayer.fieldNameIndex(inField)

outFeat = QgsFeature()
inGeom = QgsGeometry()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/PointsInPolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def processAlgorithm(self, progress):
atMap.append(QVariant(count))
else:
atMap[idxCount] = QVariant(count)
outFeat.setAttributes(atMap)
outFeat.setAttributes(atMap)
writer.addFeature(outFeat)

current += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def processAlgorithm(self, progress):
if not clazz in classes:
classes.append(clazz)

outFeat.setGeometry(geom)
outFeat.setGeometry(geom)
if idxCount == len(atMap):
atMap.append(QVariant(len(classes)))
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def processAlgorithm(self, progress):
weight = 1
count += weight

outFeat.setGeometry(geom)
outFeat.setGeometry(geom)
if idxCount == len(atMap):
atMap.append(QVariant(count))
else:
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/sextante/algs/ftools/SelectByLocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SelectByLocation(GeoAlgorithm):

INPUT = "INPUT"
INTERSECT = "INTERSECT"
METHOD = "METHOD"
METHOD = "METHOD"
OUTPUT = "OUTPUT"

METHODS = ["creating new selection",
Expand All @@ -54,7 +54,7 @@ def defineCharacteristics(self):
self.group = "Vector selection tools"
self.addParameter(ParameterVector(self.INPUT, "Layer to select from", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(self.INTERSECT, "Additional layer (intersection layer)", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterSelection(self.METHOD, "Modify current selection by", self.METHODS, 0))
self.addParameter(ParameterSelection(self.METHOD, "Modify current selection by", self.METHODS, 0))
self.addOutput(OutputVector(self.OUTPUT, "Selection", True))

def processAlgorithm(self, progress):
Expand All @@ -65,15 +65,15 @@ def processAlgorithm(self, progress):
selectLayer = QGisLayers.getObjectFromUri(filename)
inputProvider = inputLayer.dataProvider()

oldSelection = set(inputLayer.selectedFeaturesIds())
oldSelection = set(inputLayer.selectedFeaturesIds())
index = QgsSpatialIndex()
feat = QgsFeature()
while inputProvider.nextFeature(feat):
while inputProvider.nextFeature(feat):
index.insertFeature(feat)

infeat = QgsFeature()
geom = QgsGeometry()
selectedSet = []
selectedSet = []
current = 0
features = QGisLayers.features(selectLayer)
total = 100.0 / float(len(features))
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/SumLines.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ def processAlgorithm(self, progress):
if idxCount == len(atMap):
atMap.append(QVariant(count))
else:
atMap[idxCount] = QVariant(count)
outFeat.setAttributes(atMap)
atMap[idxCount] = QVariant(count)
outFeat.setAttributes(atMap)
writer.addFeature(outFeat)

current += 1
Expand Down
26 changes: 13 additions & 13 deletions python/plugins/sextante/algs/ftools/Union.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ def processAlgorithm(self, progress):
if geom.intersects( tmpGeom ):
found = True
int_geom = geom.intersection( tmpGeom )

if int_geom is None:
# There was a problem creating the intersection
raise GeoAlgorithmExecutionException("Geometry exception while computing intersection")
else:
int_geom = QgsGeometry(int_geom)

if diff_geom.intersects( tmpGeom ):
diff_geom = diff_geom.difference( tmpGeom )
if diff_geom is None:
# It's possible there was an error here?
diff_geom = QgsGeometry()
else:
diff_geom = QgsGeometry(diff_geom)

if int_geom.wkbType() == 0:
# intersection produced different geomety types
temp_list = int_geom.asGeometryCollection()
Expand All @@ -119,7 +119,7 @@ def processAlgorithm(self, progress):
outFeat.setGeometry( int_geom )
attrs = []
attrs.extend(atMapA)
attrs.extend(atMapB)
attrs.extend(atMapB)
outFeat.setAttributes(attrs)
writer.addFeature( outFeat )
except Exception, err:
Expand Down Expand Up @@ -149,17 +149,17 @@ def processAlgorithm(self, progress):
except Exception, err:
raise GeoAlgorithmExecutionException("Feature exception while computing union")

length = len(vproviderA.fields())
length = len(vproviderA.fields())

featuresA = QGisLayers.features(vlayerB)
featuresA = QGisLayers.features(vlayerB)
nFeat = len(featuresA)
for inFeatA in featuresA:
progress.setPercentage(nElement/float(nFeat) * 100)
progress.setPercentage(nElement/float(nFeat) * 100)
add = False
geom = QgsGeometry( inFeatA.geometry() )
diff_geom = QgsGeometry( geom )
atMap = [None] * length
atMap.extend(inFeatA.attributes())
atMap.extend(inFeatA.attributes())
#atMap = dict( zip( range( length, length + len( atMap ) ), atMap ) )
intersects = indexB.intersects( geom.boundingBox() )

Expand Down Expand Up @@ -193,12 +193,12 @@ def processAlgorithm(self, progress):
outFeat.setGeometry( diff_geom )
outFeat.setAttributes( atMapB )
writer.addFeature( outFeat )
except Exception, err:
raise err
FEATURE_EXCEPT = False
nElement += 1
except Exception, err:
raise err
FEATURE_EXCEPT = False
nElement += 1



del writer
if not GEOS_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Geometry exception while computing intersection")
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/UniqueValues.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterTableField(self.FIELD_NAME, "Target field", self.INPUT_LAYER, ParameterTableField.DATA_TYPE_ANY))
self.addOutput(OutputHTML(self.OUTPUT, "Unique values"))
self.addOutput(OutputNumber(self.TOTAL_VALUES, "Total unique values"))
self.addOutput(OutputString(self.UNIQUE_VALUES, "Unique values"))
self.addOutput(OutputString(self.UNIQUE_VALUES, "Unique values"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
Expand Down
334 changes: 167 additions & 167 deletions python/plugins/sextante/algs/mmqgisx/MMQGISXAlgorithms.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion python/plugins/sextante/core/AlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def getSupportedOutputVectorLayerExtensions(self):
extension = extension[:extension.find(" ")]
if extension.lower() != "shp":
extensions.append(extension)
return extensions
return extensions

def getSupportedOutputTableExtensions(self):
return ["csv"]
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/sextante/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def convertUnsupportedFormats(self, progress):
features = QGisLayers.features(layer)
for feature in features:
writer.addFeature(feature)
elif isinstance(out, OutputRaster):
elif isinstance(out, OutputRaster):
if out.compatible is not None:
layer = QGisLayers.getObjectFromUri(out.compatible)
provider = layer.dataProvider()
Expand All @@ -216,7 +216,7 @@ def convertUnsupportedFormats(self, progress):
writer = out.getTableWriter(provider.fields())
features = QGisLayers.features(layer)
for feature in features:
writer.addRecord(feature)
writer.addRecord(feature)
progress.setPercentage(100 * i / float(len(self.outputs)))

def getFormatShortNameFromFilename(self, filename):
Expand Down Expand Up @@ -272,23 +272,23 @@ def setOutputCRS(self):
return
qgis = QGisLayers.iface
self.crs = qgis.mapCanvas().mapRenderer().destinationCrs()

def checkInputCRS(self):
'''it checks that all input layers use the same CRS. If so, returns True. False otherwise'''
'''it checks that all input layers use the same CRS. If so, returns True. False otherwise'''
crs = None;
layers = QGisLayers.getAllLayers()
for param in self.parameters:
if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
if param.value:
inputlayers = param.value.split(";")
for inputlayer in inputlayers:
for layer in layers:
for layer in layers:
if layer.source() == inputlayer:
if crs is None:
crs = layer.crs()
else:
if crs != layer.crs():
return False
return False
return True

def addOutput(self, output):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/core/LayerExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def exportVectorLayer(layer):
except UnicodeEncodeError:
isASCII=False
if (not unicode(layer.source()).endswith("shp") or not isASCII):
writer = QgsVectorFileWriter( output, systemEncoding, layer.pendingFields(), provider.geometryType(), provider.crs() )
writer = QgsVectorFileWriter( output, systemEncoding, layer.pendingFields(), provider.geometryType(), provider.crs() )
for feat in layer.getFeatures():
writer.addFeature(feat)
del writer
Expand Down
16 changes: 8 additions & 8 deletions python/plugins/sextante/core/QGisLayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ def getSupportedOutputVectorLayerExtensions():
if extension.lower() != "shp":
exts.append(extension)
return exts

@staticmethod
def getSupportedOutputRasterLayerExtensions():
def getSupportedOutputRasterLayerExtensions():
allexts = ["tif"]
for exts in GdalUtils.getSupportedRasters().values():
for ext in exts:
if ext not in allexts:
allexts.append(ext)
return allexts
return allexts

@staticmethod
def getSupportedOutputTableExtensions():
exts = ["csv"]
def getSupportedOutputTableExtensions():
exts = ["csv"]
return exts

@staticmethod
def getRasterLayers():
layers = QGisLayers.iface.legendInterface().layers()
Expand Down Expand Up @@ -179,7 +179,7 @@ def getObjectFromUri(uri, forceLoad = True):
tables = QGisLayers.getTables()
for table in tables:
if table.source() == uri:
return table
return table
if forceLoad:
settings = QSettings()
prjSetting = settings.value("/Projections/defaultBehaviour")
Expand Down
16 changes: 8 additions & 8 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ def updateAlgsList():
Sextante.fireAlgsListHasChanged()

@staticmethod
def loadFromProviders():
def loadFromProviders():
Sextante.loadAlgorithms()
Sextante.loadActions()
Sextante.loadContextMenuActions()

@staticmethod
def updateProviders():

for provider in Sextante.providers:
provider.loadAlgorithms()

Expand All @@ -174,7 +174,7 @@ def loadAlgorithms():
for alg in providerAlgs:
algs[alg.commandLineName()] = alg
Sextante.algs[provider.getName()] = algs

#this is a special provider, since it depends on others
#TODO Fix circular imports, so this provider can be incorporated
#as a normal one
Expand Down Expand Up @@ -291,9 +291,9 @@ def runAlgorithm(algOrName, onFinish, *args):
return

if not alg.checkInputCRS():
print ("Warning: Not all input layers use the same CRS.\n" +
print ("Warning: Not all input layers use the same CRS.\n" +
"This can cause unexpected results.")

SextanteLog.addToLog(SextanteLog.LOG_ALGORITHM, alg.getAsCommand())

# don't set the wait cursor twice, because then when you restore it
Expand All @@ -305,10 +305,10 @@ def runAlgorithm(algOrName, onFinish, *args):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

useThreads = SextanteConfig.getSetting(SextanteConfig.USE_THREADS)

#this is doing strange things, so temporarily the thread execution is disabled from the console
useThreads = False
useThreads = False

if useThreads:
algEx = AlgorithmExecutor(alg)
progress = QProgressDialog()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/core/SextanteConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SextanteConfig():
SHOW_DEBUG_IN_DIALOG = "SHOW_DEBUG_IN_DIALOG"
RECENT_ALGORITHMS = "RECENT_ALGORITHMS"
PRE_EXECUTION_SCRIPT = "PRE_EXECUTION_SCRIPT"
POST_EXECUTION_SCRIPT = "POST_EXECUTION_SCRIPT"
POST_EXECUTION_SCRIPT = "POST_EXECUTION_SCRIPT"
SHOW_CRS_DEF = "SHOW_CRS_DEF"
WARN_UNMATCHING_CRS = "WARN_UNMATCHING_CRS"

Expand Down Expand Up @@ -74,7 +74,7 @@ def initialize():
SextanteConfig.addSetting(Setting("General", SextanteConfig.PRE_EXECUTION_SCRIPT,"Pre-execution script",""))
SextanteConfig.addSetting(Setting("General", SextanteConfig.POST_EXECUTION_SCRIPT,"Post-execution script",""))
SextanteConfig.addSetting(Setting("General", SextanteConfig.RECENT_ALGORITHMS,"Recent algs","", hidden=True))


@staticmethod
def setGroupIcon(group, icon):
Expand Down
20 changes: 10 additions & 10 deletions python/plugins/sextante/core/SextanteRasterWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class SextanteRasterWriter:

NODATA = -99999.0

def __init__(self, fileName, minx, miny, maxx, maxy, cellsize, nbands, crs):
self.fileName = fileName
self.nx = int((maxx - minx) / float(cellsize))
Expand All @@ -42,27 +42,27 @@ def __init__(self, fileName, minx, miny, maxx, maxy, cellsize, nbands, crs):
self.matrix = numpy.ones(shape=(self.ny, self.nx), dtype=numpy.float32)
self.matrix[:] = self.NODATA
self.cellsize = cellsize
self.crs = crs
self.crs = crs
self.minx = minx
self.maxy = maxy
self.maxy = maxy

def setValue(self, value, x, y, band = 0):
try:
self.matrix[y, x] = value
except IndexError:
pass
def getValue(self, x, y, band = 0):

def getValue(self, x, y, band = 0):
try:
return self.matrix[y, x]
except IndexError:
return self.NODATA
return self.NODATA

def close(self):
format = "GTiff"
driver = gdal.GetDriverByName( format )
dst_ds = driver.Create(self.fileName, self.nx, self.ny, 1, gdal.GDT_Float32)
dst_ds = driver.Create(self.fileName, self.nx, self.ny, 1, gdal.GDT_Float32)
dst_ds.SetProjection(str(self.crs.toWkt()))
dst_ds.SetGeoTransform( [self.minx, self.cellsize, 0, self.maxy, self.cellsize, 0] )
dst_ds.SetGeoTransform( [self.minx, self.cellsize, 0, self.maxy, self.cellsize, 0] )
dst_ds.GetRasterBand(1).WriteArray(self.matrix)
dst_ds = None
4 changes: 2 additions & 2 deletions python/plugins/sextante/core/SextanteVectorWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ def __init__(self, fileName, encoding, fields, geometryType, crs, options=None):
if extension not in OGRCodes:
extension = "shp"
self.filename = self.filename + "shp"

qgsfields = QgsFields()
for field in fields:
qgsfields.append(field)

self.writer = QgsVectorFileWriter(self.fileName, encoding, qgsfields, geometryType, crs, OGRCodes[extension])

def addFeature(self, feature):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def defineCharacteristicsFromFile(self):
if isinstance(parameter, ParameterVector):
hasVectorOutput = True
if isinstance(parameter, ParameterMultipleInput) and parameter.datatype < 3:
hasVectorOutput = True
hasVectorOutput = True
elif line.startswith("*Parameter"):
param = ParameterFactory.getFromString(line[1:])
param.isAdvanced = True
Expand Down Expand Up @@ -265,7 +265,7 @@ def processAlgorithm(self, progress):
for param in self.parameters:
if param.value == None or param.value == "":
continue
if (param.name == self.GRASS_REGION_CELLSIZE_PARAMETER or param.name == self.GRASS_REGION_EXTENT_PARAMETER
if (param.name == self.GRASS_REGION_CELLSIZE_PARAMETER or param.name == self.GRASS_REGION_EXTENT_PARAMETER
or param.name == self.GRASS_MIN_AREA_PARAMETER or param.name == self.GRASS_SNAP_TOLERANCE_PARAMETER):
continue
if isinstance(param, (ParameterRaster, ParameterVector)):
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/gui/AlgorithmExecutionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ def accept(self):
reply = QMessageBox.question(self, "Unmatching CRS's",
"Layers do not all use the same CRS.\n" +
"This can cause unexpected results.\n" +
"Do you want to continue?",
"Do you want to continue?",
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.No:
return
return
msg = self.alg.checkParameterValuesBeforeExecuting()
if msg:
if keepOpen or useThread:
Expand Down Expand Up @@ -294,7 +294,7 @@ def accept(self):

@pyqtSlot()
def finish(self):
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
SextantePostprocessing.handleAlgorithmResults(self.alg, self, not keepOpen)
self.executed = True
self.setInfo("Algorithm %s finished" % self.alg.name)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/ParametersPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def getExtendedLayerName(self, layer):
return layer.name() + " [" + layer.crs().description() +"]"
else:
return layer.name()

def getWidgetFromParameter(self, param):
if isinstance(param, ParameterRaster):
layers = QGisLayers.getRasterLayers()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/modeler/EditModelAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def isEnabled(self):
return isinstance(self.alg, ModelerAlgorithm)

def execute(self):
dlg = ModelerDialog(self.alg.getCopy())
dlg = ModelerDialog(self.alg.getCopy())
dlg.exec_()
if dlg.update:
self.toolbox.updateTree()
28 changes: 14 additions & 14 deletions python/plugins/sextante/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self):
#Each entry is a map with (paramname, paramvalue) values for algs[i].
#paramvalues are instances of AlgorithmAndParameter
self.algParameters = []

#algorithms that each algorithm depends on.
#This is just a list of dependencies not set by outputs and inputs
#but explicitely entered instead, meaning that an algorithm must ''wait''
Expand Down Expand Up @@ -146,7 +146,7 @@ def openModel(self, filename):
self.algs.append(alg)
dependenceline = lines.readline().strip("\n")
dependencies = [];
if dependenceline != str(None):
if dependenceline != str(None):
for index in dependenceline.split(","):
dependencies.append(int(index))
for param in alg.parameters:
Expand Down Expand Up @@ -198,7 +198,7 @@ def addAlgorithm(self, alg, parametersMap, valuesMap, outputsMap, dependencies):
def updateAlgorithm(self, algIndex, parametersMap, valuesMap, outputsMap, dependencies):
self.algParameters[algIndex] = parametersMap
self.algOutputs[algIndex] = outputsMap
self.dependencies[algIndex] = dependencies
self.dependencies[algIndex] = dependencies
for value in valuesMap.keys():
self.paramValues[value] = valuesMap[value]
self.updateModelerView()
Expand All @@ -216,11 +216,11 @@ def removeAlgorithm(self, index):
del self.algParameters[index]
del self.algOutputs[index]
del self.algPos[index]

index = -1
for paramValues in self.algParameters:
index += 1
newValues = []
newValues = []
for name, value in paramValues:
if value:
if value.alg > index:
Expand All @@ -229,7 +229,7 @@ def removeAlgorithm(self, index):
newValues[name] = value
else:
newValues[name] = value

self.updateModelerView()
return True

Expand Down Expand Up @@ -269,8 +269,8 @@ def hasDependencies(self, element, elementIndex):
return False

def deactivateAlgorithm(self, algIndex, update = False):
if algIndex not in self.deactivated:
dependent = self.getDependentAlgorithms(algIndex)
if algIndex not in self.deactivated:
dependent = self.getDependentAlgorithms(algIndex)
self.deactivated.extend(dependent)
if update:
self.updateModelerView()
Expand All @@ -297,8 +297,8 @@ def getDependsOnAlgorithms(self, algIndex):
for aap in self.algParameters[algIndex].values():
index += 1
if aap is not None:
if aap.alg != AlgorithmAndParameter.PARENT_MODEL_ALGORITHM and aap.alg not in algs:
algs.append(index)
if aap.alg != AlgorithmAndParameter.PARENT_MODEL_ALGORITHM and aap.alg not in algs:
algs.append(index)
dep = self.getDependsOnAlgorithms(index)
for alg in dep:
if alg not in algs:
Expand All @@ -315,7 +315,7 @@ def getDependentAlgorithms(self, algIndex):
continue
for aap in alg.values():
if aap is not None:
if aap.alg == algIndex:
if aap.alg == algIndex:
dep = self.getDependentAlgorithms(index)
for alg in dep:
if alg not in dependent:
Expand All @@ -324,12 +324,12 @@ def getDependentAlgorithms(self, algIndex):
index = -1
for dep in self.dependencies:
index += 1
if algIndex in dep:
if algIndex in dep:
dep = self.getDependentAlgorithms(index)
for alg in dep:
if alg not in dependent:
dependent.append(alg)

return dependent

def getPositionForAlgorithmItem(self):
Expand Down Expand Up @@ -377,7 +377,7 @@ def serialize(self):
if len(self.dependencies[i]) != 0:
s += ",".join([str(index) for index in self.dependencies[i]]) + "\n"
else:
s += str(None) + "\n"
s += str(None) + "\n"
for param in alg.parameters:
value = self.algParameters[i][param.name]
if value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def getName(self):
def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/model.png")

def _loadAlgorithms(self):
def _loadAlgorithms(self):
folder = ModelerUtils.modelsFolder()
self.loadFromFolder(folder)
folder = os.path.join(os.path.dirname(__file__), "models")
Expand Down
44 changes: 22 additions & 22 deletions python/plugins/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ def setupUi(self):
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(item)
self.valueItems[output.name] = item

label = QtGui.QLabel(" ")
self.verticalLayout.addWidget(label)
label = QtGui.QLabel("Parent algorithms")
self.dependenciesPanel = self.getDependenciesPanel()
self.dependenciesPanel = self.getDependenciesPanel()
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(self.dependenciesPanel)

self.verticalLayout.addStretch(1000)
self.setLayout(self.verticalLayout)

Expand Down Expand Up @@ -178,12 +178,12 @@ def setupUi(self):
QtCore.QMetaObject.connectSlotsByName(self)


def getAvailableDependencies(self):
def getAvailableDependencies(self):
if self.algIndex is None:
dependent = []
else:
dependent = self.model.getDependentAlgorithms(self.algIndex)
opts = []
dependent = self.model.getDependentAlgorithms(self.algIndex)
opts = []
i=0
for alg in self.model.algs:
if i not in dependent:
Expand All @@ -193,8 +193,8 @@ def getAvailableDependencies(self):

def getDependenciesPanel(self):
return MultipleInputPanel(self.getAvailableDependencies())


def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced
if self.showAdvanced:
Expand Down Expand Up @@ -420,7 +420,7 @@ def getWidgetFromParameter(self, param):
item.setText(str(param.default))
else:
item = QtGui.QComboBox()
item.setEditable(True)
item.setEditable(True)
for s in strings:
item.addItem(s.name(), s)
item.setEditText(str(param.default))
Expand Down Expand Up @@ -452,7 +452,7 @@ def getWidgetFromParameter(self, param):
item.setEditable(True)
files = self.getFiles()
for f in files:
item.addItem(f.name(), f)
item.addItem(f.name(), f)
else:
item = QtGui.QLineEdit()
try:
Expand Down Expand Up @@ -545,8 +545,8 @@ def setPreviousValues(self):
if param.multiline:
widget.setValue(value)
else:
self.setComboBoxValue(widget, value, param)
elif isinstance(param, ParameterCrs):
self.setComboBoxValue(widget, value, param)
elif isinstance(param, ParameterCrs):
value = self.model.getValueFromAlgorithmAndParameter(value)
widget.setText(unicode(value))
elif isinstance(param, ParameterFixedTable):
Expand All @@ -573,16 +573,16 @@ def setPreviousValues(self):
value = self.model.algOutputs[self.algIndex][out.name]
if value is not None:
widget = self.valueItems[out.name].setText(unicode(value))

selected = []
dependencies = self.getAvailableDependencies()
index = -1
index = -1
for dependency in dependencies:
index += 1
n = int(dependency[:dependency.find(":")]) - 1
if n in self.model.dependencies[self.algIndex]:
selected.append(index)
selected.append(index)

self.dependenciesPanel.setSelectedItems(selected)


Expand All @@ -607,18 +607,18 @@ def setParamValues(self):
self.outputs[output.name]=name
else:
self.outputs[output.name] = None

selectedOptions = self.dependenciesPanel.selectedoptions
#this index are based on the list of available dependencies.
#this index are based on the list of available dependencies.
#we translate them into indices based on the whole set of algorithm in the model
#We just take the values in the begining of the string representing the algorithm
availableDependencies = self.getAvailableDependencies()
self.dependencies = []
self.dependencies = []
for selected in selectedOptions:
s = availableDependencies[selected]
n = int(s[:s.find(":")]) - 1
self.dependencies.append(n);

return True


Expand Down Expand Up @@ -673,8 +673,8 @@ def setParamStringValue(self, param, widget):
name = self.getSafeNameForHarcodedParameter(param)
self.values[name] = value
paramValue = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = paramValue
else:
self.params[param.name] = paramValue
else:
self.params[param.name] = value
else:
if widget.currentText() == "":
Expand Down
21 changes: 10 additions & 11 deletions python/plugins/sextante/modeler/MultilineTextPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@
class MultilineTextPanel(QtGui.QWidget):

USE_TEXT = 0

def __init__(self, options, parent = None):
super(MultilineTextPanel, self).__init__(parent)
self.options = options
self.options = options
self.verticalLayout = QtGui.QVBoxLayout(self)
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
self.combo = QtGui.QComboBox()
self.combo.addItem("[Use text below]")
self.combo.addItem("[Use text below]")
for option in options:
self.combo.addItem(option.name(), option)
self.combo.addItem(option.name(), option)
self.combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.verticalLayout.addWidget(self.combo)
self.textBox = QtGui.QPlainTextEdit()
self.textBox = QtGui.QPlainTextEdit()
self.verticalLayout.addWidget(self.textBox)
self.setLayout(self.verticalLayout)

def setText(self, text):
self.textBox.setPlainText(text)

def getOption(self):
return self.combo.currentIndex()

def getValue(self):
if self.combo.currentIndex() == 0:
return unicode(self.textBox.toPlainText())
else:
return self.combo.itemData(self.combo.currentIndex()).toPyObject()

def setValue(self, value):
items = [self.combo.itemData(i).toPyObject() for i in range(1,self.combo.count())]
idx = 0
Expand All @@ -71,8 +71,7 @@ def setValue(self, value):
if item.alg == value.alg and item.param == value.param:
self.combo.setCurrentIndex(idx)
return
self.combo.setCurrentIndex(idx)
self.combo.setCurrentIndex(idx)
value = self.model.getValueFromAlgorithmAndParameter(value)
if value:
self.textBox.setPlainText(str(value))

10 changes: 5 additions & 5 deletions python/plugins/sextante/outputs/OutputRaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from sextante.core.SextanteUtils import SextanteUtils

class OutputRaster(Output):

compatible = None

def getFileFilter(self, alg):
exts = QGisLayers.getSupportedOutputRasterLayerExtensions()
for i in range(len(exts)):
Expand All @@ -40,16 +40,16 @@ def getFileFilter(self, alg):

def getDefaultFileExtension(self, alg):
return alg.provider.getSupportedOutputRasterLayerExtensions()[0]

def getCompatibleFileName(self, alg):
'''Returns a filename that is compatible with the algorithm that is going to generate this output.
If the algorithm supports the file format of the current output value, it returns that value. If not,
If the algorithm supports the file format of the current output value, it returns that value. If not,
it returns a temporary file with a supported file format, to be used to generate the output result.'''
ext = self.value[self.value.rfind(".") + 1:]
if ext in alg.provider.getSupportedOutputRasterLayerExtensions():
return self.value
else:
if self.compatible is None:
if self.compatible is None:
self.compatible = SextanteUtils.getTempFilename(self.getDefaultFileExtension(alg))
return self.compatible;

8 changes: 4 additions & 4 deletions python/plugins/sextante/outputs/OutputTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class OutputTable(Output):

compatible = None

def getFileFilter(self,alg):
exts = ['csv']
for i in range(len(exts)):
Expand All @@ -44,13 +44,13 @@ def getDefaultFileExtension(self, alg):

def getCompatibleFileName(self, alg):
'''Returns a filename that is compatible with the algorithm that is going to generate this output.
If the algorithm supports the file format of the current output value, it returns that value. If not,
If the algorithm supports the file format of the current output value, it returns that value. If not,
it returns a temporary file with a supported file format, to be used to generate the output result.'''
ext = self.value[self.value.rfind(".") + 1:]
if ext in alg.provider.getSupportedOutputTableExtensions:
return self.value
else:
if self.compatible is None:
if self.compatible is None:
self.compatible = SextanteUtils.getTempFilename(self.getDefaultFileExtension(alg))
return self.compatible;

Expand All @@ -68,4 +68,4 @@ def getTableWriter(self, fields):
settings = QSettings()
self.encoding = settings.value("/SextanteQGIS/encoding", "System").toString()

return SextanteTableWriter(self.value, self.encoding, fields)
return SextanteTableWriter(self.value, self.encoding, fields)
14 changes: 7 additions & 7 deletions python/plugins/sextante/outputs/OutputVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@ class OutputVector(Output):
encoding = None
compatible = None

def getFileFilter(self,alg):
def getFileFilter(self,alg):
exts = QGisLayers.getSupportedOutputVectorLayerExtensions()
for i in range(len(exts)):
exts[i] = exts[i].upper() + " files(*." + exts[i].lower() + ")"
return ";;".join(exts)


def getDefaultFileExtension(self, alg):
return alg.provider.getSupportedOutputVectorLayerExtensions()[0]

def getCompatibleFileName(self, alg):
'''Returns a filename that is compatible with the algorithm that is going to generate this output.
If the algorithm supports the file format of the current output value, it returns that value. If not,
If the algorithm supports the file format of the current output value, it returns that value. If not,
it returns a temporary file with a supported file format, to be used to generate the output result.'''
ext = self.value[self.value.rfind(".") + 1:]
if ext in alg.provider.getSupportedOutputVectorLayerExtensions():
return self.value
else:
if self.compatible is None:
if self.compatible is None:
self.compatible = SextanteUtils.getTempFilename(self.getDefaultFileExtension(alg))
return self.compatible;


def getVectorWriter(self, fields, geomType, crs, options=None):
'''Returns a suitable writer to which features can be added as a
result of the algorithm. Use this to transparently handle output
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/parameters/ParameterTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def setValue(self, obj):
else:
return False
if isinstance(obj, QgsVectorLayer):
source = unicode(obj.source())
source = unicode(obj.source())
self.value = source
return True
return True
else:
layers = QGisLayers.getVectorLayers()
for layer in layers:
Expand All @@ -55,7 +55,7 @@ def setValue(self, obj):
return True
val = unicode(obj)
self.value = val
return os.path.exists(self.value)
return os.path.exists(self.value)

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SagaAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def getSupportedOutputVectorLayerExtensions(self):

def getSupportedOutputRasterLayerExtensions(self):
return ["tif"]

def getSupportedOutputTableLayerExtensions(self):
return ["dbf"]

Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/ui/ui_DlgConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def setupUi(self, DlgConfig):
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))

try:
from qgis.gui import QgsFilterLineEdit
self.searchBox = QgsFilterLineEdit(DlgConfig)
self.searchBox = QgsFilterLineEdit(DlgConfig)
except ImportError:
self.searchBox = QtGui.QLineEdit(DlgConfig)
self.searchBox = QtGui.QLineEdit(DlgConfig)
self.searchBox.setObjectName(_fromUtf8("searchBox"))
self.verticalLayout.addWidget(self.searchBox)
self.tree = QtGui.QTreeWidget(DlgConfig)
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/ui/ui_DlgModeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def setupUi(self, DlgModeler):
self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
try:
from qgis.gui import QgsFilterLineEdit
self.searchBox = QgsFilterLineEdit(self.tab_2)
self.searchBox = QgsFilterLineEdit(self.tab_2)
except ImportError:
self.searchBox = QtGui.QLineEdit(self.tab_2)
self.searchBox.setObjectName(_fromUtf8("searchBox"))
self.searchBox = QtGui.QLineEdit(self.tab_2)
self.searchBox.setObjectName(_fromUtf8("searchBox"))
self.verticalLayout_3.addWidget(self.searchBox)
self.algorithmTree = QtGui.QTreeWidget(self.tab_2)
self.algorithmTree.setAlternatingRowColors(True)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/ui/ui_SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def setupUi(self, SextanteToolbox):
self.verticalLayout.addWidget(self.externalAppsButton)
try:
from qgis.gui import QgsFilterLineEdit
self.searchBox = QgsFilterLineEdit(self.dockWidgetContents)
self.searchBox = QgsFilterLineEdit(self.dockWidgetContents)
except ImportError:
self.searchBox = QtGui.QLineEdit(self.dockWidgetContents)
self.searchBox = QtGui.QLineEdit(self.dockWidgetContents)
self.searchBox.setObjectName(_fromUtf8("searchBox"))
self.verticalLayout.addWidget(self.searchBox)
self.algorithmTree = QtGui.QTreeWidget(self.dockWidgetContents)
Expand Down
12 changes: 8 additions & 4 deletions scripts/astyle-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ set -e

export elcr="$(tput el)$(tput cr)"

find src tests -type f -print | while read f; do
find python src tests -type f -print | while read f; do
case "$f" in
src/app/gps/qwtpolar-*|src/app/qtmain_android.cpp|src/core/spatialite/*|src/core/spatialindex/src/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*)
src/app/gps/qwtpolar-*|src/app/qtmain_android.cpp|src/core/spatialite/*|src/core/spatialindex/src/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
echo $f skipped
continue
;;
Expand All @@ -32,10 +32,14 @@ find src tests -type f -print | while read f; do
cmd=astyle.sh
;;

*.ui|*.qgm|*.txt|*.t2t|*.py|*.sip|resources/context_help/*)
*.ui|*.qgm|*.txt|*.t2t|*.sip|resources/context_help/*)
cmd="flip -ub"
;;

*.py)
cmd="perl -i.prepare -pe 's/[\r\t ]+$//;'"
;;

*)
echo -ne "$f skipped $elcr"
continue
Expand All @@ -53,7 +57,7 @@ find src tests -type f -print | while read f; do
fi

echo -ne "Reformating $f $elcr"
$cmd "$f"
eval "$cmd '$f'"
done

echo
2 changes: 1 addition & 1 deletion scripts/prepare-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ASTYLEDIFF=astyle.$REV.diff
# reformat
for f in $MODIFIED; do
case "$f" in
src/core/spatialite/*|src/core/gps/qextserialport/*)
src/core/spatialite/*|src/core/gps/qextserialport/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
echo $f skipped
continue
;;
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mItemIdLineEdit->setText( mItem->id() );
mFrameGroupBox->setChecked( mItem->hasFrame() );
mBackgroundGroupBox->setChecked( mItem->hasBackground() );

mOpacitySlider->blockSignals( false );
mOutlineWidthSpinBox->blockSignals( false );
mFrameGroupBox->blockSignals( false );
Expand Down
4 changes: 2 additions & 2 deletions src/app/composer/qgscomposerlabelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void QgsComposerLabelWidget::on_mHtmlCheckBox_stateChanged( int state )
{
if ( mComposerLabel )
{
if (state)
if ( state )
{
mFontButton->setEnabled( false );
mFontColorButton->setEnabled( false );
Expand All @@ -61,7 +61,7 @@ void QgsComposerLabelWidget::on_mHtmlCheckBox_stateChanged( int state )

mComposerLabel->beginCommand( tr( "Label text HTML state changed" ), QgsComposerMergeCommand::ComposerLabelSetText );
mComposerLabel->blockSignals( true );
mComposerLabel->setHtmlSate(state);
mComposerLabel->setHtmlSate( state );
mComposerLabel->setText( mTextEdit->toPlainText() );
mComposerLabel->update();
mComposerLabel->blockSignals( false );
Expand Down
2 changes: 1 addition & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ int main( int argc, char *argv[] )
else
{
#ifdef Q_WS_WIN
if ( envVarApply != "undefined" || !getenv( envVarName.toUtf8().constData() ) )
if ( envVarApply != "undefined" || !getenv( envVarName.toUtf8().constData() ) )
putenv( QString( "%1=%2" ).arg( envVarName ).arg( envVarValue ).toUtf8().constData() );
#else
setenv( envVarName.toUtf8().constData(), envVarValue.toUtf8().constData(), envVarApply == "undefined" ? 0 : 1 );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslabeldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void QgsLabelDialog::init( )
myFieldStringList.append( "" );
for ( int i = 0; i < myFields.count(); ++i )
{
myFieldStringList.append( myFields[i].name() );
myFieldStringList.append( myFields[i].name() );
}
//
//now set all the combos that need field lists using the string list
Expand Down
8 changes: 4 additions & 4 deletions src/core/composer/qgscomposerlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem*
painter->rotate( mRotation );
painter->translate( -mTextBoxWidth / 2.0, -mTextBoxHeight / 2.0 );

if( mHtmlState )
if ( mHtmlState )
{
painter->scale( 1.0 / mHtmlUnitsToMM / 10.0, 1.0 / mHtmlUnitsToMM / 10.0 );

QWebPage* webPage = new QWebPage();

//This makes the background transparent. Found on http://blog.qt.digia.com/blog/2009/06/30/transparent-qwebview-or-qwebpage/
QPalette palette = webPage->palette();
palette.setBrush(QPalette::Base, Qt::transparent);
webPage->setPalette(palette);
palette.setBrush( QPalette::Base, Qt::transparent );
webPage->setPalette( palette );
//webPage->setAttribute(Qt::WA_OpaquePaintEvent, false); //this does not compile, why ?

webPage->setViewportSize( QSize(painterRect.width() * mHtmlUnitsToMM * 10.0, painterRect.height() * mHtmlUnitsToMM * 10.0) );
webPage->setViewportSize( QSize( painterRect.width() * mHtmlUnitsToMM * 10.0, painterRect.height() * mHtmlUnitsToMM * 10.0 ) );
webPage->mainFrame()->setZoomFactor( 10.0 );
webPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
webPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void QgsComposerMap::cache( void )
double forcedWidthScaleFactor = w / requestExtent.width() / mapUnitsToMM();

mCacheImage = QImage( w, h, QImage::Format_ARGB32 );
mCacheImage.fill( QColor(255,255,255,0).rgba() ); // the background is drawn by composerItem, but we still need to start with that empty fill to avoid artifacts
mCacheImage.fill( QColor( 255, 255, 255, 0 ).rgba() ); // the background is drawn by composerItem, but we still need to start with that empty fill to avoid artifacts

double mapUnitsPerPixel = mExtent.width() / w;

Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgsscalebarstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void QgsScaleBarStyle::drawLabels( QPainter* p ) const
p->save();

p->setFont( mScaleBar->font() );
p->setPen( QPen(mScaleBar->fontColor()) );
p->setPen( QPen( mScaleBar->fontColor() ) );

QString firstLabel = mScaleBar->firstLabelString();
double xOffset = mScaleBar->textWidthMillimeters( mScaleBar->font(), firstLabel ) / 2;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsbrowsermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void QgsBrowserModel::addRootItems()

QString home = QgsProject::instance()->homePath();

if( !home.isNull() )
if ( !home.isNull() )
{
item = new QgsDirectoryItem( NULL, tr( "Project home" ), home );
mRootItems << item;
Expand Down
97 changes: 49 additions & 48 deletions src/core/qgsfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,54 +151,55 @@ typedef QMap<int, QgsField> QgsFieldMap;

class CORE_EXPORT QgsFields
{
public:

enum FieldOrigin { OriginUnknown, OriginProvider, OriginJoin, OriginEdit };
typedef struct Field {
Field(): origin(OriginUnknown), originIndex(-1) {}
Field(const QgsField& f, FieldOrigin o, int oi): field(f), origin(o), originIndex(oi) {}

QgsField field;
FieldOrigin origin; // TODO[MD]: originIndex or QVariant originID?
int originIndex;
} Field;

void clear() { mFields.clear(); mNameToIndex.clear(); }
/** append: fields must have unique names! */
bool append( const QgsField& field, FieldOrigin origin = OriginProvider, int originIndex = -1 )
{
if ( mNameToIndex.contains(field.name()) )
return false;

if (originIndex == -1 && origin == OriginProvider)
originIndex = mFields.count();
mFields.append( Field(field,origin,originIndex) );

mNameToIndex.insert( field.name(), mFields.count()-1 );
return true;
}
void remove( int fieldIdx ) { mNameToIndex.remove(mFields[fieldIdx].field.name()); mFields.remove(fieldIdx); }

inline bool isEmpty() const { return mFields.isEmpty(); }
inline int count() const { return mFields.count(); }
inline int size() const { return mFields.count(); } // TODO[MD]: delete?
inline const QgsField& operator[](int i) const { return mFields[i].field; }
inline QgsField& operator[](int i) { return mFields[i].field; }
const QgsField& at(int i) const { return mFields[i].field; }
QList<QgsField> toList() const { QList<QgsField> lst; for (int i = 0; i < mFields.count(); ++i) lst.append(mFields[i].field); return lst; } // TODO[MD]: delete?

const QgsField& field( int fieldIdx ) const { return mFields[fieldIdx].field; }
const QgsField& field( const QString& name ) const { return mFields[ indexFromName(name) ].field; }
FieldOrigin fieldOrigin( int fieldIdx ) const { return mFields[fieldIdx].origin; }
int fieldOriginIndex( int fieldIdx ) const { return mFields[fieldIdx].originIndex; }

int indexFromName( const QString& name ) const { return mNameToIndex.value(name, -1); }

protected:
QVector<Field> mFields;

//! map for quick resolution of name to index
QHash<QString, int> mNameToIndex;
public:

enum FieldOrigin { OriginUnknown, OriginProvider, OriginJoin, OriginEdit };
typedef struct Field
{
Field(): origin( OriginUnknown ), originIndex( -1 ) {}
Field( const QgsField& f, FieldOrigin o, int oi ): field( f ), origin( o ), originIndex( oi ) {}

QgsField field;
FieldOrigin origin; // TODO[MD]: originIndex or QVariant originID?
int originIndex;
} Field;

void clear() { mFields.clear(); mNameToIndex.clear(); }
/** append: fields must have unique names! */
bool append( const QgsField& field, FieldOrigin origin = OriginProvider, int originIndex = -1 )
{
if ( mNameToIndex.contains( field.name() ) )
return false;

if ( originIndex == -1 && origin == OriginProvider )
originIndex = mFields.count();
mFields.append( Field( field, origin, originIndex ) );

mNameToIndex.insert( field.name(), mFields.count() - 1 );
return true;
}
void remove( int fieldIdx ) { mNameToIndex.remove( mFields[fieldIdx].field.name() ); mFields.remove( fieldIdx ); }

inline bool isEmpty() const { return mFields.isEmpty(); }
inline int count() const { return mFields.count(); }
inline int size() const { return mFields.count(); } // TODO[MD]: delete?
inline const QgsField& operator[]( int i ) const { return mFields[i].field; }
inline QgsField& operator[]( int i ) { return mFields[i].field; }
const QgsField& at( int i ) const { return mFields[i].field; }
QList<QgsField> toList() const { QList<QgsField> lst; for ( int i = 0; i < mFields.count(); ++i ) lst.append( mFields[i].field ); return lst; } // TODO[MD]: delete?

const QgsField& field( int fieldIdx ) const { return mFields[fieldIdx].field; }
const QgsField& field( const QString& name ) const { return mFields[ indexFromName( name )].field; }
FieldOrigin fieldOrigin( int fieldIdx ) const { return mFields[fieldIdx].origin; }
int fieldOriginIndex( int fieldIdx ) const { return mFields[fieldIdx].originIndex; }

int indexFromName( const QString& name ) const { return mNameToIndex.value( name, -1 ); }

protected:
QVector<Field> mFields;

//! map for quick resolution of name to index
QHash<QString, int> mNameToIndex;
};


Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsofflineediting.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class CORE_EXPORT QgsOfflineEditing : public QObject
Q_OBJECT

public:
enum ProgressMode {
enum ProgressMode
{
CopyFeatures = 0,
ProcessFeatures,
AddFields,
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class CORE_EXPORT QgsProject : public QObject
bool topologicalEditing() const;

/** Return project's home path
@return home path of project (or QString::null if not set)
@return home path of project (or QString::null if not set)
@note added in version 2.0 */
QString homePath() const;

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectordataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ QMap<QString, int> QgsVectorDataProvider::fieldNameMap() const

QgsAttributeList QgsVectorDataProvider::attributeIndexes()
{
int count = fields().count();
int count = fields().count();
QgsAttributeList list;

for ( int i = 0; i < count; i++ )
Expand Down
112 changes: 56 additions & 56 deletions src/core/qgsvectorlayerundocommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,104 +33,104 @@ class QgsGeometry;

class QgsVectorLayerUndoCommand : public QUndoCommand
{
public:
QgsVectorLayerUndoCommand(QgsVectorLayerEditBuffer* buffer) : mBuffer(buffer) {}
inline QgsVectorLayer* layer() { return mBuffer->L; }
inline QgsVectorLayerCache* cache() { return mBuffer->L->cache(); }
public:
QgsVectorLayerUndoCommand( QgsVectorLayerEditBuffer* buffer ) : mBuffer( buffer ) {}
inline QgsVectorLayer* layer() { return mBuffer->L; }
inline QgsVectorLayerCache* cache() { return mBuffer->L->cache(); }

protected:
QgsVectorLayerEditBuffer* mBuffer;
protected:
QgsVectorLayerEditBuffer* mBuffer;
};


class QgsVectorLayerUndoCommandAddFeature : public QgsVectorLayerUndoCommand
{
public:
QgsVectorLayerUndoCommandAddFeature( QgsVectorLayerEditBuffer* buffer, QgsFeature& f );
public:
QgsVectorLayerUndoCommandAddFeature( QgsVectorLayerEditBuffer* buffer, QgsFeature& f );

virtual void undo();
virtual void redo();
virtual void undo();
virtual void redo();

private:
QgsFeature mFeature;
private:
QgsFeature mFeature;
};


class QgsVectorLayerUndoCommandDeleteFeature : public QgsVectorLayerUndoCommand
{
public:
QgsVectorLayerUndoCommandDeleteFeature( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid );
public:
QgsVectorLayerUndoCommandDeleteFeature( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid );

virtual void undo();
virtual void redo();
virtual void undo();
virtual void redo();

private:
QgsFeatureId mFid;
QgsFeature mOldAddedFeature;
private:
QgsFeatureId mFid;
QgsFeature mOldAddedFeature;
};


class QgsVectorLayerUndoCommandChangeGeometry : public QgsVectorLayerUndoCommand
{
public:
QgsVectorLayerUndoCommandChangeGeometry( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, QgsGeometry* newGeom );
~QgsVectorLayerUndoCommandChangeGeometry();
public:
QgsVectorLayerUndoCommandChangeGeometry( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, QgsGeometry* newGeom );
~QgsVectorLayerUndoCommandChangeGeometry();

virtual void undo();
virtual void redo();
virtual void undo();
virtual void redo();

private:
QgsFeatureId mFid;
QgsGeometry* mOldGeom;
QgsGeometry* mNewGeom;
private:
QgsFeatureId mFid;
QgsGeometry* mOldGeom;
QgsGeometry* mNewGeom;
};


class QgsVectorLayerUndoCommandChangeAttribute : public QgsVectorLayerUndoCommand
{
public:
QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, int fieldIndex, const QVariant& newValue );
virtual void undo();
virtual void redo();

private:
QgsFeatureId mFid;
int mFieldIndex;
QVariant mOldValue;
QVariant mNewValue;
bool mFirstChange;
public:
QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, int fieldIndex, const QVariant& newValue );
virtual void undo();
virtual void redo();

private:
QgsFeatureId mFid;
int mFieldIndex;
QVariant mOldValue;
QVariant mNewValue;
bool mFirstChange;
};


class QgsVectorLayerUndoCommandAddAttribute : public QgsVectorLayerUndoCommand
{
public:
QgsVectorLayerUndoCommandAddAttribute( QgsVectorLayerEditBuffer* buffer, const QgsField& field );
public:
QgsVectorLayerUndoCommandAddAttribute( QgsVectorLayerEditBuffer* buffer, const QgsField& field );

virtual void undo();
virtual void redo();
virtual void undo();
virtual void redo();

private:
QgsField mField;
int mFieldIndex;
private:
QgsField mField;
int mFieldIndex;
};


class QgsVectorLayerUndoCommandDeleteAttribute : public QgsVectorLayerUndoCommand
{
public:
QgsVectorLayerUndoCommandDeleteAttribute( QgsVectorLayerEditBuffer* buffer, int fieldIndex );
public:
QgsVectorLayerUndoCommandDeleteAttribute( QgsVectorLayerEditBuffer* buffer, int fieldIndex );

virtual void undo();
virtual void redo();
virtual void undo();
virtual void redo();

private:
int mFieldIndex;
bool mProviderField;
int mOriginIndex;
QgsField mOldField;
private:
int mFieldIndex;
bool mProviderField;
int mOriginIndex;
QgsField mOldField;

QMap<QgsFeatureId, QVariant> mDeletedValues;
QMap<QgsFeatureId, QVariant> mDeletedValues;
};


Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsstylev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ bool QgsStyleV2::load( QString filename )
// Make sure there are no Null fields in parenting symbols ang groups
char *query = sqlite3_mprintf( "UPDATE symbol SET groupid=0 WHERE groupid IS NULL;"
"UPDATE colorramp SET groupid=0 WHERE groupid IS NULL;"
"UPDATE symgroup SET parent=0 WHERE parent IS NULL;");
"UPDATE symgroup SET parent=0 WHERE parent IS NULL;" );
runEmptyQuery( query );

// First create all the main symbols
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,14 @@ bool QgsAttributeTableModel::setData( const QModelIndex &index, const QVariant &
if ( mFeatureMap.contains( fid ) )
{
QgsFeature &f = mFeatureMap[ fid ];
if( idx >= f.attributes().size() )
if ( idx >= f.attributes().size() )
f.attributes().resize( mFieldCount );
f.setAttribute( idx, value );
}

if ( mFeat.id() == fid || featureAtId( fid ) )
{
if( idx >= mFeat.attributes().size() )
if ( idx >= mFeat.attributes().size() )
mFeat.attributes().resize( mFieldCount );
mFeat.setAttribute( idx, value );
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ void QgsRubberBand::paint( QPainter* p )
QVector<QPointF>::const_iterator ptIt = pts.constBegin();
for ( ; ptIt != pts.constEnd(); ++ptIt )
{
double x = (*ptIt).x();
double y = (*ptIt).y();
double x = ( *ptIt ).x();
double y = ( *ptIt ).y();

qreal s = ( mIconSize - 1 ) / 2;

Expand Down Expand Up @@ -481,7 +481,7 @@ void QgsRubberBand::updateRect()
qreal s = ( mIconSize - 1 ) / 2;
qreal p = mWidth;
QgsRectangle rect = QgsRectangle( it->x() + mTranslationOffsetX - s - p, it->y() + mTranslationOffsetY - s - p,
it->x() + mTranslationOffsetX + s + p, it->y() + mTranslationOffsetY + s + p);
it->x() + mTranslationOffsetX + s + p, it->y() + mTranslationOffsetY + s + p );
r.combineExtentWith( &rect );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsrubberband.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem

/** Set the size of the point icons
* Added in 1.9 */
void setIconSize ( int iconSize );
void setIconSize( int iconSize );

/**
* Clears all the geometries in this rubberband.
Expand Down
19 changes: 11 additions & 8 deletions src/providers/gpx/qgsgpxprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ const char* QgsGPXProvider::attr[] = { "name", "elevation", "symbol", "number",
"url", "url name"
};
QVariant::Type QgsGPXProvider::attrType[] = { QVariant::String, QVariant::Double, QVariant::String, QVariant::Int,
QVariant::String, QVariant::String, QVariant::String,
QVariant::String, QVariant::String };
QgsGPXProvider::DataType QgsGPXProvider::attrUsed[] = {
QVariant::String, QVariant::String, QVariant::String,
QVariant::String, QVariant::String
};
QgsGPXProvider::DataType QgsGPXProvider::attrUsed[] =
{
QgsGPXProvider::AllType, QgsGPXProvider::WaypointType, QgsGPXProvider::TrkRteType, QgsGPXProvider::TrkRteType,
QgsGPXProvider::AllType, QgsGPXProvider::AllType, QgsGPXProvider::AllType, QgsGPXProvider::AllType,
QgsGPXProvider::AllType, QgsGPXProvider::AllType };
QgsGPXProvider::AllType, QgsGPXProvider::AllType
};

const int QgsGPXProvider::attrCount = sizeof(QgsGPXProvider::attr)/sizeof(const char*);
const int QgsGPXProvider::attrCount = sizeof( QgsGPXProvider::attr ) / sizeof( const char* );

const QString GPX_KEY = "gpx";

Expand All @@ -66,7 +69,7 @@ const QString GPX_DESCRIPTION = QObject::tr( "GPS eXchange format provider" );

QgsGPXProvider::QgsGPXProvider( QString uri ) :
QgsVectorDataProvider( uri )
, mActiveIterator( 0 )
, mActiveIterator( 0 )
{
// assume that it won't work
mValid = false;
Expand All @@ -90,8 +93,8 @@ QgsGPXProvider::QgsGPXProvider( QString uri ) :
{
if ( attrUsed[i] & mFeatureType )
{
QString attrTypeName = (attrType[i] == QVariant::Int ? "int" : (attrType[i] == QVariant::Double ? "double" : "text"));
attributeFields.append( QgsField( attr[i], attrType[i], attrTypeName) );
QString attrTypeName = ( attrType[i] == QVariant::Int ? "int" : ( attrType[i] == QVariant::Double ? "double" : "text" ) );
attributeFields.append( QgsField( attr[i], attrType[i], attrTypeName ) );
indexToAttr.append( i );
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/providers/gpx/qgsgpxprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@ class QgsGPXProvider : public QgsVectorDataProvider

private:

enum DataType {
enum DataType
{
WaypointType = 1,
RouteType = 2,
TrackType = 4,

TrkRteType = RouteType|TrackType,
AllType = WaypointType|RouteType|TrackType
TrkRteType = RouteType | TrackType,
AllType = WaypointType | RouteType | TrackType

};

Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void QgsGrassProvider::loadAttributes( GLAYER &layer )
break;
}
layer.fields.append( QgsField( db_get_column_name( column ), qtype, ctypeStr,
db_get_column_length( column ), db_get_column_precision( column ) ) );
db_get_column_length( column ), db_get_column_precision( column ) ) );

if ( G_strcasecmp( db_get_column_name( column ), layer.fieldInfo->key ) == 0 )
{
Expand Down
52 changes: 26 additions & 26 deletions src/providers/mssql/qgsmssqlfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <QTextStream>


QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlProvider* provider, const QgsFeatureRequest& request)
QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlProvider* provider, const QgsFeatureRequest& request )
: QgsAbstractFeatureIterator( request ), mProvider( provider )
{
mIsOpen = false;
Expand All @@ -38,9 +38,9 @@ QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlProvider* provider, co
QgsDebugMsg( "Creating a separate database connection" );
QString id;
// QString::sprintf adds 0x prefix
id.sprintf("%08p", this);
mDatabase = mProvider->mDatabase.cloneDatabase(mProvider->mDatabase, id);
if (!mDatabase.open())
id.sprintf( "%08p", this );
mDatabase = mProvider->mDatabase.cloneDatabase( mProvider->mDatabase, id );
if ( !mDatabase.open() )
{
QgsDebugMsg( "Failed to open database" );
QString msg = mDatabase.lastError().text();
Expand All @@ -53,7 +53,7 @@ QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlProvider* provider, co
else
{
mUseProviderQuery = true;
mQuery = &mProvider->mQuery;
mQuery = &mProvider->mQuery;
}
// start selection
rewind();
Expand All @@ -62,14 +62,14 @@ QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlProvider* provider, co

QgsMssqlFeatureIterator::~QgsMssqlFeatureIterator()
{
if (!mUseProviderQuery)
if ( !mUseProviderQuery )
{
if (mQuery)
if ( mQuery )
delete mQuery;
mDatabase.close();
}
else if (mIsOpen)
close();
else if ( mIsOpen )
close();
}

void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
Expand All @@ -79,8 +79,8 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
int fieldCount = 0;
mFidCol = -1;
mGeometryCol = -1;
if (!request.subsetOfAttributes().empty())

if ( !request.subsetOfAttributes().empty() )
{
// subset of attributes has been specified
for ( QgsAttributeList::const_iterator it = request.subsetOfAttributes().begin(); it != request.subsetOfAttributes().end(); ++it )
Expand All @@ -90,26 +90,26 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
mStatement += "[" + mProvider->mAttributeFields[*it].name() + "]";

if ( !mProvider->mFidColName.isEmpty() && mProvider->mFidColName == mProvider->mAttributeFields[*it].name() )
mFidCol = fieldCount;
mFidCol = fieldCount;

++fieldCount;
mAttributesToFetch.append(*it);
mAttributesToFetch.append( *it );
}
}
else
{
// get all attributes
for (int i = 0; i < mProvider->mAttributeFields.count(); i++)
for ( int i = 0; i < mProvider->mAttributeFields.count(); i++ )
{
if ( fieldCount != 0 )
mStatement += ",";
mStatement += "[" + mProvider->mAttributeFields[i].name() + "]";

if ( !mProvider->mFidColName.isEmpty() && mProvider->mFidColName == mProvider->mAttributeFields[i].name() )
mFidCol = fieldCount;
mFidCol = fieldCount;

++fieldCount;
mAttributesToFetch.append(i);
mAttributesToFetch.append( i );
}
}
// get fid col if not yet required
Expand Down Expand Up @@ -139,7 +139,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )

bool filterAdded = false;
// set spatial filter
if ( request.filterType() & QgsFeatureRequest::FilterRect)
if ( request.filterType() & QgsFeatureRequest::FilterRect )
{
// polygons should be CCW for SqlGeography
QString r;
Expand All @@ -159,13 +159,13 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
}

// set fid filter
if ( (request.filterType() & QgsFeatureRequest::FilterFid) && !mProvider->mFidColName.isEmpty() )
if (( request.filterType() & QgsFeatureRequest::FilterFid ) && !mProvider->mFidColName.isEmpty() )
{
// set attribute filter
if ( !filterAdded )
mStatement += QString( " where [%1] = %2" ).arg( mProvider->mFidColName, QString::number( request.filterFid() ) );
else
mStatement +=QString( " and [%1] = %2" ).arg( mProvider->mFidColName, QString::number( request.filterFid() ) );
mStatement += QString( " and [%1] = %2" ).arg( mProvider->mFidColName, QString::number( request.filterFid() ) );
filterAdded = true;
}

Expand All @@ -190,7 +190,7 @@ bool QgsMssqlFeatureIterator::nextFeature( QgsFeature& feature )
{
feature.setValid( false );

if (!mQuery)
if ( !mQuery )
return false;

if ( !mQuery->isActive() )
Expand All @@ -204,7 +204,7 @@ bool QgsMssqlFeatureIterator::nextFeature( QgsFeature& feature )
feature.initAttributes( mProvider->mAttributeFields.count() );
feature.setFields( &mProvider->mAttributeFields ); // allow name-based attribute lookups

for (int i = 0; i < mAttributesToFetch.count(); i++)
for ( int i = 0; i < mAttributesToFetch.count(); i++ )
{
QVariant v = mQuery->value( i );
feature.setAttribute( mAttributesToFetch[i], mQuery->value( i ) );
Expand Down Expand Up @@ -240,9 +240,9 @@ bool QgsMssqlFeatureIterator::rewind()
return false;
}

if (!mQuery)
if ( !mQuery )
return false;

mQuery->clear();
mQuery->setForwardOnly( true );
if ( !mQuery->exec( mStatement ) )
Expand All @@ -251,15 +251,15 @@ bool QgsMssqlFeatureIterator::rewind()
QgsDebugMsg( msg );
}
else
mIsOpen = true;
mIsOpen = true;

return true;
}

bool QgsMssqlFeatureIterator::close()
{
mIsOpen = false;
if (!mQuery)
if ( !mQuery )
return false;

if ( !mQuery->isActive() )
Expand Down
4 changes: 2 additions & 2 deletions src/providers/mssql/qgsmssqlfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class QgsMssqlProvider;
class QgsMssqlFeatureIterator : public QgsAbstractFeatureIterator
{
public:
QgsMssqlFeatureIterator( QgsMssqlProvider* provider, const QgsFeatureRequest& request);
QgsMssqlFeatureIterator( QgsMssqlProvider* provider, const QgsFeatureRequest& request );

~QgsMssqlFeatureIterator();

Expand Down Expand Up @@ -67,7 +67,7 @@ class QgsMssqlFeatureIterator : public QgsAbstractFeatureIterator
long mFidCol;

// Field index of geometry column
long mGeometryCol;
long mGeometryCol;

// List of attribute indices to fetch with nextFeature calls
QgsAttributeList mAttributesToFetch;
Expand Down
44 changes: 22 additions & 22 deletions src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ QgsMssqlProvider::QgsMssqlProvider( QString uri )
return;
}

// Create a query for default connection
// Create a query for default connection
mQuery = QSqlQuery( mDatabase );

// Database successfully opened; we can now issue SQL commands.
Expand Down Expand Up @@ -173,7 +173,7 @@ QgsFeatureIterator QgsMssqlProvider::getFeatures( const QgsFeatureRequest& reque
QgsDebugMsg( "Read attempt on an invalid mssql data source" );
return QgsFeatureIterator();
}

return QgsFeatureIterator( new QgsMssqlFeatureIterator( this, request ) );
}

Expand Down Expand Up @@ -340,7 +340,7 @@ void QgsMssqlProvider::loadFields()
mAttributeFields.clear();
mDefaultValues.clear();
// get field spec
QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
if ( !query.exec( QString( "exec sp_columns N'%1', NULL, NULL, NULL, NULL" ).arg( mTableName ) ) )
{
Expand Down Expand Up @@ -407,9 +407,9 @@ void QgsMssqlProvider::loadFields()
query.clear();
query.setForwardOnly( true );
if ( !query.exec( QString( "select count(distinct [%1]), count([%1]) from [%2].[%3]" )
.arg( pk )
.arg( mSchemaName )
.arg( mTableName ) ) )
.arg( pk )
.arg( mSchemaName )
.arg( mTableName ) ) )
{
QString msg = query.lastError().text();
QgsDebugMsg( msg );
Expand Down Expand Up @@ -461,7 +461,7 @@ QVariant QgsMssqlProvider::minimumValue( int index )
sql += QString( " where (%1)" ).arg( mSqlWhereClause );
}

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

if ( !query.exec( sql ) )
Expand Down Expand Up @@ -497,7 +497,7 @@ QVariant QgsMssqlProvider::maximumValue( int index )
sql += QString( " where (%1)" ).arg( mSqlWhereClause );
}

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

if ( !query.exec( sql ) )
Expand Down Expand Up @@ -542,7 +542,7 @@ void QgsMssqlProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, i
sql += QString( " where (%1)" ).arg( mSqlWhereClause );
}

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

if ( !query.exec( sql ) )
Expand Down Expand Up @@ -597,7 +597,7 @@ void QgsMssqlProvider::UpdateStatistics( bool estimate )
statement += " where (" + mSqlWhereClause + ")";
}

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

if ( !query.exec( statement ) )
Expand Down Expand Up @@ -702,7 +702,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
statement = QString( "INSERT INTO [%1].[%2] (" ).arg( mSchemaName, mTableName );

bool first = true;
QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

const QgsAttributes& attrs = it->attributes();
Expand Down Expand Up @@ -886,7 +886,7 @@ bool QgsMssqlProvider::addAttributes( const QList<QgsField> &attributes )
statement += QString( "[%1] %2" ).arg( it->name(), type );
}

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
if ( !query.exec( statement ) )
{
Expand Down Expand Up @@ -917,7 +917,7 @@ bool QgsMssqlProvider::deleteAttributes( const QgsAttributeIds &attributes )
statement += QString( "[%1]" ).arg( mAttributeFields[*it].name() );
}

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

if ( !query.exec( statement ) )
Expand Down Expand Up @@ -953,7 +953,7 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap & at
statement = QString( "UPDATE [%1].[%2] SET " ).arg( mSchemaName, mTableName );

bool first = true;
QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

const QgsAttributeMap& attrs = it.value();
Expand Down Expand Up @@ -1059,7 +1059,7 @@ bool QgsMssqlProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
else
statement = QString( "UPDATE [%1].[%2] SET " ).arg( mSchemaName, mTableName );

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

if ( mGeometryColType == "geometry" )
Expand Down Expand Up @@ -1125,7 +1125,7 @@ bool QgsMssqlProvider::deleteFeatures( const QgsFeatureIds & id )
featureIds += "," + FID_TO_STRING( *it );
}

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
QString statement;
if ( mSchemaName.isEmpty() )
Expand All @@ -1135,7 +1135,7 @@ bool QgsMssqlProvider::deleteFeatures( const QgsFeatureIds & id )
statement = QString( "DELETE FROM [%1].[%2] WHERE [%3] IN (%4)" ).arg( mSchemaName,
mTableName, mFidColName, featureIds );

if ( !query.exec(statement) )
if ( !query.exec( statement ) )
{
QString msg = query.lastError().text();
QgsDebugMsg( msg );
Expand All @@ -1157,7 +1157,7 @@ bool QgsMssqlProvider::createSpatialIndex()
if ( mUseEstimatedMetadata )
UpdateStatistics( false );

QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
QString statement;
if ( mSchemaName.isEmpty() )
Expand All @@ -1178,7 +1178,7 @@ bool QgsMssqlProvider::createSpatialIndex()
statement += " USING GEOGRAPHY_GRID";
}

if ( !query.exec(statement) )
if ( !query.exec( statement ) )
{
QString msg = query.lastError().text();
QgsDebugMsg( msg );
Expand All @@ -1190,7 +1190,7 @@ bool QgsMssqlProvider::createSpatialIndex()

bool QgsMssqlProvider::createAttributeIndex( int field )
{
QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
QString statement;

Expand All @@ -1207,7 +1207,7 @@ bool QgsMssqlProvider::createAttributeIndex( int field )
statement = QString( "CREATE NONCLUSTERED INDEX [qgs_%1_idx] ON [%2].[%3] ( [%4] )" ).arg(
mGeometryColName, mSchemaName, mTableName, mAttributeFields[field].name() );

if ( !query.exec(statement) )
if ( !query.exec( statement ) )
{
QString msg = query.lastError().text();
QgsDebugMsg( msg );
Expand All @@ -1222,7 +1222,7 @@ QgsCoordinateReferenceSystem QgsMssqlProvider::crs()
if ( !mCrs.isValid() && mSRId > 0 )
{
// try to load crs
QSqlQuery query = QSqlQuery(mDatabase);
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
query.exec( QString( "select srtext from spatial_ref_sys where srid = %1" ).arg( QString::number( mSRId ) ) );
if ( query.isActive() )
Expand Down
92 changes: 46 additions & 46 deletions src/providers/oracle/qgsoraclefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,54 +29,54 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleProvider *p, const
{
mQry = QSqlQuery( *P->mConnection );

if( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes )
if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes )
{
mAttributeList = mRequest.subsetOfAttributes();
if( mAttributeList.isEmpty() )
if ( mAttributeList.isEmpty() )
mAttributeList = P->attributeIndexes();
}
else
mAttributeList = P->attributeIndexes();

QString whereClause;

switch( request.filterType() )
switch ( request.filterType() )
{
case QgsFeatureRequest::FilterRect:
if( !P->mGeometryColumn.isNull() )
{
QgsRectangle rect( mRequest.filterRect() );
QString bbox = QString( "mdsys.sdo_geometry(2003,%1,NULL,"
"mdsys.sdo_elem_info_array(1,1003,3),"
"mdsys.sdo_ordinate_array(%2,%3,%4,%5)"
")" )
.arg( P->mSrid < 1 ? "NULL" : QString::number( P->mSrid ) )
.arg( rect.xMinimum(), 0, 'f', 16 )
.arg( rect.yMinimum(), 0, 'f', 16 )
.arg( rect.xMaximum(), 0, 'f', 16 )
.arg( rect.yMaximum(), 0, 'f', 16 );

if ( !P->mSpatialIndex.isNull() )
case QgsFeatureRequest::FilterRect:
if ( !P->mGeometryColumn.isNull() )
{
whereClause = QString( "sdo_filter(%1,%2)='TRUE'" ).arg( P->quotedIdentifier( P->mGeometryColumn ) ).arg( bbox );
QgsRectangle rect( mRequest.filterRect() );
QString bbox = QString( "mdsys.sdo_geometry(2003,%1,NULL,"
"mdsys.sdo_elem_info_array(1,1003,3),"
"mdsys.sdo_ordinate_array(%2,%3,%4,%5)"
")" )
.arg( P->mSrid < 1 ? "NULL" : QString::number( P->mSrid ) )
.arg( rect.xMinimum(), 0, 'f', 16 )
.arg( rect.yMinimum(), 0, 'f', 16 )
.arg( rect.xMaximum(), 0, 'f', 16 )
.arg( rect.yMaximum(), 0, 'f', 16 );

if ( !P->mSpatialIndex.isNull() )
{
whereClause = QString( "sdo_filter(%1,%2)='TRUE'" ).arg( P->quotedIdentifier( P->mGeometryColumn ) ).arg( bbox );
#if 0
if ( mRequest.flags() & QgsFeatureRequest::ExactIntersect )
{
whereClause += QString( " AND sdo_relate(%1,%2,'mask=ANYINTERACT')='TRUE'" )
.arg( quotedIdentifier( P->mGeometryColumn ) )
.arg( bbox );
}
if ( mRequest.flags() & QgsFeatureRequest::ExactIntersect )
{
whereClause += QString( " AND sdo_relate(%1,%2,'mask=ANYINTERACT')='TRUE'" )
.arg( quotedIdentifier( P->mGeometryColumn ) )
.arg( bbox );
}
#endif
}
}
}
break;
break;

case QgsFeatureRequest::FilterFid:
whereClause = P->whereClause( request.filterFid() );
break;
case QgsFeatureRequest::FilterFid:
whereClause = P->whereClause( request.filterFid() );
break;

case QgsFeatureRequest::FilterNone:
break;
case QgsFeatureRequest::FilterNone:
break;
}

if ( P->mRequestedGeomType != QGis::WKBUnknown && P->mRequestedGeomType != P->mDetectedGeomType )
Expand Down Expand Up @@ -107,7 +107,7 @@ bool QgsOracleFeatureIterator::nextFeature( QgsFeature& feature )
{
feature.setValid( false );

if( !mQry.isActive() )
if ( !mQry.isActive() )
return false;

for ( ;; )
Expand All @@ -118,18 +118,18 @@ bool QgsOracleFeatureIterator::nextFeature( QgsFeature& feature )
if ( mRewind )
{
mRewind = false;
if( !mQry.first() )
if ( !mQry.first() )
return true;
}
else if( !mQry.next() )
else if ( !mQry.next() )
{
return false;
}

int col = 0;

if ( (mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 ||
( (mRequest.flags() & QgsFeatureRequest::ExactIntersect ) != 0 && !P->mConnection->hasSpatial() ) )
if (( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 ||
(( mRequest.flags() & QgsFeatureRequest::ExactIntersect ) != 0 && !P->mConnection->hasSpatial() ) )
{
QByteArray *ba = static_cast<QByteArray*>( mQry.value( col++ ).data() );
unsigned char *copy = new unsigned char[ba->size()];
Expand All @@ -139,18 +139,18 @@ bool QgsOracleFeatureIterator::nextFeature( QgsFeature& feature )

if ( !P->mConnection->hasSpatial() &&
mRequest.filterType() == QgsFeatureRequest::FilterRect &&
(mRequest.flags() & QgsFeatureRequest::ExactIntersect ) != 0 &&
(!feature.geometry() || !feature.geometry()->intersects( mRequest.filterRect() ) ) )
( mRequest.flags() & QgsFeatureRequest::ExactIntersect ) != 0 &&
( !feature.geometry() || !feature.geometry()->intersects( mRequest.filterRect() ) ) )
{
// skip feature that don't intersect with our rectangle
QgsDebugMsg( "no intersect" );
continue;
// skip feature that don't intersect with our rectangle
QgsDebugMsg( "no intersect" );
continue;
}


if ( (mRequest.flags() & QgsFeatureRequest::NoGeometry ) != 0 )
if (( mRequest.flags() & QgsFeatureRequest::NoGeometry ) != 0 )
{
feature.setGeometryAndOwnership( 0, 0 );
feature.setGeometryAndOwnership( 0, 0 );
}
}

Expand Down Expand Up @@ -243,7 +243,7 @@ bool QgsOracleFeatureIterator::close()

bool QgsOracleFeatureIterator::openQuery( QString whereClause )
{
if ( ( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 && P->mGeometryColumn.isNull() )
if (( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 && P->mGeometryColumn.isNull() )
{
return false;
}
Expand All @@ -252,7 +252,7 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )
{
QString query = "SELECT ", delim = "";

if ( ( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 )
if (( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 )
{
query += P->quotedIdentifier( P->mGeometryColumn );
delim = ",";
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ class TestQgsExpression: public QObject
void eval_columns()
{
QgsFields fields;
fields.append( QgsField("x1") );
fields.append( QgsField("x2") );
fields.append( QgsField( "x1" ) );
fields.append( QgsField( "x2" ) );
fields.append( QgsField( "foo", QVariant::Int ) );

QgsFeature f;
Expand Down
280 changes: 140 additions & 140 deletions tests/src/python/test_qgsvectorlayer.py

Large diffs are not rendered by default.