915 changes: 915 additions & 0 deletions images/themes/gis/mIconDeselected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
915 changes: 915 additions & 0 deletions images/themes/gis/mIconSelected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
%Include qgsdatasourceuri.sip
%Include qgsdbfilterproxymodel.sip
%Include qgsdistancearea.sip
%Include qgserror.sip
%Include qgsexpression.sip
%Include qgsfeature.sip
%Include qgsfeatureiterator.sip
Expand Down Expand Up @@ -141,6 +142,7 @@
%Include raster/qgsrasterdataprovider.sip
%Include raster/qgsrasterfilewriter.sip
%Include raster/qgsrasterhistogram.sip
%Include raster/qgsrasteridentifyresult.sip
%Include raster/qgsrasterinterface.sip
%Include raster/qgsrasteriterator.sip
%Include raster/qgsrasterlayer.sip
Expand Down
47 changes: 47 additions & 0 deletions python/core/qgserror.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class QgsErrorMessage
{
%TypeHeaderCode
#include <qgserror.h>
%End
public:
enum Format
{
Text, // Plain text
Html
};

QgsErrorMessage();

QgsErrorMessage( const QString & theMessage, const QString & theTag = QString::null, const QString & theFile = QString::null, const QString & theFunction = QString::null, int theLine = 0 );

QString message() const;
QString tag() const;
QString file() const;
QString function() const;
int line() const;
};

class QgsError
{
%TypeHeaderCode
#include <qgserror.h>
%End
public:

QgsError();

QgsError( const QString & theMessage, const QString & theTag );

void append( const QString & theMessage, const QString & theTag );

void append( const QgsErrorMessage & theMessage );

bool isEmpty() const;

QString message( QgsErrorMessage::Format theFormat = QgsErrorMessage::Html ) const;

QString summary() const;

void clear();
};

4 changes: 2 additions & 2 deletions python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ class QgsMapLayer : QObject
void removeCustomProperty( const QString& key );

/** Accessor for transparency level. */
unsigned int getTransparency();
// unsigned int getTransparency();

/** Mutator for transparency level. Should be between 0 and 255 */
virtual void setTransparency( unsigned int );
// virtual void setTransparency( unsigned int );

/**
* If an operation returns 0 (e.g. draw()), this function
Expand Down
3 changes: 2 additions & 1 deletion python/core/raster/qgsrasterdataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
%TypeHeaderCode
#include <qgsrasterdataprovider.h>
#include <qgsrasterinterface.h>
#include <qgsrasteridentifyresult.h>
%End

public:
Expand Down Expand Up @@ -193,7 +194,7 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
*/
virtual QString metadata() = 0;

virtual QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );
virtual QgsRasterIdentifyResult identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

QMap<QString, QString> identify( const QgsPoint & thePoint, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

Expand Down
32 changes: 32 additions & 0 deletions python/core/raster/qgsrasteridentifyresult.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class QgsRasterIdentifyResult
{
%TypeHeaderCode
#include <qgsrasteridentifyresult.h>
%End
public:
QgsRasterIdentifyResult();

QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormat theFormat, QMap<int, QVariant> theResults );

QgsRasterIdentifyResult( QgsError theError );

virtual ~QgsRasterIdentifyResult();

bool isValid() const;

QgsRasterDataProvider::IdentifyFormat format() const;

QMap<int, QVariant> results() const;

void setParams( const QMap<QString, QVariant> & theParams );

QMap<QString, QVariant> params() const;

QgsError error() const;

void setError( const QgsError & theError );

void appendError( const QgsErrorMessage & theMessage );

};

15 changes: 10 additions & 5 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from sextante.gui.AlgorithmExecutor import AlgorithmExecutor
from sextante.gui.RenderingStyles import RenderingStyles
from sextante.gui.SextantePostprocessing import SextantePostprocessing
from sextante.gui.UnthreadedAlgorithmExecutor import UnthreadedAlgorithmExecutor,\
SilentProgress
from sextante.gui.UnthreadedAlgorithmExecutor import UnthreadedAlgorithmExecutor
from sextante.core.SilentProgress import SilentProgress
from sextante.modeler.Providers import Providers
from sextante.modeler.ModelerAlgorithmProvider import ModelerAlgorithmProvider
from sextante.modeler.ModelerOnlyAlgorithmProvider import ModelerOnlyAlgorithmProvider
Expand Down Expand Up @@ -384,13 +384,15 @@ def runalg(algOrName, *args):
return alg.getOutputValuesAsDictionary()

def runandload(name, *args):
Sextante.runAlgorithm(name, SextantePostprocessing.handleAlgorithmResults, *args)
return Sextante.runAlgorithm(name, SextantePostprocessing.handleAlgorithmResults, *args)

def extent(layers):
first = True
for layer in layers:
if not isinstance(layer, (QgsRasterLayer, QgsVectorLayer)):
layer = QGisLayers.getObjectFromUri(layer)
if layer is None:
continue
if first:
xmin = layer.extent().xMinimum()
xmax = layer.extent().xMaximum()
Expand All @@ -402,7 +404,10 @@ def extent(layers):
ymin = min(ymin, layer.extent().yMinimum())
ymax = max(ymax, layer.extent().yMaximum())
first = False
return str(xmin) + "," + str(xmax) + "," + str(ymin) + "," + str(ymax)
if first:
return "0,0,0,0"
else:
return str(xmin) + "," + str(xmax) + "," + str(ymin) + "," + str(ymax)

def getObjectFromName(name):
layers = QGisLayers.getAllLayers()
Expand All @@ -411,7 +416,7 @@ def getObjectFromName(name):
return layer

def getObjectFromUri(uri):
return QGisLayers.getObjectFromUri(uri, False)
return QGisLayers.getObjectFromUri(uri, True)

def getobject(uriorname):
ret = getObjectFromName(uriorname)
Expand Down
19 changes: 19 additions & 0 deletions python/plugins/sextante/core/SilentProgress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class SilentProgress():

def setText(self, text):
pass

def setPercentage(self, i):
pass

def setInfo(self, _):
pass

def setCommand(self, _):
pass

def setDebugInfo(self, _):
pass

def setConsoleInfo(self, _):
pass
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/BatchProcessingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def accept(self):
self.progress.setMaximum(len(self.algs))
for alg in self.algs:
self.setBaseText("Processing algorithm " + str(i+1) + "/" + str(len(self.algs)) + "...")
if UnthreadedAlgorithmExecutor.runalg(alg, self):#SilentProgress()):
if UnthreadedAlgorithmExecutor.runalg(alg, self):
#self.progress.setValue(i)
#self.loadHTMLResults(alg, i)
if self.load[i]:
Expand Down
21 changes: 1 addition & 20 deletions python/plugins/sextante/gui/UnthreadedAlgorithmExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteUtils import SextanteUtils
from sextante.gui.SextantePostprocessing import SextantePostprocessing
from sextante.core.SilentProgress import SilentProgress
import traceback

class UnthreadedAlgorithmExecutor:
Expand Down Expand Up @@ -91,23 +92,3 @@ def runalgIterating(alg,paramToIter,progress):

return True


class SilentProgress():

def setText(self, text):
pass

def setPercentage(self, i):
pass

def setInfo(self, _):
pass

def setCommand(self, _):
pass

def setDebugInfo(self, _):
pass

def setConsoleInfo(self, _):
pass
4 changes: 2 additions & 2 deletions python/plugins/sextante/modeler/models/notinorder.model
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME:Model with algorithms not in running order
GROUP:[Test algorithms]
GROUP:[Test models]
PARAMETER:ParameterRaster|RASTERLAYER_RASTER|raster|False
120.0,60.0
VALUE:HARDCODEDPARAMVALUE_MINSLOPE_1===0.01
Expand All @@ -23,7 +23,7 @@ None
None
None
-1|HARDCODEDPARAMVALUE_CONVERGENCE_0
None
catchment area
None
None
None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
##[Test scripts]=group
##number=output number

number = 10
33 changes: 15 additions & 18 deletions python/plugins/sextante/tests/GeoAlgorithmTest.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
from sextante.core.Sextante import Sextante
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm
import sextante
import unittest
from sextante.tests.TestData import points, points2, polygons, polygons2, lines, union,\
table, polygonsGeoJson, raster
from sextante.core.QGisLayers import QGisLayers

def testAlg(algname, *args):
class GeoAlgorithmTest(unittest.TestCase):
pass

#test simple execution
alg = Sextante.runAlgorithm(algname, None, *args)
assert alg is not None
def suite():
suite = unittest.makeSuite(GeoAlgorithmTest, 'test')
return suite

out = alg.getOutputValuesAsDictionary()

return out

#test execution in a model

#===========================================================================
# model = ModelerAlgorithm()
# model.addAlgorithm(alg, parametersMap, valuesMap, outputsMap, dependencies)
#===========================================================================

#test
def runtests():
result = unittest.TestResult()
testsuite = suite()
testsuite.run(result)
return result
27 changes: 20 additions & 7 deletions python/plugins/sextante/tests/ModelerAlgorithmTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,40 @@
from osgeo.gdalconst import GA_ReadOnly
from sextante.modeler import ModelerAlgorithmProvider
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm
from sextante.modeler.Providers import Providers

class ModelerAlgorithmTest(unittest.TestCase):

def testCreateModel(self):
pass

def testEditModelParameter(self):
pass

def testEditModelAlgorithm(self):
pass

def testRemoveAlgorithm(self):
folder = os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__), "models")
modelfile = os.path.join(folder, "noinputs.model")
model = ModelerAlgorithm()
model.openModel(modelfile)
model.provider = Providers.providers['model']
self.assertTrue(2, len(model.algs))
self.assertFalse(model.removeAlgorithm(0))
self.assertTrue(model.removeAlgorithm(len(model.algs) - 1));
outputs = model.execute(None)
self.assertEquals(2, len(outputs))
output=outputs['SAVENAME_ALG0']
layer=QGisLayers.getObjectFromUri(output, True)
self.assertIsNone(layer)
from threading import settrace

import sys
sys.path.append("D:\eclipse\plugins\org.python.pydev_2.6.0.2012062818\pysrc")
from pydevd import *
settrace()

model.execute(None)
outputs = model.outputs
self.assertEquals(1, len(outputs))
output=outputs[0].value
self.assertTrue(os.path.exists(output))

def testRemoveParameter(self):
folder = os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__), "models")
Expand Down Expand Up @@ -67,8 +82,6 @@ def testComputingDependecies(self):
self.assertEquals([3,2,1,0], depends)




'''The following tests correspond to example models'''

def test_modelersagagrass(self):
Expand Down
11 changes: 4 additions & 7 deletions python/plugins/sextante/tests/QgisAlgsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,21 +894,18 @@ def test_qgisexportaddgeometrycolumnspolygons(self):
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_qgisstatisticsbycategories(self):
outputs=sextante.runalg("qgis:statisticsbycategories",points2(),"POLY_NUM_A","POLY_ST_B",None)
outputs=sextante.runalg("qgis:statisticsbycategories",points2(),"POLY_NUM_A","POLY_ST_B", None)
output=outputs['OUTPUT']
layer=QGisLayers.getObjectFromUri(output, True)
fields=layer.pendingFields()
expectednames=['Category','min','max','mean','stddev']
expectedtypes=['String','Real','Real','Real','Real']
expectednames=['category','min','max','mean','stddev']
names=[str(f.name()) for f in fields]
types=[str(f.typeName()) for f in fields]
self.assertEqual(expectednames, names)
self.assertEqual(expectedtypes, types)
self.assertEqual(expectednames, names)
features=sextante.getfeatures(layer)
self.assertEqual(3, len(features))
feature=features.next()
attrs=feature.attributes()
expectedvalues=["NULL","1.1","2.2","1.925","0.55"]
expectedvalues=["","1.1","2.2","1.925","0.55"]
values=[str(attr.toString()) for attr in attrs]
self.assertEqual(expectedvalues, values)

Expand Down
11 changes: 5 additions & 6 deletions python/plugins/sextante/tests/SagaTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_SagaVectorAlgorithmWithSelection(self):
selected = [feature.id()]
layer.setSelectedFeatures(selected)
outputs=sextante.runalg("saga:polygoncentroids",polygons2(),True,None)
layer.setSelectedFeatures([])
output=outputs['CENTROIDS']
layer=QGisLayers.getObjectFromUri(output, True)
fields=layer.pendingFields()
Expand All @@ -53,7 +54,7 @@ def test_SagaVectorAlgorithmWithSelection(self):
expectedvalues=["2","1","string a"]
values=[str(attr.toString()) for attr in attrs]
self.assertEqual(expectedvalues, values)
wkt='POINT(270820.58189697 4458968.73298999)'
wkt='POINT(270806.69221918 4458924.97720492)'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self):
Expand All @@ -63,6 +64,7 @@ def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self):
selected = [feature.id()]
layer.setSelectedFeatures(selected)
outputs=sextante.runalg("saga:polygoncentroids",polygonsGeoJson(),True, SextanteUtils.getTempFilename("geojson"))
layer.setSelectedFeatures([])
output=outputs['CENTROIDS']
layer=QGisLayers.getObjectFromUri(output, True)
fields=layer.pendingFields()
Expand All @@ -81,17 +83,14 @@ def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self):
self.assertEqual(expectedvalues, values)
wkt='POINT(270787.49991451 4458955.46775295)'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_SagaRasterAlgorithmWithUnsupportedOutputFormat(self):
outputs=sextante.runalg("saga:convergenceindex",raster(),0,0,None)
output=outputs['RESULT']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,485390137)




self.assertEqual(strhash,-807227462)


def suite():
Expand Down
26 changes: 26 additions & 0 deletions python/plugins/sextante/tests/SextanteTests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'''Convenience module to create a test suite will all SEXTANTE tests'''
import unittest
from sextante.tests import QgisAlgsTest
from sextante.tests import ParametersTest
from sextante.tests import ModelerAlgorithmTest
from sextante.tests import SextanteToolsTest
from sextante.tests import ScriptTest
from sextante.tests import SagaTest
from sextante.tests import GeoAlgorithmTest

def suite():
suite = unittest.TestSuite()
suite.addTests(QgisAlgsTest.suite())
suite.addTests(ModelerAlgorithmTest.suite())
suite.addTests(SagaTest.suite())
suite.addTests(ScriptTest.suite())
suite.addTests(SextanteToolsTest.suite())
#suite.addTests(ParametersTest.suite())
suite.addTests(GeoAlgorithmTest.suite())
return suite

def runtests():
result = unittest.TestResult()
testsuite = suite()
testsuite.run(result)
return result
59 changes: 59 additions & 0 deletions python/plugins/sextante/tests/SextanteToolsTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import sextante
import unittest
from sextante.tests.TestData import points, points2, polygons, polygons2, lines, union,\
table, polygonsGeoJson, raster
from sextante.core import Sextante
from sextante.tools.vector import getAttributeValues

class SextanteToolsTest(unittest.TestCase):
'''tests the method imported when doing an "import sextante", and also in sextante.tools.
They are mostly convenience tools'''

def test_getobject(self):
layer = sextante.getobject(points());
self.assertIsNotNone(layer)
layer = sextante.getobject("points");
self.assertIsNotNone(layer)

def test_runandload(self):
sextante.runandload("qgis:countpointsinpolygon",polygons(),points(),"NUMPOINTS", None)
layer = Sextante.getObjectFromName("Result")
self.assertIsNotNone(layer)

def test_featuresWithoutSelection(self):
layer = sextante.getobject(points())
features = sextante.getfeatures(layer)
self.assertEqual(12, len(features))

def test_featuresWithSelection(self):
layer = sextante.getobject(points())
feature = layer.getFeatures().next()
selected = [feature.id()]
layer.setSelectedFeatures(selected)
features = sextante.getfeatures(layer)
self.assertEqual(1, len(features))
layer.setSelectedFeatures([])

def test_attributeValues(self):
layer = sextante.getobject(points())
values = getAttributeValues(layer, "ID")
i = 1
for value in values['ID']:
self.assertEqual(int(i), int(value))
i+=1
self.assertEquals(13,i)

def test_extent(self):
pass



def suite():
suite = unittest.makeSuite(SextanteToolsTest, 'test')
return suite

def runtests():
result = unittest.TestResult()
testsuite = suite()
testsuite.run(result)
return result
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void QgsComposerItemWidget::on_mBlendModeCombo_currentIndexChanged( int index )
Q_UNUSED( index );
if ( mItem )
{
mItem->setBlendMode(( QgsMapRenderer::BlendMode ) mBlendModeCombo->blendMode() );
mItem->setBlendMode( mBlendModeCombo->blendMode() );
}
}

Expand Down
25 changes: 10 additions & 15 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );
connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateTitle() ) );
connect( mLayer, SIGNAL( attributeAdded(int) ), this, SLOT( columnBoxInit() ) );
connect( mLayer, SIGNAL( attributeDeleted(int) ), this, SLOT( columnBoxInit() ) );

// connect table info to window
connect( mMainView, SIGNAL( filterChanged() ), this, SLOT( updateTitle() ) );

// info from table to application
connect( this, SIGNAL( saveEdits( QgsMapLayer * ) ), QgisApp::instance(), SLOT( saveEdits( QgsMapLayer * ) ) );
Expand Down Expand Up @@ -193,12 +199,11 @@ QgsAttributeTableDialog::~QgsAttributeTableDialog()
void QgsAttributeTableDialog::updateTitle()
{
QWidget *w = mDock ? qobject_cast<QWidget*>( mDock ) : qobject_cast<QWidget*>( this );
w->setWindowTitle( tr( "Attribute table - %1 :: %n / %2 feature(s) filtered",
"feature count",
mMainView->filteredFeatureCount()
)
w->setWindowTitle( tr( "Attribute table - %1 :: Features total: %2, filtered: %3, selected: %4" )
.arg( mLayer->name() )
.arg( mMainView->featureCount() )
.arg( mMainView->filteredFeatureCount() )
.arg( mLayer->selectedFeatureCount() )
);
}

Expand All @@ -219,6 +224,7 @@ void QgsAttributeTableDialog::columnBoxInit()
{
mFilterColumnsMenu->removeAction( a );
mFilterActionMapper->removeMappings( a );
mFilterButton->removeAction( a );
delete a;
}

Expand Down Expand Up @@ -345,7 +351,6 @@ void QgsAttributeTableDialog::on_mOpenFieldCalculator_clicked()
if ( col >= 0 )
{
masterModel->reload( masterModel->index( 0, col ), masterModel->index( masterModel->rowCount() - 1, col ) );
columnBoxInit();
}
}
}
Expand Down Expand Up @@ -610,14 +615,4 @@ void QgsAttributeTableDialog::setFilterExpression( QString filterString )
QgisApp::instance()->messageBar()->pushMessage( tr( "Error filtering" ), filterExpression.evalErrorString(), QgsMessageBar::WARNING, QgisApp::instance()->messageTimeout() );
return;
}

QWidget *w = mDock ? qobject_cast<QWidget*>( mDock ) : qobject_cast<QWidget*>( this );
if ( mMainView->filteredFeatureCount() )
{
w->setWindowTitle( tr( "Attribute table - %1 (%n matching features)", "matching features", mMainView->filteredFeatureCount() ).arg( mMainView->filteredFeatureCount() ) );
}
else
{
w->setWindowTitle( tr( "Attribute table - %1 (No matching features)" ).arg( mLayer->name() ) );
}
}
13 changes: 7 additions & 6 deletions src/app/qgsattributetabledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia
void filterQueryChanged( const QString& query );
void filterQueryAccepted();

/**
* update window title
*/
void updateTitle();

signals:
/**
* Informs that editing mode has been toggled
Expand All @@ -158,17 +163,13 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia
*/
void closeEvent( QCloseEvent* event );

private:
private slots:
/**
* Initialize column box
*/
void columnBoxInit();

/**
* update window title
*/
void updateTitle();

private:
QMenu* mMenuActions;
QAction* mActionToggleEditing;

Expand Down
3 changes: 1 addition & 2 deletions src/app/qgsfieldcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void QgsFieldCalculator::accept()

QString calcString = builder->expressionText();
QgsExpression exp( calcString );
exp.setGeomCalculator( myDa );

if ( !mVectorLayer || !mVectorLayer->isEditable() )
return;
Expand Down Expand Up @@ -173,8 +174,6 @@ void QgsFieldCalculator::accept()
}

exp.setCurrentRowNumber( rownum );
exp.setGeomCalculator( myDa );

QVariant value = exp.evaluate( &feature );
if ( exp.hasEvalError() )
{
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgslabelinggui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
mBufferTranspSpinBox->setValue( lyr.bufferTransp );
mBufferJoinStyleComboBox->setPenJoinStyle( lyr.bufferJoinStyle );
mBufferTranspFillChbx->setChecked( !lyr.bufferNoFill );
comboBufferBlendMode->setBlendMode( QgsMapRenderer::getBlendModeEnum( lyr.bufferBlendMode ) );
comboBufferBlendMode->setBlendMode( lyr.bufferBlendMode );
}
else
{
Expand Down Expand Up @@ -295,7 +295,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
mFontSizeSpinBox->setValue( lyr.textFont.pointSizeF() );
btnTextColor->setColor( lyr.textColor );
mFontTranspSpinBox->setValue( lyr.textTransp );
comboBlendMode->setBlendMode( QgsMapRenderer::getBlendModeEnum( lyr.blendMode ) );
comboBlendMode->setBlendMode( lyr.blendMode );

mFontWordSpacingSpinBox->setValue( lyr.textFont.wordSpacing() );
mFontLetterSpacingSpinBox->setValue( lyr.textFont.letterSpacing() );
Expand Down Expand Up @@ -336,7 +336,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
connect( mShapeTranspSlider, SIGNAL( valueChanged( int ) ), mShapeTranspSpinBox, SLOT( setValue( int ) ) );
connect( mShapeTranspSpinBox, SIGNAL( valueChanged( int ) ), mShapeTranspSlider, SLOT( setValue( int ) ) );
mShapeTranspSpinBox->setValue( lyr.shapeTransparency );
mShapeBlendCmbBx->setBlendMode( QgsMapRenderer::getBlendModeEnum( lyr.shapeBlendMode ) );
mShapeBlendCmbBx->setBlendMode( lyr.shapeBlendMode );

mLoadSvgParams = false;
on_mShapeTypeCmbBx_currentIndexChanged( lyr.shapeType ); // force update of shape background gui
Expand Down Expand Up @@ -498,7 +498,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
lyr.textFont = mRefFont;
lyr.textNamedStyle = mFontStyleComboBox->currentText();
lyr.textTransp = mFontTranspSpinBox->value();
lyr.blendMode = QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode )comboBlendMode->blendMode() );
lyr.blendMode = comboBlendMode->blendMode();
lyr.previewBkgrdColor = mPreviewBackgroundBtn->color();
lyr.enabled = chkEnableLabeling->isChecked();
lyr.priority = sliderPriority->value();
Expand All @@ -523,7 +523,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
lyr.bufferSizeInMapUnits = ( mBufferUnitComboBox->currentIndex() == 1 );
lyr.bufferJoinStyle = mBufferJoinStyleComboBox->penJoinStyle();
lyr.bufferNoFill = !mBufferTranspFillChbx->isChecked();
lyr.bufferBlendMode = QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode )comboBufferBlendMode->blendMode() );
lyr.bufferBlendMode = comboBufferBlendMode->blendMode();
}
else
{
Expand Down Expand Up @@ -551,7 +551,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
lyr.shapeBorderWidthUnits = ( QgsPalLayerSettings::SizeUnit )( mShapeBorderWidthUnitsCmbBx->currentIndex() + 1 );
lyr.shapeJoinStyle = mShapePenStyleCmbBx->penJoinStyle();
lyr.shapeTransparency = mShapeTranspSpinBox->value();
lyr.shapeBlendMode = QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode )mShapeBlendCmbBx->blendMode() );
lyr.shapeBlendMode = mShapeBlendCmbBx->blendMode();


if ( chkFormattedNumbers->isChecked() )
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "qgsproject.h"
#include "qgsrasterbandstats.h"
#include "qgsrasterhistogramwidget.h"
#include "qgsrasteridentifyresult.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsrasterpyramid.h"
Expand Down Expand Up @@ -870,7 +871,7 @@ void QgsRasterLayerProperties::apply()
}

//set the blend mode for the layer
mRasterLayer->setBlendMode(( QgsMapRenderer::BlendMode ) mBlendModeComboBox->blendMode() );
mRasterLayer->setBlendMode( mBlendModeComboBox->blendMode() );

//get the thumbnail for the layer
pixmapThumbnail->setPixmap( mRasterLayer->previewAsPixmap( pixmapThumbnail->size() ) );
Expand Down Expand Up @@ -1456,7 +1457,7 @@ void QgsRasterLayerProperties::pixelSelected( const QgsPoint& canvasPoint )
int myWidth = mMapCanvas->extent().width() / mapUnitsPerPixel;
int myHeight = mMapCanvas->extent().height() / mapUnitsPerPixel;

QMap<int, QVariant> myPixelMap = mRasterLayer->dataProvider()->identify( myPoint, QgsRasterDataProvider::IdentifyFormatValue, myExtent, myWidth, myHeight );
QMap<int, QVariant> myPixelMap = mRasterLayer->dataProvider()->identify( myPoint, QgsRasterDataProvider::IdentifyFormatValue, myExtent, myWidth, myHeight ).results();

QList<int> bands = renderer->usesBands();

Expand Down
24 changes: 17 additions & 7 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,11 @@ void QgsVectorLayerProperties::apply()
// Apply fields settings
mFieldsPropertiesDialog->apply();

QgsRendererV2PropertiesDialog* dlg = static_cast<QgsRendererV2PropertiesDialog*>( widgetStackRenderers->currentWidget() );
dlg->apply();
if ( layer->rendererV2() )
{
QgsRendererV2PropertiesDialog* dlg = static_cast<QgsRendererV2PropertiesDialog*>( widgetStackRenderers->currentWidget() );
dlg->apply();
}

//apply diagram settings
diagramPropertiesDialog->apply();
Expand Down Expand Up @@ -774,12 +777,19 @@ void QgsVectorLayerProperties::updateSymbologyPage()
delete mRendererDialog;
mRendererDialog = 0;

mRendererDialog = new QgsRendererV2PropertiesDialog( layer, QgsStyleV2::defaultStyle(), true );
if ( layer->rendererV2() )
{
mRendererDialog = new QgsRendererV2PropertiesDialog( layer, QgsStyleV2::defaultStyle(), true );

// display the menu to choose the output format (fix #5136)
pbnSaveStyleAs->setText( tr( "Save Style" ) );
pbnSaveStyleAs->setMenu( mSaveAsMenu );
QObject::disconnect( pbnSaveStyleAs, SIGNAL( clicked() ), this, SLOT( on_pbnSaveStyleAs_clicked() ) );
// display the menu to choose the output format (fix #5136)
pbnSaveStyleAs->setText( tr( "Save Style" ) );
pbnSaveStyleAs->setMenu( mSaveAsMenu );
QObject::disconnect( pbnSaveStyleAs, SIGNAL( clicked() ), this, SLOT( on_pbnSaveStyleAs_clicked() ) );
}
else
{
tabWidget->setTabEnabled( 0, false ); // hide symbology item
}

if ( mRendererDialog )
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ SET(QGIS_CORE_SRCS
raster/qgspseudocolorshader.cpp
raster/qgsrasterprojector.cpp
raster/qgsrasterchecker.cpp
raster/qgsrasteridentifyresult.cpp
raster/qgsrasterinterface.cpp
raster/qgsrasteriterator.cpp
raster/qgsrasterlayer.cpp
Expand Down Expand Up @@ -470,6 +471,7 @@ SET(QGIS_CORE_HDRS
raster/qgsrasterpyramid.h
raster/qgsrasterbandstats.h
raster/qgsrasterhistogram.h
raster/qgsrasteridentifyresult.h
raster/qgsrasterinterface.h
raster/qgsrasterlayer.h
raster/qgsrastertransparency.h
Expand Down
12 changes: 6 additions & 6 deletions src/core/composer/qgscomposeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ QgsComposerItem::QgsComposerItem( QgsComposition* composition, bool manageZValue
, mItemPositionLocked( false )
, mLastValidViewScaleFactor( -1 )
, mRotation( 0 )
, mBlendMode( QgsMapRenderer::BlendNormal )
, mBlendMode( QPainter::CompositionMode_SourceOver )
, mTransparency( 0 )
, mLastUsedPositionMode( UpperLeft )
, mId( "" )
Expand All @@ -75,7 +75,7 @@ QgsComposerItem::QgsComposerItem( qreal x, qreal y, qreal width, qreal height, Q
, mItemPositionLocked( false )
, mLastValidViewScaleFactor( -1 )
, mRotation( 0 )
, mBlendMode( QgsMapRenderer::BlendNormal )
, mBlendMode( QPainter::CompositionMode_SourceOver )
, mTransparency( 0 )
, mLastUsedPositionMode( UpperLeft )
, mId( "" )
Expand Down Expand Up @@ -205,7 +205,7 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons
composerItemElem.appendChild( bgColorElem );

//blend mode
composerItemElem.setAttribute( "blendMode", QString::number( mBlendMode ) );
composerItemElem.setAttribute( "blendMode", QgsMapRenderer::getBlendModeEnum( mBlendMode ) );

//transparency
composerItemElem.setAttribute( "transparency", QString::number( mTransparency ) );
Expand Down Expand Up @@ -331,7 +331,7 @@ bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument&
}

//blend mode
setBlendMode(( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode" , "0" ).toInt() );
setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) );

//transparency
setTransparency( itemElem.attribute( "transparency" , "0" ).toInt() );
Expand Down Expand Up @@ -884,11 +884,11 @@ void QgsComposerItem::drawBackground( QPainter* p )
}
}

void QgsComposerItem::setBlendMode( QgsMapRenderer::BlendMode blendMode )
void QgsComposerItem::setBlendMode( QPainter::CompositionMode blendMode )
{
mBlendMode = blendMode;
// Update the composer effect to use the new blend mode
mEffect->setCompositionMode( QgsMapRenderer::getCompositionMode( mBlendMode ) );
mEffect->setCompositionMode( mBlendMode );
}

void QgsComposerItem::setTransparency( int transparency )
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposeritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
void setBackgroundEnabled( bool drawBackground ) {mBackground = drawBackground;}

/** Returns the item's composition blending mode */
QgsMapRenderer::BlendMode blendMode() const {return mBlendMode;}
QPainter::CompositionMode blendMode() const {return mBlendMode;}

/** Sets the item's composition blending mode*/
void setBlendMode( QgsMapRenderer::BlendMode blendMode );
void setBlendMode( QPainter::CompositionMode blendMode );

/** Returns the item's transparency */
int transparency() const {return mTransparency;}
Expand Down Expand Up @@ -321,7 +321,7 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
double mRotation;

/**Composition blend mode for item*/
QgsMapRenderer::BlendMode mBlendMode;
QPainter::CompositionMode mBlendMode;

QgsComposerEffect *mEffect;

Expand Down
2 changes: 2 additions & 0 deletions src/core/composer/qgscomposerlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ void QgsComposerLabel::setExpressionContext( QgsFeature* feature, QgsVectorLayer
mExpressionFeature = feature;
mExpressionLayer = layer;
mSubstitutions = substitutions;
// Force label to redraw -- fixes label printing for labels with blend modes when used with atlas
update();
}

QString QgsComposerLabel::displayText() const
Expand Down
10 changes: 6 additions & 4 deletions src/core/composer/qgscomposerlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,10 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
//real symbol height. Can be different from standard height in case of point symbols
double realSymbolHeight;

int opacity = 255;
QgsComposerLayerItem* layerItem = dynamic_cast<QgsComposerLayerItem*>( symbolItem->parent() );

#if 0
int opacity = 255;
if ( layerItem )
{
QgsMapLayer* currentLayer = QgsMapLayerRegistry::instance()->mapLayer( layerItem->layerID() );
Expand All @@ -324,6 +326,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
opacity = currentLayer->getTransparency();
}
}
#endif

QString text = symbolItem->text();
if ( text.isEmpty() )
Expand All @@ -346,7 +349,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
if ( symbolNg ) //item with symbol NG?
{
// must be called also with painter=0 to get real size
drawSymbolV2( painter, symbolNg, point.y() + ( itemHeight - mSymbolHeight ) / 2, x, realSymbolHeight, opacity );
drawSymbolV2( painter, symbolNg, point.y() + ( itemHeight - mSymbolHeight ) / 2, x, realSymbolHeight );
symbolSize.rwidth() = qMax( x - point.x(), mSymbolWidth );
symbolSize.rheight() = qMax( realSymbolHeight, mSymbolHeight );
}
Expand Down Expand Up @@ -414,9 +417,8 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
}


void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double currentYCoord, double& currentXPosition, double& symbolHeight, int layerOpacity ) const
void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double currentYCoord, double& currentXPosition, double& symbolHeight ) const
{
Q_UNUSED( layerOpacity );
if ( !s )
{
return;
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerlegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem

/**Draws a symbol at the current y position and returns the new x position. Returns real symbol height, because for points,
it is possible that it differs from mSymbolHeight*/
void drawSymbolV2( QPainter* p, QgsSymbolV2* s, double currentYCoord, double& currentXPosition, double& symbolHeight, int layerOpacity = 255 ) const;
void drawSymbolV2( QPainter* p, QgsSymbolV2* s, double currentYCoord, double& currentXPosition, double& symbolHeight ) const;

/** Draw atom and return its actual size */
QSizeF drawAtom( Atom atom, QPainter* painter = 0, QPointF point = QPointF() );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscrscache.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CORE_EXPORT QgsCRSCache
~QgsCRSCache();
/**Returns the CRS for authid, e.g. 'EPSG:4326' (or an invalid CRS in case of error)*/
const QgsCoordinateReferenceSystem& crsByAuthId( const QString& authid );
const QgsCoordinateReferenceSystem& crsByEpsgId( long epgs );
const QgsCoordinateReferenceSystem& crsByEpsgId( long epsg );

protected:
QgsCRSCache();
Expand Down
7 changes: 4 additions & 3 deletions src/core/qgsgml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ void QgsGml::startElement( const XML_Char* el, const XML_Char** attr )
{
mParseModeStack.push( QgsGml::geometry );
}
else if ( mParseModeStack.size() == 0 && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
//else if ( mParseModeStack.size() == 0 && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
{
mParseModeStack.push( QgsGml::boundingBox );
}
Expand Down Expand Up @@ -240,7 +241,7 @@ void QgsGml::startElement( const XML_Char* el, const XML_Char** attr )
{
mParseModeStack.push( QgsGml::multiPolygon );
}
else if ( mParseModeStack.size() == 1 && mParseModeStack.top() == QgsGml::feature && mThematicAttributes.find( localName ) != mThematicAttributes.end() )
else if (( mParseModeStack.size() > 0 ) && ( mParseModeStack.top() == QgsGml::feature ) && ( mThematicAttributes.find( localName ) != mThematicAttributes.end() ) )
{
mParseModeStack.push( QgsGml::attribute );
mAttributeName = localName;
Expand Down Expand Up @@ -298,7 +299,7 @@ void QgsGml::endElement( const XML_Char* el )
mParseModeStack.pop();
}
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
else if ( !mParseModeStack.empty() && mParseModeStack.top() == QgsGml::boundingBox && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
{
//create bounding box from mStringCash
if ( createBBoxFromCoordinateString( mCurrentExtent, mStringCash ) != 0 )
Expand Down
17 changes: 14 additions & 3 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
mLayerOrigName( lyrname ), // store the original name
mID( "" ),
mLayerType( type ),
mBlendMode( QgsMapRenderer::BlendNormal ) // Default to normal blending
mBlendMode( QPainter::CompositionMode_SourceOver ) // Default to normal blending
{
mCRS = new QgsCoordinateReferenceSystem();

Expand Down Expand Up @@ -134,13 +134,13 @@ QgsRectangle QgsMapLayer::extent()
}

/** Write blend mode for layer */
void QgsMapLayer::setBlendMode( const QgsMapRenderer::BlendMode blendMode )
void QgsMapLayer::setBlendMode( const QPainter::CompositionMode blendMode )
{
mBlendMode = blendMode;
}

/** Read blend mode for layer */
QgsMapRenderer::BlendMode QgsMapLayer::blendMode() const
QPainter::CompositionMode QgsMapLayer::blendMode() const
{
return mBlendMode;
}
Expand Down Expand Up @@ -360,6 +360,7 @@ bool QgsMapLayer::readXML( const QDomNode& layer_node )
mAbstract = abstractElem.text();
}

#if 0
//read transparency level
QDomNode transparencyNode = layer_node.namedItem( "transparencyLevelInt" );
if ( ! transparencyNode.isNull() )
Expand All @@ -369,6 +370,7 @@ bool QgsMapLayer::readXML( const QDomNode& layer_node )
QDomElement myElement = transparencyNode.toElement();
setTransparency( myElement.text().toInt() );
}
#endif

readCustomProperties( layer_node );

Expand Down Expand Up @@ -480,11 +482,13 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
mCRS->writeXML( mySrsElement, document );
maplayer.appendChild( mySrsElement );

#if 0
// <transparencyLevelInt>
QDomElement transparencyLevelIntElement = document.createElement( "transparencyLevelInt" );
QDomText transparencyLevelIntText = document.createTextNode( QString::number( getTransparency() ) );
transparencyLevelIntElement.appendChild( transparencyLevelIntText );
maplayer.appendChild( transparencyLevelIntElement );
#endif

// now append layer node to map layer node

Expand Down Expand Up @@ -610,6 +614,7 @@ void QgsMapLayer::setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSign
emit layerCrsChanged();
}

#if 0
unsigned int QgsMapLayer::getTransparency()
{
return mTransparencyLevel;
Expand All @@ -619,6 +624,7 @@ void QgsMapLayer::setTransparency( unsigned int theInt )
{
mTransparencyLevel = theInt;
}
#endif

QString QgsMapLayer::capitaliseLayerName( const QString& name )
{
Expand Down Expand Up @@ -818,6 +824,7 @@ QString QgsMapLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );

#if 0
//read transparency level
QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
if ( ! transparencyNode.isNull() )
Expand All @@ -827,6 +834,7 @@ QString QgsMapLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
QDomElement myElement = transparencyNode.toElement();
setTransparency( myElement.text().toInt() );
}
#endif

QString errorMsg;
theResultFlag = readSymbology( myRoot, errorMsg );
Expand Down Expand Up @@ -862,11 +870,14 @@ QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag
myRootNode.setAttribute( "minimumScale", QString::number( minimumScale() ) );
myRootNode.setAttribute( "maximumScale", QString::number( maximumScale() ) );

#if 0
// <transparencyLevelInt>
QDomElement transparencyLevelIntElement = myDocument.createElement( "transparencyLevelInt" );
QDomText transparencyLevelIntText = myDocument.createTextNode( QString::number( getTransparency() ) );
transparencyLevelIntElement.appendChild( transparencyLevelIntText );
myRootNode.appendChild( transparencyLevelIntElement );
#endif

// now append layer node to map layer node

QString errorMsg;
Expand Down
8 changes: 5 additions & 3 deletions src/core/qgsmaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
const QString& abstract() const { return mAbstract; }

/* Set the blending mode used for rendering a layer */
void setBlendMode( const QgsMapRenderer::BlendMode blendMode );
void setBlendMode( const QPainter::CompositionMode blendMode );
/* Returns the current blending mode for a layer */
QgsMapRenderer::BlendMode blendMode() const;
QPainter::CompositionMode blendMode() const;

/**Synchronises with changes in the datasource
@note added in version 1.6*/
Expand Down Expand Up @@ -198,11 +198,13 @@ class CORE_EXPORT QgsMapLayer : public QObject
* @note Added in v1.4 */
void removeCustomProperty( const QString& key );

#if 0
/** Accessor for transparency level. */
unsigned int getTransparency();

/** Mutator for transparency level. Should be between 0 and 255 */
virtual void setTransparency( unsigned int );
#endif

/**
* If an operation returns 0 (e.g. draw()), this function
Expand Down Expand Up @@ -477,7 +479,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
QgsMapLayer::LayerType mLayerType;

/** Blend mode for the layer */
QgsMapRenderer::BlendMode mBlendMode;
QPainter::CompositionMode mBlendMode;

/** Tag for embedding additional information */
QString mTag;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )

// Set the QPainter composition mode so that this layer is rendered using
// the desired blending mode
mypContextPainter->setCompositionMode( getCompositionMode( ml->blendMode() ) );
mypContextPainter->setCompositionMode( ml->blendMode() );

if ( !ml->hasScaleBasedVisibility() || ( ml->minimumScale() <= mScale && mScale < ml->maximumScale() ) || mOverview )
{
Expand Down
46 changes: 36 additions & 10 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext )
QgsDebugMsg( "Starting draw of labels: " + id() );

if ( mRendererV2 && mLabelOn &&
( !mLabel->scaleBasedVisibility() ||
( mLabel->minScale() <= rendererContext.rendererScale() &&
rendererContext.rendererScale() <= mLabel->maxScale() ) ) )
( !mLabel->scaleBasedVisibility() ||
( mLabel->minScale() <= rendererContext.rendererScale() &&
rendererContext.rendererScale() <= mLabel->maxScale() ) ) )
{
QgsAttributeList attributes;
foreach ( QString attrName, mRendererV2->usedAttributes() )
Expand Down Expand Up @@ -370,8 +370,6 @@ void QgsVectorLayer::drawRendererV2( QgsFeatureIterator &fit, QgsRenderContext&
QSettings settings;
bool vertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();

mRendererV2->startRender( rendererContext, this );

#ifndef Q_WS_MAC
int featureCount = 0;
#endif //Q_WS_MAC
Expand Down Expand Up @@ -465,9 +463,6 @@ void QgsVectorLayer::drawRendererV2Levels( QgsFeatureIterator &fit, QgsRenderCon
QSettings settings;
bool vertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();

// startRender must be called before symbolForFeature() calls to make sure renderer is ready
mRendererV2->startRender( rendererContext, this );

QgsSingleSymbolRendererV2* selRenderer = NULL;
if ( !mSelectedFeatureIds.isEmpty() )
{
Expand Down Expand Up @@ -653,6 +648,9 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
//register label and diagram layer to the labeling engine
prepareLabelingAndDiagrams( rendererContext, attributes, labeling );

//do startRender before getFeatures to give renderers the possibility of querying features in the startRender method
mRendererV2->startRender( rendererContext, this );

QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
.setFilterRect( rendererContext.extent() )
.setSubsetOfAttributes( attributes ) );
Expand Down Expand Up @@ -1511,6 +1509,18 @@ bool QgsVectorLayer::readXml( const QDomNode& layer_node )
updateFields();
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( checkJoinLayerRemove( QString ) ) );

QDomNode prevExpNode = layer_node.namedItem( "previewExpression" );

if ( prevExpNode.isNull() )
{
mDisplayExpression = "";
}
else
{
QDomElement prevExpElem = prevExpNode.toElement();
mDisplayExpression = prevExpElem.text();
}

QString errorMsg;
if ( !readSymbology( layer_node, errorMsg ) )
{
Expand Down Expand Up @@ -1658,6 +1668,12 @@ bool QgsVectorLayer::writeXml( QDomNode & layer_node,
layer_node.appendChild( provider );
}

// save preview expression
QDomElement prevExpElem = document.createElement( "previewExpression" );
QDomText prevExpText = document.createTextNode( mDisplayExpression );
prevExpElem.appendChild( prevExpText );
layer_node.appendChild( prevExpElem );

//save joins
mJoinBuffer->writeXml( layer_node, document );

Expand Down Expand Up @@ -1703,7 +1719,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
if ( !blendModeNode.isNull() )
{
QDomElement e = blendModeNode.toElement();
setBlendMode(( QgsMapRenderer::BlendMode ) e.text().toInt() );
setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) e.text().toInt() ) );
}

// use scale dependent visibility flag
Expand Down Expand Up @@ -2027,7 +2043,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&

// add the blend mode field
QDomElement blendModeElem = doc.createElement( "blendMode" );
QDomText blendModeText = doc.createTextNode( QString::number( blendMode() ) );
QDomText blendModeText = doc.createTextNode( QString::number( QgsMapRenderer::getBlendModeEnum( blendMode() ) ) );
blendModeElem.appendChild( blendModeText );
node.appendChild( blendModeElem );

Expand Down Expand Up @@ -2790,6 +2806,16 @@ const QString QgsVectorLayer::displayField() const
return mDisplayField;
}

void QgsVectorLayer::setDisplayExpression( const QString displayExpression )
{
mDisplayExpression = displayExpression;
}

const QString QgsVectorLayer::displayExpression()
{
return mDisplayExpression;
}

bool QgsVectorLayer::isEditable() const
{
return ( mEditBuffer && mDataProvider );
Expand Down
25 changes: 23 additions & 2 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,24 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Returns the primary display field name used in the identify results dialog */
const QString displayField() const;

/** Set the preview expression, used to create a human readable preview string.
* Used e.g. in the attribute table feature list. Uses @link {QgsExpression}.
*
* @param previewExpression The expression which will be used to preview features
* for this layer
* @note added in 2.0
*/
void setDisplayExpression( const QString displayExpression );

/**
* Get the preview expression, used to create a human readable preview string.
* Uses @link {QgsExpression}.
*
* @return The expression which will be used to preview features for this layer
* @note added in 2.0
*/
const QString displayExpression();

/** Returns the data provider */
QgsVectorDataProvider* dataProvider();

Expand Down Expand Up @@ -329,12 +347,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
void setRendererV2( QgsFeatureRendererV2* r );

/** Draw layer with renderer V2.
/** Draw layer with renderer V2. QgsFeatureRenderer::startRender() needs to be called before using this method
* @note added in 1.4
*/
void drawRendererV2( QgsFeatureIterator &fit, QgsRenderContext& rendererContext, bool labeling );

/** Draw layer with renderer V2 using symbol levels.
/** Draw layer with renderer V2 using symbol levels. QgsFeatureRenderer::startRender() needs to be called before using this method
* @note added in 1.4
*/
void drawRendererV2Levels( QgsFeatureIterator &fit, QgsRenderContext& rendererContext, bool labeling );
Expand Down Expand Up @@ -973,6 +991,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** index of the primary label field */
QString mDisplayField;

/** the preview expression used to generate a human readable preview string for features */
QString mDisplayExpression;

/** Data provider key */
QString mProviderKey;

Expand Down
16 changes: 11 additions & 5 deletions src/core/raster/qgsrasterdataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "qgsproviderregistry.h"
#include "qgsrasterdataprovider.h"
#include "qgsrasteridentifyresult.h"
#include "qgsrasterprojector.h"
#include "qgslogger.h"

Expand All @@ -27,6 +28,9 @@

#include <qmath.h>

#define ERRMSG(message) QGS_ERROR_MESSAGE(message, "Raster provider")
#define ERR(message) QgsError(message, "Raster provider")

void QgsRasterDataProvider::setUseSrcNoDataValue( int bandNo, bool use )
{
if ( mUseSrcNoDataValue.size() < bandNo )
Expand Down Expand Up @@ -265,15 +269,16 @@ QString QgsRasterDataProvider::metadata()
}

// Default implementation for values
QMap<int, QVariant> QgsRasterDataProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
//QMap<int, QVariant> QgsRasterDataProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
QgsRasterIdentifyResult QgsRasterDataProvider::identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent, int theWidth, int theHeight )
{
QgsDebugMsg( "Entered" );
QMap<int, QVariant> results;

if ( theFormat != IdentifyFormatValue || !( capabilities() & IdentifyValue ) )
{
QgsDebugMsg( "Format not supported" );
return results;
return QgsRasterIdentifyResult( ERR( tr( "Format not supported" ) ) );
}

if ( !extent().contains( thePoint ) )
Expand All @@ -283,7 +288,7 @@ QMap<int, QVariant> QgsRasterDataProvider::identify( const QgsPoint & thePoint,
{
results.insert( bandNo, noDataValue( bandNo ) );
}
return results;
return QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormatValue, results );
}

QgsRectangle myExtent = theExtent;
Expand Down Expand Up @@ -320,7 +325,7 @@ QMap<int, QVariant> QgsRasterDataProvider::identify( const QgsPoint & thePoint,

results.insert( i, value );
}
return results;
return QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormatValue, results );
}

QMap<QString, QString> QgsRasterDataProvider::identify( const QgsPoint & thePoint, const QgsRectangle &theExtent, int theWidth, int theHeight )
Expand All @@ -345,7 +350,8 @@ QMap<QString, QString> QgsRasterDataProvider::identify( const QgsPoint & thePoin
return results;
}

QMap<int, QVariant> myResults = identify( thePoint, identifyFormat, theExtent, theWidth, theHeight );
QgsRasterIdentifyResult myResult = identify( thePoint, identifyFormat, theExtent, theWidth, theHeight );
QMap<int, QVariant> myResults = myResult.results();

if ( identifyFormat == QgsRasterDataProvider::IdentifyFormatValue )
{
Expand Down
11 changes: 7 additions & 4 deletions src/core/raster/qgsrasterdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define QGSRASTERDATAPROVIDER_H

#include <QDateTime>
#include <QVariant>

#include "qgslogger.h"
#include "qgsrectangle.h"
Expand All @@ -39,9 +40,10 @@
#include <cmath>

class QImage;
class QgsPoint;
class QByteArray;
#include <QVariant>

class QgsPoint;
class QgsRasterIdentifyResult;

#define TINY_VALUE std::numeric_limits<double>::epsilon() * 20
#define RASTER_HISTOGRAM_BINS 256
Expand Down Expand Up @@ -344,9 +346,10 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
* IdentifyFormatHtml: map of HTML strings for each sublayer (WMS).
* Empty if failed or there are no results (TODO: better error reporting).
*/
virtual QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

//virtual QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );
virtual QgsRasterIdentifyResult identify( const QgsPoint & thePoint, IdentifyFormat theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

// TODO: remove in 2.0
QMap<QString, QString> identify( const QgsPoint & thePoint, const QgsRectangle &theExtent = QgsRectangle(), int theWidth = 0, int theHeight = 0 );

/**
Expand Down
47 changes: 47 additions & 0 deletions src/core/raster/qgsrasteridentifyresult.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/***************************************************************************
qgsrasteridentifyresult.cpp
--------------------------------------
Date : Apr 8, 2013
Copyright : (C) 2013 by Radim Blazek
email : radim dot blazek at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

//#include <QTime>

#include "qgis.h"
#include "qgslogger.h"
#include "qgsrasteridentifyresult.h"
#include "qgsrasterdataprovider.h"

QgsRasterIdentifyResult::QgsRasterIdentifyResult()
: mValid(false)
, mFormat(QgsRasterDataProvider::IdentifyFormatUndefined)
{
}

QgsRasterIdentifyResult::QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormat theFormat, QMap<int, QVariant> theResults )
: mValid(true)
, mFormat(theFormat)
, mResults(theResults)
{
}

QgsRasterIdentifyResult::QgsRasterIdentifyResult( QgsError theError )
: mValid(false)
, mFormat(QgsRasterDataProvider::IdentifyFormatUndefined)
, mError(theError)
{
}

QgsRasterIdentifyResult::~QgsRasterIdentifyResult()
{
}
94 changes: 94 additions & 0 deletions src/core/raster/qgsrasteridentifyresult.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/***************************************************************************
qgsrasteridentifyresult.h
--------------------------------------
Date : Apr 8, 2013
Copyright : (C) 2013 by Radim Blazek
email : radim dot blazek at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSRASTERIDENTIFYRESULT_H
#define QGSRASTERIDENTIFYRESULT_H

#include "qgis.h"
#include "qgslogger.h"
#include "qgsrasterdataprovider.h"

/** \ingroup core
* Raster identify results container.
*/
class CORE_EXPORT QgsRasterIdentifyResult
{
public:
QgsRasterIdentifyResult();

/** \brief Constructor. Creates valid result.
* @param theResults results
*/
QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormat theFormat, QMap<int, QVariant> theResults );

/** \brief Constructor. Creates invalid result with error.
* @param theResults results
*/
QgsRasterIdentifyResult( QgsError theError );

virtual ~QgsRasterIdentifyResult();

/** \brief Returns true if valid */
bool isValid() const { return mValid; }

/** \brief Get results format */
QgsRasterDataProvider::IdentifyFormat format() const { return mFormat; }

/** \brief Get results. Results are different for each format:
* IdentifyFormatValue: map of values for each band, keys are band numbers (from 1).
* IdentifyFormatFeature: map of QgsRasterFeatureList for each sublayer (WMS)
* IdentifyFormatHtml: map of HTML strings for each sublayer (WMS).
*/
QMap<int, QVariant> results() const { return mResults; }

/** Set map of optional parameters */
void setParams( const QMap<QString, QVariant> & theParams ) { mParams = theParams; }

/** Get map of optional parameters */
QMap<QString, QVariant> params() const { return mParams; }

/** \brief Get error */
QgsError error() const { return mError; }

/** \brief Set error */
void setError( const QgsError & theError ) { mError = theError;}

/** \brief Add error message */
void appendError( const QgsErrorMessage & theMessage ) { mError.append( theMessage );}

private:
/** \brief Is valid */
bool mValid;

/** \brief Results format */
QgsRasterDataProvider::IdentifyFormat mFormat;

/** \brief Results */
// TODO: better hierarchy (sublayer multiple feature sets)?
// TODO?: results are not consistent for different formats (per band x per sublayer)
QMap<int, QVariant> mResults;

/** \brief Additional params (e.g. request url used by WMS) */
QMap<QString, QVariant> mParams;

/** \brief Error */
QgsError mError;
};

#endif


4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
if ( !blendModeNode.isNull() )
{
QDomElement e = blendModeNode.toElement();
setBlendMode(( QgsMapRenderer::BlendMode ) e.text().toInt() );
setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) e.text().toInt() ) );
}

return true;
Expand Down Expand Up @@ -2531,7 +2531,7 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum

// add blend mode node
QDomElement blendModeElement = document.createElement( "blendMode" );
QDomText blendModeText = document.createTextNode( QString::number( blendMode() ) );
QDomText blendModeText = document.createTextNode( QString::number( QgsMapRenderer::getBlendModeEnum( blendMode() ) ) );
blendModeElement.appendChild( blendModeText );
layer_node.appendChild( blendModeElement );

Expand Down
25 changes: 20 additions & 5 deletions src/core/symbology-ng/qgspointdisplacementrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ void QgsPointDisplacementRenderer::createDisplacementGroups( QgsVectorLayer* vla
QgsFeature f;
QList<QgsFeatureId> intersectList;

//Because the new vector api does not allow querying features by id within a nextFeature loop, default constructed QgsFeature() is
//inserted first and the real features are created in a second loop

QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( viewExtent ).setSubsetOfAttributes( attList ) );
while ( fit.nextFeature( f ) )
{
Expand All @@ -389,7 +392,7 @@ void QgsPointDisplacementRenderer::createDisplacementGroups( QgsVectorLayer* vla
{
found = true;
QgsFeature feature;
it->insert( f.id(), f );
it->insert( f.id(), QgsFeature() );
mDisplacementIds.insert( f.id() );
break;
}
Expand All @@ -398,17 +401,29 @@ void QgsPointDisplacementRenderer::createDisplacementGroups( QgsVectorLayer* vla
if ( !found )//insert the already existing feature and the new one into a map
{
QMap<QgsFeatureId, QgsFeature> newMap;
QgsFeature existingFeature;
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( existingEntry ) ).nextFeature( existingFeature );
newMap.insert( existingEntry, existingFeature );
newMap.insert( existingEntry, QgsFeature() );
mDisplacementIds.insert( existingEntry );
newMap.insert( f.id(), f );
newMap.insert( f.id(), QgsFeature() );
mDisplacementIds.insert( f.id() );
mDisplacementGroups.push_back( newMap );
}
}
}
}

//insert the real features into mDisplacementGroups
QList< QMap<QgsFeatureId, QgsFeature> >::iterator it = mDisplacementGroups.begin();
for ( ; it != mDisplacementGroups.end(); ++it )
{
QMap<QgsFeatureId, QgsFeature>::iterator mapIt = it->begin();
for ( ; mapIt != it->end(); ++mapIt )
{
QgsFeature fet;
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( mapIt.key() ) ).nextFeature( fet );
mapIt.value() = fet;
}
}

}

QgsRectangle QgsPointDisplacementRenderer::searchRect( const QgsPoint& p ) const
Expand Down
16 changes: 15 additions & 1 deletion src/gui/attributetable/qgsattributetablefiltermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ void QgsAttributeTableFilterModel::masterSelectionChanged( const QItemSelection
}

// Now emit the signal
layer()->setSelectedFeatures( layer()->selectedFeaturesIds() );
if ( mSyncSelection )
{
layer()->setSelectedFeatures( layer()->selectedFeaturesIds() );
}

connect( layer(), SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
}
Expand Down Expand Up @@ -321,6 +324,17 @@ QItemSelectionModel* QgsAttributeTableFilterModel::masterSelection()
return mMasterSelection;
}

void QgsAttributeTableFilterModel::disableSelectionSync()
{
mSyncSelection = false;
}

void QgsAttributeTableFilterModel::enableSelectionSync()
{
mSyncSelection = true;
layer()->setSelectedFeatures( layer()->selectedFeaturesIds() );
}

QModelIndex QgsAttributeTableFilterModel::mapToMaster( const QModelIndex &proxyIndex ) const
{
// Master is source
Expand Down
21 changes: 21 additions & 0 deletions src/gui/attributetable/qgsattributetablefiltermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel
*/
inline QgsVectorLayer *layer() const { return masterModel()->layer(); }

/**
* Returns the layerCache this filter acts on.
*
* @return The layer cache
*/
inline QgsVectorLayerCache *layerCache() const { return masterModel()->layerCache(); }

/**
Expand Down Expand Up @@ -120,6 +125,21 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel
*/
QItemSelectionModel* masterSelection();

/**
* Disables selection synchronisation with the map canvas. Changes to the selection in the master
* model are propagated to the layer, but no redraw is requested until @link{enableSelectionSync()}
* is called.
*/
void disableSelectionSync();

/**
* Enables selection synchronisation with the map canvas. Changes to the selection in the master
* are propagated and upon every change, a redraw will be requested. This method will update the
* selection to account for any cached selection change since @link{disableSelectionSync()} was
* called.
*/
void enableSelectionSync();

virtual QModelIndex mapToMaster( const QModelIndex &proxyIndex ) const;

virtual QModelIndex mapFromMaster( const QModelIndex &sourceIndex ) const;
Expand Down Expand Up @@ -194,6 +214,7 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel
bool mSelectedOnTop;
QItemSelectionModel* mMasterSelection;
QgsAttributeTableModel* mTableModel;
bool mSyncSelection;
};

#endif
6 changes: 5 additions & 1 deletion src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ void QgsAttributeTableModel::layerDeleted()

void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
{
if ( fid == mFeat.id() )
{
mFeat.setValid( false );
}
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
}

Expand Down Expand Up @@ -469,7 +473,7 @@ QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role ) cons
}

// if we don't have the row in current cache, load it from layer first
if ( mFeat.id() != rowId )
if ( mFeat.id() != rowId || !mFeat.isValid() )
{
if ( !loadFeatureAtId( rowId ) )
return QVariant( "ERROR" );
Expand Down
39 changes: 22 additions & 17 deletions src/gui/attributetable/qgsattributetableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ QgsAttributeTableView::QgsAttributeTableView( QWidget *parent )
setSelectionMode( QAbstractItemView::ExtendedSelection );
setSortingEnabled( true );

connect( verticalHeader(), SIGNAL( sectionClicked( int ) ), SLOT( onVerticalHeaderSectionClicked( int ) ) );
verticalHeader()->viewport()->installEventFilter( this );
}

QgsAttributeTableView::~QgsAttributeTableView()
Expand Down Expand Up @@ -75,6 +75,27 @@ void QgsAttributeTableView::setCanvasAndLayerCache( QgsMapCanvas *canvas, QgsVec
delete filterModel;
}

bool QgsAttributeTableView::eventFilter(QObject *object, QEvent *event)
{
if ( object == verticalHeader()->viewport() )
{
switch ( event->type() )
{
case QEvent::MouseButtonPress:
mFilterModel->disableSelectionSync();
break;

case QEvent::MouseButtonRelease:
mFilterModel->enableSelectionSync();
break;

default:
break;
}
}
return false;
}

void QgsAttributeTableView::setModel( QgsAttributeTableFilterModel* filterModel )
{
if ( mFilterModel )
Expand Down Expand Up @@ -158,22 +179,6 @@ void QgsAttributeTableView::keyPressEvent( QKeyEvent *event )
}
}

void QgsAttributeTableView::onVerticalHeaderSectionClicked( int logicalIndex )
{
Q_UNUSED( logicalIndex )

QgsFeatureIds selectedFeatures;

QModelIndexList selectedRows = selectionModel()->selectedRows();

foreach ( QModelIndex row, selectedRows )
{
selectedFeatures.insert( mFilterModel->rowToId( row ) );
}

emit selectionChangeFinished( selectedFeatures );
}

void QgsAttributeTableView::onFilterAboutToBeInvalidated()
{
disconnect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
Expand Down
28 changes: 12 additions & 16 deletions src/gui/attributetable/qgsattributetableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView
*/
void setCanvasAndLayerCache( QgsMapCanvas *canvas, QgsVectorLayerCache *layerCache );

/**
* This event filter is installed on the verticalHeader to intercept mouse press and release
* events. These are used to disable / enable live synchronisation with the map canvas selection
* which can be slow due to recurring canvas repaints. Updating the
*
* @param object The object which is the target of the event.
* @param event The intercepted event
*
* @return Returns always false, so the event gets processed
*/
virtual bool eventFilter( QObject* object, QEvent* event );

protected:
/**
* Called for mouse press events on a table cell.
Expand Down Expand Up @@ -124,23 +136,7 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView

void finished();

/**
* @brief
* Is emitted, after the selection has been changed.
*
* @param selectedFeatures A list of currently selected features.
*/
void selectionChangeFinished( const QgsFeatureIds &selectedFeatures );

public slots:
/**
* Is triggered after a mouse release event on the vertical header.
* Emits a selectionChangeFinished() signal, so the underlying sort filter
* can adapt to the current selection without disturbing the users current interaction.
*
* @param logicalIndex The section's logical index
*/
void onVerticalHeaderSectionClicked( int logicalIndex );
void onFilterAboutToBeInvalidated();
void onFilterInvalidated();
void onSelectionChanged( const QItemSelection& selected, const QItemSelection& deselected );
Expand Down
101 changes: 66 additions & 35 deletions src/gui/attributetable/qgsdualview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ QgsDualView::QgsDualView( QWidget* parent )
// Connect layer list preview signals
connect( mActionExpressionPreview, SIGNAL( triggered() ), SLOT( previewExpressionBuilder() ) );
connect( mPreviewActionMapper, SIGNAL( mapped( QObject* ) ), SLOT( previewColumnChanged( QObject* ) ) );
connect( mFeatureList, SIGNAL( displayExpressionChanged( QString ) ), this, SLOT( previewExpressionChanged( QString ) ) );
}

QgsDualView::~QgsDualView()
Expand Down Expand Up @@ -76,6 +77,54 @@ void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QgsDista

void QgsDualView::columnBoxInit()
{
// load fields
QList<QgsField> fields = mLayerCache->layer()->pendingFields().toList();

// default expression: saved value
QString displayExpression = mLayerCache->layer()->displayExpression();

// if no display expression is saved: use display field instead
if ( displayExpression == "" )
{
displayExpression = mLayerCache->layer()->displayField();
}

// if neither diaplay expression nor display field is saved...
if ( displayExpression == "" )
{
QgsAttributeList pkAttrs = mLayerCache->layer()->pendingPkAttributesList();

if ( pkAttrs.size() > 0 )
{
// ... If there are primary key(s) defined
QStringList pkFields;

foreach ( int attr, pkAttrs )
{
pkFields.append( "\"" + fields[attr].name() + "\"" );
}

displayExpression = pkFields.join( "||', '||" );
}
else if ( fields.size() > 0 )
{
// ... concat all fields
QStringList fieldNames;
foreach ( QgsField field, fields )
{
fieldNames.append( "\"" + field.name() + "\"" );
}

displayExpression = fieldNames.join( "||', '||" );
}
else
{
// ... there isn't really much to display
displayExpression = "[Please define preview text]";
}
}

// now initialise the menu
QList< QAction* > previewActions = mFeatureListPreviewButton->actions();
foreach ( QAction* a, previewActions )
{
Expand All @@ -89,8 +138,6 @@ void QgsDualView::columnBoxInit()
mFeatureListPreviewButton->addAction( mActionExpressionPreview );
mFeatureListPreviewButton->addAction( mActionPreviewColumnsMenu );

QList<QgsField> fields = mLayerCache->layer()->pendingFields().toList();

foreach ( const QgsField field, fields )
{
if ( mLayerCache->layer()->editType( mLayerCache->layer()->fieldNameIndex( field.name() ) ) != QgsVectorLayer::Hidden )
Expand All @@ -104,45 +151,18 @@ void QgsDualView::columnBoxInit()
connect( previewAction, SIGNAL( triggered() ), mPreviewActionMapper, SLOT( map() ) );
mPreviewColumnsMenu->addAction( previewAction );

if ( text == mLayerCache->layer()->displayField() )
if ( text == displayExpression )
{
mFeatureListPreviewButton->setDefaultAction( previewAction );
}
}
}

// Most likely no displayField is defined
// Join primary key fields
// If there is no single field found as preview
if ( !mFeatureListPreviewButton->defaultAction() )
{
mFeatureList->setDisplayExpression( displayExpression );
mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
QgsAttributeList pkAttrs = mLayerCache->layer()->pendingPkAttributesList();
// If there is a primary key defined
if ( pkAttrs.size() > 0 )
{
QStringList pkFields;

foreach ( int attr, pkAttrs )
{
pkFields.append( "\"" + fields[attr].name() + "\"" );
}

mFeatureList->setDisplayExpression( pkFields.join( "||', '||" ) );
}
else if ( fields.size() > 0 )
{
QStringList fieldNames;
foreach ( QgsField field, fields )
{
fieldNames.append( "\"" + field.name() + "\"" );
}

mFeatureList->setDisplayExpression( fieldNames.join( "||', '||" ) );
}
else
{
mFeatureList->setDisplayExpression( "[Please define preview text]" );
}
}
else
{
Expand Down Expand Up @@ -191,6 +211,10 @@ void QgsDualView::initModels( QgsMapCanvas* mapCanvas )
mMasterModel->loadLayer();

mFilterModel = new QgsAttributeTableFilterModel( mapCanvas, mMasterModel, mMasterModel );

connect( mFilterModel, SIGNAL( filterInvalidated() ), this, SIGNAL( filterChanged() ) );
connect( mFeatureList, SIGNAL( displayExpressionChanged( QString ) ), this, SIGNAL( displayExpressionChanged( QString ) ) );

mFeatureListModel = new QgsFeatureListModel( mFilterModel, mFilterModel );
}

Expand Down Expand Up @@ -272,9 +296,11 @@ void QgsDualView::previewColumnChanged( QObject* action )
.arg( mFeatureList->parserErrorString() )
);
}

mFeatureListPreviewButton->setDefaultAction( previewAction );
mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
else
{
mFeatureListPreviewButton->setDefaultAction( previewAction );
mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
}
}

Q_ASSERT( previewAction );
Expand Down Expand Up @@ -325,6 +351,11 @@ void QgsDualView::viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex )
menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
}

void QgsDualView::previewExpressionChanged( const QString expression )
{
mLayerCache->layer()->setDisplayExpression( expression );
}

void QgsDualView::setFilteredFeatures( QgsFeatureIds filteredFeatures )
{
mFilterModel->setFilteredFeatures( filteredFeatures );
Expand Down
12 changes: 12 additions & 0 deletions src/gui/attributetable/qgsdualview.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
void setCurrentEditSelection( const QgsFeatureIds& fids );

signals:
/**
* Is emitted, whenever the display expression is successfully changed
* @param The expression that was applied
*/
void displayExpressionChanged( const QString expression );

/**
* Is emitted, whenever the filter changes
*/
void filterChanged();

private slots:
/**
Expand All @@ -113,6 +123,8 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas

void viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex );

void previewExpressionChanged( const QString expression );

/**
* Will be called periodically, when loading layers from slow data providers.
*
Expand Down
10 changes: 10 additions & 0 deletions src/gui/attributetable/qgsfeaturelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,13 @@ int QgsFeatureListModel::rowCount( const QModelIndex& parent ) const
Q_UNUSED( parent )
return sourceModel()->rowCount();
}

void QgsFeatureListModel::disableSelectionSync()
{
mFilterModel->disableSelectionSync();
}

void QgsFeatureListModel::enableSelectionSync()
{
mFilterModel->enableSelectionSync();
}
15 changes: 15 additions & 0 deletions src/gui/attributetable/qgsfeaturelistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ class QgsFeatureListModel : public QAbstractProxyModel
virtual int columnCount( const QModelIndex&parent = QModelIndex() ) const;
virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;

/**
* Disables selection synchronisation with the map canvas. Changes to the selection in the master
* model are propagated to the layer, but no redraw is requested until @link{enableSelectionSync()}
* is called.
*/
void disableSelectionSync();

/**
* Enables selection synchronisation with the map canvas. Changes to the selection in the master
* are propagated and upon every change, a redraw will be requested. This method will update the
* selection to account for any cached selection change since @link{disableSelectionSync()} was
* called.
*/
void enableSelectionSync();

public slots:
void onBeginRemoveRows( const QModelIndex& parent, int first, int last );
void onEndRemoveRows( const QModelIndex& parent, int first, int last );
Expand Down
25 changes: 20 additions & 5 deletions src/gui/attributetable/qgsfeaturelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ void QgsFeatureListView::setModel( QgsFeatureListModel* featureListModel )

bool QgsFeatureListView::setDisplayExpression( const QString expression )
{
return mModel->setDisplayExpression( expression );
if ( mModel->setDisplayExpression( expression ) )
{
emit displayExpressionChanged( expression );
return true;
}
else
{
return false;
}
}

const QString& QgsFeatureListView::displayExpression() const
Expand Down Expand Up @@ -106,7 +114,7 @@ void QgsFeatureListView::mousePressEvent( QMouseEvent *event )
{
QPoint pos = event->pos();

if ( QgsFeatureListViewDelegate::EditButtonElement == mItemDelegate->positionToElement( event->pos() ) )
if ( QgsFeatureListViewDelegate::EditElement == mItemDelegate->positionToElement( event->pos() ) )
{
mEditSelectionDrag = true;
QModelIndex index = mModel->mapToMaster( indexAt( pos ) );
Expand All @@ -115,15 +123,22 @@ void QgsFeatureListView::mousePressEvent( QMouseEvent *event )
}
else
{
mModel->disableSelectionSync();
QListView::mousePressEvent( event );
}
}

void QgsFeatureListView::mouseReleaseEvent( QMouseEvent *event )
{
mEditSelectionDrag = false;

QListView::mouseReleaseEvent( event );
if ( mEditSelectionDrag )
{
mEditSelectionDrag = false;
}
else
{
QListView::mouseReleaseEvent( event );
mModel->enableSelectionSync();
}
}

void QgsFeatureListView::editSelectionChanged( QItemSelection deselected, QItemSelection selected )
Expand Down
6 changes: 6 additions & 0 deletions src/gui/attributetable/qgsfeaturelistview.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class GUI_EXPORT QgsFeatureListView : public QListView
*/
void currentEditSelectionChanged( QgsFeature &feat );

/**
* Is emitted, whenever the display expression is successfully changed
* @param The expression that was applied
*/
void displayExpressionChanged( const QString expression );

public slots:
/**
* Set the feature(s) to be edited
Expand Down
44 changes: 23 additions & 21 deletions src/gui/attributetable/qgsfeaturelistviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ QgsFeatureListViewDelegate::QgsFeatureListViewDelegate( QgsFeatureListModel *lis

QgsFeatureListViewDelegate::Element QgsFeatureListViewDelegate::positionToElement( const QPoint &pos )
{
if ( pos.x() < sIconSize )
if ( pos.x() > sIconSize )
{
return EditButtonElement;
return EditElement;
}
else
{
return TextElement;
return SelectionElement;
}
}

Expand All @@ -45,46 +45,48 @@ void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionVie
{
QString text = index.model()->data( index, Qt::EditRole ).toString();
QgsFeatureListModel::FeatureInfo featInfo = index.model()->data( index, Qt::UserRole ).value<QgsFeatureListModel::FeatureInfo>();
bool isEdited = mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );

// Edit button state
bool checked = mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );
// Icon layout options
QStyleOptionViewItem iconOption;

QStyleOptionButton pbn1Opts;
QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );

pbn1Opts.iconSize = QSize( sIconSize, sIconSize );
QPixmap icon;

pbn1Opts.state |= QStyle::State_Enabled;
if ( checked )
if ( option.state.testFlag( QStyle::State_Selected ) )
{
pbn1Opts.icon = QgsApplication::getThemeIcon( "/mIconEditableEdits.png" );
pbn1Opts.state |= QStyle::State_On;
// Item is selected
icon = QgsApplication::getThemePixmap( "/mIconSelected.svg" );
}
else
{
pbn1Opts.icon = QgsApplication::getThemeIcon( "/mIconEditable.png" );
pbn1Opts.state |= QStyle::State_Off;
icon = QgsApplication::getThemePixmap( "/mIconDeselected.svg" );
}

QRect pbn1Rect( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );
pbn1Opts.rect = pbn1Rect;
// Text layout options
QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );

QApplication::style()->drawControl( QStyle::CE_PushButton, &pbn1Opts, painter );

QRect textLayoutBounds( pbn1Rect.x() + pbn1Rect.width(), option.rect.y(), option.rect.width() - ( pbn1Rect.x() + pbn1Rect.width() ), option.rect.height() );

QStyleOptionViewItem textOption = option;
QStyleOptionViewItem textOption;
textOption.state |= QStyle::State_Enabled;
if ( isEdited )
{
textOption.state |= QStyle::State_Selected;
}

if ( featInfo.isNew )
{
textOption.font.setStyle( QFont::StyleItalic );
textOption.palette.setColor( QPalette::Text, Qt::darkGreen );
textOption.palette.setColor( QPalette::HighlightedText, Qt::darkGreen );
}
else if ( featInfo.isEdited || checked )
else if ( featInfo.isEdited || isEdited )
{
textOption.font.setStyle( QFont::StyleItalic );
textOption.palette.setColor( QPalette::Text, Qt::red );
textOption.palette.setColor( QPalette::HighlightedText, Qt::red );
}

drawDisplay( painter, textOption, textLayoutBounds, text );
drawDecoration( painter, iconOption, iconLayoutBounds, icon );
}
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsfeaturelistviewdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class QgsFeatureListViewDelegate : public QItemDelegate

enum Element
{
EditButtonElement,
TextElement
EditElement,
SelectionElement
};

explicit QgsFeatureListViewDelegate( QgsFeatureListModel* listModel, QObject *parent = 0 );
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsblendmodecombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ void QgsBlendModeComboBox::updateModes()
blockSignals( false );
}

//! Function to read the selected blend mode as int
int QgsBlendModeComboBox::blendMode()
//! Function to read the selected blend mode
QPainter::CompositionMode QgsBlendModeComboBox::blendMode()
{
return mListIndexToBlendMode[ currentIndex()];
return QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) mListIndexToBlendMode[ currentIndex()] );
}

//! Function to set the selected blend mode from int
void QgsBlendModeComboBox::setBlendMode( int blendMode )
//! Function to set the selected blend mode
void QgsBlendModeComboBox::setBlendMode( QPainter::CompositionMode blendMode )
{
setCurrentIndex( mBlendModeToListIndex[ blendMode ] );
setCurrentIndex( mBlendModeToListIndex[( int ) QgsMapRenderer::getBlendModeEnum( blendMode )] );
}

10 changes: 6 additions & 4 deletions src/gui/qgsblendmodecombobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#define QGSBLENDMODECOMBOBOX_H

#include <QComboBox>
#include <QPainter> // For QPainter::CompositionMode enum
#include "qgsmaprenderer.h" //for getCompositionMode

/** \ingroup gui
* A combobox which lets the user select blend modes from a predefined list
Expand All @@ -30,10 +32,10 @@ class GUI_EXPORT QgsBlendModeComboBox : public QComboBox
QgsBlendModeComboBox( QWidget* parent = 0 );
virtual ~QgsBlendModeComboBox();

//! Function to read the selected blend mode as integer
int blendMode();
//! Function to set the selected blend mode from integer
void setBlendMode( int blendMode );
//! Function to read the selected blend mode as QPainter::CompositionMode
QPainter::CompositionMode blendMode();
//! Function to set the selected blend mode from QPainter::CompositionMode
void setBlendMode( QPainter::CompositionMode blendMode );
private:
//! Returns a list of grouped blend modes (with seperators)
QStringList blendModesList() const;
Expand Down
5 changes: 3 additions & 2 deletions src/gui/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "qgsmessageviewer.h"
#include "qgsmaplayer.h"
#include "qgsrasterlayer.h"
#include "qgsrasteridentifyresult.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
Expand Down Expand Up @@ -392,7 +393,7 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
if ( mCanvas->hasCrsTransformEnabled() && dprovider->crs() != mCanvas->mapRenderer()->destinationCrs() )
{
viewExtent = toLayerCoordinates( layer, viewExtent );
values = dprovider->identify( point, format );
values = dprovider->identify( point, format ).results();
}
else
{
Expand All @@ -415,7 +416,7 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( width ).arg( height ) );
QgsDebugMsg( QString( "xRes = %1 yRes = %2 mapUnitsPerPixel = %3" ).arg( viewExtent.width() / width ).arg( viewExtent.height() / height ).arg( mapUnitsPerPixel ) );

values = dprovider->identify( point, format, viewExtent, width, height );
values = dprovider->identify( point, format, viewExtent, width, height ).results();
}

derivedAttributes.insert( tr( "(clicked coordinate)" ), point.toString() );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void QgsRendererV2PropertiesDialog::apply()
}

// set the blend mode for the layer
mLayer->setBlendMode(( QgsMapRenderer::BlendMode ) mBlendModeComboBox->blendMode() );
mLayer->setBlendMode( mBlendModeComboBox->blendMode() );
}

void QgsRendererV2PropertiesDialog::onOK()
Expand Down
12 changes: 12 additions & 0 deletions src/mapserver/qgssldparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c
#ifdef DIAGRAMSERVER
overlaysFromUserStyle( userStyleElement, v );
#endif //DIAGRAMSERVER
#if 0
setOpacityForLayer( namedLayerElemList[i], v );
#endif

resultList.push_back( v );
return resultList;
Expand All @@ -293,7 +295,9 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c
{
rasterSymbologyFromUserStyle( userStyleElement, r );

#if 0
setOpacityForLayer( namedLayerElemList[i], r );
#endif

//Using a contour symbolizer, there may be a raster and a vector layer
QgsVectorLayer* v = contourLayerFromRaster( userStyleElement, r );
Expand All @@ -320,11 +324,13 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c
resultList = mFallbackParser->mapLayerFromStyle( layerName, styleName, useCache );
}

#if 0
QList<QgsMapLayer*>::iterator it = resultList.begin();
for ( ; it != resultList.end(); ++it )
{
setOpacityForLayer( userLayerElement, *it );
}
#endif

return resultList;
}
Expand Down Expand Up @@ -361,7 +367,9 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c
mLayersToRemove.push_back( v );
}
}
#if 0
setOpacityForLayer( userLayerElement, theMapLayer );
#endif
resultList.push_back( theMapLayer );

return resultList;
Expand Down Expand Up @@ -394,7 +402,9 @@ QList<QgsMapLayer*> QgsSLDParser::mapLayerFromStyle( const QString& layerName, c
}
theVectorLayer->setRendererV2( theRenderer );
QgsDebugMsg( "Returning the vectorlayer" );
#if 0
setOpacityForLayer( userLayerElement, theVectorLayer );
#endif
resultList.push_back( theVectorLayer );
return resultList;
}
Expand Down Expand Up @@ -1449,6 +1459,7 @@ QString QgsSLDParser::layerNameFromUri( const QString& uri ) const
return "";
}

#if 0
void QgsSLDParser::setOpacityForLayer( const QDomElement& layerElem, QgsMapLayer* layer ) const
{
QDomNode opacityNode = layerElem.namedItem( "Opacity" );
Expand Down Expand Up @@ -1477,6 +1488,7 @@ void QgsSLDParser::setOpacityForLayer( const QDomElement& layerElem, QgsMapLayer
QgsDebugMsg( "Setting opacity value: " + QString::number( opacityValue ) );
layer->setTransparency( opacityValue );
}
#endif

void QgsSLDParser::clearRasterSymbology( QgsRasterLayer* rl ) const
{
Expand Down
2 changes: 2 additions & 0 deletions src/mapserver/qgssldparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ class QgsSLDParser: public QgsConfigParser
QgsVectorLayer* contourLayerFromRaster( const QDomElement& userStyleElem, QgsRasterLayer* rasterLayer ) const;
/**Creates a suitable layer name from a URL. */
QString layerNameFromUri( const QString& uri ) const;
#if 0
/**Sets the opacity on layer level if the <Opacity> tag is present*/
void setOpacityForLayer( const QDomElement& layerElem, QgsMapLayer* layer ) const;
#endif
/**Resets the former symbology of a raster layer. This is important for single band layers (e.g. dems)
coming from the cash*/
void clearRasterSymbology( QgsRasterLayer* rl ) const;
Expand Down
27 changes: 5 additions & 22 deletions src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,10 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )

QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> > bkVectorRenderers;
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > > bkRasterRenderers;
QList< QPair< QgsVectorLayer*, unsigned int> > bkVectorOld;
QList< QPair< QgsVectorLayer*, double > > labelTransparencies;
QList< QPair< QgsVectorLayer*, double > > labelBufferTransparencies;

applyOpacities( layersList, bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
applyOpacities( layersList, bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );


QgsComposition* c = mConfigParser->createPrintComposition( mParameterMap[ "TEMPLATE" ], mMapRenderer, QMap<QString, QString>( mParameterMap ) );
Expand Down Expand Up @@ -591,7 +590,7 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
throw QgsMapServiceException( "InvalidFormat", "Output format '" + formatString + "' is not supported in the GetPrint request" );
}

restoreOpacities( bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
restoreOpacities( bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
restoreLayerFilters( originalLayerFilters );
clearFeatureSelections( selectedLayerIdList );

Expand Down Expand Up @@ -632,11 +631,10 @@ QImage* QgsWMSServer::getMap()

QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> > bkVectorRenderers;
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > > bkRasterRenderers;
QList< QPair< QgsVectorLayer*, unsigned int> > bkVectorOld;
QList< QPair< QgsVectorLayer*, double > > labelTransparencies;
QList< QPair< QgsVectorLayer*, double > > labelBufferTransparencies;

applyOpacities( layersList, bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
applyOpacities( layersList, bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );

mMapRenderer->render( &thePainter );
if ( mConfigParser )
Expand All @@ -645,7 +643,7 @@ QImage* QgsWMSServer::getMap()
mConfigParser->drawOverlays( &thePainter, theImage->dotsPerMeterX() / 1000.0 * 25.4, theImage->width(), theImage->height() );
}

restoreOpacities( bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
restoreOpacities( bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
restoreLayerFilters( originalLayerFilters );
clearFeatureSelections( selectedLayerIdList );

Expand Down Expand Up @@ -1499,13 +1497,6 @@ void QgsWMSServer::drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p,

currentY += layerTitleSpace;

int opacity = 0;
QgsMapLayer* layerInstance = QgsMapLayerRegistry::instance()->mapLayer( item->layerID() );
if ( layerInstance )
{
opacity = layerInstance->getTransparency(); //maplayer says transparency but means opacity
}

//then draw all the children
QFontMetricsF itemFontMetrics( itemFont );

Expand Down Expand Up @@ -1947,7 +1938,6 @@ void QgsWMSServer::clearFeatureSelections( const QStringList& layerIds ) const
}

void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair< QgsVectorLayer*, unsigned int> >& vectorOld,
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelTransparencies,
QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies )
Expand Down Expand Up @@ -2036,12 +2026,11 @@ void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< Q
}

void QgsWMSServer::restoreOpacities( QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair< QgsVectorLayer*, unsigned int> >& vectorOld,
QList < QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelOpacities,
QList< QPair< QgsVectorLayer*, double > >& labelBufferOpacities )
{
if ( vectorRenderers.isEmpty() && vectorOld.isEmpty() && rasterRenderers.isEmpty() )
if ( vectorRenderers.isEmpty() && rasterRenderers.isEmpty() )
{
return;
}
Expand All @@ -2058,12 +2047,6 @@ void QgsWMSServer::restoreOpacities( QList< QPair< QgsVectorLayer*, QgsFeatureRe
( *rIt ).first->setRenderer(( *rIt ).second );
}

QList< QPair< QgsVectorLayer*, unsigned int> >::iterator oIt = vectorOld.begin();
for ( ; oIt != vectorOld.end(); ++oIt )
{
( *oIt ).first->setTransparency(( *oIt ).second );
}

QList< QPair< QgsVectorLayer*, double > >::iterator loIt = labelOpacities.begin();
for ( ; loIt != labelOpacities.end(); ++loIt )
{
Expand Down
2 changes: 0 additions & 2 deletions src/mapserver/qgswmsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,13 @@ class QgsWMSServer

/**Applies opacity on layer/group level*/
void applyOpacities( const QStringList& layerList, QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair< QgsVectorLayer*, unsigned int> >& vectorOld,
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelTransparencies,
QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies
);

/**Restore original opacities*/
void restoreOpacities( QList< QPair <QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair <QgsVectorLayer*, unsigned int> >& vectorOld,
QList< QPair < QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelTransparencies,
QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies );
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/globe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ IF(HAVE_OSGEARTH_CHILD_SPACING)
ADD_DEFINITIONS(-DHAVE_OSGEARTH_CHILD_SPACING)
ENDIF(HAVE_OSGEARTH_CHILD_SPACING)

IF(OSGEARTH_ELEVATION_QUERY)
ADD_DEFINITIONS(-DHAVE_OSGEARTH_ELEVATION_QUERY)
ENDIF(OSGEARTH_ELEVATION_QUERY)

########################################################
# Files

Expand Down
12 changes: 12 additions & 0 deletions src/plugins/globe/globe_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,12 @@ void GlobePlugin::run()
mOsgViewer->addEventHandler( new FlyToExtentHandler( this ) );
mOsgViewer->addEventHandler( new KeyboardControlHandler( manip, mQGisIface ) );

#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#else
mOsgViewer->addEventHandler( new QueryCoordinatesHandler( this, mElevationManager,
mMapNode->getMap()->getProfile()->getSRS() )
);
#endif
}
else
{
Expand Down Expand Up @@ -376,6 +379,8 @@ void GlobePlugin::setupMap()
elevationLayersChanged();

// model placement utils
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#else
mElevationManager = new osgEarth::Util::ElevationManager( mMapNode->getMap() );
mElevationManager->setTechnique( osgEarth::Util::ElevationManager::TECHNIQUE_GEOMETRIC );
mElevationManager->setMaxTilesToCache( 50 );
Expand All @@ -398,6 +403,7 @@ void GlobePlugin::setupMap()
}
}
}
#endif

}

Expand Down Expand Up @@ -863,6 +869,8 @@ void GlobePlugin::help()

void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt /*= 0.0*/ )
{
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#else
// get elevation
double elevation = 0.0;
double resolution = 0.0;
Expand All @@ -875,6 +883,7 @@ void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt
osg::MatrixTransform* mt = new osg::MatrixTransform( mat );
mt->addChild( node );
mRootNode->addChild( mt );
#endif
}

void GlobePlugin::copyFolder( QString sourceFolder, QString destFolder )
Expand Down Expand Up @@ -1068,6 +1077,8 @@ bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIAct
return false;
}

#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#else
bool QueryCoordinatesHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE )
Expand Down Expand Up @@ -1144,6 +1155,7 @@ osg::Vec3d QueryCoordinatesHandler::getCoords( float x, float y, osgViewer::View
}
return coords;
}
#endif

/**
* Required extern functions needed for every plugin
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/globe/globe_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ using namespace osgEarth::Util::Controls21;
#include <osgEarthUtil/Controls>
using namespace osgEarth::Util::Controls;
#endif
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#include <osgEarth/ElevationQuery>
#include <osgEarthUtil/ObjectLocator>
#else
#include <osgEarthUtil/ElevationManager>
#include <osgEarthUtil/ObjectPlacer>
#endif

class QAction;
class QToolBar;
Expand Down Expand Up @@ -136,10 +141,17 @@ class GlobePlugin : public QObject, public QgisPlugin
osgEarth::Drivers::QgsOsgEarthTileSource* mTileSource;
//! Control Canvas
ControlCanvas* mControlCanvas;
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
//! Elevation manager
osgEarth::ElevationQuery* mElevationManager;
//! Object placer
osgEarth::Util::ObjectLocator* mObjectPlacer;
#else
//! Elevation manager
osgEarth::Util::ElevationManager* mElevationManager;
//! Object placer
osgEarth::Util::ObjectPlacer* mObjectPlacer;
#endif
//! tracks if the globe is open
bool mIsGlobeRunning;
//! coordinates of the right-clicked point on the globe
Expand All @@ -164,6 +176,8 @@ class FlyToExtentHandler : public osgGA::GUIEventHandler
};

// An event handler that will print out the coordinates at the clicked point
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#else
class QueryCoordinatesHandler : public osgGA::GUIEventHandler
{
public:
Expand All @@ -181,6 +195,7 @@ class QueryCoordinatesHandler : public osgGA::GUIEventHandler
osg::ref_ptr<osgEarth::Util::ElevationManager> _elevMan;
bool _mouseDown;
};
#endif


class KeyboardControlHandler : public osgGA::GUIEventHandler
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/topology/checkDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ checkDock::checkDock( QgisInterface* qIface, QWidget* parent )
mErrorTableView->verticalHeader()->setDefaultSectionSize( 20 );

mLayerRegistry = QgsMapLayerRegistry::instance();
mConfigureDialog = new rulesDialog( mLayerRegistry->mapLayers().keys(), mTest->testMap(), qIface, parent );
mTestTable = mConfigureDialog->testTable();
mConfigureDialog = new rulesDialog( mTest->testMap(), qIface, parent );
mTestTable = mConfigureDialog->rulesTable();

mValidateExtentButton->setIcon( QIcon( ":/topology/validateExtent.png" ) );
mValidateAllButton->setIcon( QIcon( ":/topology/validateAll.png" ) );
mConfigureButton->setIcon( QIcon( ":/topology/configureRules.png" ) );


// mQgisApp = QgisApp::instance();
QgsMapCanvas* canvas = qIface->mapCanvas();// mQgisApp->mapCanvas();
mRBFeature1 = new QgsRubberBand( canvas );
mRBFeature2 = new QgsRubberBand( canvas );
Expand All @@ -94,11 +92,12 @@ checkDock::checkDock( QgisInterface* qIface, QWidget* parent )
connect( mFixButton, SIGNAL( clicked() ), this, SLOT( fix() ) );
connect( mErrorTableView, SIGNAL( clicked( const QModelIndex & ) ), this, SLOT( errorListClicked( const QModelIndex & ) ) );

connect( mLayerRegistry, SIGNAL( layerWasAdded( QgsMapLayer* ) ), mConfigureDialog, SLOT( addLayer( QgsMapLayer* ) ) );
connect( mLayerRegistry, SIGNAL( layerWillBeRemoved( QString ) ), mConfigureDialog, SLOT( removeLayer( QString ) ) );
connect( mLayerRegistry, SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( parseErrorListByLayer( QString ) ) );

connect( this, SIGNAL( visibilityChanged( bool ) ), this, SLOT( updateRubberBands( bool ) ) );
connect( qgsInterface, SIGNAL( newProjectCreated() ), mConfigureDialog, SLOT( clearRules() ) );
connect( qgsInterface, SIGNAL( newProjectCreated() ), this, SLOT( deleteErrors() ) );

}

checkDock::~checkDock()
Expand Down Expand Up @@ -204,6 +203,7 @@ void checkDock::parseErrorListByFeature( int featureId )

void checkDock::configure()
{
mConfigureDialog->initGui();
mConfigureDialog->show();
}

Expand Down
Loading