18 changes: 9 additions & 9 deletions python/plugins/sextante/SextantePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ def __init__(self, iface):
Sextante.setInterface(iface)
Sextante.setPlugin(self)

def initGui(self):
def initGui(self):
self.commander = None
self.toolbox = SextanteToolbox(self.iface)
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
self.toolbox.hide()
Sextante.addAlgListListener(self.toolbox)

self.menu = QMenu(self.iface.mainWindow())
self.menu.setTitle(QCoreApplication.translate("SEXTANTE", "Analysis"))

Expand Down Expand Up @@ -101,7 +101,7 @@ def initGui(self):
self.iface.mainWindow())
self.commanderAction.triggered.connect(self.openCommander)
self.menu.addAction(self.commanderAction)
self.iface.registerMainWindowAction(self.commanderAction, "Ctrl+Alt+M")
self.iface.registerMainWindowAction(self.commanderAction, "Ctrl+Alt+M")

def unload(self):
self.toolbox.setVisible(False)
Expand All @@ -110,18 +110,18 @@ def unload(self):
folder = SextanteUtils.tempFolder()
if QDir(folder).exists():
shutil.rmtree(folder, True)

self.iface.unregisterMainWindowAction(self.commanderAction)
def openCommander(self):

def openCommander(self):
if self.commander is None:
self.commander = CommanderWindow(self.iface.mainWindow(), self.iface.mapCanvas())
Sextante.addAlgListListener(self.commander)
self.commander.prepareGui()
self.commander.show()
self.commander.show()
#dlg.exec_()


def openToolbox(self):
if self.toolbox.isVisible():
self.toolbox.hide()
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/sextante/algs/ftools/Dissolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def processAlgorithm(self, progress):
tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
outFeat.setGeometry( tmpOutGeom )
except:
raise GeoAlgorithmExecutionException("Geometry exception while dissolving")
raise GeoAlgorithmExecutionException("Geometry exception while dissolving")
outFeat.setAttributes( attrs )
writer.addFeature( outFeat )
else:
Expand All @@ -99,14 +99,14 @@ def processAlgorithm(self, progress):
outFeat.setGeometry( tmpInGeom )
first = False
attrs = inFeat.attributes()
else:
else:
tmpInGeom = QgsGeometry( inFeat.geometry() )
tmpOutGeom = QgsGeometry( outFeat.geometry() )
try:
tmpOutGeom = QgsGeometry( outFeat.geometry() )
try:
tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
outFeat.setGeometry( tmpOutGeom )
except:
raise GeoAlgorithmExecutionException("Geometry exception while dissolving")
raise GeoAlgorithmExecutionException("Geometry exception while dissolving")
if add:
outFeat.setAttributes( attrs )
writer.addFeature( outFeat )
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/mmqgisx/MMQGISXAlgorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ def processAlgorithm(self, progress):
spokey = spokepoint.geometry().boundingBox().center().y()
spokeid = unicode(spokepoint.attributes()[spokeindex].toString())
progress.setPercentage(float(i) / len(spokepoints) * 100)
# Scan hub points to find first matching hub
# Scan hub points to find first matching hub
hubpoints = QGisLayers.features(hublayer)
for hubpoint in hubpoints:
hubid = unicode(hubpoint.attributes()[hubindex].toString())
Expand Down
96 changes: 48 additions & 48 deletions python/plugins/sextante/commander/CommanderWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@
import imp

ITEMHEIGHT = 30
OFFSET = 20
OFFSET = 20
HEIGHT = 60

class CommanderWindow(QtGui.QDialog):
def __init__(self, parent, canvas):
def __init__(self, parent, canvas):
self.canvas = canvas
QtGui.QDialog.__init__(self, parent, Qt.FramelessWindowHint)
QtGui.QDialog.__init__(self, parent, Qt.FramelessWindowHint)
#self.setModal(True)
self.commands = imp.load_source("commands", self.commandsFile())
self.initGui()
def commandsFolder(self):
self.commands = imp.load_source("commands", self.commandsFile())
self.initGui()

def commandsFolder(self):
folder = unicode(os.path.join(SextanteUtils.userFolder(), "commander"))
mkdir(folder)
return os.path.abspath(folder)

def commandsFile(self):
f = os.path.join(self.commandsFolder(), "commands.py")
if not os.path.exists(f):
Expand All @@ -60,18 +60,18 @@ def commandsFile(self):
out.write("def removeall():\n")
out.write("\tmapreg = QgsMapLayerRegistry.instance()\n")
out.write("\tmapreg.removeAllMapLayers()\n\n")
out.write("def load(*args):\n")
out.write("def load(*args):\n")
out.write("\tsextante.load(args[0])\n")
out.close()
return f
return f

def algsListHasChanged(self):
self.fillCombo()
def initGui(self):
self.combo= ExtendedComboBox()
self.fillCombo()

def initGui(self):
self.combo= ExtendedComboBox()
self.fillCombo()

self.combo.setEditable(True)
self.label = QtGui.QLabel("Enter command:")
self.errorLabel = QtGui.QLabel("Enter command:")
Expand All @@ -90,76 +90,76 @@ def initGui(self):
self.setLayout(self.vlayout)
self.combo.lineEdit().returnPressed.connect(self.run)
self.prepareGui()

def fillCombo(self):
self.combo.clear()
#add algorithms
for providerName in Sextante.algs.keys():
provider = Sextante.algs[providerName]
algs = provider.values()
provider = Sextante.algs[providerName]
algs = provider.values()
for alg in algs:
self.combo.addItem("SEXTANTE algorithm: " + alg.name)
self.combo.addItem("SEXTANTE algorithm: " + alg.name)
#add functions
for command in dir(self.commands):
if isinstance(self.commands.__dict__.get(command), types.FunctionType):
self.combo.addItem("Command: " + command);
self.combo.addItem("Command: " + command);
#add menu entries
menuActions = []
actions = Sextante.getInterface().mainWindow().menuBar().actions()
for action in actions:
menuActions.extend(self.getActions(action))
for action in menuActions:
self.combo.addItem("Menu action: " + unicode(action.text()))


def prepareGui(self):
self.combo.setEditText("")
self.combo.setMaximumSize(QtCore.QSize(self.canvas.rect().width() - 2 * OFFSET, ITEMHEIGHT))
self.combo.view().setStyleSheet("min-height: 150px")
self.combo.setFocus(Qt.OtherFocusReason)
self.combo.view().setStyleSheet("min-height: 150px")
self.combo.setFocus(Qt.OtherFocusReason)
self.label.setMaximumSize(self.combo.maximumSize())
self.label.setVisible(False)
self.adjustSize()
self.label.setVisible(False)
self.adjustSize()
pt = self.canvas.rect().topLeft()
absolutePt = self.canvas.mapToGlobal(pt)
self.move(absolutePt)
self.resize(self.canvas.rect().width(), HEIGHT)
self.setStyleSheet("CommanderWindow { background-color: #e7f5fe; border: 1px solid #b9cfe4; }")


def getActions(self, action):
menuActions = []
menu = action.menu()
if menu is None:
menuActions.append(action)
return menuActions
else:
else:
actions = menu.actions()
for subaction in actions:
if subaction.menu() is not None:
menuActions.extend(self.getActions(subaction))
elif not subaction.isSeparator():
menuActions.append(subaction)

return menuActions

def run(self):
s = unicode(self.combo.currentText())
if s.startswith("SEXTANTE algorithm: "):
algName = s[len("SEXTANTE algorithm: "):]
alg = Sextante.getAlgorithmFromFullName(algName)
if alg is not None:
self.close()
self.runAlgorithm(alg)
self.runAlgorithm(alg)
elif s.startswith("Command: "):
command = s[len("Command: "):]
command = s[len("Command: "):]
try:
self.runCommand(command)
self.close()
except Exception, e:
self.label.setVisible(True)
self.label.setText("Error:" + unicode(e) )
self.label.setVisible(True)
self.label.setText("Error:" + unicode(e) )

elif s.startswith("Menu action: "):
actionName = s[len("Menu action: "):]
menuActions = []
Expand All @@ -169,39 +169,39 @@ def run(self):
for action in menuActions:
if action.text() == actionName:
self.close()
action.trigger()
return
action.trigger()
return
else:
try:
self.runCommand(s)
self.close()
except Exception, e:
self.label.setVisible(True)
self.label.setVisible(True)
self.label.setText("Error:" + unicode(e) )

def runCommand(self, command):
tokens = command.split(" ")
if len(tokens) == 1:
method = self.commands.__dict__.get(command)
if method is not None:
method()
method()
else:
raise Exception("Wrong command")
else:
method = self.commands.__dict__.get(tokens[0])
if method is not None:
method(*tokens[1:])
method(*tokens[1:])
else:
raise Exception("Wrong command")
def runAlgorithm(self, alg):



def runAlgorithm(self, alg):
alg = alg.getCopy()
message = alg.checkBeforeOpeningParametersDialog()
if message:
dlg = MissingDependencyDialog(message)
dlg.exec_()
dlg.exec_()
return
dlg = alg.getCustomParametersDialog()
if not dlg:
Expand All @@ -217,7 +217,7 @@ def runAlgorithm(self, alg):
pass
canvas.setMapTool(prevMapTool)


class ExtendedComboBox(QComboBox):
def __init__(self, parent=None):
super(ExtendedComboBox, self).__init__(parent)
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/core/LayerExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ def exportVectorLayer(layer):
It also export to a new file if the original one contains non-ascii characters'''
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()

filename = os.path.basename(unicode(layer.source()))
idx = filename.rfind(".")
if idx != -1:
filename = filename[:idx]

filename = str(layer.name())
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
filename = ''.join(c for c in filename if c in validChars)
if len(filename) == 0:
filename = "layer"
output = SextanteUtils.getTempFilenameInTempFolder(filename + ".shp")
filename = "layer"
output = SextanteUtils.getTempFilenameInTempFolder(filename + ".shp")
provider = layer.dataProvider()
useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)
if useSelection and layer.selectedFeatureCount() != 0:
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ def getInterface():
@staticmethod
def setInterface(iface):
Sextante.iface = iface

@staticmethod
def setPlugin(iface):
Sextante.plugin = iface
Sextante.plugin = iface

@staticmethod
def getPlugin():
return Sextante.plugin
return Sextante.plugin

@staticmethod
def initialize():
Expand Down Expand Up @@ -239,7 +239,7 @@ def getAlgorithm(name):
if name in provider:
return provider[name]
return None

@staticmethod
def getAlgorithmFromFullName(name):
for provider in Sextante.algs.values():
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 @@ -28,7 +28,7 @@
from PyQt4 import QtGui

class SextanteConfig():

TABLE_LIKE_PARAM_PANEL = "TABLE_LIKE_PARAM_PANEL"
OUTPUT_FOLDER = "OUTPUT_FOLDER"
RASTER_STYLE = "RASTER_STYLE"
Expand Down Expand Up @@ -60,7 +60,7 @@ def initialize():
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_SELECTED, "Use only selected features", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.TABLE_LIKE_PARAM_PANEL, "Show table-like parameter panels", False))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_FILENAME_AS_LAYER_NAME, "Use filename as layer name", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.OUTPUT_FOLDER, "Output folder", SextanteUtils.tempFolder()))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_CRS_DEF, "Show layer CRS definition in selection boxes", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.WARN_UNMATCHING_CRS, "Warn before executing if layer CRS's do not match", True))
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/sextante/grass/GrassUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ def grassPath():

folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
if folder == None:
if SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
if SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "grass")
if os.path.isdir(testfolder):
if os.path.isdir(testfolder):
for subfolder in os.listdir(testfolder):
if subfolder.startswith("grass"):
folder = os.path.join(testfolder, subfolder)
Expand All @@ -94,8 +94,8 @@ def grassPath():
def grassWinShell():
folder = SextanteConfig.getSetting(GrassUtils.GRASS_WIN_SHELL)
if folder == None:
folder = os.path.dirname(str(QgsApplication.prefixPath()))
folder = os.path.join(folder, "msys")
folder = os.path.dirname(str(QgsApplication.prefixPath()))
folder = os.path.join(folder, "msys")
return folder

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/gui/AlgorithmExecutionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def accept(self):
self.progress.setMaximum(0)
self.progressLabel.setText("Processing algorithm...")
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if useThread and not self.iterateParam: #iterative execution on separate thread is still not working fine...
if useThread and not self.iterateParam: #iterative execution on separate thread is still not working fine...
command = self.alg.getAsCommand()
if command:
SextanteLog.addToLog(SextanteLog.LOG_ALGORITHM, command)
Expand Down Expand Up @@ -298,7 +298,7 @@ def finish(self):
self.setInfo("HTML output has been generated by this algorithm.\nOpen the SEXTANTE results dialog to check it.")

@pyqtSlot(str)
def error(self, msg):
def error(self, msg):
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
self.setInfo(msg, True)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/AlgorithmExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def runalgIterating(self):
SextantePostprocessing.handleAlgorithmResults(self.algorithm, self.progress, False)
self.iterated.emit(i)
i += 1
self.algExecuted.emit()
self.algExecuted.emit()
except BaseException, e:
self.error.emit(str(e))
print "Error iterating " + str(e)
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/sextante/gui/ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def __init__(self, toolbox):
self.fillTree()
self.tree.itemClicked.connect(self.edit)
self.tree.itemDoubleClicked.connect(self.edit)
def edit(self, item, column):

def edit(self, item, column):
if column > 0:
self.tree.editItem(item, column)

Expand All @@ -76,10 +76,10 @@ def fillTree(self):
self.tree.addTopLevelItem(groupItem)
if text != "":
groupItem.setExpanded(True)

providersItem = QTreeWidgetItem()
providersItem.setText(0, "Providers")
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
providersItem.setIcon(0, icon)
for group in settings.keys():
if group in priorityKeys:
Expand All @@ -94,11 +94,11 @@ def fillTree(self):
if text =="" or text.lower() in setting.description.lower():
settingItem = TreeSettingItem(setting, icon)
self.items[setting]=settingItem
groupItem.addChild(settingItem)
groupItem.addChild(settingItem)
if text != "":
groupItem.setExpanded(True)
providersItem.addChild(groupItem)
self.tree.addTopLevelItem(providersItem)
self.tree.addTopLevelItem(providersItem)

self.tree.sortItems(0, Qt.AscendingOrder)
self.tree.setColumnWidth(0, 400)
Expand Down Expand Up @@ -131,7 +131,7 @@ class TreeSettingItem(QTreeWidgetItem):
def __init__(self, setting, icon):
QTreeWidgetItem.__init__(self)
self.setting = setting
self.setText(0, setting.description)
self.setText(0, setting.description)
if isinstance(setting.value,bool):
if setting.value:
self.setCheckState(1, Qt.Checked)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/UnthreadedAlgorithmExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def runalgIterating(alg,paramToIter,progress):
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
layerfile = alg.getParameterValue(paramToIter)
layer = QGisLayers.getObjectFromUri(layerfile, False)
layer = QGisLayers.getObjectFromUri(layerfile, False)
feat = QgsFeature()
filelist = []
outputs = {}
Expand Down
38 changes: 19 additions & 19 deletions python/plugins/sextante/modeler/ModelerArrowItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def endItem(self):
def boundingRect(self):
#this is a quick fix to avoid arrows not being drawn
return QtCore.QRectF(0, 0, 4000,4000)

def shape(self):
path = super(ModelerArrowItem, self).shape()
path.addPolygon(self.arrowHead)
Expand All @@ -80,27 +80,27 @@ def updatePosition(self):
line = QtCore.QLineF(self.mapFromItem(self.myStartItem, 0, 0), self.mapFromItem(self.myEndItem, 0, 0))
self.setLine(line)

def paint(self, painter, option, widget=None):
def paint(self, painter, option, widget=None):
myStartItem = self.myStartItem
myEndItem = self.myEndItem
myPen = self.pen()
myPen.setColor(self.myColor)
arrowSize = 6.0
painter.setPen(myPen)
painter.setBrush(self.myColor)
painter.setBrush(self.myColor)

if isinstance(self.startItem().element, GeoAlgorithm):
if self.startItem().element.outputs:
endPt = self.endItem().getLinkPointForParameter(self.paramIndex)
startPt = self.startItem().getLinkPointForOutput(self.outputIndex)
arrowLine = QtCore.QLineF(myEndItem.pos() + endPt - QtCore.QPointF(endPt.x() + ModelerGraphicItem.BOX_WIDTH /2, 0), myEndItem.pos() + endPt)
startPt = self.startItem().getLinkPointForOutput(self.outputIndex)
arrowLine = QtCore.QLineF(myEndItem.pos() + endPt - QtCore.QPointF(endPt.x() + ModelerGraphicItem.BOX_WIDTH /2, 0), myEndItem.pos() + endPt)
painter.drawLine(arrowLine)
tailLine = QtCore.QLineF(myStartItem.pos() + startPt + QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH /2 - startPt.x(),0), myStartItem.pos() + startPt)
painter.drawLine(tailLine)
pt = QtCore.QPointF(myStartItem.pos() + startPt + QtCore.QPointF(- 2, -2))
rect = QtCore.QRectF(pt.x(), pt.y(), 4, 4)
rect = QtCore.QRectF(pt.x(), pt.y(), 4, 4)
painter.fillRect(rect, QtCore.Qt.gray)
line = QtCore.QLineF(myStartItem.pos() + startPt + QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH /2 - startPt.x(),0),
line = QtCore.QLineF(myStartItem.pos() + startPt + QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH /2 - startPt.x(),0),
myEndItem.pos() + endPt - QtCore.QPointF(endPt.x() + ModelerGraphicItem.BOX_WIDTH /2, 0))
else: # case where there is a dependency on an algorithm not on an output
endPolygon = myEndItem.polygon()
Expand All @@ -114,35 +114,35 @@ def paint(self, painter, option, widget=None):
if intersectType == QtCore.QLineF.BoundedIntersection:
break
p1 = p2

self.setLine(QtCore.QLineF(intersectPoint, myStartItem.pos()))
line = self.line()
line = self.line()
if line.length() == 0: #division by zero might occur if arrow has no length
return
angle = math.acos(line.dx() / line.length())
if line.dy() >= 0:
angle = (math.pi * 2.0) - angle

arrowP1 = line.p1() + QtCore.QPointF(math.sin(angle + math.pi / 3.0) * arrowSize,
math.cos(angle + math.pi / 3) * arrowSize)
arrowP2 = line.p1() + QtCore.QPointF(math.sin(angle + math.pi - math.pi / 3.0) * arrowSize,
math.cos(angle + math.pi - math.pi / 3.0) * arrowSize)

self.arrowHead.clear()
for point in [line.p1(), arrowP1, arrowP2]:
self.arrowHead.append(point)

painter.drawLine(line)
painter.drawPolygon(self.arrowHead)
return;
painter.drawPolygon(self.arrowHead)
return;
else:
endPt = self.endItem().getLinkPointForParameter(self.paramIndex)
arrowLine = QtCore.QLineF(myEndItem.pos() + endPt - QtCore.QPointF(endPt.x() + ModelerGraphicItem.BOX_WIDTH /2, 0), myEndItem.pos() + endPt)
endPt = self.endItem().getLinkPointForParameter(self.paramIndex)
arrowLine = QtCore.QLineF(myEndItem.pos() + endPt - QtCore.QPointF(endPt.x() + ModelerGraphicItem.BOX_WIDTH /2, 0), myEndItem.pos() + endPt)
painter.drawLine(arrowLine)
line = QtCore.QLineF(myStartItem.pos(),
line = QtCore.QLineF(myStartItem.pos(),
myEndItem.pos() + endPt - QtCore.QPointF(endPt.x() + ModelerGraphicItem.BOX_WIDTH /2, 0))
self.setLine(line);

self.setLine(line);

if line.length() == 0: #division by zero might occur if arrow has no length
return
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/modeler/ModelerDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
from sextante.ui.ui_DlgModeler import Ui_DlgModeler

class ModelerDialog(QDialog, Ui_DlgModeler):

USE_CATEGORIES = "/SextanteQGIS/UseCategories"

def __init__(self, alg=None):
QDialog.__init__(self)

Expand Down Expand Up @@ -272,7 +272,7 @@ def addAlgorithm(self):

def fillAlgorithmTree(self):
settings = QSettings()
useCategories = settings.value(self.USE_CATEGORIES).toBool()
useCategories = settings.value(self.USE_CATEGORIES).toBool()
if useCategories:
self.fillAlgorithmTreeUsingCategories()
else:
Expand Down
135 changes: 67 additions & 68 deletions python/plugins/sextante/modeler/ModelerGraphicItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,56 +56,56 @@ def __init__(self, element, elementIndex, model):
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
self.setZValue(1000)

icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/edit.png")
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, ModelerGraphicItem.BOX_HEIGHT / 2 - FlatButtonGraphicItem.HEIGHT / 2 + 1)
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, ModelerGraphicItem.BOX_HEIGHT / 2 - FlatButtonGraphicItem.HEIGHT / 2 + 1)
self.editButton = FlatButtonGraphicItem(icon, pt, self.editElement)
self.editButton.setParentItem(self)
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/delete.png")
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, -ModelerGraphicItem.BOX_HEIGHT / 2 + FlatButtonGraphicItem.HEIGHT / 2 + 1)
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, -ModelerGraphicItem.BOX_HEIGHT / 2 + FlatButtonGraphicItem.HEIGHT / 2 + 1)
self.deleteButton = FlatButtonGraphicItem(icon, pt, self.removeElement)
self.deleteButton.setParentItem(self)
if isinstance(element, GeoAlgorithm):
if element.parameters:

if isinstance(element, GeoAlgorithm):
if element.parameters:
pt = self.getLinkPointForParameter(-1)
x = self.getXPositionForFoldButton()
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y() + 3)
self.inButton = FoldButtonGraphicItem(pt, self.foldInput)
self.inButton.setParentItem(self)
if element.outputs:
pt = self.getLinkPointForOutput(-1)
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y() + 3)
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y() + 3)
self.outButton = FoldButtonGraphicItem(pt, self.foldOutput)
self.outButton.setParentItem(self)


def foldInput(self, folded):
self.inputFolded = folded
self.prepareGeometryChange()
if self.element.outputs:
self.prepareGeometryChange()
if self.element.outputs:
pt = self.getLinkPointForOutput(-1)
x = self.getXPositionForFoldButton()
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y())
self.outButton.position = pt
self.update()

def foldOutput(self, folded):
self.outputFolded = folded
self.prepareGeometryChange()
self.update()
self.outputFolded = folded
self.prepareGeometryChange()
self.update()

def addArrow(self, arrow):
self.arrows.append(arrow)

def boundingRect(self):
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
fm = QtGui.QFontMetricsF(font)
numParams = 0 if self.inputFolded else len(self.element.parameters)
numOutputs = 0 if self.outputFolded else len(self.element.outputs)
numElements = numParams + numOutputs + 3
h = (fm.height() * 1.2) * numElements
numOutputs = 0 if self.outputFolded else len(self.element.outputs)
numElements = numParams + numOutputs + 3
h = (fm.height() * 1.2) * numElements
rect = QtCore.QRectF(-(ModelerGraphicItem.BOX_WIDTH + 2)/2, -(ModelerGraphicItem.BOX_HEIGHT + 2)/2,
ModelerGraphicItem.BOX_WIDTH + 2, ModelerGraphicItem.BOX_HEIGHT + h)
return rect
Expand Down Expand Up @@ -196,37 +196,37 @@ def paint(self, painter, option, widget=None):
painter.setPen(QtGui.QPen(QtCore.Qt.blue))
if isinstance(self.element, GeoAlgorithm):
if self.elementIndex in self.model.deactivated:
painter.setPen(QtGui.QPen(QtCore.Qt.lightGray))
painter.setPen(QtGui.QPen(QtCore.Qt.lightGray))
fm = QtGui.QFontMetricsF(font)
text = self.getAdjustedText(self.text)
h = fm.height()
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 25, h/2.0)
painter.drawText(pt, text)
painter.setPen(QtGui.QPen(QtCore.Qt.black))
if isinstance(self.element, GeoAlgorithm):
if isinstance(self.element, GeoAlgorithm):
h = (fm.height() * 1.2)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 25, h)
painter.drawText(pt, "In")
i = 1
if not self.inputFolded:
for param in self.element.parameters:
text = self.getAdjustedText(param.description)
text = self.getAdjustedText(param.description)
h = (fm.height() * 1.2) * (i + 1)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 33, h)
painter.drawText(pt, text)
i += 1
i += 1
h = (fm.height() * 1.2) * (i + 1)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 25, h)
painter.drawText(pt, "Out")
i += 1
if not self.outputFolded:
for out in self.element.outputs:
text = self.getAdjustedText(out.description)
text = self.getAdjustedText(out.description)
h = (fm.height() * 1.2) * (i + 1)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 33, h)
painter.drawText(pt, text)
i += 1
Expand All @@ -238,25 +238,25 @@ def getLinkPointForParameter(self, paramIndex):
paramIndex = -1
offsetX = 22
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
fm = QtGui.QFontMetricsF(font)
h = (fm.height() * 1.2) * (paramIndex + 2) - fm.height() / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
return QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + offsetX, h)


def getXPositionForFoldButton(self):
return 0
def getLinkPointForOutput(self, outputIndex):
if isinstance(self.element, GeoAlgorithm):

def getLinkPointForOutput(self, outputIndex):
if isinstance(self.element, GeoAlgorithm):
numParams = 0 if self.inputFolded else len(self.element.parameters)
outputIndex = outputIndex if not self.outputFolded else -1
text = self.getAdjustedText(self.element.outputs[outputIndex].description)
outputIndex = outputIndex if not self.outputFolded else -1
text = self.getAdjustedText(self.element.outputs[outputIndex].description)
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
fm = QtGui.QFontMetricsF(font)
w = fm.width(QtCore.QString(text))
h = (fm.height() * 1.2) * (outputIndex + 3 + numParams) - fm.height() / 2.0
y = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
y = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
x = -(ModelerGraphicItem.BOX_WIDTH)/2 + 33 + w + 5 if not self.outputFolded else 10
return QtCore.QPointF(x, y)
else:
Expand All @@ -271,9 +271,9 @@ def itemChange(self, change, value):

def polygon(self):
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
numElements = len(self.element.parameters) + len(self.element.outputs) + 3
h = (fm.height() * 1.2) * numElements
fm = QtGui.QFontMetricsF(font)
numElements = len(self.element.parameters) + len(self.element.outputs) + 3
h = (fm.height() * 1.2) * numElements
pol = QtGui.QPolygonF([
QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH + 2)/2, -(ModelerGraphicItem.BOX_HEIGHT + 2)/2),
QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH + 2)/2, (ModelerGraphicItem.BOX_HEIGHT + 2)/2 + h),
Expand All @@ -283,62 +283,61 @@ def polygon(self):
return pol

class FlatButtonGraphicItem(QtGui.QGraphicsItem):

WIDTH = 16
HEIGHT = 16
HEIGHT = 16

def __init__(self, icon, position, action):
super(FlatButtonGraphicItem, self).__init__(None, None)
self.setAcceptHoverEvents(True)
self.setAcceptHoverEvents(True)
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, False)
self.pixmap = icon.pixmap(self.WIDTH, self.HEIGHT, state=QtGui.QIcon.On)
self.position = position
self.isIn = False
self.action = action
self.isIn = False
self.action = action

def mousePressEvent(self, event):
self.action()

def paint(self, painter, option, widget=None):
pt = QtCore.QPointF(-self.WIDTH / 2, -self.HEIGHT / 2) + self.position
rect = QtCore.QRectF(pt.x(), pt.y(), self.WIDTH, self.HEIGHT)
rect = QtCore.QRectF(pt.x(), pt.y(), self.WIDTH, self.HEIGHT)
if self.isIn:
painter.setPen(QtGui.QPen(QtCore.Qt.transparent, 1))
painter.setBrush(QtGui.QBrush(QtCore.Qt.lightGray, QtCore.Qt.SolidPattern))
painter.setBrush(QtGui.QBrush(QtCore.Qt.lightGray, QtCore.Qt.SolidPattern))
else:
painter.setPen(QtGui.QPen(QtCore.Qt.transparent, 1))
painter.setPen(QtGui.QPen(QtCore.Qt.transparent, 1))
painter.setBrush(QtGui.QBrush(QtCore.Qt.white, QtCore.Qt.SolidPattern))
painter.drawRect(rect)
painter.drawRect(rect)
painter.drawPixmap(pt.x(), pt.y(), self.pixmap)

def boundingRect(self):
rect = QtCore.QRectF(self.position.x() - self.WIDTH / 2, self.position.y() - self.HEIGHT / 2, self.WIDTH, self.HEIGHT)
return rect
return rect

def hoverEnterEvent(self, event):
self.isIn = True
self.isIn = True
self.update()

def hoverLeaveEvent(self, event):
self.isIn = False
self.isIn = False
self.update()

class FoldButtonGraphicItem(FlatButtonGraphicItem):

WIDTH = 11
HEIGHT = 11
icons = { True : QtGui.QIcon(os.path.dirname(__file__) + "/../images/plus.png"),

icons = { True : QtGui.QIcon(os.path.dirname(__file__) + "/../images/plus.png"),
False : QtGui.QIcon(os.path.dirname(__file__) + "/../images/minus.png")}

def __init__(self, position, action):
self.folded = True
icon = self.icons[True]
super(FoldButtonGraphicItem, self).__init__(icon, position, action)
super(FoldButtonGraphicItem, self).__init__(icon, position, action)

def mousePressEvent(self, event):
self.folded = not self.folded
icon = self.icons[self.folded]
self.pixmap = icon.pixmap(self.WIDTH, self.HEIGHT, state=QtGui.QIcon.On)
self.action(self.folded)

Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,17 @@ def setupUi(self):
self.fileFolderCombo.addItem("Folder")
self.horizontalLayout2.addWidget(self.fileFolderCombo)
if self.param is not None:
self.fileFolderCombo.setCurrentIndex(1 if self.param.isFolder else 0)
self.fileFolderCombo.setCurrentIndex(1 if self.param.isFolder else 0)

self.buttonBox = QtGui.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.okPressed)
QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.cancelPressed)

self.verticalLayout.addWidget(self.buttonBox)

self.setLayout(self.verticalLayout)


Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/modeler/ModelerScene.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def getItemsFromAAP(self, aap, isMultiple):
if output.name == aap.param:
items.append((self.algItems[start], idx))
break
idx += 1
idx += 1

return items

Expand Down Expand Up @@ -116,7 +116,7 @@ def paintModel(self, model):
for alg in model.algs:
params = model.algParameters[iAlg]
idx = 0
for parameter in alg.parameters:
for parameter in alg.parameters:
param = params[parameter.name]
if param:
sourceItems = self.getItemsFromAAP(param, isinstance(alg.getParameterFromName(parameter.name), ParameterMultipleInput))
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/otb/OTBUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ def otbLibPath():
else:
testfolder = "/usr/local/lib/otb/applications"
if os.path.exists(testfolder):
folder = testfolder
folder = testfolder
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "orfeotoolbox")
testfolder = os.path.join(testfolder, "applications")
testfolder = os.path.join(testfolder, "applications")
if os.path.exists(testfolder):
folder = testfolder
else:
testfolder = "/usr/lib/otb/applications"
if os.path.exists(testfolder):
folder = testfolder
folder = testfolder
return folder

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def sagaPath():
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
folder = testfolder
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "saga")
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "saga")
if os.path.exists(os.path.join(testfolder, "saga_cmd.exe")):
folder = testfolder
return folder
Expand Down
44 changes: 22 additions & 22 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int QgisAppInterface::addToolBarIcon( QAction * qAction )
return qgis->addPluginToolBarIcon( qAction );
}

QAction*QgisAppInterface::addToolBarWidget( QWidget* widget )
QAction *QgisAppInterface::addToolBarWidget( QWidget* widget )
{
return qgis->addPluginToolBarWidget( widget );
}
Expand All @@ -218,7 +218,7 @@ int QgisAppInterface::addRasterToolBarIcon( QAction * qAction )
return qgis->addRasterToolBarIcon( qAction );
}

QAction*QgisAppInterface::addRasterToolBarWidget( QWidget* widget )
QAction *QgisAppInterface::addRasterToolBarWidget( QWidget* widget )
{
return qgis->addRasterToolBarWidget( widget );
}
Expand All @@ -233,7 +233,7 @@ int QgisAppInterface::addVectorToolBarIcon( QAction * qAction )
return qgis->addVectorToolBarIcon( qAction );
}

QAction*QgisAppInterface::addVectorToolBarWidget(QWidget* widget)
QAction *QgisAppInterface::addVectorToolBarWidget( QWidget* widget )
{
return qgis->addVectorToolBarWidget( widget );
}
Expand All @@ -248,7 +248,7 @@ int QgisAppInterface::addDatabaseToolBarIcon( QAction * qAction )
return qgis->addDatabaseToolBarIcon( qAction );
}

QAction*QgisAppInterface::addDatabaseToolBarWidget(QWidget* widget)
QAction *QgisAppInterface::addDatabaseToolBarWidget( QWidget* widget )
{
return qgis->addDatabaseToolBarWidget( widget );
}
Expand All @@ -263,7 +263,7 @@ int QgisAppInterface::addWebToolBarIcon( QAction * qAction )
return qgis->addWebToolBarIcon( qAction );
}

QAction*QgisAppInterface::addWebToolBarWidget(QWidget* widget)
QAction *QgisAppInterface::addWebToolBarWidget( QWidget* widget )
{
return qgis->addWebToolBarWidget( widget );
}
Expand Down Expand Up @@ -571,32 +571,32 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b

void QgisAppInterface::preloadForm( QString uifile )
{
QSignalMapper* signalMapper = new QSignalMapper ( this );
mTimer = new QTimer(this);
QSignalMapper* signalMapper = new QSignalMapper( this );
mTimer = new QTimer( this );

connect( mTimer ,SIGNAL( timeout() ), signalMapper,SLOT( map() ) );
connect( signalMapper, SIGNAL( mapped(QString) ), mTimer, SLOT( stop() ) );
connect( signalMapper, SIGNAL( mapped(QString) ), this, SLOT( cacheloadForm( QString ) ) );
connect( mTimer , SIGNAL( timeout() ), signalMapper, SLOT( map() ) );
connect( signalMapper, SIGNAL( mapped( QString ) ), mTimer, SLOT( stop() ) );
connect( signalMapper, SIGNAL( mapped( QString ) ), this, SLOT( cacheloadForm( QString ) ) );

signalMapper->setMapping( mTimer, uifile );
signalMapper->setMapping( mTimer, uifile );

mTimer->start(0);
mTimer->start( 0 );
}

void QgisAppInterface::cacheloadForm( QString uifile )
{
QFile file( uifile );
QFile file( uifile );

if ( file.open( QFile::ReadOnly ) )
{
QUiLoader loader;
if ( file.open( QFile::ReadOnly ) )
{
QUiLoader loader;

QFileInfo fi( uifile );
loader.setWorkingDirectory( fi.dir() );
QWidget *myWidget = loader.load( &file );
file.close();
delete myWidget;
}
QFileInfo fi( uifile );
loader.setWorkingDirectory( fi.dir() );
QWidget *myWidget = loader.load( &file );
file.close();
delete myWidget;
}
}

QDialog* QgisAppInterface::getFeatureForm( QgsVectorLayer *l, QgsFeature &f )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class QgisAppInterface : public QgisInterface
*
* More information here: http://qt-project.org/forums/viewthread/27098/
*/
virtual void preloadForm(QString uifile);
virtual void preloadForm( QString uifile );

/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void QgsMapToolCapture::undo()
return;
}

mRubberBand->removePoint(-2); // remove the one before the last one
mRubberBand->removePoint( -2 ); // remove the one before the last one
mCaptureList.removeLast();

validateGeometry();
Expand Down
2 changes: 1 addition & 1 deletion src/core/diagram/qgshistogramdiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributes& attributes, const
{
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.height() ) / ( is.upperValue - is.lowerValue ) );
mScaleFactor = (( is.upperSize.width() - is.lowerSize.height() ) / ( is.upperValue - is.lowerValue ) );
size.scale( s.barWidth * attributes.size(), maxValue * mScaleFactor, Qt::IgnoreAspectRatio );
break;

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscacheindexfeatureid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ QgsCacheIndexFeatureId::QgsCacheIndexFeatureId( QgsVectorLayerCache* cachedVecto

}

void QgsCacheIndexFeatureId::flushFeature(const QgsFeatureId fid)
void QgsCacheIndexFeatureId::flushFeature( const QgsFeatureId fid )
{
Q_UNUSED( fid )
}
Expand All @@ -42,7 +42,7 @@ void QgsCacheIndexFeatureId::requestCompleted( QgsFeatureRequest featureRequest,

bool QgsCacheIndexFeatureId::getCacheIterator( QgsFeatureIterator &featureIterator, const QgsFeatureRequest &featureRequest )
{
if( featureRequest.filterType() == QgsFeatureRequest::FilterFid )
if ( featureRequest.filterType() == QgsFeatureRequest::FilterFid )
{
if ( C->isFidCached( featureRequest.filterFid() ) )
{
Expand Down
38 changes: 19 additions & 19 deletions src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString theDefinition
if ( reCrsStr.cap( 1 ).toLower() == "proj4" )
{
result = createFromProj4( reCrsStr.cap( 2 ) );
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( srsid() == 0 )
if ( srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS( myName );
}
}
else
Expand Down Expand Up @@ -471,16 +471,16 @@ bool QgsCoordinateReferenceSystem::createFromWkt( QString theWkt )

createFromProj4( proj4src );
}
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mSrsId == 0 )
if ( mSrsId == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS( myName );
}

CPLFree( proj4src );
Expand Down Expand Up @@ -1212,16 +1212,16 @@ bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
//@TODO this srs needs to be validated!!!
mIsValidFlag = true; //shamelessly hard coded for now
}
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mSrsId == 0 )
if ( mSrsId == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS( myName );
}

}
Expand Down Expand Up @@ -1420,7 +1420,7 @@ QString QgsCoordinateReferenceSystem::validationHint()
/// Copied from QgsCustomProjectionDialog ///
/// Please refactor into SQL handler !!! ///

bool QgsCoordinateReferenceSystem::saveAsUserCRS(QString name)
bool QgsCoordinateReferenceSystem::saveAsUserCRS( QString name )
{
if ( ! mIsValidFlag )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinatereferencesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* @note added in 1.8
*/
static int syncDb();


/*! Save the proj4-string as a custom CRS
* @returns bool true if success else false
*/
Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsdistancearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ bool QgsDistanceArea::setEllipsoid( const QString& ellipsoid )
QString proj4 = "+proj=longlat +ellps=" + ellipsoid + " +no_defs";
QgsCoordinateReferenceSystem destCRS;
destCRS.createFromProj4( proj4 );
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( destCRS.srsid() == 0 )
if ( destCRS.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( destCRS.toProj4() );
destCRS.saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( destCRS.toProj4() );
destCRS.saveAsUserCRS( myName );
}
//

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsmaplayerregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* @note As a side-effect QgsProject is made dirty.
* @note Added in QGIS 1.8
*/
QList<QgsMapLayer *> addMapLayers(QList<QgsMapLayer *> theMapLayers,
QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
bool addToLegend = true );

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
*
* @note As a side-effect QgsProject is made dirty.
*/
void removeMapLayers(QStringList theLayerIds );
void removeMapLayers( QStringList theLayerIds );

/**
* @brief
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ QPair< bool, QList<QDomNode> > QgsProject::_getMapLayers( QDomDocument const &do
QDomElement element = node.toElement();

QString name = node.namedItem( "layername" ).toElement().text();
if( !name.isNull() )
if ( !name.isNull() )
emit loadingLayer( tr( "Loading layer %1" ).arg( name ) );

if ( element.attribute( "embedded" ) == "1" )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayercache.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
* @param fid The feature id to look for
* @return True if this id is in the cache
*/
bool isFidCached(const QgsFeatureId fid );
bool isFidCached( const QgsFeatureId fid );

/**
* Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayer* la
for ( int i = 0; i < subset.count(); ++i )
{
int attrIndex = subset[i];
if( attrIndex < 0 || attrIndex >= nPendingFields ) continue;
if ( attrIndex < 0 || attrIndex >= nPendingFields ) continue;
if ( L->pendingFields().fieldOrigin( attrIndex ) == QgsFields::OriginProvider )
providerSubset << L->pendingFields().fieldOriginIndex( attrIndex );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterfilewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class CORE_EXPORT QgsRasterFileWriter
const QString& outputUrl, int fileIndex, int nBands, QGis::DataType type,
const QgsCoordinateReferenceSystem& crs );

/** \brie Init VRT (for tiled mode) or create global output provider (single-file mode)
/** \brief Init VRT (for tiled mode) or create global output provider (single-file mode)
* @param destHasNoDataValueList true if destination has no data value, indexed from 0
* @param destNoDataValueList no data value, indexed from 0
*/
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsdualview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ QgsDualView::QgsDualView( QWidget* parent )
connect( mActionExpressionPreview, SIGNAL( triggered() ), SLOT( previewExpressionBuilder() ) );
connect( mPreviewActionMapper, SIGNAL( mapped( QObject* ) ), SLOT( previewColumnChanged( QObject* ) ) );
connect( mFeatureList, SIGNAL( displayExpressionChanged( QString ) ), this, SLOT( previewExpressionChanged( QString ) ) );
connect( this, SIGNAL( currentChanged(int) ), this, SLOT( saveEditChanges() ) );
connect( this, SIGNAL( currentChanged( int ) ), this, SLOT( saveEditChanges() ) );
}

QgsDualView::~QgsDualView()
Expand All @@ -62,7 +62,7 @@ void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QgsDista
connect( mTableView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );

connect( layer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
connect( layer, SIGNAL( beforeCommitChanges() ), this, SLOT( editingToggled() ) );
connect( layer, SIGNAL( beforeCommitChanges() ), this, SLOT( editingToggled() ) );

initLayerCache( layer );
initModels( mapCanvas );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsdualview.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
*/
void columnBoxInit();

virtual void hideEvent(QHideEvent *);
virtual void focusOutEvent(QFocusEvent *);
virtual void hideEvent( QHideEvent * );
virtual void focusOutEvent( QFocusEvent * );

public slots:
/**
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsprojectionselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
}
else
{
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( crs.srsid() == 0 )
if ( crs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( crs.toProj4() );
crs.saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( crs.toProj4() );
crs.saveAsUserCRS( myName );
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void QgsRubberBand::removePoint( int index, bool doUpdate/* = true*/, int geomet
{
index = mPoints[geometryIndex].size() + index;
}
mPoints[geometryIndex].removeAt(index);
mPoints[geometryIndex].removeAt( index );
}

if ( doUpdate )
Expand All @@ -175,7 +175,7 @@ void QgsRubberBand::removePoint( int index, bool doUpdate/* = true*/, int geomet

void QgsRubberBand::removeLastPoint( int geometryIndex )
{
removePoint(-1, true, geometryIndex);
removePoint( -1, true, geometryIndex );
}

/*!
Expand Down Expand Up @@ -487,8 +487,8 @@ void QgsRubberBand::updateRect()
qreal s = ( mIconSize - 1 ) / 2;
qreal p = mWidth;

QgsRectangle r ( it->x() + mTranslationOffsetX - s - p, it->y() + mTranslationOffsetY - s - p,
it->x() + mTranslationOffsetX + s + p, it->y() + mTranslationOffsetY + s + p );
QgsRectangle r( it->x() + mTranslationOffsetX - s - p, it->y() + mTranslationOffsetY - s - p,
it->x() + mTranslationOffsetX + s + p, it->y() + mTranslationOffsetY + s + p );

for ( int i = 0; i < mPoints.size(); ++i )
{
Expand Down
66 changes: 33 additions & 33 deletions src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,39 +316,39 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
QGis::WkbType wkbType = layer->wkbType();
if ( wkbType != QGis::WKBNoGeometry )
{
switch ( wkbType )
{
case QGis::WKBPoint25D:
case QGis::WKBPoint:
geomElem.setAttribute( "type", "gml:PointPropertyType" );
break;
case QGis::WKBLineString25D:
case QGis::WKBLineString:
geomElem.setAttribute( "type", "gml:LineStringPropertyType" );
break;
case QGis::WKBPolygon25D:
case QGis::WKBPolygon:
geomElem.setAttribute( "type", "gml:PolygonPropertyType" );
break;
case QGis::WKBMultiPoint25D:
case QGis::WKBMultiPoint:
geomElem.setAttribute( "type", "gml:MultiPointPropertyType" );
break;
case QGis::WKBMultiLineString25D:
case QGis::WKBMultiLineString:
geomElem.setAttribute( "type", "gml:MultiLineStringPropertyType" );
break;
case QGis::WKBMultiPolygon25D:
case QGis::WKBMultiPolygon:
geomElem.setAttribute( "type", "gml:MultiPolygonPropertyType" );
break;
default:
geomElem.setAttribute( "type", "gml:GeometryPropertyType" );
break;
}
geomElem.setAttribute( "minOccurs", "0" );
geomElem.setAttribute( "maxOccurs", "1" );
sequenceElem.appendChild( geomElem );
switch ( wkbType )
{
case QGis::WKBPoint25D:
case QGis::WKBPoint:
geomElem.setAttribute( "type", "gml:PointPropertyType" );
break;
case QGis::WKBLineString25D:
case QGis::WKBLineString:
geomElem.setAttribute( "type", "gml:LineStringPropertyType" );
break;
case QGis::WKBPolygon25D:
case QGis::WKBPolygon:
geomElem.setAttribute( "type", "gml:PolygonPropertyType" );
break;
case QGis::WKBMultiPoint25D:
case QGis::WKBMultiPoint:
geomElem.setAttribute( "type", "gml:MultiPointPropertyType" );
break;
case QGis::WKBMultiLineString25D:
case QGis::WKBMultiLineString:
geomElem.setAttribute( "type", "gml:MultiLineStringPropertyType" );
break;
case QGis::WKBMultiPolygon25D:
case QGis::WKBMultiPolygon:
geomElem.setAttribute( "type", "gml:MultiPolygonPropertyType" );
break;
default:
geomElem.setAttribute( "type", "gml:GeometryPropertyType" );
break;
}
geomElem.setAttribute( "minOccurs", "0" );
geomElem.setAttribute( "maxOccurs", "1" );
sequenceElem.appendChild( geomElem );
}

const QgsFields& fields = provider->fields();
Expand Down
12 changes: 6 additions & 6 deletions src/mapserver/qgssldparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,16 +1524,16 @@ void QgsSLDParser::setCrsForLayer( const QDomElement& layerElem, QgsMapLayer* ml
{
QgsCoordinateReferenceSystem srs;
srs.createFromProj4( projString );
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( srs.srsid() == 0 )
if ( srs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( srs.toProj4() );
srs.saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( srs.toProj4() );
srs.saveAsUserCRS( myName );
}

ml->setCrs( srs );
Expand Down
8 changes: 4 additions & 4 deletions src/mapserver/qgswfsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,13 +820,13 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
if ( layer->wkbType() != QGis::WKBNoGeometry )
{
req.setFilterRect( searchRect )
.setFlags( QgsFeatureRequest::ExactIntersect | ( mWithGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
.setFlags( QgsFeatureRequest::ExactIntersect | ( mWithGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
}
QgsFeatureIterator fit = layer->getFeatures( req );
QgsExpression *mFilter = new QgsExpression( expFilter );
if ( mFilter->hasParserError() )
{
throw QgsMapServiceException( "RequestNotWellFormed",QString( "Expression filter error message: %1." ).arg( mFilter->parserErrorString() ) );
throw QgsMapServiceException( "RequestNotWellFormed", QString( "Expression filter error message: %1." ).arg( mFilter->parserErrorString() ) );
}
if ( mFilter )
{
Expand Down Expand Up @@ -934,7 +934,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
if ( layer->wkbType() != QGis::WKBNoGeometry )
{
req.setFilterRect( searchRect )
.setFlags( QgsFeatureRequest::ExactIntersect | ( mWithGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
.setFlags( QgsFeatureRequest::ExactIntersect | ( mWithGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
}
QgsFeatureIterator fit = layer->getFeatures( req );
while ( fit.nextFeature( feature ) && featureCounter < maxFeat )
Expand Down Expand Up @@ -965,7 +965,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
if ( layer->wkbType() != QGis::WKBNoGeometry )
{
req.setFilterRect( searchRect )
.setFlags( QgsFeatureRequest::ExactIntersect | ( mWithGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
.setFlags( QgsFeatureRequest::ExactIntersect | ( mWithGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
}
QgsFeatureIterator fit = layer->getFeatures( req );
while ( fit.nextFeature( feature ) && featureCounter < maxFeat )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )
if ( mClosed )
return false;

bool gotFeature = P->nextFeature(feature,P->mFile,mRequest);
if( ! gotFeature ) close();
bool gotFeature = P->nextFeature( feature, P->mFile, mRequest );
if ( ! gotFeature ) close();
return gotFeature;
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void QgsDelimitedTextFile::setFieldNames( const QStringList &names )
bool nameOk = true;
int fieldNo = mFieldNames.size() + 1;
name = name.trimmed();
if( name.length() > mMaxNameLength ) name=name.mid(0,mMaxNameLength );
if ( name.length() > mMaxNameLength ) name = name.mid( 0, mMaxNameLength );

// If the name is invalid then reset it to default name
if ( InvalidFieldRegexp.exactMatch( name ) )
Expand Down
56 changes: 28 additions & 28 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
, mWktHasZM( false )
, mWktHasPrefix( false )
, mXyDms( false )
, mSubsetString("")
, mSubsetString( "" )
, mSubsetExpression( 0 )
, mMaxInvalidLines( 50 )
, mShowInvalidLines( true )
Expand Down Expand Up @@ -125,9 +125,9 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
QgsDebugMsg( "xField is: " + xField );
QgsDebugMsg( "yField is: " + yField );

if( url.hasQueryItem( "subset" ))
if ( url.hasQueryItem( "subset" ) )
{
subset = url.queryItemValue("subset");
subset = url.queryItemValue( "subset" );
QgsDebugMsg( "subset is: " + subset );
}

Expand Down Expand Up @@ -401,7 +401,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
reportErrors( warnings );
mValid = mGeometryType != QGis::UnknownGeometry;

if( ! subset.isEmpty())
if ( ! subset.isEmpty() )
{
setSubsetString( subset );
}
Expand Down Expand Up @@ -511,7 +511,7 @@ QgsDelimitedTextProvider::~QgsDelimitedTextProvider()
mFile = 0;
}

if( mSubsetExpression )
if ( mSubsetExpression )
{
delete mSubsetExpression;
mSubsetExpression = 0;
Expand Down Expand Up @@ -616,52 +616,52 @@ bool QgsDelimitedTextProvider::setSubsetString( QString subset, bool updateFeatu
// If there is a new subset string then encode it..

QgsExpression *expression = 0;
if( ! subset.isEmpty() )
if ( ! subset.isEmpty() )
{

expression = new QgsExpression( subset );
QString error;
if( expression->hasParserError())
if ( expression->hasParserError() )
{
error = expression->parserErrorString();
}
else
{
expression->prepare( fields() );
if( expression->hasEvalError() )
if ( expression->hasEvalError() )
{
error = expression->evalErrorString();
}
}
if( ! error.isEmpty() )
if ( ! error.isEmpty() )
{
valid = false;
delete expression;
expression = 0;
QString tag( "DelimitedText" );
QgsMessageLog::logMessage( tr( "Invalid subset string %1 for %2" ).arg(subset).arg( mFile->fileName() ), tag );
QgsMessageLog::logMessage( tr( "Invalid subset string %1 for %2" ).arg( subset ).arg( mFile->fileName() ), tag );
}
}


// if the expression is valid, then reset the subset string and data source Uri

if( valid )
if ( valid )
{

if( mSubsetExpression ) delete mSubsetExpression;
if ( mSubsetExpression ) delete mSubsetExpression;
mSubsetString = subset;
mSubsetExpression = expression;

// Encode the subset string into the data source URI.

QUrl url = QUrl::fromEncoded( dataSourceUri().toAscii() );
if( url.hasQueryItem("subset")) url.removeAllQueryItems("subset");
if( ! subset.isEmpty()) url.addQueryItem("subset",subset);
if ( url.hasQueryItem( "subset" ) ) url.removeAllQueryItems( "subset" );
if ( ! subset.isEmpty() ) url.addQueryItem( "subset", subset );
setDataSourceUri( QString::fromAscii( url.toEncoded() ) );

// Update the feature count and extents if requested
if( updateFeatureCount )
if ( updateFeatureCount )
{
resetDataSummary();
}
Expand All @@ -672,22 +672,22 @@ bool QgsDelimitedTextProvider::setSubsetString( QString subset, bool updateFeatu

void QgsDelimitedTextProvider::resetDataSummary()
{
QgsFeatureIterator fi = getFeatures(QgsFeatureRequest());
QgsFeatureIterator fi = getFeatures( QgsFeatureRequest() );
mNumberFeatures = 0;
mExtent = QgsRectangle();
QgsFeature f;
while( fi.nextFeature(f))
while ( fi.nextFeature( f ) )
{
if( mGeometryType != QGis::NoGeometry )
if ( mGeometryType != QGis::NoGeometry )
{
if( mNumberFeatures == 0 )
if ( mNumberFeatures == 0 )
{
mExtent = f.geometry()->boundingBox();
}
else
{
QgsRectangle bbox( f.geometry()->boundingBox());
mExtent.combineExtentWith( &bbox);
QgsRectangle bbox( f.geometry()->boundingBox() );
mExtent.combineExtentWith( &bbox );
}
}
mNumberFeatures++;
Expand All @@ -708,7 +708,7 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature, QgsDelimitedTex
if ( status != QgsDelimitedTextFile::RecordOk ) continue;

int fid = file->recordLineNumber();
if( request.filterType() == QgsFeatureRequest::FilterFid && fid != request.filterFid()) continue;
if ( request.filterType() == QgsFeatureRequest::FilterFid && fid != request.filterFid() ) continue;
if ( recordIsEmpty( tokens ) ) continue;

while ( tokens.size() < mFieldCount )
Expand All @@ -725,7 +725,7 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature, QgsDelimitedTex
}
else if ( mXFieldIndex >= 0 && mYFieldIndex >= 0 )
{
geom = loadGeometryXY( tokens,request );
geom = loadGeometryXY( tokens, request );
}

if ( !geom && mWkbType != QGis::WKBNoGeometry )
Expand Down Expand Up @@ -767,11 +767,11 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature, QgsDelimitedTex
// Are we using a subset expression, if so try and evaluate
// and accept result if passes.

if( mSubsetExpression )
if ( mSubsetExpression )
{
QVariant isOk = mSubsetExpression->evaluate( &feature );
if( mSubsetExpression->hasEvalError() ) continue;
if( ! isOk.toBool() ) continue;
if ( mSubsetExpression->hasEvalError() ) continue;
if ( ! isOk.toBool() ) continue;
}

// We have a good line, so return
Expand Down Expand Up @@ -848,9 +848,9 @@ bool QgsDelimitedTextProvider::boundsCheck( QgsGeometry *geom, const QgsFeatureR

void QgsDelimitedTextProvider::fetchAttribute( QgsFeature& feature, int fieldIdx, const QStringList& tokens )
{
if( fieldIdx < 0 || fieldIdx >= attributeColumns.count()) return;
if ( fieldIdx < 0 || fieldIdx >= attributeColumns.count() ) return;
int column = attributeColumns[fieldIdx];
if( column < 0 || column >= tokens.count()) return;
if ( column < 0 || column >= tokens.count() ) return;
const QString &value = tokens[column];
QVariant val;
switch ( attributeFields[fieldIdx].type() )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/delimitedtext/qgsdelimitedtextprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class QgsDelimitedTextProvider : public QgsVectorDataProvider
void resetStream();
bool recordIsEmpty( QStringList &record );
bool nextFeature( QgsFeature& feature, QgsDelimitedTextFile *file, const QgsFeatureRequest& request );
QgsGeometry* loadGeometryWkt( const QStringList& tokens, const QgsFeatureRequest& request);
QgsGeometry* loadGeometryWkt( const QStringList& tokens, const QgsFeatureRequest& request );
QgsGeometry* loadGeometryXY( const QStringList& tokens, const QgsFeatureRequest& request );
bool boundsCheck( const QgsPoint &pt, const QgsFeatureRequest& request );
bool boundsCheck( QgsGeometry *geom, const QgsFeatureRequest& request );
Expand Down
14 changes: 7 additions & 7 deletions src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <QTextCodec>
#include <QUrl>

const int MAX_SAMPLE_LENGTH=200;
const int MAX_SAMPLE_LENGTH = 200;

QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget * parent, Qt::WFlags fl, bool embedded ):
QDialog( parent, fl ),
Expand All @@ -53,7 +53,7 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget * parent, Qt
}

cmbEncoding->clear();
cmbEncoding->addItems( QgsVectorDataProvider::availableEncodings());
cmbEncoding->addItems( QgsVectorDataProvider::availableEncodings() );
cmbEncoding->setCurrentIndex( cmbEncoding->findText( "UTF-8" ) );
loadSettings();

Expand Down Expand Up @@ -420,7 +420,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists()
for ( int i = 0; i < tblSample->columnCount(); i++ )
{
QString value = i < nv ? values[i] : "";
if( value.length() > MAX_SAMPLE_LENGTH ) value = value.mid(0,MAX_SAMPLE_LENGTH)+"...";
if ( value.length() > MAX_SAMPLE_LENGTH ) value = value.mid( 0, MAX_SAMPLE_LENGTH ) + "...";
QTableWidgetItem *item = new QTableWidgetItem( value );
tblSample->setItem( counter - 1, i, item );
if ( ! value.isEmpty() )
Expand Down Expand Up @@ -685,9 +685,9 @@ bool QgsDelimitedTextSourceSelect::validate()
else if ( tblSample->rowCount() == 0 )
{
message = tr( "No data found in file" );
if( mBadRowCount > 0 )
if ( mBadRowCount > 0 )
{
message = message + " (" + tr("%1 badly formatted records discarded").arg(mBadRowCount)+")";
message = message + " (" + tr( "%1 badly formatted records discarded" ).arg( mBadRowCount ) + ")";
}
}
else if ( geomTypeXY->isChecked() && ( cmbXField->currentText().isEmpty() || cmbYField->currentText().isEmpty() ) )
Expand All @@ -705,9 +705,9 @@ bool QgsDelimitedTextSourceSelect::validate()
else
{
enabled = true;
if( mBadRowCount > 0 )
if ( mBadRowCount > 0 )
{
message = tr("%1 badly formatted records discarded from sample data").arg(mBadRowCount);
message = tr( "%1 badly formatted records discarded from sample data" ).arg( mBadRowCount );
}

}
Expand Down
12 changes: 6 additions & 6 deletions src/providers/grass/qgsgrassgislib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ int GRASS_LIB_EXPORT QgsGrassGisLib::G__gisinit( const char * version, const cha
{
fatal( "Cannot create CRS from QGIS_GRASS_CRS: " + crsStr );
}
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mCrs.srsid() == 0 )
if ( mCrs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( mCrs.toProj4() );
mCrs.saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( mCrs.toProj4() );
mCrs.saveAsUserCRS( myName );
}
}
mDistanceArea.setSourceCrs( mCrs.srsid() );
Expand Down
12 changes: 6 additions & 6 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3200,16 +3200,16 @@ QgsCoordinateReferenceSystem QgsSpatiaLiteProvider::crs()
if ( !srs.isValid() )
{
srs.createFromProj4( mProj4text );
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( srs.srsid() == 0 )
if ( srs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( srs.toProj4() );
srs.saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( srs.toProj4() );
srs.saveAsUserCRS( myName );
}

}
Expand Down
12 changes: 6 additions & 6 deletions src/providers/sqlanywhere/qgssqlanywhereprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,16 +1886,16 @@ QgsSqlAnywhereProvider::checkSrs()
SaDebugMsg( "Failed to create CRS from Proj4 description. Trying WKT." );
mCrs.createFromWkt( srsWkt );
}
//TODO: createFromProj4 used to save to the user database any new CRS
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mCrs.srsid() == 0 )
if ( mCrs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( mCrs.toProj4() );
mCrs.saveAsUserCRS(myName);
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( mCrs.toProj4() );
mCrs.saveAsUserCRS( myName );
}

return true;
Expand Down
20 changes: 10 additions & 10 deletions tests/src/core/testqgsblendmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class TestQgsBlendModes: public QObject
QgsMapRenderer * mpMapRenderer;
QgsMapLayer * mpPointsLayer;
QgsMapLayer * mpPolysLayer;
QgsRasterLayer* mRasterLayer1;
QgsRasterLayer* mRasterLayer2;
QgsRasterLayer* mRasterLayer1;
QgsRasterLayer* mRasterLayer2;
QString mTestDataDir;
};

Expand Down Expand Up @@ -84,20 +84,20 @@ void TestQgsBlendModes::initTestCase()
myPolyFileInfo.completeBaseName(), "ogr" );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPolysLayer );

//create two raster layers
QFileInfo rasterFileInfo( mTestDataDir + "landsat.tif" );
mRasterLayer1 = new QgsRasterLayer( rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName() );
rasterFileInfo.completeBaseName() );
mRasterLayer2 = new QgsRasterLayer( rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName() );
rasterFileInfo.completeBaseName() );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer1->dataProvider(), 2, 3, 4 );
mRasterLayer1->setRenderer( rasterRenderer );
mRasterLayer2->setRenderer( rasterRenderer );
mRasterLayer2->setRenderer( rasterRenderer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mRasterLayer1 );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mRasterLayer2);
QList<QgsMapLayer *>() << mRasterLayer2 );

mpMapRenderer = new QgsMapRenderer();
}
Expand All @@ -113,7 +113,7 @@ void TestQgsBlendModes::vectorBlending()
myLayers << mpPointsLayer->id();
myLayers << mpPolysLayer->id();
mpMapRenderer->setLayerSet( myLayers );

//Set blending modes for both layers
mpPointsLayer->setBlendMode( QPainter::CompositionMode_Overlay );
mpPolysLayer->setBlendMode( QPainter::CompositionMode_Multiply );
Expand All @@ -126,10 +126,10 @@ void TestQgsBlendModes::rasterBlending()
//Add two raster layers to map renderer
QStringList myLayers;
myLayers << mRasterLayer1->id();
myLayers << mRasterLayer2->id();
myLayers << mRasterLayer2->id();
mpMapRenderer->setLayerSet( myLayers );
mpMapRenderer->setExtent( mRasterLayer1->extent() );

// set blending mode for top layer
mRasterLayer1->setBlendMode( QPainter::CompositionMode_Plus );
QVERIFY( imageCheck( "raster_blendmodes" ) );
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsvectorlayercache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void TestVectorLayerCache::testSubsetRequest()
mVectorLayerCache->featureAtId( 16, f );
QVariant a = f.attribute( 3 );

QgsFeatureIterator itSubset = mVectorLayerCache->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( requiredFields, fields) );
QgsFeatureIterator itSubset = mVectorLayerCache->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( requiredFields, fields ) );
while ( itSubset.nextFeature( f ) ) {}
itSubset.close();

Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/testziplayer.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ class TestZipLayer: public QObject
void testZipItemAll();
void testTarItemAll();
// test that styles are loaded from .qml files outside zip files
#if 0
#if 0
// TODO - find a simple way to test vector style loading
void testZipItemVectorTransparency();
void testTarItemVectorTransparency();
void testGzipItemVectorTransparency();
#endif
#endif
void testZipItemRasterTransparency();
void testTarItemRasterTransparency();
void testGzipItemRasterTransparency();
Expand Down Expand Up @@ -235,7 +235,7 @@ int TestZipLayer::getLayerTransparency( QString myFileName, QString myProviderKe
QgsRasterLayer* layer = dynamic_cast<QgsRasterLayer*>( myLayer );
if ( layer && layer->renderer() )
{
myTransparency = ceil(layer->renderer()->opacity() * 255);
myTransparency = ceil( layer->renderer()->opacity() * 255 );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/gui/testqgsrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void TestQgsRubberband::initTestCase()
QString myPolygonFileName = mTestDataDir + "polys.shp";
QFileInfo myPolygonFileInfo( myPolygonFileName );
mPolygonLayer = new QgsVectorLayer( myPolygonFileInfo.filePath(),
myPolygonFileInfo.completeBaseName(), "ogr" );
myPolygonFileInfo.completeBaseName(), "ogr" );

mCanvas = new QgsMapCanvas();
mRubberband = 0;
Expand Down
8 changes: 4 additions & 4 deletions tests/src/python/test_qgscomposereffects.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, methodName):
self.mMapRenderer = QgsMapRenderer()
self.mComposition = QgsComposition(self.mMapRenderer)
self.mComposition.setPaperSize(297, 210)

self.mComposerRect1 = QgsComposerShape(20, 20, 150, 100, self.mComposition)
self.mComposerRect1.setShapeType(QgsComposerShape.Rectangle)
self.mComposerRect1.setBackgroundColor(QColor.fromRgb(255, 150, 0))
Expand All @@ -54,11 +54,11 @@ def __init__(self, methodName):
self.mComposerRect2 = QgsComposerShape(50, 50, 150, 100, self.mComposition)
self.mComposerRect2.setShapeType(QgsComposerShape.Rectangle)
self.mComposerRect2.setBackgroundColor(QColor.fromRgb(0, 100, 150))
self.mComposition.addComposerShape(self.mComposerRect2)
self.mComposition.addComposerShape(self.mComposerRect2)

def testBlendModes(self):
"""Test that blend modes work for composer items."""

self.mComposerRect2.setBlendMode(QPainter.CompositionMode_Multiply)

checker = QgsCompositionChecker()
Expand All @@ -74,7 +74,7 @@ def testBlendModes(self):

def testTransparency(self):
"""Test that transparency works for composer items."""

self.mComposerRect2.setTransparency( 50 )

checker = QgsCompositionChecker()
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgscomposermap.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def testOverviewMapBlend(self):
myPngPath)
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

def testOverviewMapInvert(self):
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
overviewMap.setFrameEnabled(True)
Expand All @@ -176,7 +176,7 @@ def testOverviewMapInvert(self):
myPngPath)
self.mComposition.removeComposerItem(overviewMap)
assert myTestResult == True, myMessage

# Fails because addItemsFromXML has been commented out in sip
@expectedFailure
def testuniqueId(self):
Expand Down
28 changes: 14 additions & 14 deletions tests/src/python/test_qgsdelimitedtextprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def runTest( name, wanted, file, requests, **params ):
msg='Missing log message: '+l
print ' '+msg
failures.append(msg)

for l in log:
msg='Extra log message: '+l
print ' '+msg
Expand Down Expand Up @@ -1397,8 +1397,8 @@ def test_030_filter_rect_xy(self):
filename='testextpt.txt'
params={'yField': 'y', 'delimiter': '|', 'type': 'csv', 'xField': 'x'}
requests=[
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [110, 130, 130, 150]}]
if rebuildTests:
createTest(description,filename,requests,**params)
Expand Down Expand Up @@ -1449,8 +1449,8 @@ def test_031_filter_rect_wkt(self):
filename='testextw.txt'
params={'delimiter': '|', 'type': 'csv', 'wktField': 'wkt'}
requests=[
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [110, 130, 130, 150]}]
if rebuildTests:
createTest(description,filename,requests,**params)
Expand Down Expand Up @@ -1517,10 +1517,10 @@ def test_032_filter_fid(self):
filename='test.csv'
params={'geomType': 'none', 'type': 'csv'}
requests=[
{'fid': 3},
{'fid': 9},
{'fid': 5},
{'fid': 7},
{'fid': 3},
{'fid': 9},
{'fid': 5},
{'fid': 7},
{'fid': 3}]
if rebuildTests:
createTest(description,filename,requests,**params)
Expand Down Expand Up @@ -1576,11 +1576,11 @@ def test_033_filter_attributes(self):
filename='test.csv'
params={'geomType': 'none', 'type': 'csv'}
requests=[
{'attributes': [1, 3]},
{'fid': 9},
{'attributes': [1, 3], 'fid': 9},
{'attributes': [3, 1], 'fid': 9},
{'attributes': [1, 3, 7], 'fid': 9},
{'attributes': [1, 3]},
{'fid': 9},
{'attributes': [1, 3], 'fid': 9},
{'attributes': [3, 1], 'fid': 9},
{'attributes': [1, 3, 7], 'fid': 9},
{'attributes': [], 'fid': 9}]
if rebuildTests:
createTest(description,filename,requests,**params)
Expand Down