25 changes: 20 additions & 5 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,10 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext& con
}

// paint the text
painter->setCompositionMode( tmpLyr.blendMode );
if ( context.useAdvancedEffects() )
{
painter->setCompositionMode( tmpLyr.blendMode );
}
// painter->setPen( Qt::NoPen );
// painter->setBrush( tmpLyr.textColor );
// painter->drawPath( path );
Expand Down Expand Up @@ -2350,7 +2353,10 @@ void QgsPalLabeling::drawLabelBuffer( QgsRenderContext& context,
}

p->save();
p->setCompositionMode( tmpLyr.bufferBlendMode );
if ( context.useAdvancedEffects() )
{
p->setCompositionMode( tmpLyr.bufferBlendMode );
}
// p->setPen( pen );
// p->setBrush( tmpColor );
// p->drawPath( path );
Expand Down Expand Up @@ -2512,7 +2518,10 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
( 100.0 - ( double )( tmpLyr.shapeTransparency ) ) / 100.0 );

p->save();
p->setCompositionMode( tmpLyr.shapeBlendMode );
if ( context.useAdvancedEffects() )
{
p->setCompositionMode( tmpLyr.shapeBlendMode );
}
p->translate( component.center().x(), component.center().y() );
p->rotate( component.rotation() );
double xoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.x(), context, tmpLyr.shapeOffsetUnits );
Expand Down Expand Up @@ -2642,7 +2651,10 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
}

p->setOpacity(( 100.0 - ( double )( tmpLyr.shapeTransparency ) ) / 100.0 );
p->setCompositionMode( tmpLyr.shapeBlendMode );
if ( context.useAdvancedEffects() )
{
p->setCompositionMode( tmpLyr.shapeBlendMode );
}

// scale for any print output or image saving @ specific dpi
p->scale( component.dpiRatio(), component.dpiRatio() );
Expand Down Expand Up @@ -2744,7 +2756,10 @@ void QgsPalLabeling::drawLabelShadow( QgsRenderContext& context,

p->save();
p->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
p->setCompositionMode( tmpLyr.shadowBlendMode );
if ( context.useAdvancedEffects() )
{
p->setCompositionMode( tmpLyr.shadowBlendMode );
}
p->setOpacity(( 100.0 - ( double )( tmpLyr.shadowTransparency ) ) / 100.0 );

double scale = ( double )tmpLyr.shadowScale / 100.0;
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,17 @@ class CORE_EXPORT QgsProject : public QObject
* @param mapLayer The map layer which is being initialized
* @param layerNode The layer node from the project file
*/
void readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerNode );
void readMapLayer( QgsMapLayer *mapLayer, const QDomElement &layerNode );

/**
* Emitted, when a layer is being saved. You can use this method to save
* additional information to the layer.
*
* @param mapLayer The map layer which is being initialized
* @param layerNode The layer node from the project file
* @param layerElem The layer element from the project file
* @param doc The document
*/
void writeMapLayer( QgsMapLayer* mapLayer, QDomElement& layerElem, QDomDocument& doc );
void writeMapLayer( QgsMapLayer *mapLayer, QDomElement &layerElem, QDomDocument &doc );

//! emitted when the project file has been written and closed
void projectSaved();
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsrendercontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ QgsRenderContext::QgsRenderContext()
mCoordTransform( 0 ),
mDrawEditingInformation( true ),
mForceVectorOutput( false ),
mUseAdvancedEffects( true ),
mRenderingStopped( false ),
mScaleFactor( 1.0 ),
mRasterScaleFactor( 1.0 ),
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgsrendercontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class CORE_EXPORT QgsRenderContext

bool forceVectorOutput() const {return mForceVectorOutput;}

/**Returns true if advanced effects such as blend modes such be used
@note added in 1.9*/
bool useAdvancedEffects() const {return mUseAdvancedEffects;}
/**Used to enable or disable advanced effects such as blend modes
@note: added in version 1.9*/
void setUseAdvancedEffects( bool enabled ) { mUseAdvancedEffects = enabled; }

bool drawEditingInformation() const {return mDrawEditingInformation;}

double rendererScale() const {return mRendererScale;}
Expand Down Expand Up @@ -104,6 +111,9 @@ class CORE_EXPORT QgsRenderContext
/**If true then no rendered vector elements should be cached as image*/
bool mForceVectorOutput;

/**Flag if advanced visual effects such as blend modes should be used. True by default*/
bool mUseAdvancedEffects;

QgsMapToPixel mMapToPixel;

/**True if the rendering has been canceled*/
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,10 @@ void QgsVectorLayer::saveStyleToDatabase( QString name, QString description,



QString QgsVectorLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
{
return loadNamedStyle( theURI, theResultFlag, false );
}

QString QgsVectorLayer::loadNamedStyle( const QString theURI, bool &theResultFlag , bool loadFromLocalDB )
{
Expand Down
21 changes: 17 additions & 4 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer

/**
* Lists all the style in db split into related to the layer and not related to
* @param ids the QVector in which will be stored the style db ids
* @param names the QVector in which will be stored the style names
* @param descriptions the QVector in which will be stored the style descriptions
* @param ids the list in which will be stored the style db ids
* @param names the list in which will be stored the style names
* @param descriptions the list in which will be stored the style descriptions
* @param msgError
* @return the number of styles related to current layer
*/
Expand All @@ -724,7 +724,20 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
virtual QString getStyleFromDatabase( QString styleId, QString &msgError );

virtual QString loadNamedStyle( const QString theURI, bool &theResultFlag, bool loadFromLocalDb = false );
/**
* Load a named style from file/local db/datasource db
* @param theURI the URI of the style or the URI of the layer
* @param theResultFlag will be set to true if a named style is correctly loaded
* @param loadFromLocalDb if true forces to load from local db instead of datasource one
*/
virtual QString loadNamedStyle( const QString theURI, bool &theResultFlag, bool loadFromLocalDb );

/**
* Calls loadNamedStyle( theURI, theResultFlag, false );
* Retained for backward compatibility
*/
virtual QString loadNamedStyle( const QString theURI, bool &theResultFlag );

virtual bool applyNamedStyle( QString namedStyle , QString errorMsg );

/** convert a saved attribute editor element into a AttributeEditor structure as it's used internally.
Expand Down
12 changes: 11 additions & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <qgsrectangle.h>
#include <qgscoordinatereferencesystem.h>

#include <QMessageBox>

#include "qgsvectorlayerimport.h"
#include "qgsprovidercountcalcevent.h"
#include "qgsproviderextentcalcevent.h"
Expand Down Expand Up @@ -3307,6 +3309,15 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
res = conn->PQexec( checkQuery );
if ( res.PQntuples() > 0 )
{
if ( QMessageBox::question( 0, QObject::tr( "Save style in database" ),
QObject::tr( "A style named \"%1\" already exists in the database for this layer. Do you want to overwrite it?" )
.arg( styleName.isEmpty() ? dsUri.table() : styleName ),
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No )
{
errCause = QObject::tr( "Operation aborted. No changes were made in the database" );
return false;
}

sql = QString( "UPDATE layer_styles"
" SET useAsDefault=%1"
",styleQML=XMLPARSE(DOCUMENT %2)"
Expand Down Expand Up @@ -3398,7 +3409,6 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
return -1;
}

// ORDER BY (CASE WHEN useAsDefault THEN 1 ELSE 2 END), update_time DESC;")
QString selectRelatedQuery = QString( "SELECT id,styleName,description"
" FROM layer_styles"
" WHERE f_table_catalog=%1"
Expand Down
6 changes: 6 additions & 0 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
</property>
<addaction name="mActionHelpContents"/>
<addaction name="mActionHelpAPI"/>
<addaction name="mActionNeedSupport"/>
<addaction name="separator"/>
<addaction name="mActionQgisHomePage"/>
<addaction name="mActionCheckQgisVersion"/>
Expand Down Expand Up @@ -2068,6 +2069,11 @@ Acts on currently active editable layer</string>
<string>Select features using an expression</string>
</property>
</action>
<action name="mActionNeedSupport">
<property name="text">
<string>Need Support?</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsprojectpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@
<string notr="true">font-weight:bold;</string>
</property>
<property name="text">
<string>Defaut styles</string>
<string>Default styles</string>
</property>
</widget>
</item>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgssavetodbdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>355</width>
<height>235</height>
<height>246</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -94,7 +94,7 @@
<item row="2" column="0" rowspan="2" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Optionally pick an input form for attribute editing (QT Creator UI format), it will be stored on the db</string>
<string>Optionally pick an input form for attribute editing (QT Designer UI format), it will be stored in the database</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
Expand Down