QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type, QString lyrname, QString source ) : mValid( false ), // assume the layer is invalid mDataSource( source ), mLayerOrigName( lyrname ), // store the original name mID( "" ), mLayerType( type ), mBlendMode( QPainter::CompositionMode_SourceOver ) // Default to normal blending { mCRS = new QgsCoordinateReferenceSystem(); // Set the display name = internal name QgsDebugMsg( "original name: '" + mLayerOrigName + "'" ); mLayerName = capitaliseLayerName( mLayerOrigName ); QgsDebugMsg( "display name: '" + mLayerName + "'" ); // Generate the unique ID of this layer QDateTime dt = QDateTime::currentDateTime(); mID = lyrname + dt.toString( "yyyyMMddhhmmsszzz" ); // Tidy the ID up to avoid characters that may cause problems // elsewhere (e.g in some parts of XML). Replaces every non-word // character (word characters are the alphabet, numbers and // underscore) with an underscore. // Note that the first backslashe in the regular expression is // there for the compiler, so the pattern is actually \W mID.replace( QRegExp( "[\\W]" ), "_" ); //set some generous defaults for scale based visibility mMinScale = 0; mMaxScale = 100000000; mScaleBasedVisibility = false; }
/** Write property of QString layerName. */ void QgsMapLayer::setLayerName( const QString & name ) { QgsDebugMsg( "new name is '" + name + "'" ); QString newName = capitaliseLayerName( name ); if ( newName == mLayerName ) return; mLayerName = newName; emit layerNameChanged(); }
/** Write property of QString layerName. */ void QgsMapLayer::setLayerName( const QString & name ) { QgsDebugMsg( "new original name: '" + name + "'" ); QString newName = capitaliseLayerName( name ); QgsDebugMsg( "new display name: '" + name + "'" ); if ( name == mLayerOrigName && newName == mLayerName ) return; mLayerOrigName = name; // store the new original name mLayerName = newName; emit layerNameChanged(); }
/** Write property of QString layerName. */ void QgsMapLayer::setLayerName( const QString & name ) { QgsDebugMsg( "new name is '" + name + "'" ); mLayerName = capitaliseLayerName( name ); emit layerNameChanged(); }