8 changes: 4 additions & 4 deletions python/core/qgspoint.sip
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


class QgsPoint
class QgsPoint
{

%TypeHeaderCode
Expand All @@ -11,7 +11,7 @@ class QgsPoint
public:
/// Default constructor
QgsPoint();

/*! Create a point from another point */
QgsPoint( const QgsPoint& p );

Expand All @@ -32,7 +32,7 @@ class QgsPoint
* @param y y coordinate
*/
void setY( double y );

/*! Sets the x and y value of the point */
void set( double x, double y );

Expand Down Expand Up @@ -116,7 +116,7 @@ class QgsPoint


SIP_PYOBJECT __getitem__(int);
%MethodCode
%MethodCode
if (a0 == 0) {
sipRes = Py_BuildValue("d",sipCpp->x());
} else if (a0 == 1) {
Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgsrasterblock.sip
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class QgsRasterBlock
bool convert( QGis::DataType destDataType );
QImage image() const;
bool setImage( const QImage * image );

static bool valueInRange( double value, const QList<QgsRasterBlock::Range> &rangeList );

};
Expand Down
12 changes: 6 additions & 6 deletions python/core/raster/qgsrasterinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class QgsRasterInterface

/** Returns a bitmask containing the supported capabilities */
virtual int capabilities() const;

/**
* Returns the above in friendly format.
*/
*/
QString capabilitiesString() const;

/** Returns data type for the band specified by number */
Expand Down Expand Up @@ -163,14 +163,14 @@ class QgsRasterInterface
const QgsRectangle & theExtent,
int theSampleSize,
bool theIncludeOutOfRange );
/** \brief Returns true if histogram is available (cached, already calculated), the parameters are the same as in histogram()

/** \brief Returns true if histogram is available (cached, already calculated), the parameters are the same as in histogram()
* @note theBinCount, theMinimun and theMaximum not optional in python bindings
*/
virtual bool hasHistogram( int theBandNo,
int theBinCount,
double theMinimum,
double theMaximum,
double theMinimum,
double theMaximum,
const QgsRectangle & theExtent,
int theSampleSize,
bool theIncludeOutOfRange );
Expand Down
2 changes: 1 addition & 1 deletion python/core/symbology-ng/qgsvectorcolorrampv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class QgsVectorColorRampV2
virtual ~QgsVectorColorRampV2();

virtual int count() const = 0;

virtual double value( int index ) const = 0;

virtual QColor color( double value ) const = 0;
Expand Down
36 changes: 25 additions & 11 deletions python/gui/qgisinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ class QgisInterface : QObject
public slots: // TODO: do these functions really need to be slots?

/* Exposed functions */
/** Set the app font size
* @param fontSize point size of font
* @note added in 2.0
*/
virtual void setFontSize( int fontSize ) = 0;

/** Set the app font family
* @param fontFamily family of font (not including any style)
* @note added in 2.0
*/
virtual void setFontFamily( QString fontFamily ) = 0;

//! Zoom to full extent of map layers
virtual void zoomFull() = 0;
Expand Down Expand Up @@ -132,6 +121,27 @@ class QgisInterface : QObject
/**Return mainwindows / composer views of running composer instances (currently only one)*/
virtual QList<QgsComposerView*> activeComposers() = 0;

/** Return changeable options built from settings and/or defaults
* @note (added in 1.9)
*/
virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;

/** Generate stylesheet
* @param opts generated default option values, or a changed copy of them
* @note added in 1.9
*/
virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;

/** Save changed default option keys/values to user settings
* @note added in 1.9
*/
virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;

/** Get reference font for initial qApp (may not be same as QgisApp)
* @note added in 1.9
*/
virtual QFont defaultStyleSheetFont() = 0;

/** Add action to the plugins menu */
virtual void addPluginToMenu( QString name, QAction* action ) = 0;

Expand Down Expand Up @@ -398,6 +408,10 @@ class QgisInterface : QObject
* @note added in 1.9 */
virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;

/** Get timeout for timed messages: default of 5 seconds
* @note added in 1.9 */
virtual int messageTimeout() = 0;

signals:
/** Emited whenever current (selected) layer changes.
* The pointer to layer can be null if no layer is selected
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsannotationitem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class QgsAnnotationItem: QgsMapCanvasItem
%TypeHeaderCode
#include <qgsannotationitem.h>
%End

public:
enum MouseMoveAction
{
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmapcanvasitem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class QgsMapCanvasItem : QGraphicsItem
%TypeHeaderCode
#include <qgsmapcanvasitem.h>
%End

protected:

//! protected constructor: cannot be constructed directly
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgsmaptool.sip
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class QgsMapTool : QObject
%End

public:

//! virtual destructor
virtual ~QgsMapTool();

Expand Down Expand Up @@ -118,5 +118,5 @@ class QgsMapTool : QObject
//! transformation from map coordinates to screen coordinates
QPoint toCanvasCoordinates( const QgsPoint& point );


};
2 changes: 1 addition & 1 deletion python/gui/qgsmaptoolemitpoint.sip
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class QgsMapToolEmitPoint : QgsMapTool
%TypeHeaderCode
#include <qgsmaptoolemitpoint.h>
%End

public:
//! constructor
QgsMapToolEmitPoint( QgsMapCanvas* canvas );
Expand Down
3 changes: 3 additions & 0 deletions python/gui/qgsmessagebar.sip
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ class QgsMessageBar: QFrame
* @return true if all items were removed, false otherwise
*/
bool clearWidgets();

protected:
void mousePressEvent( QMouseEvent * e );
};
2 changes: 1 addition & 1 deletion python/gui/qgsquickprint.sip
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** QgsQuickPrint is a convenience class to quickly print a
/** QgsQuickPrint is a convenience class to quickly print a
preformatted map to pdf.
*/
class QgsQuickPrint : QObject
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsrasterformatsaveoptionswidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class QgsRasterFormatSaveOptionsWidget : QWidget
%TypeHeaderCode
#include <qgsrasterformatsaveoptionswidget.h>
%End

public:

enum Type
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsvertexmarker.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class QgsVertexMarker : QgsMapCanvasItem
%End

public:

//! Icons
enum IconType
{
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/dialogSRS.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def proj4string(self):
return self.selector.selectedProj4String()

def getProjection(self):
if self.authid().startsWith("EPSG:", Qt.CaseInsensitive):
if self.authid().startswith("EPSG:", Qt.CaseInsensitive):
return self.authid()

if not self.selector.selectedProj4String().isEmpty():
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/fTools/tools/ftools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def dirDialog( parent ):
if not fileDialog.exec_() == QDialog.Accepted:
return None, None
folders = fileDialog.selectedFiles()
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( folders.first() ) ) ) )
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( folders.first() ) ).absolutePath() ) )
return ( unicode( folders.first() ), unicode( fileDialog.encoding() ) )

# Return field type from it's name
Expand Down
24 changes: 12 additions & 12 deletions python/plugins/sextante/admintools/ImportIntoPostGIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def getIcon(self):
def processAlgorithm(self, progress):
connection = self.getParameterValue(self.DATABASE)
overwrite = self.getParameterValue(self.OVERWRITE)
createIndex = self.getParameterValue(self.CREATEINDEX)
createIndex = self.getParameterValue(self.CREATEINDEX)
settings = QSettings()
mySettings = "/PostgreSQL/connections/"+ connection
try:
Expand All @@ -61,33 +61,33 @@ def processAlgorithm(self, progress):
password = settings.value(mySettings+"/password").toString()
except Exception, e:
raise GeoAlgorithmExecutionException("Wrong database connection name: " + connection)

table = self.getParameterValue(self.TABLENAME);
table.replace(" ", "")
providerName = "postgres"

try:
db = postgis_utils.GeoDB(host=host, port=port, dbname=database, user=username, passwd=password)
except postgis_utils.DbError, e:
raise GeoAlgorithmExecutionException("Couldn't connect to database:\n"+e.message)

uri = QgsDataSourceURI()
uri.setConnection(host, str(port), database, username, password)
uri.setConnection(host, str(port), database, username, password)
uri.setDataSource("public", table, "the_geom", "")

options = {}
if overwrite:
options['overwrite'] = True

layerUri = self.getParameterValue(self.INPUT);
layer = QGisLayers.getObjectFromUri(layerUri)
layerUri = self.getParameterValue(self.INPUT);
layer = QGisLayers.getObjectFromUri(layerUri)
ret, errMsg = QgsVectorLayerImport.importLayer(layer, uri.uri(), providerName, self.crs, False, False, options)
if ret != 0:
raise GeoAlgorithmExecutionException(u"Error importing to PostGIS\n%s" % errMsg)
raise GeoAlgorithmExecutionException(u"Error importing to PostGIS\n%s" % errMsg)

if createIndex:
db.create_spatial_index(table, "public", "the_geom")

db.vacuum_analyze(table, "public")

def defineCharacteristics(self):
Expand All @@ -96,10 +96,10 @@ def defineCharacteristics(self):
self.addParameter(ParameterVector(self.INPUT, "Layer to import"))
self.addParameter(ParameterString(self.DATABASE, "Database (connection name)"))
self.addParameter(ParameterString(self.TABLENAME, "Table to import to"))
self.addParameter(ParameterBoolean(self.OVERWRITE, "Overwrite", True))
self.addParameter(ParameterBoolean(self.CREATEINDEX, "Create spatial index", True))
self.addParameter(ParameterBoolean(self.OVERWRITE, "Overwrite", True))
self.addParameter(ParameterBoolean(self.CREATEINDEX, "Create spatial index", True))





4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/AddTableField.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def processAlgorithm(self, progress):
vprovider.select( allAttrs )
fields = vprovider.fields()
fields[len(fields)] = QgsField(fieldname, self.TYPES[fieldtype])
writer = output.getVectorWriter(fields, vprovider.geometryType(), vprovider.crs() )
writer = output.getVectorWriter(fields, vprovider.geometryType(), vprovider.crs() )
outFeat = QgsFeature()
inGeom = QgsGeometry()
nFeat = vprovider.featureCount()
nElement = 0
features = QGisLayers.features(vlayer)
features = QGisLayers.features(vlayer)
for inFeat in features:
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
Expand Down
28 changes: 14 additions & 14 deletions python/plugins/sextante/algs/FieldPyculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FieldsPyculator(GeoAlgorithm):
def defineCharacteristics(self):
self.name = "Advanced Python field calculator"
self.group = "Vector table tools"
self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterString(self.FIELD_NAME, "Result field name", "NewField"))
self.addParameter(ParameterString(self.GLOBAL, "Global expression", multiline = True))
self.addParameter(ParameterString(self.FORMULA, "Formula", "value = ", multiline = True))
Expand All @@ -63,7 +63,7 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
fieldname = self.getParameterValue(self.FIELD_NAME)
code = self.getParameterValue(self.FORMULA)
globalExpression = self.getParameterValue(self.GLOBAL)
globalExpression = self.getParameterValue(self.GLOBAL)
output = self.getOutputFromName(self.OUTPUT_LAYER)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
vprovider = layer.dataProvider()
Expand Down Expand Up @@ -108,40 +108,40 @@ def processAlgorithm(self, progress):
"Field code block can't be executed! %s \n %s"
(unicode(sys.exc_info()[0].__name__), unicode(sys.exc_info()[1])))

#run
#run
if need_attrs:
attr_ind = vprovider.attributeIndexes()
else:
attr_ind = []
vprovider.select(attr_ind, QgsRectangle(), True)

features = QGisLayers.features(layer)
nFeatures = len(features)
nElement = 1
for feat in features:
progress.setPercentage(int((100 * nElement)/nFeatures))
attrMap = feat.attributeMap()
feat_id = feat.id()

#add needed vars
if need_id:
new_ns['__id'] = feat_id

if need_geom:
geom = feat.geometry()
new_ns['__geom'] = geom

if need_attrs:
attr = []
for num,a in attrMap.iteritems():
attr.append(self.Qvar2py(a))
new_ns['__attr'] = attr

#clear old result
if new_ns.has_key(self.RESULT_VAR_NAME):
del new_ns[self.RESULT_VAR_NAME]


#exec
#try:
exec bytecode in new_ns
Expand All @@ -154,21 +154,21 @@ def processAlgorithm(self, progress):
# unicode(sys.exc_info()[1]),
# unicode(feat_id)))
#===============================================================

#check result
if not new_ns.has_key(self.RESULT_VAR_NAME):
raise GeoAlgorithmExecutionException("FieldPyculator code execute error\n" +
"Field code block does not return '%s1' variable! Please declare this variable in your code!" %
self.RESULT_VAR_NAME)


#write feature
nElement += 1
outFeat.setGeometry( feat.geometry() )
outFeat.setAttributeMap( attrMap )
outFeat.addAttribute(len(vprovider.fields()), QVariant(new_ns[self.RESULT_VAR_NAME]))
writer.addFeature(outFeat)

del writer


Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/FieldsCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def processAlgorithm(self, progress):
vprovider.select(allAttrs)
fields = vprovider.fields()
fields[len(fields)] = QgsField(fieldname, QVariant.Double)
writer = output.getVectorWriter(fields, vprovider.geometryType(), vprovider.crs())
writer = output.getVectorWriter(fields, vprovider.geometryType(), vprovider.crs())
outFeat = QgsFeature()
inGeom = QgsGeometry()
nFeat = vprovider.featureCount()
nElement = 0
features = QGisLayers.features(vlayer)
features = QGisLayers.features(vlayer)
for inFeat in features:
progress.setPercentage(int((100 * nElement) / nFeat))
attrs = inFeat.attributeMap()
Expand Down
26 changes: 13 additions & 13 deletions python/plugins/sextante/algs/JoinAttributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


class JoinAttributes(GeoAlgorithm):

OUTPUT_LAYER = "OUTPUT_LAYER"
INPUT_LAYER = "INPUT_LAYER"
INPUT_LAYER_2 = "INPUT_LAYER_2"
Expand All @@ -56,8 +56,8 @@ def processAlgorithm(self, progress):
input2 = self.getParameterValue(self.INPUT_LAYER_2)
output = self.getOutputFromName(self.OUTPUT_LAYER)
field = self.getParameterValue(self.TABLE_FIELD)
field2 = self.getParameterValue(self.TABLE_FIELD_2)
field2 = self.getParameterValue(self.TABLE_FIELD_2)

# Layer 1
layer = QGisLayers.getObjectFromUri(input)
provider = layer.dataProvider()
Expand All @@ -71,36 +71,36 @@ def processAlgorithm(self, progress):
provider2.select(allAttrs)
fields2 = provider2.fields()
join_field2_index = provider2.fieldNameIndex(field2)

# Output
outFields = provider.fields()
for (i, f) in fields2.iteritems():
f.setName("x_" + f.name())
outFields[len(outFields)] = f

writer = output.getVectorWriter(outFields, provider.geometryType(), provider.crs())

inFeat = QgsFeature()
inFeat2 = QgsFeature()
outFeat = QgsFeature()

# Create output vector layer with additional attribute
while provider.nextFeature(inFeat):
inGeom = inFeat.geometry()
atMap = inFeat.attributeMap()
join_value1 = atMap[join_field1_index].toString()
provider2.rewind()
while provider2.nextFeature(inFeat2):
join_value1 = atMap[join_field1_index].toString()
provider2.rewind()
while provider2.nextFeature(inFeat2):
atMap2 = inFeat2.attributeMap()
join_value2 = atMap2[join_field2_index].toString()
join_value2 = atMap2[join_field2_index].toString()
if join_value1 == join_value2:
# create the new feature
outFeat.setGeometry(inGeom)
outFeat.setAttributeMap(atMap)
l = len(provider.fields())
for (i, a) in atMap2.iteritems():
outFeat.addAttribute(l + i, a)

writer.addFeature(outFeat)

del writer
6 changes: 3 additions & 3 deletions python/plugins/sextante/algs/QGISAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
from sextante.algs.ftools.Union import Union
from sextante.algs.ftools.DensifyGeometriesInterval import DensifyGeometriesInterval
from sextante.algs.mmqgisx.MMQGISXAlgorithms import (mmqgisx_delete_columns_algorithm,
mmqgisx_delete_duplicate_geometries_algorithm,
mmqgisx_geometry_convert_algorithm,
mmqgisx_delete_duplicate_geometries_algorithm,
mmqgisx_geometry_convert_algorithm,
mmqgisx_grid_algorithm, mmqgisx_gridify_algorithm,
mmqgisx_hub_distance_algorithm, mmqgisx_hub_lines_algorithm,
mmqgisx_label_point_algorithm, mmqgisx_merge_algorithm,
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(self):
# geometry
ExportGeometryInfo(), Centroids(), Delaunay(), VoronoiPolygons(),
SimplifyGeometries(), DensifyGeometries(), DensifyGeometriesInterval(),
MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(),
MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(),
LinesToPolygons(), ExtractNodes(),
# geoprocessing
ConvexHull(), FixedDistanceBuffer(), VariableDistanceBuffer(),
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/algs/ftools/BasicStatisticsNumbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def processAlgorithm(self, progress):

index = layer.fieldNameIndex(fieldName)
layer.select([index], QgsRectangle(), False)

cvValue = 0
minValue = 0
maxValue = 0
Expand All @@ -104,12 +104,12 @@ def processAlgorithm(self, progress):

isFirst = True
values = []

features = QGisLayers.features(layer)
count = len(features)
total = 100.0 / float(count)
current = 0
for ft in features:
for ft in features:
value = float(ft.attributeMap()[index].toDouble()[0])

if isFirst:
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/sextante/algs/ftools/Buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))

# with dissolve
if dissolve:
first = True
Expand All @@ -57,7 +57,7 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
value = atMap[field].toDouble()[0]
else:
value = distance

inGeom = QgsGeometry(inFeat.geometry())
try:
outGeom = inGeom.buffer(float(value), segments)
Expand All @@ -73,7 +73,7 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
except:
GEOS_EXCEPT = False
continue

current += 1
progress.setPercentage(int(current * total))
try:
Expand All @@ -89,7 +89,7 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
value = atMap[field].toDouble()[0]
else:
value = distance

inGeom = QgsGeometry(inFeat.geometry())
try:
outGeom = inGeom.buffer(float(value), segments)
Expand All @@ -103,10 +103,10 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
except:
GEOS_EXCEPT = False
continue

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

del writer

if not GEOS_EXCEPT:
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/algs/ftools/Centroids.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))

writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(layer.pendingFields(),
QGis.WKBPoint, layer.dataProvider().crs())

layer.select(layer.pendingAllAttributesList())

outFeat = QgsFeature()

features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
total = 100.0 / float(len(features))
current = 0

for inFeat in features:
Expand Down
20 changes: 10 additions & 10 deletions python/plugins/sextante/algs/ftools/ConvexHull.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ConvexHull(GeoAlgorithm):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/convex_hull.png")
#===========================================================================

def processAlgorithm(self, progress):
def processAlgorithm(self, progress):
useField = (self.getParameterValue(ConvexHull.METHOD) == 1)
field = self.getParameterValue(ConvexHull.FIELD)
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(ConvexHull.INPUT))
Expand All @@ -67,9 +67,9 @@ def processAlgorithm(self, progress):
outGeom = QgsGeometry()
nElement = 0
index = vproviderA.fieldNameIndex(field)

features = QGisLayers.features(vlayerA)
nFeat = len(features)
nFeat = len(features)

if useField:
unique = ftools_utils.getUniqueValues(vproviderA, index)
Expand All @@ -80,14 +80,14 @@ def processAlgorithm(self, progress):
outID = 0
vproviderA.select(allAttrsA)
features = QGisLayers.features(vlayerA)
for inFeat in features:
for inFeat in features:
atMap = inFeat.attributeMap()
idVar = atMap[ index ]
if idVar.toString().trimmed() == i.toString().trimmed():
if first:
outID = idVar
first = False
inGeom = QgsGeometry(inFeat.geometry())
inGeom = QgsGeometry(inFeat.geometry())
points = ftools_utils.extractPoints(inGeom)
hull.extend(points)
nElement += 1
Expand All @@ -106,10 +106,10 @@ def processAlgorithm(self, progress):
GEOS_EXCEPT = False
continue
else:
hull = []
hull = []
vproviderA.select(allAttrsA)
features = QGisLayers.features(vlayerA)
for inFeat in features:
for inFeat in features:
inGeom = QgsGeometry(inFeat.geometry())
points = ftools_utils.extractPoints(inGeom)
hull.extend(points)
Expand All @@ -122,7 +122,7 @@ def processAlgorithm(self, progress):
writer.addFeature(outFeat)
except:
GEOS_EXCEPT = False

del writer

if not GEOS_EXCEPT:
Expand Down Expand Up @@ -151,12 +151,12 @@ def perimMeasure(self, inGeom, measure):
for k in poly:
value = value + measure.measureLine(k)
return value

def defineCharacteristics(self):
self.name = "Convex hull"
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(ConvexHull.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(ConvexHull.FIELD, "Field", ConvexHull.INPUT))
self.addParameter(ParameterSelection(ConvexHull.METHOD, "Method", ConvexHull.METHODS))
self.addParameter(ParameterSelection(ConvexHull.METHOD, "Method", ConvexHull.METHODS))
self.addOutput(OutputVector(ConvexHull.OUTPUT, "Convex hull"))
#=========================================================
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/Delaunay.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(self.OUTPUT, "Delaunay triangulation"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

provider = layer.dataProvider()
provider.select()
Expand All @@ -69,7 +69,7 @@ def processAlgorithm(self, progress):

pts = []
ptDict = {}
ptNdx = -1
ptNdx = -1
c = voronoi.Context()
features = QGisLayers.features(layer)
for inFeat in features:
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/algs/ftools/DensifyGeometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
class DensifyGeometries(GeoAlgorithm):

INPUT = "INPUT"
VERTICES = "VERTICES"
VERTICES = "VERTICES"
OUTPUT = "OUTPUT"

#def getIcon(self):
Expand All @@ -51,13 +51,13 @@ def defineCharacteristics(self):
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterNumber(self.VERTICES, "Vertices to add", 1, 10000000, 1))
self.addParameter(ParameterNumber(self.VERTICES, "Vertices to add", 1, 10000000, 1))

self.addOutput(OutputVector(self.OUTPUT, "Simplified layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
vertices = self.getParameterValue(self.VERTICES)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
vertices = self.getParameterValue(self.VERTICES)

isPolygon = layer.geometryType() == QGis.Polygon

Expand Down
18 changes: 9 additions & 9 deletions python/plugins/sextante/algs/ftools/DensifyGeometriesInterval.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@

class DensifyGeometriesInterval(GeoAlgorithm):

INPUT = "INPUT"
INPUT = "INPUT"
INTERVAL = "INTERVAL"
OUTPUT = "OUTPUT"

def defineCharacteristics(self):
self.name = "Densify geometries given an interval"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterNumber(self.INTERVAL, "Interval between Vertices to add", 1, 10000000, 1))
self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterNumber(self.INTERVAL, "Interval between Vertices to add", 1, 10000000, 1))

self.addOutput(OutputVector(self.OUTPUT, "Simplified layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
interval = self.getParameterValue(self.INTERVAL)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
interval = self.getParameterValue(self.INTERVAL)

isPolygon = layer.geometryType() == QGis.Polygon

Expand All @@ -64,11 +64,11 @@ def processAlgorithm(self, progress):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields(),
layer.wkbType(), provider.crs())


features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
current = 0
for f in features:
for f in features:
featGeometry = QgsGeometry(f.geometry())
attrMap = f.attributeMap()
newGeometry = self.densifyGeometry(featGeometry, interval, isPolygon)
Expand Down Expand Up @@ -109,15 +109,15 @@ def densifyGeometry(self, geometry, interval, isPolygon):
points = geometry.asPolyline()
output = self.densify(points, interval)
return QgsGeometry.fromPolyline(output)

def densify(self, polyline, interval):
output = []
for i in xrange(len(polyline) - 1):
p1 = polyline[i]
p2 = polyline[i + 1]
output.append(p1)
# calculate necessary number of points between p1 and p2
pointsNumber = sqrt(p1.sqrDist(p2)) / interval
pointsNumber = sqrt(p1.sqrDist(p2)) / interval
if pointsNumber > 1:
multiplier = 1.0 / float(pointsNumber)
else:
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/Dissolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Dissolve(GeoAlgorithm):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/dissolve.png")
#===========================================================================

def processAlgorithm(self, progress):
def processAlgorithm(self, progress):
useField = not self.getParameterValue(Dissolve.DISSOLVE_ALL)
fieldname = self.getParameterValue(Dissolve.FIELD)
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(Dissolve.INPUT))
Expand Down Expand Up @@ -125,7 +125,7 @@ def processAlgorithm(self, progress):
def defineCharacteristics(self):
self.name = "Dissolve"
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(Dissolve.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_POLYGON))
self.addParameter(ParameterVector(Dissolve.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_POLYGON))
self.addParameter(ParameterBoolean(Dissolve.DISSOLVE_ALL, "Dissolve all (do not use field)", True))
self.addParameter(ParameterTableField(Dissolve.FIELD, "Unique ID field",Dissolve.INPUT ))
self.addOutput(OutputVector(Dissolve.OUTPUT, "Dissolved"))
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/algs/ftools/ExportGeometryInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
method = self.getParameterValue(self.METHOD)
method = self.getParameterValue(self.METHOD)

provider = layer.dataProvider()
geometryType = layer.geometryType()
Expand Down Expand Up @@ -105,14 +105,14 @@ def processAlgorithm(self, progress):
mapCRS = QGisLayers.iface.mapCanvas().mapRenderer().destinationCrs()
layCRS = layer.crs()
coordTransform = QgsCoordinateTransform(layCRS, mapCRS)

outFeat = QgsFeature()
inGeom = QgsGeometry()

current = 0
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
for inFeat in features:
inGeom = inFeat.geometry()

if method == 1:
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/ExtentFromLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def featureExtent(self, layer, writer, progress):
outFeat = QgsFeature()

provider = layer.dataProvider()
provider.select()
provider.select()
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
for inFeat in features:
rect = inFeat.geometry().boundingBox()
minx = rect.xMinimum()
miny = rect.yMinimum()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/ExtractNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(self.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

provider = layer.dataProvider()
layer.select(layer.pendingAllAttributesList())
Expand All @@ -66,7 +66,7 @@ def processAlgorithm(self, progress):
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
for inFeat in features:
inGeom = inFeat.geometry()
atMap = inFeat.attributeMap()

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/FToolsUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
from qgis.core import *

def createSpatialIndex(layer):
provider = layer.provider()
provider = layer.provider()
idx = QgsSpatialIndex()
provider.rewind()
provider.select()
features = QGisLayers.features(layer)
for ft in features:
for ft in features:
idx.insertFeature(ft)
return idx

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/LinesIntersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def processAlgorithm(self, progress):
layerB = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_B))
fieldA = self.getParameterValue(self.FIELD_A)
fieldB = self.getParameterValue(self.FIELD_B)

providerA = layerA.dataProvider()
providerB = layerB.dataProvider()

Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/algs/ftools/LinesToPolygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(self.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

provider = layer.dataProvider()
layer.select(layer.pendingAllAttributesList())
Expand All @@ -57,10 +57,10 @@ def processAlgorithm(self, progress):

outFeat = QgsFeature()

current = 0
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
for inFeat in features:
outGeomList = []
if inFeat.geometry().isMultipart():
outGeomList = inFeat.geometry().asMultiPolyline()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/MultipartToSingleparts.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def processAlgorithm(self, progress):

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields(),
geomType, provider.crs())

outFeat = QgsFeature()
inGeom = QgsGeometry()

current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
for inFeat in features:
inGeom = inFeat.geometry()
atMap = inFeat.attributeMap()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ def processAlgorithm(self, progress):
spatialIndex = utils.createSpatialIndex(layer)
provider.rewind()
provider.select()

neighbour = QgsFeature()
distance = QgsDistanceArea()

sumDist = 0.00
A = layer.extent()
A = float(A.width() * A.height())

current = 0
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for feat in features:
for feat in features:
neighbourID = spatialIndex.nearestNeighbor(feat.geometry().asPoint(), 2)[1]
provider.featureAtId(neighbourID, neighbour, True)
sumDist += distance.measureLine(neighbour.geometry().asPoint(), feat.geometry().asPoint())
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/PointsInPolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def processAlgorithm(self, progress):

features = QGisLayers.features(polyLayer)
total = 100.0 / float(len(features))
for ftPoly in features:
for ftPoly in features:
geom = ftPoly.geometry()
atMap = ftPoly.attributeMap()

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

features = QGisLayers.features(polyLayer)
total = 100.0 / float(len(features))
for ftPoly in features:
for ftPoly in features:
geom = ftPoly.geometry()
atMap = ftPoly.attributeMap()

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

features = QGisLayers.features(polyLayer)
total = 100.0 / float(len(features))
for ftPoly in features:
for ftPoly in features:
geom = ftPoly.geometry()
atMap = ftPoly.attributeMap()

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/PolygonsToLines.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def processAlgorithm(self, progress):
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
for inFeat in features:
inGeom = inFeat.geometry()
atMap = inFeat.attributeMap()
lineList = self.extractAsLine(inGeom)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/RandomSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ def processAlgorithm(self, progress):

layer.setSelectedFeatures(selran)
self.setOutputValue(self.OUTPUT, filename)

4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/ftools/ReprojectLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ def processAlgorithm(self, progress):

layerCrs = layer.crs()
crsTransform = QgsCoordinateTransform(layerCrs, targetCrs)

outFeat = QgsFeature()
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for f in features:
for f in features:
geom = f.geometry()
geom.transform(crsTransform)
outFeat.setGeometry(geom)
Expand Down
16 changes: 8 additions & 8 deletions python/plugins/sextante/algs/ftools/SimplifyGeometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def defineCharacteristics(self):
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterNumber(self.TOLERANCE, "Tolerance", 0.0, 10000000.0, 1.0))
self.addParameter(ParameterNumber(self.TOLERANCE, "Tolerance", 0.0, 10000000.0, 1.0))

self.addOutput(OutputVector(self.OUTPUT, "Simplified layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
tolerance =self.getParameterValue(self.TOLERANCE)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
tolerance =self.getParameterValue(self.TOLERANCE)

pointsBefore = 0
pointsAfter = 0
Expand All @@ -68,22 +68,22 @@ def processAlgorithm(self, progress):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields(),
layer.wkbType(), provider.crs())

current = 0
current = 0
selection = QGisLayers.features(layer)
total = 100.0 / float(len(selection))
total = 100.0 / float(len(selection))
for f in selection:
featGeometry = QgsGeometry(f.geometry())
attrMap = f.attributeMap()
attrMap = f.attributeMap()
pointsBefore += self.geomVertexCount(featGeometry)
newGeometry = featGeometry.simplify(tolerance)
pointsAfter += self.geomVertexCount(newGeometry)
pointsAfter += self.geomVertexCount(newGeometry)
feature = QgsFeature()
feature.setGeometry(newGeometry)
feature.setAttributeMap(attrMap)
writer.addFeature(feature)
current += 1
progress.setPercentage(int(current * total))

del writer

SextanteLog.addToLog(SextanteLog.LOG_INFO, "Simplify: Input geometries have been simplified from"
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/SumLines.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def processAlgorithm(self, progress):
current = 0
features = QGisLayers.features(polyLayer)
total = 100.0 / float(len(features))
hasIntersections = False
hasIntersections = False
for ftPoly in features:
inGeom = QgsGeometry(ftPoly.geometry())
atMap = ftPoly.attributeMap()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/ftools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def getUniqueValuesCount( layer, fieldIndex):
allAttrs = vprovider.attributeIndexes()
vprovider.select( allAttrs )
count = 0
values = []
values = []
features = QGisLayers.features(layer)
for feat in features:
if feat.attributeMap()[ fieldIndex ].toString() not in values:
Expand Down
28 changes: 14 additions & 14 deletions python/plugins/sextante/algs/mmqgisx/MMQGISXAlgorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def defineCharacteristics(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_export.png")
#===========================================================================

def processAlgorithm(self, progress):
def processAlgorithm(self, progress):

outfilename = self.getOutputValue(self.OUTFILENAME)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))

if self.getParameterValue(self.FIELDDELIMITER) == 1:
field_delimiter = "|"
Expand Down Expand Up @@ -94,10 +94,10 @@ def defineCharacteristics(self):
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(self.JOINATTRIBUTE,
"Layer attribute field", mmqgisx_attribute_join_algorithm.LAYERNAME))

self.addParameter(ParameterTable(self.INFILENAME, "Table to join", False))
self.addParameter(ParameterTableField(self.JOINFIELD, "Table field", self.INFILENAME))


self.addOutput(OutputVector(self.OUTFILENAME, "Output"))
self.addOutput(OutputTable(self.NOTFOUNDNAME, "Not Found CSV Output List"))
Expand Down Expand Up @@ -148,7 +148,7 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))

column = self.getParameterValue(self.COLUMN)
savename = self.getOutputValue(self.SAVENAME)
Expand Down Expand Up @@ -181,7 +181,7 @@ def processAlgorithm(self, progress):
from sextante.core.Sextante import Sextante
qgis = Sextante.getInterface()

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))

savename = self.getOutputValue(self.SAVENAME)

Expand Down Expand Up @@ -266,7 +266,7 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
savename = self.getOutputValue(self.SAVENAME)

index = self.getParameterValue(self.NEWTYPE)
Expand Down Expand Up @@ -422,7 +422,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.GRIDTYPE, "Grid type",
self.gridtype_options, default = 0))
self.addOutput(OutputVector(self.SAVENAME, "Output"))

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_grid.png")
Expand Down Expand Up @@ -469,7 +469,7 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
hspacing = self.getParameterValue(self.HSPACING)
vspacing = self.getParameterValue(self.VSPACING)
savename = self.getOutputValue(self.SAVENAME)
Expand Down Expand Up @@ -581,7 +581,7 @@ def defineCharacteristics(self):
#===========================================================================

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))

labelattribute = self.getParameterValue(self.LABELATTRIBUTE)

Expand Down Expand Up @@ -648,12 +648,12 @@ def defineCharacteristics(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_export.png")
#===========================================================================

def processAlgorithm(self, progress):
def processAlgorithm(self, progress):

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))

attribute = self.getParameterValue(self.ATTRIBUTE)
comparison = self.comparisons [ self.getParameterValue(self.COMPARISON) ]
comparison = self.comparisons [ self.getParameterValue(self.COMPARISON) ]
comparisonvalue = self.getParameterValue(self.COMPARISONVALUE)
savename = self.getOutputValue(self.SAVENAME)

Expand Down Expand Up @@ -686,7 +686,7 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))

attribute = self.getParameterValue(self.ATTRIBUTE)
direction = self.directions [ self.getParameterValue(self.DIRECTION) ]
Expand Down
60 changes: 30 additions & 30 deletions python/plugins/sextante/algs/mmqgisx/mmqgisx_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,18 @@ def mmqgisx_attribute_export(progress, outfilename, layer, attribute_names, fiel
i = 0
layer.dataProvider().select(layer.dataProvider().attributeIndexes())
layer.dataProvider().rewind()
while layer.dataProvider().nextFeature(feature):
while layer.dataProvider().nextFeature(feature):
progress.setPercentage(float(i) / feature_count * 100)
attributes = feature.attributeMap()

row = []
for column in attribute_indices:
row.append(unicode(attributes[column].toString()).encode("iso-8859-1"))
row.append(unicode(attributes[column].toString()).encode("iso-8859-1"))

writer.writerow(row)
i+=1

del writer
del writer

return None

Expand Down Expand Up @@ -421,7 +421,7 @@ def mmqgisx_delete_columns(progress, layer, columns, savename, addlayer):
return "Failure creating output shapefile: " + unicode(outfile.errorMessage())


# Write the features with modified attributes
# Write the features with modified attributes
featurecount = layer.dataProvider().featureCount();
layer.dataProvider().select(layer.dataProvider().attributeIndexes())
layer.dataProvider().rewind()
Expand Down Expand Up @@ -665,14 +665,14 @@ def mmqgisx_geometry_convert(progress, layer, newtype, splitnodes, savename, add

# Iterate through each feature in the source layer
feature_count = layer.dataProvider().featureCount()

layer.dataProvider().select(layer.dataProvider().attributeIndexes())
layer.dataProvider().rewind()
features = QGisLayers.features(layer)
i = 0
for feature in features:
i += 1
progress.setPercentage(float(i) / feature_count * 100)
i += 1
progress.setPercentage(float(i) / feature_count * 100)

if (feature.geometry().wkbType() == QGis.WKBPoint) or \
(feature.geometry().wkbType() == QGis.WKBPoint25D):
Expand Down Expand Up @@ -950,7 +950,7 @@ def mmqgisx_geometry_import_from_csv(progress, node_filename, long_colname, lat_

if reading and (len(row) > long_col) and (len(row) > lat_col) and (len(row) > shapeid_col) \
and mmqgisx_is_float(row[long_col]) and mmqgisx_is_float(row[lat_col]):
node_count += 1
node_count += 1
point = QgsPoint(float(row[long_col]), float(row[lat_col]))
else:
point = False
Expand Down Expand Up @@ -1213,8 +1213,8 @@ def mmqgisx_gridify_layer(progress, layer, hspacing, vspacing, savename, addlaye
layer.dataProvider().rewind()

features = QGisLayers.features(layer)
for feature in features:
progress.setPercentage(float(feature_number) / feature_count * 100)
for feature in features:
progress.setPercentage(float(feature_number) / feature_count * 100)
geometry = feature.geometry()

if geometry.wkbType() == QGis.WKBPoint:
Expand Down Expand Up @@ -1365,16 +1365,16 @@ def mmqgisx_hub_distance(progress, sourcelayer, hubslayer, nameattributename, un


# Create array of hubs in memory
hubs = []
hubs = []
hubslayer.dataProvider().select(hubslayer.dataProvider().attributeIndexes())
hubslayer.dataProvider().rewind()
features = QGisLayers.features(hubslayer)
for feature in features:
for feature in features:
hubs.append(mmqgisx_hub(feature.geometry().boundingBox().center(), \
feature.attributeMap()[nameindex].toString()))

del hubslayer

featureCount = sourcelayer.dataProvider().featureCount()

# Scan source points, find nearest hub, and write to output file
Expand Down Expand Up @@ -1430,10 +1430,10 @@ def mmqgisx_hub_distance(progress, sourcelayer, hubslayer, nameattributename, un
outfile.addFeature(outfeature)

writecount += 1
progress.setPercentage(float(writecount) / featureCount * 100)
progress.setPercentage(float(writecount) / featureCount * 100)

del outfile

return None

# --------------------------------------------------------
Expand Down Expand Up @@ -1491,14 +1491,14 @@ def mmqgisx_hub_lines(progress, hublayer, hubattr, spokelayer, spokeattr, savena
i += 1
spokex = spokepoint.geometry().boundingBox().center().x()
spokey = spokepoint.geometry().boundingBox().center().y()
spokeid = unicode(spokepoint.attributeMap()[spokeindex].toString())
spokeid = unicode(spokepoint.attributeMap()[spokeindex].toString())
progress.setPercentage(float(i) / len(spokepoints) * 100)
# Scan hub points to find first matching hub
hubpoint = QgsFeature()
hublayer.dataProvider().select(hublayer.dataProvider().attributeIndexes())
hublayer.dataProvider().rewind()
hubpoints = QGisLayers.features(hublayer)
for hubpoint in hubpoints:
for hubpoint in hubpoints:
hubid = unicode(hubpoint.attributeMap()[hubindex].toString())
if hubid == spokeid:
hubx = hubpoint.geometry().boundingBox().center().x()
Expand Down Expand Up @@ -1565,7 +1565,7 @@ def mmqgisx_label_point(progress, layer, labelattributename, savename, addlayer)
return "Failure creating output shapefile: " + unicode(outfile.errorMessage())

# Build dictionary of items, averaging center for multi-feature items
features = {}
features = {}
readcount = 0
feature_count = layer.featureCount()
layer.dataProvider().select(layer.dataProvider().attributeIndexes())
Expand Down Expand Up @@ -1605,7 +1605,7 @@ def mmqgisx_label_point(progress, layer, labelattributename, savename, addlayer)
return "Failure writing feature to shapefile"

writecount += 1
progress.setPercentage(float(writecount) / len(features) * 100)
progress.setPercentage(float(writecount) / len(features) * 100)

del outfile

Expand Down Expand Up @@ -1664,23 +1664,23 @@ def mmqgisx_merge(progress, layers, savename, addlayer):

# Copy layer features to output file
featurecount = 0
for layer in layers:
for layer in layers:
layer.dataProvider().select(layer.dataProvider().attributeIndexes())
layer.dataProvider().rewind()
idx = {}
for dindex, dfield in fields.iteritems():
for dindex, dfield in fields.iteritems():
for sindex, sfield in layer.dataProvider().fields().iteritems():
if (sfield.name() == dfield.name()) and (sfield.type() == dfield.type()):
idx[dindex] = sindex
features = QGisLayers.features(layer)
for feature in features:
sattributes = feature.attributeMap()
dattributes = {}
for dindex, dfield in fields.iteritems():
for dindex, dfield in fields.iteritems():
if (dindex in idx):
dattributes[dindex] = sattributes[idx[dindex]]
else:
dattributes[dindex] = QVariant(dfield.type())
dattributes[dindex] = QVariant(dfield.type())
feature.setAttributeMap(dattributes)
outfile.addFeature(feature)
featurecount += 1
Expand All @@ -1694,8 +1694,8 @@ def mmqgisx_merge(progress, layers, savename, addlayer):
# mmqgisx_select - Select features by attribute
# ----------------------------------------------------------

def mmqgisx_select(progress, layer, selectattributename, comparisonvalue, comparisonname, savename, addlayer):
def mmqgisx_select(progress, layer, selectattributename, comparisonvalue, comparisonname, savename, addlayer):

selectindex = layer.dataProvider().fieldNameIndex(selectattributename)
if selectindex < 0:
return "Invalid select field name: " + selectattributename
Expand Down Expand Up @@ -1756,11 +1756,11 @@ def mmqgisx_select(progress, layer, selectattributename, comparisonvalue, compar
if (match):
outfile.addFeature(feature)
writecount += 1

progress.setPercentage(float(readcount) / totalcount * 100)

del outfile

return None

# --------------------------------------------------------
Expand Down Expand Up @@ -1789,7 +1789,7 @@ def mmqgisx_sort(progress, layer, sortattributename, savename, direction, addlay
if (outfile.hasError() != QgsVectorFileWriter.NoError):
return "Failure creating output shapefile: " + unicode(outfile.errorMessage())

table = []
table = []
layer.dataProvider().select(layer.dataProvider().attributeIndexes())
layer.dataProvider().rewind()
features = QGisLayers.features(layer)
Expand Down Expand Up @@ -1817,7 +1817,7 @@ def mmqgisx_sort(progress, layer, sortattributename, savename, direction, addlay
progress.setPercentage(float(writecount)/len(table) * 100)

del outfile

return None

# --------------------------------------------------------
Expand All @@ -1827,7 +1827,7 @@ def mmqgisx_sort(progress, layer, sortattributename, savename, direction, addlay

def mmqgisx_geocode_street_layer(qgis, layername, csvname, addressfield, shapefilename, streetname,
fromx, fromy, tox, toy, leftfrom, rightfrom, leftto, rightto, setback, notfoundfile, addlayer):

if layer == None:
return "Address layer not found: " + layername

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/core/QGisLayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ def getAllLayers():
def getTables():
layers = QGisLayers.iface.legendInterface().layers()
tables = list()
for layer in layers:
for layer in layers:
if layer.type() == layer.VectorLayer :
uri = unicode(layer.source())
if uri.lower().endswith("csv") or uri.lower().endswith("dbf") or uri.lower().endswith("shp"):
tables.append(layer)
tables.append(layer)
return tables

@staticmethod
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/core/SextanteTableWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
class SextanteTableWriter:

def __init__(self, fileName, encoding, fields):
self.fileName = fileName
self.fileName = fileName
self.writer = None

if encoding is None:
settings = QSettings()
encoding = settings.value("/SextanteQGIS/encoding", "System").toString()

if fileName.endswith("csv"):
fileName += ".csv"
fileName += ".csv"
file = open(fileName, "w")
file.write(";".join(field.name() for field in fields))
file.write("\n")
file.close()

def addFeature(self, values):
def addFeature(self, values):
file = open(self.fileName, "a")
file.write(";".join([value.toString() for value in values]))
file.write("\n")
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/gdal/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def defineCharacteristics(self):
self.addOutput(OutputRaster(translate.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):

out = self.getOutputValue(translate.OUTPUT)
outsize = str(self.getParameterValue(translate.OUTSIZE))
outsizePerc = str(self.getParameterValue(translate.OUTSIZE_PERC))
Expand All @@ -78,15 +78,15 @@ def processAlgorithm(self, progress):
srs = str(self.getParameterValue(translate.SRS))
sds = str(self.getParameterValue(translate.SDS))
extra = str(self.getParameterValue(translate.EXTRA))

commands = ["gdal_translate"]
commands.append("-of")
commands.append(GdalUtils.getFormatShortNameFromFilename(out))
if outsizePerc == "True":
outsizeStr = "-outsize "+outsize+"% "+outsize+"%"
else:
outsizeStr = "-outsize "+outsize+" "+outsize
commands.append(outsizeStr)
commands.append(outsizeStr)
commands.append("-a_nodata "+noData)
if expand != "none":
commands.append("-expand "+expand)
Expand Down
44 changes: 22 additions & 22 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def defineCharacteristicsFromFile(self):
param.isAdvanced = True
self.addParameter(param)
else:
output = OutputFactory.getFromString(line)
self.addOutput(output);
output = OutputFactory.getFromString(line)
self.addOutput(output);
if isinstance(output, OutputRaster):
hasRasterOutput = True
hasRasterOutput = True
line = lines.readline().strip("\n").strip()
except Exception,e:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + self.descriptionFile + "\n" + line)
Expand Down Expand Up @@ -231,7 +231,7 @@ def processAlgorithm(self, progress):
commands.append(self.exportVectorLayer(layer))

self.setSessionProjectionFromProject(commands)

region = str(self.getParameterValue(self.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(",")
command = "g.region"
Expand All @@ -241,10 +241,10 @@ def processAlgorithm(self, progress):
command +=" w=" + str(regionCoords[0])
cellsize = self.getParameterValue(self.GRASS_REGION_CELLSIZE_PARAMETER)
if cellsize:
command +=" res=" + str(cellsize);
command +=" res=" + str(cellsize);
else:
command +=" res=" + str(self.getDefaultCellsize())

commands.append(command)

#2: set parameters and outputs
Expand Down Expand Up @@ -273,7 +273,7 @@ def processAlgorithm(self, progress):
idx = int(param.value)
command+=(" " + param.name + "=" + str(param.options[idx]));
elif isinstance(param, ParameterSelection):
command+=(" " + param.name + "=" + str(param.value));
command+=(" " + param.name + "=" + str(param.value));
else:
command+=(" " + param.name + "=" + str(param.value));

Expand Down Expand Up @@ -323,24 +323,24 @@ def processAlgorithm(self, progress):
progress.setCommand(line)
loglines.append(line)
if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_COMMANDS):
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
self.consoleOutput = GrassUtils.executeGrass(commands, progress, outputCommands);
self.postProcessResults();
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
self.consoleOutput = GrassUtils.executeGrass(commands, progress, outputCommands);
self.postProcessResults();
# if the session has been created outside of this algorithm, add the new GRASS layers to it
# otherwise finish the session
if existingSession:
GrassUtils.addSessionLayers(self.exportedLayers)
else:
GrassUtils.endGrassSession()

def postProcessResults(self):
def postProcessResults(self):
name = self.commandLineName().replace('.','_')[len('grass:'):]
try:
try:
module = importlib.import_module('sextante.grass.ext.' + name)
except ImportError:
except ImportError:
return
if hasattr(module, 'postProcessResults'):
func = getattr(module,'postProcessResults')
if hasattr(module, 'postProcessResults'):
func = getattr(module,'postProcessResults')
func(self)

def exportVectorLayer(self, orgFilename):
Expand Down Expand Up @@ -372,8 +372,8 @@ def exportVectorLayer(self, orgFilename):
return command

def setSessionProjectionFromProject(self, commands):
if not GrassUtils.projectionSet:
from sextante.core.Sextante import Sextante
if not GrassUtils.projectionSet:
from sextante.core.Sextante import Sextante
qgis = Sextante.getInterface()
proj4 = qgis.mapCanvas().mapRenderer().destinationCrs().toProj4()
command = "g.proj"
Expand Down Expand Up @@ -411,14 +411,14 @@ def getTempFilename(self):

def commandLineName(self):
return "grass:" + self.name[:self.name.find(" ")]

def checkParameterValuesBeforeExecuting(self):
name = self.commandLineName().replace('.','_')[len('grass:'):]
try:
try:
module = importlib.import_module('sextante.grass.ext.' + name)
except ImportError:
except ImportError:
return
if hasattr(module, 'checkParameterValuesBeforeExecuting'):
func = getattr(module,'checkParameterValuesBeforeExecuting')
if hasattr(module, 'checkParameterValuesBeforeExecuting'):
func = getattr(module,'checkParameterValuesBeforeExecuting')
return func(self)

9 changes: 4 additions & 5 deletions python/plugins/sextante/grass/ext/HtmlReportPostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

def postProcessResults(alg):
def postProcessResults(alg):
htmlFile = alg.getOutputFromName('html').value
grassName = alg.grassName
grassName = alg.grassName
found = False
f = open(htmlFile, "w")
f.write("<h2>" + grassName + "</h2>\n")
f.write("<h2>" + grassName + "</h2>\n")
for line in alg.consoleOutput:
if found and not line.strip().endswith('exit'):
f.write(line + "<br>\n")
if grassName in line and not line.startswith("GRASS"):
found = True
found = True
f.close()

3 changes: 1 addition & 2 deletions python/plugins/sextante/grass/ext/r_coin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)

5 changes: 2 additions & 3 deletions python/plugins/sextante/grass/ext/r_covar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)



3 changes: 1 addition & 2 deletions python/plugins/sextante/grass/ext/r_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)

4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/ext/r_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)

4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/ext/r_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)

5 changes: 2 additions & 3 deletions python/plugins/sextante/grass/ext/r_regression_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)



3 changes: 1 addition & 2 deletions python/plugins/sextante/grass/ext/v_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)

4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/ext/v_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)

5 changes: 2 additions & 3 deletions python/plugins/sextante/grass/ext/v_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)



3 changes: 1 addition & 2 deletions python/plugins/sextante/grass/ext/v_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)

2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/ext/v_univar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@

from sextante.grass.ext import HtmlReportPostProcessor

def postProcessResults(alg):
def postProcessResults(alg):
HtmlReportPostProcessor.postProcessResults(alg)
10 changes: 5 additions & 5 deletions python/plugins/sextante/grass/nviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def defineCharacteristics(self):
self.addParameter(ParameterMultipleInput(nviz.VECTOR, "Vector layers", ParameterMultipleInput.TYPE_VECTOR_ANY, True))
self.addParameter(ParameterExtent(nviz.GRASS_REGION_EXTENT_PARAMETER, "GRASS region extent"))
self.addParameter(ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER, "GRASS region cellsize (leave 0 for default)", 0, None, 0.0))

def processAlgorithm(self, progress):
commands = []
vector = self.getParameterValue(self.VECTOR);
elevation = self.getParameterValue(self.ELEVATION);

region = str(self.getParameterValue(self.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(",")
command = "g.region "
Expand All @@ -68,11 +68,11 @@ def processAlgorithm(self, progress):
command +=" w=" + str(regionCoords[0])
cellsize = self.getParameterValue(self.GRASS_REGION_CELLSIZE_PARAMETER)
if cellsize:
command +=" res=" + str(cellsize);
command +=" res=" + str(cellsize);
else:
command +=" res=" + str(self.getDefaultCellsize())
commands.append(command)

command = "nviz"
if vector:
layers = vector.split(";")
Expand Down Expand Up @@ -116,7 +116,7 @@ def exportRasterLayer(self, layer):
command +=" out=" + destFilename;
command +=" --overwrite -o"
return command, destFilename

def getDefaultCellsize(self):
cellsize = 0
for param in self.parameters:
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 @@ -191,7 +191,7 @@ def setParamValue(self, param, widget):
value.append(options[index])
return param.setValue(value)
elif isinstance(param, (ParameterNumber, ParameterFile, ParameterCrs, ParameterExtent)):
return param.setValue(widget.getValue())
return param.setValue(widget.getValue())
elif isinstance(param, ParameterString):
if param.multiline:
return param.setValue(unicode(widget.toPlainText()))
Expand Down Expand Up @@ -301,7 +301,7 @@ def error(self, msg):
#self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
self.setInfo(msg, True)
self.setInfo(msg, True)
if not keepOpen:
QMessageBox.critical(self, "Error", msg)
self.close()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/FileSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def showSelectionDialog(self):
path = str(settings.value( "/SextanteQGIS/LastInputPath",QtCore.QVariant( "" ) ).toString())
else:
path = ""

if self.isFolder:
folder = QtGui.QFileDialog.getExistingDirectory (self, "Select folder", path)
if folder:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/InputLayerSelectorPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def showSelectionDialog(self):
path = str(settings.value( "/SextanteQGIS/LastInputPath",QtCore.QVariant( "" ) ).toString())
else:
path = ""

filename = QtGui.QFileDialog.getOpenFileName(self, "All files", path, "*.*")
if filename:
self.text.addItem(filename, filename)
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def prepareAlgorithm(self, alg, iAlg):
aap = self.algParameters[iAlg][param.name]
if aap == None:
if isinstance(param, ParameterExtent):
value = self.getValueFromAlgorithmAndParameter(aap)
value = self.getValueFromAlgorithmAndParameter(aap)
if value is None:
value = self.getMinCoveringExtent()
if not param.setValue(value):
Expand All @@ -365,7 +365,7 @@ def prepareAlgorithm(self, alg, iAlg):
value = ";".join(layerslist)
if not param.setValue(value):
raise GeoAlgorithmExecutionException("Wrong value: " + str(value))

else:
value = self.getValueFromAlgorithmAndParameter(aap)
if not param.setValue(value):
Expand Down Expand Up @@ -417,14 +417,14 @@ def addToRegion(self, layer, first):
self.ymin = min(self.ymin, layer.extent().yMinimum())
self.ymax = max(self.ymax, layer.extent().yMaximum())


def getSafeNameForOutput(self, ialg, out):
return out.name +"_ALG" + str(ialg)


def getValueFromAlgorithmAndParameter(self, aap):
if aap is None:
return None
return None
if float(aap.alg) == float(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM):
for key in self.paramValues.keys():
if aap.param == key:
Expand Down
30 changes: 15 additions & 15 deletions python/plugins/sextante/modeler/ModelerParameterDefinitionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def setupUi(self):
self.yesNoCombo = QtGui.QComboBox()
self.yesNoCombo.addItem("Yes")
self.yesNoCombo.addItem("No")
if self.param is not None:
self.yesNoCombo.setCurrentIndex(0 if self.param.value else 1)
if self.param is not None:
self.yesNoCombo.setCurrentIndex(0 if self.param.value else 1)
self.horizontalLayout2.addWidget(self.yesNoCombo)
self.verticalLayout.addLayout(self.horizontalLayout2)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD \
Expand All @@ -110,7 +110,7 @@ def setupUi(self):
if self.param is not None:
if self.param.parent == param.name:
self.parentCombo.setCurrentIndex(idx)
idx += 1
idx += 1
self.horizontalLayout2.addWidget(self.parentCombo)
self.verticalLayout.addLayout(self.horizontalLayout2)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER \
Expand All @@ -119,8 +119,8 @@ def setupUi(self):
self.yesNoCombo = QtGui.QComboBox()
self.yesNoCombo.addItem("Yes")
self.yesNoCombo.addItem("No")
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
self.horizontalLayout2.addWidget(self.yesNoCombo)
self.verticalLayout.addLayout(self.horizontalLayout2)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE \
Expand All @@ -129,25 +129,25 @@ def setupUi(self):
self.yesNoCombo = QtGui.QComboBox()
self.yesNoCombo.addItem("Yes")
self.yesNoCombo.addItem("No")
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
self.horizontalLayout2.addWidget(self.yesNoCombo)
self.verticalLayout.addLayout(self.horizontalLayout2)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR \
or isinstance(self.param, ParameterVector):
self.horizontalLayout2.addWidget(QtGui.QLabel("Required"))
self.yesNoCombo = QtGui.QComboBox()
self.yesNoCombo.addItem("Yes")
self.yesNoCombo.addItem("No")
self.yesNoCombo.addItem("No")
self.horizontalLayout2.addWidget(self.yesNoCombo)
self.horizontalLayout3.addWidget(QtGui.QLabel("Shape type"))
self.shapetypeCombo = QtGui.QComboBox()
self.shapetypeCombo.addItem("Any")
self.shapetypeCombo.addItem("Point")
self.shapetypeCombo.addItem("Line")
self.shapetypeCombo.addItem("Polygon")
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
self.shapetypeCombo.setCurrentIndex(self.param.shapetype + 1)
self.horizontalLayout3.addWidget(self.shapetypeCombo)
self.verticalLayout.addLayout(self.horizontalLayout3)
Expand All @@ -167,8 +167,8 @@ def setupUi(self):
self.datatypeCombo.addItem("Vector (polygon)")
self.datatypeCombo.addItem("Raster")
self.datatypeCombo.addItem("Table")
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
if self.param is not None:
self.yesNoCombo.setCurrentIndex(1 if self.param.optional else 0)
self.datatypeCombo.setCurrentIndex(self.param.datatype + 1)
self.horizontalLayout3.addWidget(self.datatypeCombo)
self.verticalLayout.addLayout(self.horizontalLayout3)
Expand All @@ -184,16 +184,16 @@ def setupUi(self):
self.horizontalLayout3.addWidget(QtGui.QLabel("Default value"))
self.defaultTextBox = QtGui.QLineEdit()
self.defaultTextBox.setText("0")
if self.param is not None:
if self.param is not None:
self.defaultTextBox.setText(self.param.default)
self.horizontalLayout3.addWidget(self.defaultTextBox)
self.verticalLayout.addLayout(self.horizontalLayout3)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING \
or isinstance(self.param, ParameterString):
self.horizontalLayout2.addWidget(QtGui.QLabel("Default value"))
self.defaultTextBox = QtGui.QLineEdit()
if self.param is not None:
self.defaultTextBox.setText(self.param.default)
if self.param is not None:
self.defaultTextBox.setText(self.param.default)
self.minTextBox.setText(self.param.min if self.param.min is not None else "")
self.maxTextBox.setText(self.param.max if self.param.max is not None else "")
self.horizontalLayout2.addWidget(self.defaultTextBox)
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def getExtents(self):
params = self.model.parameters
for param in params:
if isinstance(param, ParameterExtent):
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
return extents

def getNumbers(self):
Expand Down Expand Up @@ -412,10 +412,10 @@ def getWidgetFromParameter(self, param):
item = QtGui.QComboBox()
item.setEditable(True)
extents = self.getExtents()
if self.canUseAutoExtent():
if self.canUseAutoExtent():
item.addItem(self.USE_MIN_COVERING_EXTENT, None)
for ex in extents:
item.addItem(ex.name(), ex)
item.addItem(ex.name(), ex)
if not self.canUseAutoExtent():
item.setEditText(str(param.default))
elif isinstance(param, ParameterFile):
Expand All @@ -438,7 +438,7 @@ def canUseAutoExtent(self):
return True
if isinstance(param, ParameterMultipleInput):
return True

def setTableContent(self):
params = self.alg.parameters
outputs = self.alg.outputs
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/outputs/OutputTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ def getFileFilter(self,alg):

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

def getCompatibleFileName(self, alg):
#TODO!!!
return self.value

def getTableWriter(self, fields):
'''Returns a suitable writer to which records can be added as a
result of the algorithm. Use this to transparently handle output
values instead of creating your own method.

@param fields a dict of int-QgsField

@return writer instance of the table writer class
'''

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def deserialize(self, s):
if len(tokens) == 4:
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True), tokens[3] == str(True))
else:
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True))
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True))

def getAsScriptCode(self):
if self.isFolder:
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/parameters/ParameterNumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, name="", description="", minValue = None, maxValue = None, de
except:
self.default = default
self.isInteger = False
self.min = minValue
self.min = minValue
self.max = maxValue
self.value = None

Expand All @@ -51,9 +51,9 @@ def setValue(self, n):
if (float(n) - int(float(n)) == 0):
value = int(float(n))
else:
value = float(n)
value = float(n)
if self.min is not None:
if value < self.min:
if value < self.min:
return False
if self.max is not None:
if value > self.max:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterString.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from sextante.parameters.Parameter import Parameter

class ParameterString(Parameter):

NEWLINE = "\n"
ESCAPED_NEWLINE = "\\n"

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def processAlgorithm(self, progress):
if SextanteUtils.isWindows():
path = SagaUtils.sagaPath()
if path == "":
raise GeoAlgorithmExecutionException("SAGA folder is not configured.\nPlease configure it before running SAGA algorithms.")
raise GeoAlgorithmExecutionException("SAGA folder is not configured.\nPlease configure it before running SAGA algorithms.")
commands = list()
self.exportedLayers = {}

Expand Down
6 changes: 3 additions & 3 deletions scripts/context_help_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@

This script generates a unique context id based for use in the QGIS
context sensitive help system. It uses the SHA1 hash for the class name
and converts the first 12 characters to a unique integer.
and converts the first 12 characters to a unique integer.

To create a context id, pass the name of the QGIS class on the command line.
Example:
./context_help_id.py QgsAbout

This script requires Python 2.5 or higher (hashlib was introduced at 2.5).

NOTE: Due to a change in the way context ids are generated, ids
NOTE: Due to a change in the way context ids are generated, ids
generated by the old method (Java hashCode function) will be different than
the id generated by the new method for the same class.
the id generated by the new method for the same class.
"""
import hashlib
import sys
Expand Down
9 changes: 9 additions & 0 deletions scripts/prepare-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ for f in $MODIFIED; do
*.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H)
;;

*.py)
perl -i.prepare -pe "s/[\t ]+$//;" $f
if diff -u $f.prepare $f >>$ASTYLEDIFF; then
# no difference found
rm $f.prepare
fi
continue
;;

*)
continue
;;
Expand Down
6 changes: 2 additions & 4 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SET(QGIS_APP_SRCS
main.cpp
qgisapp.cpp
qgisappinterface.cpp
qgisappstylesheet.cpp
qgsabout.cpp
qgssponsors.cpp
qgsaddattrdialog.cpp
Expand Down Expand Up @@ -167,6 +168,7 @@ ENDIF (ANDROID)
SET (QGIS_APP_MOC_HDRS
qgisapp.h
qgisappinterface.h
qgisappstylesheet.h
qgsabout.h
qgsaddattrdialog.h
qgsaddjoindialog.h
Expand Down Expand Up @@ -501,10 +503,6 @@ IF (POSTGRES_FOUND)
TARGET_LINK_LIBRARIES (${QGIS_APP_NAME} ${POSTGRES_LIBRARY})
ENDIF (POSTGRES_FOUND)

IF (SPATIALITE_FOUND)
TARGET_LINK_LIBRARIES (${QGIS_APP_NAME} ${SPATIALITE_LIBRARY})
ENDIF (SPATIALITE_FOUND)

IF(MSVC)
INSTALL(FILES qgis.ico DESTINATION ${CMAKE_INSTALL_PREFIX}/icons)
ENDIF(MSVC)
Expand Down
18 changes: 3 additions & 15 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( close() ) );

QSettings settings;
setAppStyleSheet();
setStyleSheet( QgisApp::instance()->styleSheet() );

int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt();
setIconSize( QSize( size, size ) );
Expand Down Expand Up @@ -394,18 +394,6 @@ void QgsComposer::setIconSizes( int size )
}
}

void QgsComposer::setFontSize( int fontSize )
{
//Convenience method for backwards compatibility
//Should set directly for QgisApp instead
QgisApp::instance()->setFontSize( fontSize );
}

void QgsComposer::setAppStyleSheet()
{
setStyleSheet( QgisApp::instance()->styleSheet() );
}

void QgsComposer::connectSlots()
{
connect( mView, SIGNAL( selectedItemChanged( QgsComposerItem* ) ), this, SLOT( showItemOptions( QgsComposerItem* ) ) );
Expand Down Expand Up @@ -705,8 +693,8 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
{
outputFileName = QDir( outputDir ).filePath( atlasMap->currentFilename() ) + ".pdf";
mComposition->beginPrintAsPDF( printer, outputFileName );
// set the correct resolution
mComposition->beginPrint( printer );
// set the correct resolution
mComposition->beginPrint( printer );
painter.begin( &printer );
mComposition->doPrint( printer, painter );
painter.end();
Expand Down
4 changes: 0 additions & 4 deletions src/app/composer/qgscomposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
void setupTheme();

void setIconSizes( int size );
void setFontSize( int size );
//! Set app stylesheet from main app
//! @note added in 2.0
void setAppStyleSheet();

//! Open and show, set defaults if first time
void open();
Expand Down
21 changes: 21 additions & 0 deletions src/app/composer/qgscompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )
mPrintAsRasterCheckBox->setCheckState( Qt::Unchecked );
}

mAlignmentSnapCheckBox->setCheckState( mComposition->alignmentSnap() ? Qt::Checked : Qt::Unchecked );
mAlignmentToleranceSpinBox->setValue( mComposition->alignmentSnapTolerance() );

//snap grid
if ( mComposition->snapToGridEnabled() )
{
Expand Down Expand Up @@ -524,6 +527,22 @@ void QgsCompositionWidget::on_mSelectionToleranceSpinBox_valueChanged( double d
}
}

void QgsCompositionWidget::on_mAlignmentSnapCheckBox_stateChanged( int state )
{
if ( mComposition )
{
mComposition->setAlignmentSnap( state == Qt::Checked ? true : false );
}
}

void QgsCompositionWidget::on_mAlignmentToleranceSpinBox_valueChanged( double d )
{
if ( mComposition )
{
mComposition->setAlignmentSnapTolerance( d );
}
}

void QgsCompositionWidget::blockSignals( bool block )
{
mPaperSizeComboBox->blockSignals( block );
Expand All @@ -542,4 +561,6 @@ void QgsCompositionWidget::blockSignals( bool block )
mGridColorButton->blockSignals( block );
mGridStyleComboBox->blockSignals( block );
mSelectionToleranceSpinBox->blockSignals( block );
mAlignmentSnapCheckBox->blockSignals( block );
mAlignmentToleranceSpinBox->blockSignals( block );
}
2 changes: 2 additions & 0 deletions src/app/composer/qgscompositionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
void on_mGridStyleComboBox_currentIndexChanged( const QString& text );
void on_mPenWidthSpinBox_valueChanged( double d );
void on_mSelectionToleranceSpinBox_valueChanged( double d );
void on_mAlignmentSnapCheckBox_stateChanged( int state );
void on_mAlignmentToleranceSpinBox_valueChanged( double d );

/**Sets GUI elements to width/height from composition*/
void displayCompositionWidthHeight();
Expand Down
116 changes: 60 additions & 56 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@

#include "qgisapp.h"
#include "qgisappinterface.h"
#include "qgisappstylesheet.h"
#include "qgis.h"
#include "qgisplugin.h"
#include "qgsabout.h"
Expand Down Expand Up @@ -464,7 +465,12 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
qApp->processEvents();

QSettings settings;
setAppStyleSheet();

// set up stylesheet builder and apply saved or default style options
mStyleSheetBuilder = new QgisAppStyleSheet( this );
connect( mStyleSheetBuilder, SIGNAL( appStyleSheetChanged( const QString& ) ),
this, SLOT( setAppStyleSheet( const QString& ) ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetBuilder->defaultOptions() );

QWidget *centralWidget = this->centralWidget();
QGridLayout *centralLayout = new QGridLayout( centralWidget );
Expand Down Expand Up @@ -525,12 +531,17 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mSnappingDialog = new QgsSnappingDialog( this, mMapCanvas );
mSnappingDialog->setObjectName( "SnappingOption" );

mBrowserWidget = new QgsBrowserDockWidget( this );
mBrowserWidget = new QgsBrowserDockWidget( tr( "Browser" ), this );
mBrowserWidget->setObjectName( "Browser" );
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget );
mBrowserWidget->hide();

// create the GPS tool on starting QGIS - this is like the Browser
mBrowserWidget2 = new QgsBrowserDockWidget( tr( "Browser (2)" ), this );
mBrowserWidget2->setObjectName( "Browser2" );
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget2 );
mBrowserWidget2->hide();

// create the GPS tool on starting QGIS - this is like the browser
mpGpsWidget = new QgsGPSInformationWidget( mMapCanvas );
//create the dock widget
mpGpsDock = new QDockWidget( tr( "GPS Information" ), this );
Expand Down Expand Up @@ -712,6 +723,7 @@ QgisApp::~QgisApp()
{
delete mInternalClipboard;
delete mQgisInterface;
delete mStyleSheetBuilder;

delete mMapTools.mZoomIn;
delete mMapTools.mZoomOut;
Expand Down Expand Up @@ -833,6 +845,11 @@ bool QgisApp::event( QEvent * event )
return done;
}

QgisAppStyleSheet* QgisApp::styleSheetBuilder()
{
Q_ASSERT( mStyleSheetBuilder );
return mStyleSheetBuilder;
}

// restore any application settings stored in QSettings
void QgisApp::readSettings()
Expand Down Expand Up @@ -1170,53 +1187,23 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionChangeLabelProperties );
}

void QgisApp::setFontSize( int fontSize )
{
if ( fontSize < 4 || 99 < fontSize ) // defaults for Options spinbox
{
return;
}
QSettings settings;
settings.setValue( "/fontPointSize", fontSize );
setAppStyleSheet();
}

void QgisApp::setFontFamily( const QString& fontFamily )
void QgisApp::setAppStyleSheet( const QString& stylesheet )
{
QSettings settings;
settings.setValue( "/fontFamily", fontFamily );
setAppStyleSheet();
}

void QgisApp::setAppStyleSheet()
{
QSettings settings;
int fontSize = settings.value( "/fontPointSize", QGIS_DEFAULT_FONTSIZE ).toInt();

QString fontFamily = settings.value( "/fontFamily", QVariant( "QtDefault" ) ).toString();

QString family = QString( "" ); // use default Qt font family
if ( fontFamily != "QtDefault" )
{
QFont *tempFont = new QFont( fontFamily );
// is exact family match returned from system?
if ( tempFont->family() == fontFamily )
{
family = QString( " \"%1\";" ).arg( fontFamily );
}
delete tempFont;
}

QString stylesheet = QString( "font: %1pt%2\n" ).arg( fontSize ).arg( family );
setStyleSheet( stylesheet );

// cascade styles to any current project composers
foreach ( QgsComposer *c, mPrintComposers )
{
c->setAppStyleSheet();
c->setStyleSheet( stylesheet );
}
}

int QgisApp::messageTimeout()
{
QSettings settings;
return settings.value( "/qgis/messageTimeout", 5 ).toInt();
}

void QgisApp::createMenus()
{
/*
Expand Down Expand Up @@ -4042,7 +4029,7 @@ void QgisApp::labeling()
messageBar()->pushMessage( tr( "Labeling Options" ),
tr( "Please select a vector layer first" ),
QgsMessageBar::INFO,
5 );
messageTimeout() );
return;
}

Expand Down Expand Up @@ -5223,14 +5210,15 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
break;

case QMessageBox::Discard:
mMapCanvas->freeze( true );
if ( !vlayer->rollBack() )
{
QMessageBox::information( 0, tr( "Error" ), tr( "Problems during roll back" ) );
res = false;
}
mMapCanvas->freeze( false );

// canvas refreshes handled in QgsUndoWidget::indexChanged
//vlayer->triggerRepaint();
vlayer->triggerRepaint();
break;

default:
Expand All @@ -5239,7 +5227,9 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
}
else //layer not modified
{
mMapCanvas->freeze( true );
vlayer->rollBack();
mMapCanvas->freeze( false );
res = true;
vlayer->triggerRepaint();
}
Expand All @@ -5257,10 +5247,10 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )

void QgisApp::saveActiveLayerEdits()
{
saveEdits( activeLayer() );
saveEdits( activeLayer(), true, true );
}

void QgisApp::saveEdits( QgsMapLayer *layer, bool leaveEditable )
void QgisApp::saveEdits( QgsMapLayer *layer, bool leaveEditable, bool triggerRepaint )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( !vlayer || !vlayer->isEditable() || !vlayer->isModified() )
Expand All @@ -5283,10 +5273,13 @@ void QgisApp::saveEdits( QgsMapLayer *layer, bool leaveEditable )
{
vlayer->startEditing();
}
vlayer->triggerRepaint();
if ( triggerRepaint )
{
vlayer->triggerRepaint();
}
}

void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable )
void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable, bool triggerRepaint )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( !vlayer || !vlayer->isEditable() )
Expand All @@ -5295,6 +5288,7 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable )
if ( vlayer == activeLayer() && leaveEditable )
mSaveRollbackInProgress = true;

mMapCanvas->freeze( true );
if ( !vlayer->rollBack() )
{
mSaveRollbackInProgress = false;
Expand All @@ -5305,12 +5299,16 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable )
.arg( vlayer->name() )
.arg( vlayer->commitErrors().join( "\n " ) ) );
}
mMapCanvas->freeze( false );

if ( leaveEditable )
{
vlayer->startEditing();
}
vlayer->triggerRepaint();
if ( triggerRepaint )
{
vlayer->triggerRepaint();
}
}

void QgisApp::saveEdits()
Expand All @@ -5320,8 +5318,9 @@ void QgisApp::saveEdits()

foreach ( QgsMapLayer * layer, mMapLegend->selectedLayers() )
{
saveEdits( layer );
saveEdits( layer, true, false );
}
mMapCanvas->refresh();
activateDeactivateLayerRelatedActions( activeLayer() );
}

Expand All @@ -5338,8 +5337,9 @@ void QgisApp::saveAllEdits( bool verifyAction )

foreach ( QgsMapLayer * layer, editableLayers( true ) )
{
saveEdits( layer );
saveEdits( layer, true, false );
}
mMapCanvas->refresh();
activateDeactivateLayerRelatedActions( activeLayer() );
}

Expand All @@ -5350,8 +5350,9 @@ void QgisApp::rollbackEdits()

foreach ( QgsMapLayer * layer, mMapLegend->selectedLayers() )
{
cancelEdits( layer );
cancelEdits( layer, true, false );
}
mMapCanvas->refresh();
activateDeactivateLayerRelatedActions( activeLayer() );
}

Expand All @@ -5368,8 +5369,9 @@ void QgisApp::rollbackAllEdits( bool verifyAction )

foreach ( QgsMapLayer * layer, editableLayers( true ) )
{
cancelEdits( layer );
cancelEdits( layer, true, false );
}
mMapCanvas->refresh();
activateDeactivateLayerRelatedActions( activeLayer() );
}

Expand All @@ -5380,8 +5382,9 @@ void QgisApp::cancelEdits()

foreach ( QgsMapLayer * layer, mMapLegend->selectedLayers() )
{
cancelEdits( layer, false );
cancelEdits( layer, false, false );
}
mMapCanvas->refresh();
activateDeactivateLayerRelatedActions( activeLayer() );
}

Expand All @@ -5398,12 +5401,13 @@ void QgisApp::cancelAllEdits( bool verifyAction )

foreach ( QgsMapLayer * layer, editableLayers() )
{
cancelEdits( layer, false );
cancelEdits( layer, false, false );
}
mMapCanvas->refresh();
activateDeactivateLayerRelatedActions( activeLayer() );
}

bool QgisApp::verifyEditsActionDialog( QString act, QString upon )
bool QgisApp::verifyEditsActionDialog( const QString& act, const QString& upon )
{
bool res = false;
switch ( QMessageBox::information( 0,
Expand Down
42 changes: 27 additions & 15 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class QTcpSocket;
class QValidator;

class QgisAppInterface;
class QgisAppStyleSheet;
class QgsAnnotationItem;
class QgsClipboard;
class QgsComposer;
Expand Down Expand Up @@ -175,13 +176,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void setTheme( QString themeName = "default" );

void setIconSizes( int size );
void setFontSize( int fontSize );
//! Set app font family
//! @note added in 2.0
void setFontFamily( const QString& fontFamily );
//! Set app stylesheet from settings
//! @note added in 2.0
void setAppStyleSheet();

//! Get stylesheet builder object for app and print composers
//! @note added in 1.9
QgisAppStyleSheet* styleSheetBuilder();

//! Setup the toolbar popup menus for a given theme
void setupToolbarPopups( QString themeName );
Expand Down Expand Up @@ -398,6 +396,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
* @note added in 1.9 */
QList<QgsMapLayer *> editableLayers( bool modified = false ) const;

/** Get timeout for timed messages: default of 5 seconds
* @note added in 1.9 */
int messageTimeout();

#ifdef Q_OS_WIN
//! ugly hack
void skipNextContextMenuEvent();
Expand Down Expand Up @@ -452,12 +454,18 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
* @note added in 1.9 */
void saveActiveLayerEdits();

//! Save edits of a layer
void saveEdits( QgsMapLayer *layer, bool leaveEditable = true );
/** Save edits of a layer
* @param leaveEditable leave the layer in editing mode when done (added in QGIS 1.9)
* @param triggerRepaint send layer signal to repaint canvas when done (added in QGIS 1.9)
*/
void saveEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true );

/** Cancel edits for a layer
* @note added in 1.9 */
void cancelEdits( QgsMapLayer *layer, bool leaveEditable = true );
* @param leaveEditable leave the layer in editing mode when done
* @param triggerRepaint send layer signal to repaint canvas when done
* @note added in 1.9
*/
void cancelEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true );

//! Save current edits for selected layer(s) and start new transaction(s)
void saveEdits();
Expand Down Expand Up @@ -526,6 +534,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! project was read
void readProject( const QDomDocument & );

//! Set app stylesheet from settings
//! @note added in 1.9
void setAppStyleSheet( const QString& stylesheet );

//! request credentials for network manager
void namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *auth );
void namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth );
Expand Down Expand Up @@ -835,7 +847,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

/** Dialog for verification of action on many edits
* @note added in 1.9 */
bool verifyEditsActionDialog( QString act, QString upon );
bool verifyEditsActionDialog( const QString& act, const QString& upon );

/** Update gui actions/menus when layers are modified
* @note added in 1.9 */
Expand Down Expand Up @@ -1096,6 +1108,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
/**Do histogram stretch for singleband gray / multiband color rasters*/
void histogramStretch( bool visibleAreaOnly = false, QgsRasterLayer::ContrastEnhancementLimits theLimits = QgsRasterLayer::ContrastEnhancementMinMax );

QgisAppStyleSheet* mStyleSheetBuilder;

// actions for menus and toolbars -----------------

#ifdef Q_WS_MAC
Expand Down Expand Up @@ -1300,6 +1314,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QgsUndoWidget* mUndoWidget;

QgsBrowserDockWidget* mBrowserWidget;
QgsBrowserDockWidget* mBrowserWidget2;

QgsSnappingDialog* mSnappingDialog;

Expand Down Expand Up @@ -1342,11 +1357,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

#ifdef ANDROID
#define QGIS_ICON_SIZE 32
//TODO find a better default fontsize maybe using DPI detection or so
#define QGIS_DEFAULT_FONTSIZE 8
#else
#define QGIS_ICON_SIZE 24
#define QGIS_DEFAULT_FONTSIZE qApp->font().pointSize()
#endif

#endif
36 changes: 26 additions & 10 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QAbstractButton>

#include "qgisappinterface.h"
#include "qgisappstylesheet.h"
#include "qgisapp.h"
#include "qgscomposer.h"
#include "qgsmaplayer.h"
Expand Down Expand Up @@ -67,16 +68,6 @@ QgsLegendInterface* QgisAppInterface::legendInterface()
return &legendIface;
}

void QgisAppInterface::setFontSize( int fontSize )
{
qgis->setFontSize( fontSize );
}

void QgisAppInterface::setFontFamily( QString fontFamily )
{
qgis->setFontFamily( fontFamily );
}

void QgisAppInterface::zoomFull()
{
qgis->zoomFull();
Expand Down Expand Up @@ -299,6 +290,26 @@ QList<QgsComposerView*> QgisAppInterface::activeComposers()
return composerViewList;
}

QMap<QString, QVariant> QgisAppInterface::defaultStyleSheetOptions()
{
return qgis->styleSheetBuilder()->defaultOptions();
}

void QgisAppInterface::buildStyleSheet( const QMap<QString, QVariant>& opts )
{
qgis->styleSheetBuilder()->buildStyleSheet( opts );
}

void QgisAppInterface::saveStyleSheetOptions( const QMap<QString, QVariant>& opts )
{
qgis->styleSheetBuilder()->saveToSettings( opts );
}

QFont QgisAppInterface::defaultStyleSheetFont()
{
return qgis->styleSheetBuilder()->defaultFont();
}

void QgisAppInterface::addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget )
{
qgis->addDockWidget( area, dockwidget );
Expand Down Expand Up @@ -485,3 +496,8 @@ QList<QgsMapLayer *> QgisAppInterface::editableLayers( bool modified ) const
{
return qgis->editableLayers( modified );
}

int QgisAppInterface::messageTimeout()
{
return qgis->messageTimeout();
}
36 changes: 25 additions & 11 deletions src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ class QgisAppInterface : public QgisInterface
QgsLegendInterface* legendInterface();

/* Exposed functions */
/** Set the app font size
* @param fontSize point size of font
* @note added in 2.0
*/
void setFontSize( int fontSize );

/** Set the app font family
* @param fontFamily family of font (not including any style)
* @note added in 2.0
*/
void setFontFamily( QString fontFamily );

//! Zoom map to full extent
void zoomFull();
Expand Down Expand Up @@ -136,6 +125,27 @@ class QgisAppInterface : public QgisInterface

QList<QgsComposerView*> activeComposers();

/** Return changeable options built from settings and/or defaults
* @note (added in 1.9)
*/
QMap<QString, QVariant> defaultStyleSheetOptions();

/** Generate stylesheet
* @param opts generated default option values, or a changed copy of them
* @note added in 1.9
*/
void buildStyleSheet( const QMap<QString, QVariant>& opts );

/** Save changed default option keys/values to user settings
* @note added in 1.9
*/
void saveStyleSheetOptions( const QMap<QString, QVariant>& opts );

/** Get reference font for initial qApp (may not be same as QgisApp)
* @note added in 1.9
*/
QFont defaultStyleSheetFont();

/** Add action to the plugins menu */
void addPluginToMenu( QString name, QAction* action );
/** Remove action from the plugins menu */
Expand Down Expand Up @@ -353,6 +363,10 @@ class QgisAppInterface : public QgisInterface
* @note added in 1.9 */
virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const;

/** Get timeout for timed messages: default of 5 seconds
* @note added in 1.9 */
virtual int messageTimeout();

signals:
void currentThemeChanged( QString );

Expand Down
Loading