[QGIS Commit] r12090 - trunk/qgis/src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Nov 11 13:27:54 EST 2009
Author: jef
Date: 2009-11-11 13:27:52 -0500 (Wed, 11 Nov 2009)
New Revision: 12090
Modified:
trunk/qgis/src/core/qgsmaplayer.cpp
Log:
qml fix:
- consider changes in data source notation of ogr provider
- consider min and max visibility scale for qml (fixes #2076)
Modified: trunk/qgis/src/core/qgsmaplayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaplayer.cpp 2009-11-11 17:12:17 UTC (rev 12089)
+++ trunk/qgis/src/core/qgsmaplayer.cpp 2009-11-11 18:27:52 UTC (rev 12090)
@@ -83,10 +83,10 @@
QgsMapLayer::~QgsMapLayer()
{
delete mCRS;
- if ( mpCacheImage )
- {
- delete mpCacheImage;
- }
+ if ( mpCacheImage )
+ {
+ delete mpCacheImage;
+ }
}
QgsMapLayer::LayerType QgsMapLayer::type() const
@@ -171,6 +171,12 @@
uri.setDatabase( QgsProject::instance()->readPath( uri.database() ) );
mDataSource = uri.uri();
}
+ else if ( provider == "ogr" )
+ {
+ QStringList theURIParts = mDataSource.split( "|" );
+ theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] );
+ mDataSource = theURIParts.join( "|" );
+ }
else
{
mDataSource = QgsProject::instance()->readPath( mDataSource );
@@ -221,15 +227,7 @@
}
// use scale dependent visibility flag
- QString hasScaleBasedVisibility = element.attribute( "hasScaleBasedVisibilityFlag" );
- if ( "1" == hasScaleBasedVisibility )
- {
- toggleScaleBasedVisibility( true );
- }
- else
- {
- toggleScaleBasedVisibility( false );
- }
+ toggleScaleBasedVisibility( element.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
setMinimumScale( element.attribute( "minimumScale" ).toFloat() );
setMaximumScale( element.attribute( "maximumScale" ).toFloat() );
@@ -267,14 +265,7 @@
QDomElement maplayer = document.createElement( "maplayer" );
// use scale dependent visibility flag
- if ( hasScaleBasedVisibility() )
- {
- maplayer.setAttribute( "hasScaleBasedVisibilityFlag", 1 );
- }
- else
- {
- maplayer.setAttribute( "hasScaleBasedVisibilityFlag", 0 );
- }
+ maplayer.setAttribute( "hasScaleBasedVisibilityFlag", hasScaleBasedVisibility() ? 1 : 0 );
maplayer.setAttribute( "minimumScale", minimumScale() );
maplayer.setAttribute( "maximumScale", maximumScale() );
@@ -298,6 +289,12 @@
uri.setConnection( uri.host(), uri.port(), database, uri.username(), uri.password() );
src = uri.uri();
}
+ else if ( vlayer && vlayer->providerType() == "ogr" )
+ {
+ QStringList theURIParts = src.split( "|" );
+ theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] );
+ src = theURIParts.join( "|" );
+ }
else
{
src = QgsProject::instance()->writePath( src );
@@ -584,6 +581,11 @@
return myErrorMessage;
}
+ // use scale dependent visibility flag
+ toggleScaleBasedVisibility( myRoot.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
+ setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
+ setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );
+
QString errorMsg;
theResultFlag = readSymbology( myRoot, errorMsg );
if ( !theResultFlag )
@@ -613,6 +615,11 @@
myRootNode.setAttribute( "version", QString( "%1" ).arg( QGis::QGIS_VERSION ) );
myDocument.appendChild( myRootNode );
+ // use scale dependent visibility flag
+ myRootNode.setAttribute( "hasScaleBasedVisibilityFlag", hasScaleBasedVisibility() ? 1 : 0 );
+ myRootNode.setAttribute( "minimumScale", minimumScale() );
+ myRootNode.setAttribute( "maximumScale", maximumScale() );
+
QString errorMsg;
if ( !writeSymbology( myRootNode, myDocument, errorMsg ) )
{
@@ -621,10 +628,23 @@
// check if the uri is a file or ends with .qml,
// which indicates that it should become one
- // everything else goes to the database.
- QFileInfo myFileInfo( theURI );
- if ( myFileInfo.exists() || theURI.endsWith( ".qml", Qt::CaseInsensitive ) )
+ // everything else goes to the database
+ QString filename;
+
+ QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( this );
+ if ( vlayer && vlayer->providerType() == "ogr" )
{
+ QStringList theURIParts = theURI.split( "|" );
+ filename = theURIParts[0];
+ }
+ else
+ {
+ filename = theURI;
+ }
+
+ QFileInfo myFileInfo( filename );
+ if ( myFileInfo.exists() || filename.endsWith( ".qml", Qt::CaseInsensitive ) )
+ {
QFileInfo myDirInfo( myFileInfo.path() ); //excludes file name
if ( !myDirInfo.isWritable() )
{
@@ -742,12 +762,12 @@
return &mUndoStack;
}
-void QgsMapLayer::setCacheImage( QImage * thepImage )
-{
+void QgsMapLayer::setCacheImage( QImage * thepImage )
+{
QgsDebugMsg( "cache Image set!" );
- if ( mpCacheImage )
- {
- delete mpCacheImage;
- }
- mpCacheImage = thepImage;
+ if ( mpCacheImage )
+ {
+ delete mpCacheImage;
+ }
+ mpCacheImage = thepImage;
}
More information about the QGIS-commit
mailing list