106 changes: 76 additions & 30 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,42 @@ bool QgsSymbolLayerV2Utils::needMarkerLine( QDomElement &element )
return hasWellKnownMark( graphicStrokeElem );
}

bool QgsSymbolLayerV2Utils::needLinePatternFill( QDomElement &element ) { Q_UNUSED( element ); return false; }
bool QgsSymbolLayerV2Utils::needLinePatternFill( QDomElement &element ) {
QDomElement fillElem = element.firstChildElement( "Fill" );
if ( fillElem.isNull() )
return false;

QDomElement graphicFillElem = fillElem.firstChildElement( "GraphicFill" );
if ( graphicFillElem.isNull() )
return false;

QDomElement graphicElem = graphicFillElem.firstChildElement( "Graphic" );
if ( graphicElem.isNull() )
return false;

// line pattern fill uses horline wellknown marker with an angle

QString name;
QColor fillColor, borderColor;
double size, borderWidth;
if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderWidth, size ) )
return false;

if ( name != "horline" )
return false;

QString angleFunc;
if ( !QgsSymbolLayerV2Utils::rotationFromSldElement( graphicElem, angleFunc ) )
return false;

bool ok;
double angle = angleFunc.toDouble( &ok );
if ( !ok || angle == 0 )
return false;

return true;
}

bool QgsSymbolLayerV2Utils::needPointPatternFill( QDomElement &element ) { Q_UNUSED( element ); return false; }

bool QgsSymbolLayerV2Utils::needSvgFill( QDomElement &element )
Expand Down Expand Up @@ -1478,11 +1513,12 @@ void QgsSymbolLayerV2Utils::lineToSld( QDomDocument &doc, QDomElement &element,
const QVector<qreal> *customDashPattern, double dashOffset )
{
QVector<qreal> dashPattern;
const QVector<qreal> *pattern = &dashPattern;

if ( penStyle == Qt::CustomDashLine && !customDashPattern )
{
element.appendChild( doc.createComment( "WARNING: Custom dash pattern required but not provided. Using default dash pattern." ) );
penStyle = Qt::DashLine;
customDashPattern = &dashPattern;
}

switch ( penStyle )
Expand Down Expand Up @@ -1518,6 +1554,7 @@ void QgsSymbolLayerV2Utils::lineToSld( QDomDocument &doc, QDomElement &element,

case Qt::CustomDashLine:
Q_ASSERT( customDashPattern );
pattern = customDashPattern;
break;

default:
Expand All @@ -1538,9 +1575,9 @@ void QgsSymbolLayerV2Utils::lineToSld( QDomDocument &doc, QDomElement &element,
if ( penCapStyle )
element.appendChild( createSvgParameterElement( doc, "stroke-linecap", encodeSldLineCapStyle( *penCapStyle ) ) );

if ( customDashPattern && customDashPattern->size() > 0 )
if ( pattern->size() > 0 )
{
element.appendChild( createSvgParameterElement( doc, "stroke-dasharray", encodeSldRealVector( *customDashPattern ) ) );
element.appendChild( createSvgParameterElement( doc, "stroke-dasharray", encodeSldRealVector( *pattern ) ) );
if ( !doubleNear( dashOffset, 0.0 ) )
element.appendChild( createSvgParameterElement( doc, "stroke-dashoffset", QString::number( dashOffset ) ) );
}
Expand Down Expand Up @@ -1601,49 +1638,49 @@ bool QgsSymbolLayerV2Utils::lineFromSld( QDomElement &element,
{
*penCapStyle = decodeSldLineCapStyle( it.value() );
}
else if ( it.key() == "stroke-dasharray" && customDashPattern )
else if ( it.key() == "stroke-dasharray" )
{
*customDashPattern = decodeSldRealVector( it.value() );
if ( customDashPattern->size() > 0 )
QVector<qreal> dashPattern = decodeSldRealVector( it.value() );
if ( dashPattern.size() > 0 )
{
// convert the dasharray to one of the QT pen style,
// if no match is found then set pen style to CustomDashLine
bool dashPatternFound = false;

if ( customDashPattern->count() == 2 )
if ( dashPattern.count() == 2 )
{
if ( customDashPattern->at( 0 ) == 4.0 &&
customDashPattern->at( 1 ) == 2.0 )
if ( dashPattern.at( 0 ) == 4.0 &&
dashPattern.at( 1 ) == 2.0 )
{
penStyle = Qt::DashLine;
dashPatternFound = true;
}
else if ( customDashPattern->at( 0 ) == 1.0 &&
customDashPattern->at( 1 ) == 2.0 )
else if ( dashPattern.at( 0 ) == 1.0 &&
dashPattern.at( 1 ) == 2.0 )
{
penStyle = Qt::DotLine;
dashPatternFound = true;
}
}
else if ( customDashPattern->count() == 4 )
else if ( dashPattern.count() == 4 )
{
if ( customDashPattern->at( 0 ) == 4.0 &&
customDashPattern->at( 1 ) == 2.0 &&
customDashPattern->at( 2 ) == 1.0 &&
customDashPattern->at( 3 ) == 2.0 )
if ( dashPattern.at( 0 ) == 4.0 &&
dashPattern.at( 1 ) == 2.0 &&
dashPattern.at( 2 ) == 1.0 &&
dashPattern.at( 3 ) == 2.0 )
{
penStyle = Qt::DashDotLine;
dashPatternFound = true;
}
}
else if ( customDashPattern->count() == 6 )
else if ( dashPattern.count() == 6 )
{
if ( customDashPattern->at( 0 ) == 4.0 &&
customDashPattern->at( 1 ) == 2.0 &&
customDashPattern->at( 2 ) == 1.0 &&
customDashPattern->at( 3 ) == 2.0 &&
customDashPattern->at( 4 ) == 1.0 &&
customDashPattern->at( 5 ) == 2.0 )
if ( dashPattern.at( 0 ) == 4.0 &&
dashPattern.at( 1 ) == 2.0 &&
dashPattern.at( 2 ) == 1.0 &&
dashPattern.at( 3 ) == 2.0 &&
dashPattern.at( 4 ) == 1.0 &&
dashPattern.at( 5 ) == 2.0 )
{
penStyle = Qt::DashDotDotLine;
dashPatternFound = true;
Expand All @@ -1653,7 +1690,16 @@ bool QgsSymbolLayerV2Utils::lineFromSld( QDomElement &element,
// default case: set pen style to CustomDashLine
if ( !dashPatternFound )
{
penStyle = Qt::CustomDashLine;
if ( customDashPattern )
{
penStyle = Qt::CustomDashLine;
*customDashPattern = dashPattern;
}
else
{
QgsDebugMsg( "custom dash pattern required but not provided. Using default dash pattern." );
penStyle = Qt::DashLine;
}
}
}
}
Expand Down Expand Up @@ -1887,7 +1933,7 @@ bool QgsSymbolLayerV2Utils::rotationFromSldElement( QDomElement &element, QStrin
QDomElement rotationElem = element.firstChildElement( "Rotation" );
if ( !rotationElem.isNull() )
{
functionFromSldElement( rotationElem, rotationFunc );
return functionFromSldElement( rotationElem, rotationFunc );
}
return true;
}
Expand All @@ -1908,7 +1954,7 @@ bool QgsSymbolLayerV2Utils::opacityFromSldElement( QDomElement &element, QString
QDomElement opacityElem = element.firstChildElement( "Opacity" );
if ( !opacityElem.isNull() )
{
functionFromSldElement( opacityElem, alphaFunc );
return functionFromSldElement( opacityElem, alphaFunc );
}
return true;
}
Expand Down Expand Up @@ -1939,7 +1985,7 @@ bool QgsSymbolLayerV2Utils::displacementFromSldElement( QDomElement &element, QP
if ( displacementElem.isNull() )
return true;

QDomElement dispXElem = element.firstChildElement( "DisplacementX" );
QDomElement dispXElem = displacementElem.firstChildElement( "DisplacementX" );
if ( !dispXElem.isNull() )
{
bool ok;
Expand All @@ -1948,7 +1994,7 @@ bool QgsSymbolLayerV2Utils::displacementFromSldElement( QDomElement &element, QP
offset.setX( offsetX );
}

QDomElement dispYElem = element.firstChildElement( "DisplacementY" );
QDomElement dispYElem = displacementElem.firstChildElement( "DisplacementY" );
if ( !dispYElem.isNull() )
{
bool ok;
Expand Down Expand Up @@ -2051,7 +2097,7 @@ bool QgsSymbolLayerV2Utils::functionFromSldElement( QDomElement &element, QStrin
if ( !expr )
return false;

bool valid = expr->hasParserError();
bool valid = !expr->hasParserError();
if ( !valid )
{
QgsDebugMsg( "parser error: " + expr->parserErrorString() );
Expand Down
5 changes: 3 additions & 2 deletions src/gui/qgsattributeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,15 +600,16 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
if ( editType == QgsVectorLayer::ValueRelation )
{
text = '{';
for ( int i = 0; i < lw->count(); i++ )
for ( int i = 0, n = 0; i < lw->count(); i++ )
{
if ( lw->item( i )->checkState() == Qt::Checked )
{
if ( i > 0 )
if ( n > 0 )
{
text.append( ',' );
}
text.append( lw->item( i )->data( Qt::UserRole ).toString() );
n++;
}
}
text.append( '}' );
Expand Down
3 changes: 3 additions & 0 deletions src/python/qgspythonutilsimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ void QgsPythonUtilsImpl::initPython( QgisInterface* interface )

// initialize 'iface' object
runString( "qgis.utils.initInterface(" + QString::number(( unsigned long ) interface ) + ")" );

QString startuppath = homePythonPath() + " + \"/startup.py\"";
runString( "if os.path.exists(" + startuppath + "): from startup import *\n" );
}

void QgsPythonUtilsImpl::exitPython()
Expand Down
4 changes: 0 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
IF (ENABLE_TESTS)
IF (APPLE)
# override default data path, otherwise looks for Resources in app bundle
SET (QGIS_DATA_SUBDIR "${CMAKE_SOURCE_DIR}/resources")
ENDIF (APPLE)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(bench)
ENDIF (ENABLE_TESTS)
13 changes: 0 additions & 13 deletions tests/src/python/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,6 @@ def getQgisTestApp():
myGuiFlag = True # All test will run qgis in gui mode

QGISAPP = QgsApplication(sys.argv, myGuiFlag)

if sys.platform.startswith('darwin'):
# override resource paths, otherwise looks for Resources in app
if 'QGIS_MAC_PKGDATA_DIR' in os.environ:
myPkgPath = os.environ['QGIS_MAC_PKGDATA_DIR']
QGISAPP.setPkgDataPath(myPkgPath)
if 'QGIS_MAC_SVG_DIR' in os.environ:
mySVGPath = os.environ['QGIS_MAC_SVG_DIR']
mySVGPaths = QGISAPP.svgPaths()
# doesn't get rid of incorrect path, just adds correct one
mySVGPaths.prepend(mySVGPath)
QGISAPP.setDefaultSvgPaths(mySVGPaths)

QGISAPP.initQgis()
s = QGISAPP.showSettings()
print s
Expand Down
6 changes: 3 additions & 3 deletions tests/testdata/points_uniquevalue_symbol.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<lowervalue>B52</lowervalue>
<uppervalue></uppervalue>
<label></label>
<pointsymbol>svg:/Applications/qgis0.9.2.app/Contents/MacOS/share/qgis/svg/gpsicons/plane.svg</pointsymbol>
<pointsymbol>svg:/gpsicons/plane.svg</pointsymbol>
<pointsize>6</pointsize>
<rotationclassificationfield>1</rotationclassificationfield>
<scaleclassificationfield>2</scaleclassificationfield>
Expand All @@ -45,7 +45,7 @@
<lowervalue>Biplane</lowervalue>
<uppervalue></uppervalue>
<label></label>
<pointsymbol>svg:/Applications/qgis0.9.2.app/Contents/MacOS/share/qgis/svg/gpsicons/plane_orange.svg</pointsymbol>
<pointsymbol>svg:/gpsicons/plane_orange.svg</pointsymbol>
<pointsize>5</pointsize>
<rotationclassificationfield>1</rotationclassificationfield>
<scaleclassificationfield>2</scaleclassificationfield>
Expand All @@ -60,7 +60,7 @@
<lowervalue>Jet</lowervalue>
<uppervalue></uppervalue>
<label></label>
<pointsymbol>svg:/Applications/qgis0.9.2.app/Contents/MacOS/share/qgis/svg/gpsicons/plane.svg</pointsymbol>
<pointsymbol>svg:/gpsicons/plane.svg</pointsymbol>
<pointsize>5</pointsize>
<rotationclassificationfield>1</rotationclassificationfield>
<scaleclassificationfield>2</scaleclassificationfield>
Expand Down