[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db

2012-03-20 Thread Giuseppe Sucameli
The following commit has been merged in the master branch:
commit 213138e583321648d32562c74980d6b0f0c974a4
Author: Giuseppe Sucameli brush.ty...@gmail.com
Date:   Sun Mar 11 02:30:15 2012 +0100

BuildVRT: set input layer list when tool starting (follow d6ea1a03).
Thanks Etienne for the patch.

diff --git a/python/plugins/GdalTools/tools/doBuildVRT.py 
b/python/plugins/GdalTools/tools/doBuildVRT.py
index d2483a9..d355ffe 100644
--- a/python/plugins/GdalTools/tools/doBuildVRT.py
+++ b/python/plugins/GdalTools/tools/doBuildVRT.py
@@ -47,6 +47,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
   def initialize(self):
   # connect to mapCanvas.layerChanged() signal
   self.connect(self.iface.mapCanvas(), SIGNAL(layersChanged()), 
self.onVisibleLayersChanged)
+  self.onVisibleLayersChanged()
   BasePluginWidget.initialize(self)
 
   def onClosing(self):

-- 
The Quantum GIS in Debian project

___
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel


[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db

2012-03-20 Thread Giuseppe Sucameli
The following commit has been merged in the master branch:
commit 9da5d0345ba165970a4fca5a05bb8b1bf108ad6a
Author: Etienne Tourigny etourigny@gmail.com
Date:   Thu Mar 8 23:20:10 2012 -0300

allow to use loaded layers as input files (instead of file selector) for 
GDALTools Build Virtual Raster

diff --git a/python/plugins/GdalTools/tools/doBuildVRT.py 
b/python/plugins/GdalTools/tools/doBuildVRT.py
index 67df116..9dbdca2 100644
--- a/python/plugins/GdalTools/tools/doBuildVRT.py
+++ b/python/plugins/GdalTools/tools/doBuildVRT.py
@@ -3,6 +3,7 @@ from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 from qgis.core import *
 from qgis.gui import *
+from qgis.utils import *
 
 from ui_widgetBuildVRT import Ui_GdalToolsWidget as Ui_Widget
 from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
@@ -38,6 +39,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
   self.connect(self.inSelector, SIGNAL(selectClicked()), 
self.fillInputFilesEdit)
   self.connect(self.outSelector, SIGNAL(selectClicked()), 
self.fillOutputFileEdit)
   self.connect( self.inputDirCheck, SIGNAL( stateChanged( int ) ), 
self.switchToolMode )
+  self.connect( self.useSelectedLayersCheck, SIGNAL( stateChanged( int ) 
), self.switchLayerMode )
 
   def switchToolMode(self):
   self.recurseCheck.setVisible( self.inputDirCheck.isChecked() )
@@ -55,6 +57,12 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
 QObject.connect(self.inSelector, SIGNAL(selectClicked()), 
self.fillInputFilesEdit)
 QObject.disconnect(self.inSelector, SIGNAL(selectClicked()), 
self.fillInputDir)
 
+  def switchLayerMode(self):
+  enableInputFiles = not self.useSelectedLayersCheck.isChecked()
+  self.inputDirCheck.setEnabled( enableInputFiles )
+  self.inSelector.setEnabled( enableInputFiles )
+  self.recurseCheck.setEnabled( enableInputFiles )
+
   def fillInputFilesEdit(self):
   lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
   files = Utils.FileDialog.getOpenFileNames(self, self.tr( Select the 
files for VRT ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
@@ -88,10 +96,13 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
   if self.allowProjDiffCheck.isChecked():
 arguments  -allow_projection_difference
   arguments  self.getOutputFileName()
-  if self.inputDirCheck.isChecked():
-arguments  Utils.getRasterFiles( self.getInputFileName(), 
self.recurseCheck.isChecked() )
+  if self.useSelectedLayersCheck.isChecked():
+arguments  self.getInputFileNamesFromSelectedLayers()
   else:
-arguments  self.getInputFileName()
+if self.inputDirCheck.isChecked():
+  arguments  Utils.getRasterFiles( self.getInputFileName(), 
self.recurseCheck.isChecked() )
+else:
+  arguments  self.getInputFileName()
   return arguments
 
   def getOutputFileName(self):
@@ -102,6 +113,14 @@ class GdalToolsDialog(QWidget, Ui_Widget, 
BasePluginWidget):
 return self.inSelector.filename()
   return self.inSelector.filename().split(,)
 
+  def getInputFileNamesFromSelectedLayers(self):
+  layers = iface.mapCanvas().layers()
+  files = list()
+  for layer in layers:
+if layer.type() == QgsMapLayer.RasterLayer and layer.providerType() == 
gdal:
+  files.append( str(layer.source()) )
+  return files
+
   def addLayerIntoCanvas(self, fileInfo):
   self.iface.addRasterLayer(fileInfo.filePath())
 
diff --git a/python/plugins/GdalTools/tools/widgetBuildVRT.ui 
b/python/plugins/GdalTools/tools/widgetBuildVRT.ui
index 2192538..b0df505 100644
--- a/python/plugins/GdalTools/tools/widgetBuildVRT.ui
+++ b/python/plugins/GdalTools/tools/widgetBuildVRT.ui
@@ -26,13 +26,20 @@
   enumQLayout::SetNoConstraint/enum
  /property
  item row=0 column=0 colspan=2
+  widget class=QCheckBox name=useSelectedLayersCheck
+   property name=text
+stringUse selected layers for input/string
+   /property
+  /widget
+ /item
+ item row=1 column=0 colspan=2
   widget class=QCheckBox name=inputDirCheck
property name=text
 stringChoose input directory instead of files/string
/property
   /widget
  /item
- item row=1 column=0
+ item row=2 column=0
   widget class=QLabel name=label
property name=text
 stringamp;Input files/string
@@ -42,14 +49,14 @@
/property
   /widget
  /item
- item row=2 column=1
+ item row=3 column=1
   widget class=QCheckBox name=recurseCheck
property name=text
 stringRecurse subdirectories/string
/property
   /widget
  /item
- item row=3 column=0
+ item row=4 column=0
   widget class=QLabel name=label_2
property name=text
 stringamp;Output file/string
@@ -59,14 +66,14 @@
/property
   /widget
  /item
- item row=4 column=0
+ 

[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db

2012-03-20 Thread Giuseppe Sucameli
The following commit has been merged in the master branch:
commit db1c401dd90e0e7ef6c7dc4e76113427dcfa32f1
Author: Giuseppe Sucameli brush.ty...@gmail.com
Date:   Mon Mar 12 08:38:41 2012 +0100

Run feature action tool does the action for all the matching features 
(fix #5126)

diff --git a/src/app/qgsmaptoolfeatureaction.cpp 
b/src/app/qgsmaptoolfeatureaction.cpp
index 72e3232..7ab3873 100644
--- a/src/app/qgsmaptoolfeatureaction.cpp
+++ b/src/app/qgsmaptoolfeatureaction.cpp
@@ -72,6 +72,12 @@ void QgsMapToolFeatureAction::canvasReleaseEvent( 
QMouseEvent *e )
 return;
   }
 
+  if ( !mCanvas-layers().contains( layer ) )
+  {
+// do not run actions on hidden layers
+return;
+  }
+
   QgsVectorLayer *vlayer = qobject_castQgsVectorLayer *( layer );
   if ( vlayer-actions()-size() == 0 )
   {
@@ -110,7 +116,7 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer 
*layer, int x, int y )
   if ( identifyValue = 0.0 )
 identifyValue = QGis::DEFAULT_IDENTIFY_RADIUS;
 
-  QgsFeature feat;
+  QgsFeatureList featList;
 
   // toLayerCoordinates will throw an exception for an 'invalid' point.
   // For example, if you project a world map onto a globe using EPSG 2163
@@ -130,10 +136,8 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer 
*layer, int x, int y )
 
 layer-select( layer-pendingAllAttributesList(), r, true, true );
 QgsFeature f;
-if ( layer-nextFeature( f ) )
-  feat = QgsFeature( f );
-else
-  return false;
+while ( layer-nextFeature( f ) )
+  featList  QgsFeature( f );
   }
   catch ( QgsCsException  cse )
   {
@@ -142,15 +146,22 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer 
*layer, int x, int y )
 QgsDebugMsg( QString( Caught CRS exception %1 ).arg( cse.what() ) );
   }
 
-  int action = layer-actions()-defaultAction();
+  if ( featList.size() == 0 )
+return false;
 
-  // define custom substitutions: layer id and clicked coords
-  QMapQString, QVariant substitutionMap;
-  substitutionMap.insert( $layerid, layer-id() );
-  point = toLayerCoordinates( layer, point );
-  substitutionMap.insert( $clickx, point.x() );
-  substitutionMap.insert( $clicky, point.y() );
+  foreach ( QgsFeature feat, featList )
+  {
+int actionIdx = layer-actions()-defaultAction();
+
+// define custom substitutions: layer id and clicked coords
+QMapQString, QVariant substitutionMap;
+substitutionMap.insert( $layerid, layer-id() );
+point = toLayerCoordinates( layer, point );
+substitutionMap.insert( $clickx, point.x() );
+substitutionMap.insert( $clicky, point.y() );
+
+layer-actions()-doAction( actionIdx, feat, substitutionMap );
+  }
 
-  layer-actions()-doAction( action, feat, substitutionMap );
   return true;
 }

-- 
The Quantum GIS in Debian project

___
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel


[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db

2012-03-20 Thread Giuseppe Sucameli
The following commit has been merged in the master branch:
commit 03f86366cd8b0764377f84f0c6c1dd241bb79294
Author: Giuseppe Sucameli brush.ty...@gmail.com
Date:   Wed Mar 14 00:54:36 2012 +0100

convert $currfield (was %%) running actions from Identify actions tool

diff --git a/src/core/qgsattributeaction.cpp b/src/core/qgsattributeaction.cpp
index f934d1c..b5a8fe5 100644
--- a/src/core/qgsattributeaction.cpp
+++ b/src/core/qgsattributeaction.cpp
@@ -77,7 +77,10 @@ void QgsAttributeAction::doAction( int index, QgsFeature 
feat, int defaultValue
 {
   QMapQString, QVariant substitutionMap;
   if ( defaultValueIndex = 0 )
-substitutionMap.insert( $currfield, QVariant( defaultValueIndex ) );
+  {
+if ( feat.attributeMap().contains( defaultValueIndex ) )
+  substitutionMap.insert( $currfield, feat.attributeMap()[ 
defaultValueIndex ] );
+  }
 
   doAction( index, feat, substitutionMap );
 }

-- 
The Quantum GIS in Debian project

___
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel


[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db

2012-03-20 Thread Giuseppe Sucameli
The following commit has been merged in the master branch:
commit 2c0fb43986aa00fb954851d4519f9a82a1c10cef
Author: Giuseppe Sucameli brush.ty...@gmail.com
Date:   Wed Mar 14 00:58:26 2012 +0100

fix memory leak instantiating QgsExpression in actions

diff --git a/src/core/qgsattributeaction.cpp b/src/core/qgsattributeaction.cpp
index b5a8fe5..1fc78f7 100644
--- a/src/core/qgsattributeaction.cpp
+++ b/src/core/qgsattributeaction.cpp
@@ -206,7 +206,7 @@ QString QgsAttributeAction::expandAction( QString action, 
QgsFeature feat, cons
 index = pos + rx.matchedLength();
 
 QString to_replace = rx.cap( 1 ).trimmed();
-QgsDebugMsg( Found expression: + to_replace );
+QgsDebugMsg( Found expression:  + to_replace );
 
 if ( substitutionMap  substitutionMap-contains( to_replace ) )
 {
@@ -214,18 +214,18 @@ QString QgsAttributeAction::expandAction( QString action, 
QgsFeature feat, cons
   continue;
 }
 
-QgsExpression* exp = new QgsExpression( to_replace );
-if ( exp-hasParserError() )
+QgsExpression exp( to_replace );
+if ( exp.hasParserError() )
 {
-  QgsDebugMsg( Expression parser error: + exp-parserErrorString() );
+  QgsDebugMsg( Expression parser error:  + exp.parserErrorString() );
   expr_action += action.mid( start, index - start );
   continue;
 }
 
-QVariant result = exp-evaluate( feat, mLayer-pendingFields() );
-if ( exp-hasEvalError() )
+QVariant result = exp.evaluate( feat, mLayer-pendingFields() );
+if ( exp.hasEvalError() )
 {
-  QgsDebugMsg( Expression parser eval error: + exp-evalErrorString() );
+  QgsDebugMsg( Expression parser eval error:  + exp.evalErrorString() );
   expr_action += action.mid( start, index - start );
   continue;
 }

-- 
The Quantum GIS in Debian project

___
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel


[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db

2012-03-20 Thread Giuseppe Sucameli
The following commit has been merged in the master branch:
commit c5769bf3799c785ab90d4f37fa1a0c7fe88cfc3f
Author: Giuseppe Sucameli brush.ty...@gmail.com
Date:   Fri Mar 16 16:50:59 2012 +0100

Append Filter tag to Rule tag when exporting Categorized/Graduated 
rendererV2 to SLD doc (fix #5191)

diff --git a/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp 
b/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
index ea9d014..c55bd76 100644
--- a/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
+++ b/src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
@@ -73,28 +73,27 @@ void QgsRendererCategoryV2::toSld( QDomDocument doc, 
QDomElement element, QgsS
   if ( !mSymbol || props.value( attribute,  ).isEmpty() )
 return;
 
+  QString attrName = props[ attribute ];
+
   QDomElement ruleElem = doc.createElement( se:Rule );
   element.appendChild( ruleElem );
 
-  QString valueStr = QString( value: %1 ).arg( mValue.toString() );
-
   QDomElement nameElem = doc.createElement( se:Name );
-  nameElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : 
valueStr ) );
+  nameElem.appendChild( doc.createTextNode( mLabel ) );
   ruleElem.appendChild( nameElem );
 
-  QString descrName = props.value( version, 1.1 )  1.1 ? Abstract : 
se:Description;
-  QString descrValue = QString( Categorized symbol rendererV2 - %1 ).arg( 
valueStr );
-
-  QDomElement descrElem = doc.createElement( descrName );
-  descrElem.appendChild( doc.createTextNode( descrValue ) );
+  QDomElement descrElem = doc.createElement( se:Description );
+  QString descrStr = QString( %1 is '%2' ).arg( attrName ).arg( 
mValue.toString() );
+  descrElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : 
descrStr ) );
   ruleElem.appendChild( descrElem );
 
   // create the ogc:Filter for the range
   QDomElement filterElem = doc.createElement( ogc:Filter );
-
   QString filterFunc = QString( %1 = '%2' )
-  .arg( props[ attribute ] ).arg( mValue.toString().replace( ', '' ) 
);
+  .arg( attrName.replace( \, \\ ) )
+  .arg( mValue.toString().replace( ', '' ) );
   QgsSymbolLayerV2Utils::createFunctionElement( doc, filterElem, filterFunc );
+  ruleElem.appendChild( filterElem );
 
   mSymbol-toSld( doc, ruleElem, props );
 }
diff --git a/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp 
b/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
index 190c95b..a9b128f 100644
--- a/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
+++ b/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
@@ -103,27 +103,24 @@ void QgsRendererRangeV2::toSld( QDomDocument doc, 
QDomElement element, QgsStri
   if ( !mSymbol || props.value( attribute,  ).isEmpty() )
 return;
 
+  QString attrName = props[ attribute ];
+
   QDomElement ruleElem = doc.createElement( se:Rule );
   element.appendChild( ruleElem );
 
-  QString valueStr = QString( range: %1 - %2 ).arg( mLowerValue ).arg( 
mUpperValue );
-
   QDomElement nameElem = doc.createElement( se:Name );
-  nameElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : 
valueStr ) );
+  nameElem.appendChild( doc.createTextNode( mLabel ) );
   ruleElem.appendChild( nameElem );
 
-  QString descrName = props.value( version, 1.1 )  1.1 ? Abstract : 
se:Description;
-  QString descrValue = QString( Graduated symbol rendererV2 - %1 ).arg( 
valueStr );
-
-  QDomElement descrElem = doc.createElement( descrName );
-  descrElem.appendChild( doc.createTextNode( descrValue ) );
+  QDomElement descrElem = doc.createElement( se:Description );
+  QString descrStr = QString( range: %1 - %2 ).arg( mLowerValue ).arg( 
mUpperValue );
+  descrElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : 
descrStr ) );
   ruleElem.appendChild( descrElem );
 
   // create the ogc:Filter for the range
   QDomElement filterElem = doc.createElement( ogc:Filter );
-
   QString filterFunc = QString( %1  %2 AND %1 = %3 )
-  .arg( props[ attribute ] )
+  .arg( attrName.replace( \, \\ ) )
   .arg( mLowerValue ).arg( mUpperValue );
   QgsSymbolLayerV2Utils::createFunctionElement( doc, filterElem, filterFunc );
 

-- 
The Quantum GIS in Debian project

___
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel