44 changes: 22 additions & 22 deletions python/plugins/sextante/algs/StatisticsByCategories.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ class StatisticsByCategories(GeoAlgorithm):

INPUT_LAYER = "INPUT_LAYER"
VALUES_FIELD_NAME = "VALUES_FIELD_NAME"
CATEGORIES_FIELD_NAME = "CATEGORIES_FIELD_NAME"
CATEGORIES_FIELD_NAME = "CATEGORIES_FIELD_NAME"
OUTPUT = "OUTPUT"

def defineCharacteristics(self):
self.name = "Statistics by categories"
self.group = "Vector table tools"

self.addParameter(ParameterVector(self.INPUT_LAYER, "Input vector layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterTableField(self.VALUES_FIELD_NAME, "Field to calculate statistics on",
self.addParameter(ParameterTableField(self.VALUES_FIELD_NAME, "Field to calculate statistics on",
self.INPUT_LAYER, ParameterTableField.DATA_TYPE_NUMBER))
self.addParameter(ParameterTableField(self.CATEGORIES_FIELD_NAME, "Field with categories",
self.INPUT_LAYER, ParameterTableField.DATA_TYPE_ANY))
self.addParameter(ParameterTableField(self.CATEGORIES_FIELD_NAME, "Field with categories",
self.INPUT_LAYER, ParameterTableField.DATA_TYPE_ANY))

self.addOutput(OutputTable(self.OUTPUT, "Statistics"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
valuesFieldName = self.getParameterValue(self.VALUES_FIELD_NAME)
Expand All @@ -59,7 +59,7 @@ def processAlgorithm(self, progress):
output = self.getOutputFromName(self.OUTPUT)
valuesField = layer.fieldNameIndex(valuesFieldName)
categoriesField = layer.fieldNameIndex(categoriesFieldName)

features = QGisLayers.features(layer)
nFeats = len(features)
values = {}
Expand All @@ -76,26 +76,26 @@ def processAlgorithm(self, progress):
values[cat].append(value)
except:
pass
fields = [QgsField("category", QVariant.String), QgsField("min", QVariant.Double),
QgsField("max", QVariant.Double), QgsField("mean", QVariant.Double),

fields = [QgsField("category", QVariant.String), QgsField("min", QVariant.Double),
QgsField("max", QVariant.Double), QgsField("mean", QVariant.Double),
QgsField("stddev", QVariant.Double)]
writer = output.getTableWriter(fields)
for cat, v in values.items():
for cat, v in values.items():
min, max, mean, stddev = calculateStats(v)
record = [cat, min, max, mean, stddev]
record = [cat, min, max, mean, stddev]
writer.addRecord(record)
def calculateStats(values):
n = 0

def calculateStats(values):
n = 0
sum = 0
mean = 0
M2 = 0
M2 = 0
minvalue = None
maxvalue = None
for v in values:
sum += v

for v in values:
sum += v
n = n + 1
delta = v - mean
mean = mean + delta/n
Expand All @@ -105,11 +105,11 @@ def calculateStats(values):
maxvalue = v
else:
minvalue = min(v, minvalue)
maxvalue = max(v, maxvalue)
maxvalue = max(v, maxvalue)

if n > 1:
variance = M2/(n - 1)
else:
variance = 0;
stddev = math.sqrt(variance)
return minvalue,maxvalue, mean, stddev
return minvalue,maxvalue, mean, stddev
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/VectorLayerHistogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def processAlgorithm(self, progress):
bins = self.getParameterValue(self.BINS)
plt.hist(values[fieldname], bins)
plotFilename = output +".png"
lab.savefig(plotFilename)
lab.savefig(plotFilename)
f = open(output, "w")
f.write("<img src=\"" + plotFilename + "\"/>")
f.close()
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/algs/VectorLayerScatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VectorLayerScatterplot(GeoAlgorithm):
OUTPUT = "OUTPUT"
XFIELD = "XFIELD"
YFIELD = "YFIELD"


def processAlgorithm(self, progress):
uri = self.getParameterValue(self.INPUT)
Expand All @@ -51,10 +51,10 @@ def processAlgorithm(self, progress):
output = self.getOutputValue(self.OUTPUT)
values = vector.getAttributeValues(layer, xfieldname, yfieldname)
plt.close()

plt.scatter(values[xfieldname], values[yfieldname])
plotFilename = output +".png"
lab.savefig(plotFilename)
lab.savefig(plotFilename)
f = open(output, "w")
f.write("<img src=\"" + plotFilename + "\"/>")
f.close()
Expand All @@ -64,6 +64,6 @@ def defineCharacteristics(self):
self.group = "Graphics"
self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(self.XFIELD, "X attribute", self.INPUT,ParameterTableField.DATA_TYPE_NUMBER))
self.addParameter(ParameterTableField(self.YFIELD, "Y attribute", self.INPUT,ParameterTableField.DATA_TYPE_NUMBER))
self.addParameter(ParameterTableField(self.YFIELD, "Y attribute", self.INPUT,ParameterTableField.DATA_TYPE_NUMBER))
self.addOutput(OutputHTML(self.OUTPUT, "Output"))

8 changes: 4 additions & 4 deletions python/plugins/sextante/algs/ftools/BasicStatisticsNumbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ class BasicStatisticsNumbers(GeoAlgorithm):
INPUT_LAYER = "INPUT_LAYER"
FIELD_NAME = "FIELD_NAME"
OUTPUT_HTML_FILE = "OUTPUT_HTML_FILE"

CV = "CV"
MIN = "MIN"
MAX = "MAX"
SUM = "SUM"
MEAN = "MEAN"
COUNT = "COUNT"
COUNT = "COUNT"
STD_DEV = "STD_DEV"
RANGE = "RANGE"
MEDIAN = "MEDIAN"
UNIQUE = "UNIQUE"


#===========================================================================
# def getIcon(self):
Expand All @@ -63,7 +63,7 @@ def defineCharacteristics(self):
self.group = "Vector table tools"

self.addParameter(ParameterVector(self.INPUT_LAYER, "Input vector layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterTableField(self.FIELD_NAME, "Field to calculate statistics on",
self.addParameter(ParameterTableField(self.FIELD_NAME, "Field to calculate statistics on",
self.INPUT_LAYER, ParameterTableField.DATA_TYPE_NUMBER))

self.addOutput(OutputHTML(self.OUTPUT_HTML_FILE, "Statistics for numeric field"))
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/sextante/algs/ftools/FToolsUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from qgis.core import *

def createSpatialIndex(layer):
idx = QgsSpatialIndex()
idx = QgsSpatialIndex()
features = QGisLayers.features(layer)
for ft in features:
idx.insertFeature(ft)
Expand Down Expand Up @@ -61,12 +61,12 @@ def createUniqueFieldName(fieldName, fieldList):

def findOrCreateField(layer, fieldList, fieldName, fieldLen=24, fieldPrec=15):
idx = layer.fieldNameIndex(fieldName)
if idx == -1:
if idx == -1:
fn = createUniqueFieldName(fieldName, fieldList)
field = QgsField(fn, QVariant.Double, "", fieldLen, fieldPrec)
idx = len(fieldList)
fieldList.append(field)

return idx, fieldList

def extractPoints( geom ):
Expand Down Expand Up @@ -96,13 +96,13 @@ def extractPoints( geom ):

return points

def getUniqueValues(layer, fieldIndex):
def getUniqueValues(layer, fieldIndex):
values = []
layer.select([fieldIndex], QgsRectangle(), False)
features = QGisLayers.features(layer)
for feat in features:
if feat.attributes()[fieldIndex] not in values:
values.append(feat.attributes()[fieldIndex])
values.append(feat.attributes()[fieldIndex])
return values

def getUniqueValuesCount(layer, fieldIndex):
Expand All @@ -116,7 +116,7 @@ def combineVectorFields( layerA, layerB ):
namesA = [unicode(f.name()).lower() for f in fieldsA]
fieldsB = layerB.dataProvider().fields()
for field in fieldsB:
name = unicode(field.name()).lower()
name = unicode(field.name()).lower()
if name in namesA:
idx=2
newName = name + "_" + unicode(idx)
Expand All @@ -125,7 +125,7 @@ def combineVectorFields( layerA, layerB ):
newName = name + "_" + unicode(idx)
field = QgsField(newName, field.type(), field.typeName())
fields.append(field)

return fields

# Create a unique field name based on input field name
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/sextante/algs/ftools/PointsInPolygonWeighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ def processAlgorithm(self, progress):
hasIntersections = True

if hasIntersections:
progress.setText(str(len(points)))
for i in points:
pointLayer.featureAtId(int(i), ftPoint, True, True)
progress.setText(str(len(points)))
for i in points:
pointLayer.featureAtId(int(i), ftPoint, True, True)
tmpGeom = QgsGeometry(ftPoint.geometry())
if geom.contains(tmpGeom):
#try:
weight, ok = ftPoint.attributes()[fieldidx].toDouble()
if ok:
count += weight
if ok:
count += weight

outFeat.setGeometry(geom)
if idxCount == len(atMap):
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()
for feat in inputLayer.getFeatures():
for feat in inputLayer.getFeatures():
index.insertFeature(feat)

infeat = QgsFeature()
geom = QgsGeometry()
selectedSet = []
selectedSet = []
current = 0
features = QGisLayers.features(selectLayer)
total = 100.0 / float(len(features))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/Union.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def processAlgorithm(self, progress):

fields = utils.combineVectorFields(vlayerA, vlayerB )
names = [field.name() for field in fields]
SextanteLog.addToLog(SextanteLog.LOG_INFO, str(names))
SextanteLog.addToLog(SextanteLog.LOG_INFO, str(names))
writer = self.getOutputFromName(Union.OUTPUT).getVectorWriter(fields, vproviderA.geometryType(), vproviderA.crs() )
inFeatA = QgsFeature()
inFeatB = QgsFeature()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def commandLineName(self):
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
name = ''.join(c for c in name if c in validChars)
return name


def removeOutputFromName(self, name):
for out in self.outputs:
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/sextante/core/LayerExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ def exportRasterLayer(layer):
#TODO:Do the conversion here
return unicode(layer.source())


@staticmethod
def exportTable( table):
'''Takes a QgsVectorLayer and returns the filename to refer to its attributes table,
which allows external apps which support only file-based layers to use it.
It performs the necessary export in case the input layer is not in a standard format
'''Takes a QgsVectorLayer and returns the filename to refer to its attributes table,
which allows external apps which support only file-based layers to use it.
It performs the necessary export in case the input layer is not in a standard format
suitable for most applications, it isa remote one or db-based (non-file based) one
Currently, the output is restricted to dbf.
It also export to a new file if the original one contains non-ascii characters'''
Expand All @@ -115,11 +115,11 @@ def exportTable( table):
return output
else:
filename = unicode(table.source())
if unicode(table.source()).endswith("shp"):
if unicode(table.source()).endswith("shp"):
return filename[:-3] + "dbf"
else:
return filename




6 changes: 3 additions & 3 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def initialize():
SextanteLog.startLogging()
SextanteConfig.initialize()
SextanteConfig.loadSettings()
RenderingStyles.loadStyles()
RenderingStyles.loadStyles()
Sextante.loadFromProviders()

@staticmethod
Expand Down Expand Up @@ -416,8 +416,8 @@ def getObjectFromUri(uri):
def getobject(uriorname):
ret = getObjectFromName(uriorname)
if ret is None:
ret = getObjectFromUri(uriorname)
return ret
ret = getObjectFromUri(uriorname)
return ret

def load(path):
'''Loads a layer into QGIS'''
Expand Down
32 changes: 16 additions & 16 deletions python/plugins/sextante/core/SextanteLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class LogEntry():
def __init__(self, date, text):
self.date = date
self.text = text

import re
import time

Expand All @@ -148,19 +148,19 @@ def __init__(self, date, text):
#this code has been take from pytailer
# http://code.google.com/p/pytailer/

# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#===============================================================================

Expand All @@ -177,7 +177,7 @@ def __init__(self, filename, read_size=1024, end=False):
self.start_pos = self.file.tell()
if end:
self.seek_end()

def splitlines(self, data):
return re.split('|'.join(self.line_terminators), data)

Expand Down Expand Up @@ -221,7 +221,7 @@ def seek_line(self):
# found crlf
bytes_read -= 1

while bytes_read > 0:
while bytes_read > 0:
# Scan backward, counting the newlines in this bufferfull
i = bytes_read - 1
while i >= 0:
Expand All @@ -241,7 +241,7 @@ def seek_line(self):
bytes_read, read_str = self.read(self.read_size)

return None

def tail(self, lines=10):
"""\
Return the last lines of the file.
Expand All @@ -258,7 +258,7 @@ def tail(self, lines=10):
return self.splitlines(data)
else:
return []



def __iter__(self):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/core/SextanteTableWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def __init__(self, fileName, encoding, fields):
def addRecord(self, values):
for i in range(len(values)):
if isinstance(values[i], QVariant):
values[i] = values[i].toString()
values[i] = values[i].toString()

file = open(self.fileName, "a")
file.write(";".join([unicode(value) for value in values]))
file.write("\n")
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/core/SextanteVectorWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, fileName, encoding, fields, geometryType, crs, options=None):
fieldsstring = "&".join(fieldsdesc)
uri += fieldsstring
self.memLayer = QgsVectorLayer(uri, self.fileName, "memory")
self.writer = self.memLayer.dataProvider()
self.writer = self.memLayer.dataProvider()
else:
formats = QgsVectorFileWriter.supportedFiltersAndFormats()
OGRCodes = {}
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def processAlgorithm(self, progress):
if self.getParameterValue(warp.TR) != 0:
trStr = "-tr "+str(self.getParameterValue(warp.TR))+" "+str(self.getParameterValue(warp.TR))
commands.append(trStr)
commands.append(str(self.getParameterValue(warp.EXTRA)))
commands.append(str(self.getParameterValue(warp.EXTRA)))
commands.append(self.getParameterValue(warp.INPUT))
commands.append(out)

Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/gui/AlgorithmClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AlgorithmDecorator():
classification = {};

@staticmethod
def loadClassification():
def loadClassification():
if not os.path.isfile(AlgorithmDecorator.classificationFile()):
return
lines = open(AlgorithmDecorator.classificationFile())
Expand All @@ -45,9 +45,9 @@ def loadClassification():
lines.close()

@staticmethod
def classificationFile():
def classificationFile():
folder = os.path.join(os.path.dirname(__file__), "help")
f = os.path.join(folder, "algclasssification.txt")
f = os.path.join(folder, "algclasssification.txt")
return f

@staticmethod
Expand Down
30 changes: 15 additions & 15 deletions python/plugins/sextante/gui/BatchProcessingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,36 @@ def __init__(self, alg):
self.addRowButton.clicked.connect(self.addRow)
self.deleteRowButton.clicked.connect(self.deleteRow)
self.table.horizontalHeader().sectionDoubleClicked.connect(self.headerDoubleClicked)


def headerDoubleClicked(self, col):
widget = self.table.cellWidget(0, col)
if isinstance(widget, QtGui.QComboBox):
widgetValue = widget.currentIndex()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setCurrentIndex(widgetValue)

elif isinstance(widget, ExtentSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
if widgetValue != None:
self.table.cellWidget(row, col).text.setText(widgetValue)
else:
self.table.cellWidget(row, col).text.setText("")
self.table.cellWidget(row, col).text.setText("")

elif isinstance(widget, CrsSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).epsg = widgetValue
self.table.cellWidget(row, col).setText()

elif isinstance(widget, QtGui.QLineEdit):
widgetValue = widget.text()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)
else:
pass
pass


def setTableContent(self):
i = 0
Expand All @@ -130,14 +130,14 @@ def setTableContent(self):
self.table.setColumnWidth(i,250)
self.table.setHorizontalHeaderItem(i, QtGui.QTableWidgetItem(out.description))
i+=1

self.table.setColumnWidth(i, 200)
self.table.setHorizontalHeaderItem(i, QtGui.QTableWidgetItem("Load in QGIS"))

for i in range(3):
self.addRow()


def accept(self):
self.algs = []
self.load = []
Expand Down Expand Up @@ -166,8 +166,8 @@ def accept(self):
self.algs = None
return
self.algs.append(alg)
widget = self.table.cellWidget(row, col)
self.load.append(widget.currentIndex() == 0)
widget = self.table.cellWidget(row, col)
self.load.append(widget.currentIndex() == 0)

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.table.setEnabled(False)
Expand All @@ -189,7 +189,7 @@ def accept(self):
return

self.finishAll()

def loadHTMLResults(self, alg, i):
for out in alg.outputs:
if out.hidden or not out.open:
Expand Down Expand Up @@ -323,10 +323,10 @@ def addRow(self):
for out in self.alg.outputs:
self.table.setCellWidget(self.table.rowCount()-1,i, BatchOutputSelectionPanel(out, self.alg, self.table.rowCount()-1, i, self))
i+=1

item = QtGui.QComboBox()
item.addItem("Yes")
item.addItem("No")
item.addItem("No")
item.setCurrentIndex(0)
self.table.setCellWidget(self.table.rowCount()-1, i, item)

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/gui/CrsSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class CrsSelectionPanel(QtGui.QWidget):

def __init__(self, default):
super(CrsSelectionPanel, self).__init__(None)
super(CrsSelectionPanel, self).__init__(None)
self.authid = default
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
Expand All @@ -44,7 +44,7 @@ def __init__(self, default):
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
self.setText()

def setAuthid(self, authid):
self.authid = authid
self.setText()
Expand Down
20 changes: 10 additions & 10 deletions python/plugins/sextante/gui/HistoryDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def __init__(self):
self.clearButton.setToolTip(self.tr("Clear history and log"))
self.buttonBox.addButton(self.clearButton, QDialogButtonBox.ActionRole)

self.tree.doubleClicked.connect(self.executeAlgorithm)
self.tree.doubleClicked.connect(self.executeAlgorithm)
self.tree.currentItemChanged.connect(self.changeText)
self.clearButton.clicked.connect(self.clearLog)

self.tree.customContextMenuRequested.connect(self.showPopupMenu)

self.fillTree()
Expand Down Expand Up @@ -85,30 +85,30 @@ def changeText(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
self.text.setText(item.entry.text.replace("|","\n"))



def createTest(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
TestTools.createTest(item)










def showPopupMenu(self,point):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
popupmenu = QMenu()
createTestAction = QAction(self.tr("Create test"), self.tree)
createTestAction.triggered.connect(self.createTest)
popupmenu.addAction(createTestAction)
popupmenu.exec_(self.tree.mapToGlobal(point))
popupmenu.addAction(createTestAction)
popupmenu.exec_(self.tree.mapToGlobal(point))

class TreeLogEntryItem(QTreeWidgetItem):
def __init__(self, entry, isAlg):
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 @@ -194,7 +194,7 @@ def buttonToggled(self, value):

def getExtendedLayerName(self, layer):
authid = layer.crs().authid()
if SextanteConfig.getSetting(SextanteConfig.SHOW_CRS_DEF) and authid is not None:
if SextanteConfig.getSetting(SextanteConfig.SHOW_CRS_DEF) and authid is not None:
return layer.name() + " [" + str(authid) +"]"
else:
return layer.name()
Expand Down
16 changes: 8 additions & 8 deletions python/plugins/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def fillTreeUsingCategories(self):
mainItem = QTreeWidgetItem()
mainItem.setText(0, "Geoalgorithms")
mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
mainItem.setToolTip(0, mainItem.text(0))
mainItem.setToolTip(0, mainItem.text(0))
for groupname, group in groups.items():
groupItem = QTreeWidgetItem()
groupItem.setText(0, groupname)
Expand All @@ -218,9 +218,9 @@ def fillTreeUsingCategories(self):
groupItem.addChild(subgroupItem)
for alg in subgroup:
algItem = TreeAlgorithmItem(alg)
subgroupItem.addChild(algItem)
self.algorithmTree.addTopLevelItem(mainItem)
subgroupItem.addChild(algItem)

self.algorithmTree.addTopLevelItem(mainItem)

for providerName in Sextante.algs.keys():
groups = {}
Expand Down Expand Up @@ -266,10 +266,10 @@ def fillTreeUsingCategories(self):
for groupItem in groups.values():
providerItem.addChild(groupItem)
self.algorithmTree.addTopLevelItem(providerItem)

if (text != ""):
self.algorithmTree.expandAll()

def fillTreeUsingProviders(self):
self.algorithmTree.clear()
text = unicode(self.searchBox.text())
Expand Down Expand Up @@ -317,7 +317,7 @@ def fillTreeUsingProviders(self):
providerItem.addChild(groupItem)
self.algorithmTree.addTopLevelItem(providerItem)
providerItem.setExpanded(text!="")
for groupItem in groups.values():
for groupItem in groups.values():
groupItem.setExpanded(text != "")


Expand All @@ -327,7 +327,7 @@ class TreeAlgorithmItem(QTreeWidgetItem):
def __init__(self, alg):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
QTreeWidgetItem.__init__(self)
self.alg = alg
self.alg = alg
icon = alg.getIcon()
name = alg.name
if useCategories:
Expand Down
29 changes: 14 additions & 15 deletions python/plugins/sextante/gui/TestTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.outputs.OutputVector import OutputVector

def createTest(item):
s = ""
tokens = item.entry.text[len("sextante.runalg("):-1].split(",")
def createTest(item):
s = ""
tokens = item.entry.text[len("sextante.runalg("):-1].split(",")
cmdname = tokens[0][1:-1];
methodname = "test_" + cmdname.replace(":","")
s += "def " + methodname + "():\n"
Expand All @@ -46,16 +46,16 @@ def createTest(item):
execcommand+=token + ","
else:
execcommand+="None,"
i+=1
i+=1
s += "\toutputs=" + execcommand[:-1] + ")\n"

i = -1 * len(alg.outputs)
for out in alg.outputs:
filename = tokens[i][1:-1]
filename = tokens[i][1:-1]
s+="\toutput=outputs['" + out.name + "']\n"
if isinstance(out, (OutputNumber, OutputString)):
s+="self.assertTrue(" + str(out) + ", output)\n"
if isinstance(out, OutputRaster):
if isinstance(out, OutputRaster):
dataset = gdal.Open(filename, GA_ReadOnly)
array = dataset.ReadAsArray(1)
s+="\tself.assertTrue(os.path.isfile(output))\n"
Expand Down Expand Up @@ -83,27 +83,26 @@ def createTest(item):
s+="\texpectedvalues=[" + ",".join([str(attr.toString()) for attr in attrs]) + "]\n"
s+="\tvalues=[str(attr.toString()) for attr in attrs]\n"
s+="\tself.assertEqual(exceptedtypes, types)\n"

dlg = ShowTestDialog(s)
dlg.exec_()

from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class ShowTestDialog(QtGui.QDialog):
def __init__(self, s):
def __init__(self, s):
QtGui.QDialog.__init__(self)
self.setModal(True)
self.resize(600,400)
self.setWindowTitle("Unit test")
layout = QVBoxLayout()
self.text = QtGui.QTextEdit()
self.text.setEnabled(True)
self.text.setText(s)
layout.addWidget(self.text)
self.text = QtGui.QTextEdit()
self.text.setEnabled(True)
self.text.setText(s)
layout.addWidget(self.text)
self.setLayout(layout)
QtCore.QMetaObject.connectSlotsByName(self)



10 changes: 5 additions & 5 deletions python/plugins/sextante/modeler/ModelerDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def fillAlgorithmTree(self):
self.fillAlgorithmTreeUsingProviders()

self.algorithmTree.sortItems(0, Qt.AscendingOrder)

text = unicode(self.searchBox.text())
if (text != ""):
self.algorithmTree.expandAll()
Expand Down Expand Up @@ -316,8 +316,8 @@ def fillAlgorithmTreeUsingCategories(self):
groupItem.addChild(subgroupItem)
for alg in subgroup:
algItem = TreeAlgorithmItem(alg)
subgroupItem.addChild(algItem)
self.algorithmTree.addTopLevelItem(mainItem)
subgroupItem.addChild(algItem)
self.algorithmTree.addTopLevelItem(mainItem)

for providerName in allAlgs.keys():
groups = {}
Expand Down Expand Up @@ -400,7 +400,7 @@ class TreeAlgorithmItem(QTreeWidgetItem):
def __init__(self, alg):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
QTreeWidgetItem.__init__(self)
self.alg = alg
self.alg = alg
icon = alg.getIcon()
name = alg.name
if useCategories:
Expand All @@ -409,4 +409,4 @@ def __init__(self, alg):
self.setIcon(0, icon)
self.setToolTip(0, name)
self.setText(0, name)

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from sextante.core.AlgorithmProvider import AlgorithmProvider
from sextante.modeler.CalculatorModelerAlgorithm import CalculatorModelerAlgorithm
from sextante.modeler.RasterLayerBoundsAlgorithm import RasterLayerBoundsAlgorithm
from sextante.modeler.VectorLayerBoundsAlgorithm import VectorLayerBoundsAlgorithm
from sextante.modeler.VectorLayerBoundsAlgorithm import VectorLayerBoundsAlgorithm

import os.path

Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def getWidgetFromParameter(self, param):
item.addItem(n.name(), n)
item.setEditText(str(param.default))
elif isinstance(param, ParameterCrs):
item = CrsSelectionPanel(param.default)
item = CrsSelectionPanel(param.default)
elif isinstance(param, ParameterExtent):
item = QtGui.QComboBox()
item.setEditable(True)
Expand Down Expand Up @@ -773,13 +773,13 @@ def setParamValue(self, param, widget):
elif isinstance(param, ParameterCrs):
authid = widget.getValue()
if authid is None:
self.params[param.name] = None
self.params[param.name] = None
else:
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = value
self.values[name] = authid
return True
return True
elif isinstance(param, ParameterFixedTable):
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/modeler/RasterLayerBoundsAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class RasterLayerBoundsAlgorithm(GeoAlgorithm):

LAYER = "LAYER"
LAYER = "LAYER"
XMIN = "XMIN"
XMAX = "XMAX"
YMIN = "YMIN"
Expand All @@ -41,7 +41,7 @@ def defineCharacteristics(self):
self.showInToolbox = False
self.name = "Raster layer bounds"
self.group = "Modeler-only tools"
self.addParameter(ParameterRaster(self.LAYER, "Layer"))
self.addParameter(ParameterRaster(self.LAYER, "Layer"))
self.addOutput(OutputNumber(self.XMIN, "min X"))
self.addOutput(OutputNumber(self.XMAX, "max X"))
self.addOutput(OutputNumber(self.YMIN, "min Y"))
Expand All @@ -54,4 +54,4 @@ def processAlgorithm(self, progress):
self.setOutputValue(self.XMAX, layer.extent().xMaximum())
self.setOutputValue(self.YMIN, layer.extent().yMinimum())
self.setOutputValue(self.YMAX, layer.extent().yMaximum())

6 changes: 3 additions & 3 deletions python/plugins/sextante/modeler/VectorLayerBoundsAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class VectorLayerBoundsAlgorithm(GeoAlgorithm):

LAYER = "LAYER"
LAYER = "LAYER"
XMIN = "XMIN"
XMAX = "XMAX"
YMIN = "YMIN"
Expand All @@ -40,7 +40,7 @@ def defineCharacteristics(self):
self.showInToolbox = False
self.name = "Vector layer bounds"
self.group = "Modeler-only tools"
self.addParameter(ParameterVector(self.LAYER, "Layer"))
self.addParameter(ParameterVector(self.LAYER, "Layer"))
self.addOutput(OutputNumber(self.XMIN, "min X"))
self.addOutput(OutputNumber(self.XMAX, "max X"))
self.addOutput(OutputNumber(self.YMIN, "min Y"))
Expand All @@ -53,4 +53,4 @@ def processAlgorithm(self, progress):
self.setOutputValue(self.XMAX, layer.extent().xMaximum())
self.setOutputValue(self.YMIN, layer.extent().yMinimum())
self.setOutputValue(self.YMAX, layer.extent().yMaximum())

4 changes: 2 additions & 2 deletions python/plugins/sextante/parameters/ParameterCrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def serialize(self):
"|" + str(self.default)

def deserialize(self, s):
tokens = s.split("|")
if tokens[2]==str(None):
tokens = s.split("|")
if tokens[2]==str(None):
tokens[2] = None
return ParameterCrs(tokens[0], tokens[1], tokens[2])

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 @@ -59,11 +59,11 @@ def setValue(self, obj):
val = unicode(obj)
self.value = val
return os.path.exists(self.value)

def getSafeExportedTable(self):
'''Returns not the value entered by the user, but a string with a filename which
contains the data of this table, but saved in a standard format (currently always
a dbf file) so that it can be opened by most external applications.
a dbf file) so that it can be opened by most external applications.
Works only if the table represented by the parameter value is currently loaded in QGIS.
Otherwise, it will not perform any export and return the current value string.
If the current value represents a table in a suitable format, it does not export at all
Expand All @@ -77,7 +77,7 @@ def getSafeExportedTable(self):
self.exported = LayerExporter.exportTable(table)
else:
self.exported = self.value
return self.exported
return self.exported

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/sextante/r/RAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def processParameterLine(self,line):
return
if line.lower().strip().startswith("userasterpackage"):
self.useRasterPackage = True
return
if line.lower().strip().startswith("passfilenames"):
return
if line.lower().strip().startswith("passfilenames"):
self.passFileNames = True
return
tokens = line.split("=");
Expand Down Expand Up @@ -267,9 +267,9 @@ def getImportCommands(self):
# just use main mirror
commands.append('options("repos"="http://cran.at.r-project.org/")')
rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
if not os.path.isdir(rLibDir):
if not os.path.isdir(rLibDir):
os.mkdir(rLibDir)
# .libPaths("%s") substitutes the personal libPath with "%s"! With '.libPaths(c("%s",deflibloc))' it is added without replacing and we can use all installed R packages!
# .libPaths("%s") substitutes the personal libPath with "%s"! With '.libPaths(c("%s",deflibloc))' it is added without replacing and we can use all installed R packages!
commands.append('deflibloc <- .libPaths()[1]')
commands.append('.libPaths(c("%s",deflibloc))' % rLibDir )
commands.append(
Expand Down Expand Up @@ -300,7 +300,7 @@ def getImportCommands(self):
else:
commands.append(param.name + " = readOGR(\"" + folder + "\",layer=\"" + filename + "\")")
if isinstance(param, ParameterTable):
value = param.value
value = param.value
if not value.lower().endswith("csv"):
raise GeoAlgorithmExecutionException("Unsupported input file format.\n" + value)
if self.passFileNames:
Expand All @@ -325,7 +325,7 @@ def getImportCommands(self):
#raise GeoAlgorithmExecutionException("Unsupported input file format.\n" + layer)
layer = layer.replace("\\", "/")
if self.passFileNames:
commands.append("tempvar" + str(iLayer)+ " <- \"" + layer + "\"")
commands.append("tempvar" + str(iLayer)+ " <- \"" + layer + "\"")
elif self.useRasterPackage:
commands.append("tempvar" + str(iLayer)+ " <- " + "brick(\"" + layer + "\")")
else:
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ def exportRasterLayer(self, layer):

def checkBeforeOpeningParametersDialog(self):
return SagaUtils.checkSagaIsInstalled()


def helpFile(self):
return os.path.join(os.path.dirname(__file__), "help", self.name.replace(" ", "") + ".html")
return os.path.join(os.path.dirname(__file__), "help", self.name.replace(" ", "") + ".html")


def commandLineName(self):
name = self.provider.getName().lower() + ":" + self.cmdname.lower()
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
Expand Down
21 changes: 10 additions & 11 deletions python/plugins/sextante/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def executeSaga(progress):
if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_CONSOLE):
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)


@classmethod
def checkSagaIsInstalled(cls):
if SextanteUtils.isWindows():
Expand All @@ -122,15 +122,15 @@ def checkSagaIsInstalled(cls):
return "SAGA folder is not configured.\nPlease configure it before running SAGA algorithms."
cmdpath = os.path.join(path, "saga_cmd.exe")
if not os.path.exists(cmdpath):
return ("The specified SAGA folder does not contain a valid SAGA executable.\n"
+ "Please, go to the SEXTANTE settings dialog, and check that the SAGA\n"
return ("The specified SAGA folder does not contain a valid SAGA executable.\n"
+ "Please, go to the SEXTANTE settings dialog, and check that the SAGA\n"
+ "folder is correctly configured")

SAGA_INSTALLED = "/SextanteQGIS/SagaInstalled"
settings = QSettings()
if settings.contains(SAGA_INSTALLED):
return

try:
qgis = QGisLayers.iface
crs = qgis.mapCanvas().mapRenderer().destinationCrs()
Expand All @@ -146,17 +146,16 @@ def checkSagaIsInstalled(cls):
pt = QgsPoint(x, y)
outFeat.setGeometry(QgsGeometry.fromPoint(pt))
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
writer.addFeature(outFeat)
del writer.writer
del writer
from sextante.core.Sextante import runalg
del writer
from sextante.core.Sextante import runalg
result = runalg("saga:thiessenpolygons", filename, None)
if not os.path.exists(result['POLYGONS']):
return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms."
except:
s = traceback.format_exc()
return "Error while checking SAGA installation. SAGA might not be correctly configured.\n" + s;


settings.setValue("/SextanteQGIS/SagaInstalled", True)


settings.setValue("/SextanteQGIS/SagaInstalled", True)
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@
# Create output vector layer with additional attribute
feats = sextante.getfeatures(layer)
nElement = 0
for inFeat in feats:
for inFeat in feats:
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
inGeom = inFeat.geometry()
outFeat.setGeometry(inGeom)
attrs = inFeat.attributes()
clazz = attrs[class_field_index].toString()
attrs.append(QVariant(len(classes[clazz])))
outFeat.setAttributes(attrs)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

del writer
8 changes: 4 additions & 4 deletions python/plugins/sextante/tools/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def scanraster(layer, progress):
filename = unicode(layer.source())
dataset = gdal.Open(filename, GA_ReadOnly)
band = dataset.GetRasterBand(1)
nodata = band.GetNoDataValue()
for y in xrange(band.YSize):
progress.setPercentage(y / float(band.YSize) * 100)
scanline = band.ReadRaster(0, y, band.XSize, 1,band.XSize, 1, band.DataType)
nodata = band.GetNoDataValue()
for y in xrange(band.YSize):
progress.setPercentage(y / float(band.YSize) * 100)
scanline = band.ReadRaster(0, y, band.XSize, 1,band.XSize, 1, band.DataType)
values = struct.unpack('f' * band.XSize, scanline)
for value in values:
if value == nodata:
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/sextante/tools/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ def getAttributeValues(layer, *attributeNames):
values.append(None)
ret[name] = values;
return ret



2 changes: 1 addition & 1 deletion scripts/astyle-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export elcr="$(tput el)$(tput cr)"

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/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
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/providers/spatialite/qspatialite/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
echo $f skipped
continue
;;
Expand Down
27 changes: 17 additions & 10 deletions src/app/composer/qgsatlascompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ void QgsAtlasCompositionWidget::on_mAtlasSingleFileCheckBox_stateChanged( int st
{
return;
}
if ( state == Qt::Checked ) {
if ( state == Qt::Checked )
{
mAtlasFilenamePatternEdit->setEnabled( false );
mAtlasFilenameExpressionButton->setEnabled( false );
}
else {
else
{
mAtlasFilenamePatternEdit->setEnabled( true );
mAtlasFilenameExpressionButton->setEnabled( true );
}
Expand All @@ -295,12 +297,14 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged( int s
{
return;
}

if ( state == Qt::Checked ) {

if ( state == Qt::Checked )
{
mAtlasSortFeatureDirectionButton->setEnabled( true );
mAtlasSortFeatureKeyComboBox->setEnabled( true );
}
else {
else
{
mAtlasSortFeatureDirectionButton->setEnabled( false );
mAtlasSortFeatureKeyComboBox->setEnabled( false );
}
Expand All @@ -315,7 +319,8 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureKeyComboBox_currentIndexChan
return;
}

if ( index != -1 ) {
if ( index != -1 )
{
atlasMap->setSortKeyAttributeIndex( index );
}
}
Expand Down Expand Up @@ -355,11 +360,12 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
void QgsAtlasCompositionWidget::on_mAtlasSortFeatureDirectionButton_clicked()
{
Qt::ArrowType at = mAtlasSortFeatureDirectionButton->arrowType();
at = (at == Qt::UpArrow) ? Qt::DownArrow : Qt::UpArrow;
at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
mAtlasSortFeatureDirectionButton->setArrowType( at );

QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
if ( !atlasMap ) {
if ( !atlasMap )
{
return;
}

Expand All @@ -377,8 +383,9 @@ void QgsAtlasCompositionWidget::fillSortColumns()
mAtlasSortFeatureKeyComboBox->clear();
// Get fields of the selected coverage layer
const QgsFields& fields = atlasMap->coverageLayer()->pendingFields();
for ( int i = 0; i < fields.count(); ++i ) {
mAtlasSortFeatureKeyComboBox->insertItem( i, fields.at(i).name() );
for ( int i = 0; i < fields.count(); ++i )
{
mAtlasSortFeatureKeyComboBox->insertItem( i, fields.at( i ).name() );
}
}

Expand Down
34 changes: 17 additions & 17 deletions src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem* item ): QWidget( parent ), mItem( item )
{

setupUi( this );

//make button exclusive
Expand All @@ -37,16 +37,16 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem*
buttonGroup->addButton( mLowerLeftCheckBox );
buttonGroup->addButton( mLowerMiddleCheckBox );
buttonGroup->addButton( mLowerRightCheckBox );
buttonGroup->setExclusive( true );
buttonGroup->setExclusive( true );

mXLineEdit->setValidator( new QDoubleValidator( 0 ) );
mYLineEdit->setValidator( new QDoubleValidator( 0 ) );
mWidthLineEdit->setValidator( new QDoubleValidator( 0 ) );
mHeightLineEdit->setValidator( new QDoubleValidator( 0 ) );

setValuesForGuiElements();
connect( mItem, SIGNAL( sizeChanged() ), this, SLOT( setValuesForGuiPositionElements() ) );

}

QgsComposerItemWidget::QgsComposerItemWidget(): QWidget( 0 ), mItem( 0 )
Expand Down Expand Up @@ -141,7 +141,7 @@ void QgsComposerItemWidget::changeItemTransparency( int value )
mItem->beginCommand( tr( "Item Transparency changed" ) );
QBrush itemBrush = mItem->brush();
QColor brushColor = itemBrush.color();
brushColor.setAlpha( 255-value );
brushColor.setAlpha( 255 - value );
mItem->setBrush( QBrush( brushColor ) );
mItem->update();
mItem->endCommand();
Expand Down Expand Up @@ -265,63 +265,63 @@ void QgsComposerItemWidget::setValuesForGuiPositionElements()
mHeightLineEdit->blockSignals( true );


if( mItem->lastUsedPositionMode() == QgsComposerItem::UpperLeft )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperLeft )
{
mUpperLeftCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::UpperMiddle )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperMiddle )
{
mUpperMiddleCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() / 2.0 ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::UpperRight )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperRight )
{
mUpperRightCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleLeft )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleLeft )
{
mMiddleLeftCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() / 2.0 ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::Middle )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::Middle )
{
mMiddleCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() / 2.0 ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() / 2.0 ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleRight )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleRight )
{
mMiddleRightCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() / 2.0 ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::LowerLeft )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerLeft )
{
mLowerLeftCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::LowerMiddle )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerMiddle )
{
mLowerMiddleCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() / 2.0 ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::LowerRight )
if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerRight )
{
mLowerRightCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() ) );
Expand Down Expand Up @@ -354,8 +354,8 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mItemIdLineEdit->blockSignals( true );
mTransparencySpinBox->blockSignals( true );

mTransparencySpinBox->setValue( 255-mItem->brush().color().alpha() );
mTransparencySlider->setValue( 255-mItem->brush().color().alpha() );
mTransparencySpinBox->setValue( 255 - mItem->brush().color().alpha() );
mTransparencySlider->setValue( 255 - mItem->brush().color().alpha() );
mOutlineWidthSpinBox->setValue( mItem->pen().widthF() );
mItemIdLineEdit->setText( mItem->id() );
mFrameGroupBox->setChecked( mItem->hasFrame() );
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgsatlascomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
bool mSortFeatures;
// sort direction
bool mSortAscending;
public:
public:
typedef std::map< QgsFeatureId, QVariant > SorterKeys;
private:
private:
// value of field that is used for ordering of features
SorterKeys mFeatureKeys;
// key (attribute index) used for ordering
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons
composerItemElem.setAttribute( "y", QString::number( transform().dy() ) );
composerItemElem.setAttribute( "width", QString::number( rect().width() ) );
composerItemElem.setAttribute( "height", QString::number( rect().height() ) );
composerItemElem.setAttribute( "positionMode", QString::number( (int) mLastUsedPositionMode ) );
composerItemElem.setAttribute( "positionMode", QString::number(( int ) mLastUsedPositionMode ) );
composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) );
composerItemElem.setAttribute( "rotation", QString::number( mRotation ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
/**Returns item's last used position mode.
@note: This property has no effect on actual's item position, which is always the top-left corner.
@note: this method was added in version 2.0*/
ItemPositionMode lastUsedPositionMode(){ return mLastUsedPositionMode; }
ItemPositionMode lastUsedPositionMode() { return mLastUsedPositionMode; }

/**Sets this items bound in scene coordinates such that 1 item size units
corresponds to 1 scene size unit*/
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposershape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

QgsComposerShape::QgsComposerShape( QgsComposition* composition ): QgsComposerItem( composition ), mShape( Ellipse )
{
setFrameEnabled(true);
setFrameEnabled( true );
}

QgsComposerShape::QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition ), mShape( Ellipse )
{
setSceneRect( QRectF( x, y, width, height ) );
setFrameEnabled(true);
setFrameEnabled( true );
}

QgsComposerShape::~QgsComposerShape()
Expand Down Expand Up @@ -73,7 +73,7 @@ void QgsComposerShape::drawShape( QPainter* p )
case Triangle:
QPolygonF triangle;
triangle << QPointF( 0, rect().height() );
triangle << QPointF( rect().width() , rect().height() );
triangle << QPointF( rect().width() , rect().height() );
triangle << QPointF( rect().width() / 2.0, 0 );
p->drawPolygon( triangle );
break;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsscalecombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ void QgsScaleComboBox::fixupScale()

// QgsDebugMsg( QString( "entered with oldScale: %1" ).arg( oldScale ) );
newScale = toDouble( currentText(), &ok );

// Valid string representation
if ( ok && (newScale != oldScale))
if ( ok && ( newScale != oldScale ) )
{
// if a user types scale = 2345, we transform to 1:2345
if(userSetScale)
if ( userSetScale )
{
mScale = 1 / newScale;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgswfsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, QgsCoordinateRefer
QString fStr = "{\"type\": \"Feature\",\n";

fStr += " \"id\": ";
fStr += "\""+ mTypeName +"."+ QString::number( feat->id() ) +"\"";
fStr += "\"" + mTypeName + "." + QString::number( feat->id() ) + "\"";
fStr += ",\n";

QgsGeometry* geom = feat->geometry();
Expand Down
18 changes: 9 additions & 9 deletions src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,18 @@ void QgsMssqlProvider::loadFields()
}
if ( sqlType == QVariant::String )
{
mAttributeFields.append(
QgsField(
query.value( 3 ).toString(), sqlType,
sqlTypeName,
query.value( 7 ).toInt() ) );
mAttributeFields.append(
QgsField(
query.value( 3 ).toString(), sqlType,
sqlTypeName,
query.value( 7 ).toInt() ) );
}
else
{
mAttributeFields.append(
QgsField(
query.value( 3 ).toString(), sqlType,
sqlTypeName ) );
mAttributeFields.append(
QgsField(
query.value( 3 ).toString(), sqlType,
sqlTypeName ) );
}

if ( !query.value( 12 ).isNull() )
Expand Down
234 changes: 117 additions & 117 deletions src/providers/osm/osmprovider.cpp

Large diffs are not rendered by default.