21 #include <QDomDocument> 22 #include <QDomElement> 23 #include <QDomImplementation> 28 #include <QTextStream> 57 , mDataSource( source )
58 , mLayerOrigName( lyrname )
61 , mBlendMode(
QPainter::CompositionMode_SourceOver )
77 mID = lyrname + dt.
toString(
"yyyyMMddhhmmsszzz" );
88 mMaxScale = 100000000;
89 mScaleBasedVisibility =
false;
113 QgsDebugMsg(
"new original name: '" + name +
'\'' );
115 QgsDebugMsg(
"new display name: '" + name +
'\'' );
162 Q_UNUSED( rendererContext );
168 Q_UNUSED( rendererContext );
182 mnl = layerElement.
namedItem(
"provider" );
184 provider = mne.
text();
187 mnl = layerElement.
namedItem(
"datasource" );
192 QRegExp rx(
"authcfg=([a-z]|[A-Z]|[0-9]){7}" );
201 if ( provider ==
"spatialite" )
207 else if ( provider ==
"ogr" )
213 else if ( provider ==
"gpx" )
219 else if ( provider ==
"delimitedtext" )
234 else if ( provider ==
"wms" )
249 QgsDebugMsg(
"Old WMS URI format detected -> converting to new format" );
254 QStringListIterator iter( parts );
255 while ( iter.hasNext() )
274 if ( params.
size() == 2 )
279 else if ( params.
size() > 2 )
283 uri.
setParam(
"tileMatrixSet",
"" );
286 else if ( item.
startsWith(
"featureCount=" ) )
312 bool handled =
false;
314 if ( provider ==
"gdal" )
320 QRegExp r(
"NETCDF:(.+):([^:]+)" );
325 filename = filename.
mid( 1, filename.
length() - 2 );
334 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
339 filename = filename.
mid( 1, filename.
length() - 2 );
348 QRegExp r(
"HDF5:(.+):([^:]+)" );
353 filename = filename.
mid( 1, filename.
length() - 2 );
362 QRegExp r(
"([^:]+):([^:]+):(.+)" );
379 mnl = layerElement.
namedItem(
"layername" );
394 layerError = !
readXml( layerElement );
429 mnl = layerElement.
namedItem(
"layername" );
435 if ( !shortNameElem.isNull() )
442 if ( !titleElem.
isNull() )
449 if ( !abstractElem.
isNull() )
456 if ( !keywordListElem.
isNull() )
461 kwdList << n.toElement().text();
468 if ( !dataUrlElem.
isNull() )
476 if ( !legendUrlElem.
isNull() )
484 if ( !attribElem.
isNull() )
492 if ( !metaUrlElem.
isNull() )
502 if ( ! transparencyNode.
isNull() )
507 setTransparency( myElement.
text().
toInt() );
519 Q_UNUSED( layer_node );
559 src = theURIParts.
join(
"|" );
565 src = theURIParts.
join(
"?" );
567 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
571 urlDest.setQueryItems( urlSource.
queryItems() );
574 else if ( vlayer && vlayer->
providerType() ==
"memory" )
581 bool handled =
false;
593 QRegExp r(
"NETCDF:(.+):([^:]+)" );
598 filename = filename.
mid( 1, filename.
length() - 2 );
607 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
612 filename = filename.
mid( 1, filename.
length() - 2 );
621 QRegExp r(
"HDF5:(.+):([^:]+)" );
626 filename = filename.
mid( 1, filename.
length() - 2 );
635 QRegExp r(
"([^:]+):([^:]+):(.+)" );
690 if ( !keywordStringList.
isEmpty() )
693 for (
int i = 0; i < keywordStringList.
size(); ++i )
731 layerAttribution.
appendChild( layerAttributionText );
742 layerMetadataUrl.
appendChild( layerMetadataUrlText );
765 mCRS->
writeXML( mySrsElement, document );
772 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
773 maplayer.
appendChild( transparencyLevelIntElement );
780 return writeXml( layerElement, document );
804 for (
int i = 0; i < layernodes.
size(); ++i )
813 if ( type ==
"vector" )
817 else if ( type ==
"raster" )
821 else if ( type ==
"plugin" )
843 QFile file( qlrfile );
844 if ( !file.
open( QIODevice::ReadOnly ) )
851 if ( !doc.setContent( &file ) )
865 Q_UNUSED( layer_node );
866 Q_UNUSED( document );
875 mCustomProperties.
readXml( layerNode, keyStartsWith );
880 mCustomProperties.
writeXml( layerNode, doc );
886 if ( !styleMgrElem.
isNull() )
887 mStyleManager->
readXml( styleMgrElem );
889 mStyleManager->
reset();
897 mStyleManager->
writeXml( styleMgrElem );
944 return mScaleBasedVisibility;
949 mMinScale = theMinScale;
960 mMaxScale = theMaxScale;
965 mScaleBasedVisibility = enabled;
1019 if ( capitaliseLayerName )
1030 if ( myURI.
startsWith(
"/vsigzip/", Qt::CaseInsensitive ) )
1034 else if ( myURI.
startsWith(
"/vsizip/", Qt::CaseInsensitive ) &&
1035 myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1040 else if ( myURI.
startsWith(
"/vsitar/", Qt::CaseInsensitive ) &&
1041 ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) ||
1042 myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) ||
1043 myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) ) )
1052 if ( myFileInfo.
exists() )
1055 if ( myURI.
endsWith(
".gz", Qt::CaseInsensitive ) )
1057 else if ( myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1059 else if ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) )
1061 else if ( myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) )
1063 else if ( myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) )
1086 bool theResultFlag =
false;
1090 sqlite3_stmt *myPreparedStatement;
1094 QgsDebugMsg(
QString(
"Trying to load style for \"%1\" from \"%2\"" ).arg( theURI, db ) );
1099 myResult = sqlite3_open_v2( db.
toUtf8().
data(), &myDatabase, SQLITE_OPEN_READONLY, nullptr );
1100 if ( myResult != SQLITE_OK )
1105 QString mySql =
"select qml from tbl_styles where style=?";
1106 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1107 if ( myResult == SQLITE_OK )
1111 if ( sqlite3_bind_text( myPreparedStatement, 1, param.
data(), param.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1112 sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1114 qml =
QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 0 ) ) );
1115 theResultFlag =
true;
1118 sqlite3_finalize( myPreparedStatement );
1121 sqlite3_close( myDatabase );
1123 return theResultFlag;
1131 theResultFlag =
false;
1139 QFile myFile( theURI );
1140 if ( myFile.
open( QFile::ReadOnly ) )
1143 theResultFlag = myDocument.
setContent( &myFile, &myErrorMessage, &line, &column );
1144 if ( !theResultFlag )
1145 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1158 theResultFlag = myDocument.
setContent( qml, &myErrorMessage, &line, &column );
1159 if ( !theResultFlag )
1161 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1166 myErrorMessage =
tr(
"Style not found in database" );
1170 if ( !theResultFlag )
1172 return myErrorMessage;
1176 if ( !theResultFlag )
1177 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, myErrorMessage );
1179 return myErrorMessage;
1188 myErrorMessage =
tr(
"Root <qgis> element could not be found" );
1196 if ( thisVersion > fileVersion )
1209 myErrorMessage =
tr(
"Cannot apply style to layer with a different geometry type" );
1222 if ( ! transparencyNode.isNull() )
1227 setTransparency( myElement.
text().
toInt() );
1252 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
1253 myRootNode.
appendChild( transparencyLevelIntElement );
1258 errorMsg =
QObject::tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1303 filename = theURIParts[0];
1308 filename = theURIParts[0];
1310 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
1323 if ( myFileInfo.
exists() || filename.
endsWith(
".qml", Qt::CaseInsensitive ) )
1326 if ( !myDirInfo.isWritable() )
1328 return tr(
"The directory containing your dataset needs to be writable!" );
1334 QFile myFile( myFileName );
1335 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1339 myDocument.
save( myFileStream, 2 );
1341 theResultFlag =
true;
1342 return tr(
"Created default style file as %1" ).
arg( myFileName );
1346 theResultFlag =
false;
1347 return tr(
"ERROR: Failed to created default style file as %1. Check file permissions and retry." ).
arg( myFileName );
1356 sqlite3_stmt *myPreparedStatement;
1361 if ( myResult != SQLITE_OK )
1363 return tr(
"User database could not be opened." );
1369 QString mySql =
"create table if not exists tbl_styles(style varchar primary key,qml varchar)";
1370 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1371 if ( myResult == SQLITE_OK )
1373 if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
1375 sqlite3_finalize( myPreparedStatement );
1376 sqlite3_close( myDatabase );
1377 theResultFlag =
false;
1378 return tr(
"The style table could not be created." );
1382 sqlite3_finalize( myPreparedStatement );
1384 mySql =
"insert into tbl_styles(style,qml) values (?,?)";
1385 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1386 if ( myResult == SQLITE_OK )
1388 if ( sqlite3_bind_text( myPreparedStatement, 1, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1389 sqlite3_bind_text( myPreparedStatement, 2, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1390 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1392 theResultFlag =
true;
1393 myErrorMessage =
tr(
"The style %1 was saved to database" ).
arg( theURI );
1397 sqlite3_finalize( myPreparedStatement );
1399 if ( !theResultFlag )
1401 QString mySql =
"update tbl_styles set qml=? where style=?";
1402 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1403 if ( myResult == SQLITE_OK )
1405 if ( sqlite3_bind_text( myPreparedStatement, 2, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1406 sqlite3_bind_text( myPreparedStatement, 1, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1407 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1409 theResultFlag =
true;
1410 myErrorMessage =
tr(
"The style %1 was updated in the database." ).
arg( theURI );
1414 theResultFlag =
false;
1415 myErrorMessage =
tr(
"The style %1 could not be updated in the database." ).
arg( theURI );
1420 theResultFlag =
false;
1421 myErrorMessage =
tr(
"The style %1 could not be inserted into database." ).
arg( theURI );
1424 sqlite3_finalize( myPreparedStatement );
1427 sqlite3_close( myDatabase );
1430 return myErrorMessage;
1444 root.
setAttribute(
"xsi:schemaLocation",
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1445 root.
setAttribute(
"xmlns:ogc",
"http://www.opengis.net/ogc" );
1446 root.
setAttribute(
"xmlns:se",
"http://www.opengis.net/se" );
1447 root.
setAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink" );
1448 root.
setAttribute(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
1458 errorMsg =
tr(
"Could not save symbology because:\n%1" )
1459 .
arg(
"Non-vector layers not supported yet" );
1463 if ( !vlayer->
writeSld( namedLayerNode, myDocument, errorMsg ) )
1465 errorMsg =
tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1477 if ( !errorMsg.
isNull() )
1479 theResultFlag =
false;
1490 filename = theURIParts[0];
1495 filename = theURIParts[0];
1501 if ( filename.isEmpty() )
1510 if ( myFileInfo.
exists() || filename.endsWith(
".sld", Qt::CaseInsensitive ) )
1513 if ( !myDirInfo.isWritable() )
1515 return tr(
"The directory containing your dataset needs to be writable!" );
1521 QFile myFile( myFileName );
1522 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1526 myDocument.
save( myFileStream, 2 );
1528 theResultFlag =
true;
1529 return tr(
"Created default style file as %1" ).
arg( myFileName );
1533 theResultFlag =
false;
1534 return tr(
"ERROR: Failed to created SLD style file as %1. Check file permissions and retry." ).
arg( filename );
1541 theResultFlag =
false;
1549 QFile myFile( theURI );
1550 if ( myFile.
open( QFile::ReadOnly ) )
1553 theResultFlag = myDocument.
setContent( &myFile,
true, &myErrorMessage, &line, &column );
1554 if ( !theResultFlag )
1555 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1560 myErrorMessage =
tr(
"Unable to open file %1" ).
arg( theURI );
1563 if ( !theResultFlag )
1565 return myErrorMessage;
1572 myErrorMessage =
QString(
"Error: StyledLayerDescriptor element not found in %1" ).
arg( theURI );
1573 theResultFlag =
false;
1574 return myErrorMessage;
1580 if ( namedLayerElem.
isNull() )
1582 myErrorMessage =
QLatin1String(
"Info: NamedLayer element not found." );
1583 theResultFlag =
false;
1584 return myErrorMessage;
1588 theResultFlag =
readSld( namedLayerElem, errorMsg );
1589 if ( !theResultFlag )
1591 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, errorMsg );
1592 return myErrorMessage;
1607 mCustomProperties.
setValue( key, value );
1612 return mCustomProperties.
value( value, defaultValue );
1617 mCustomProperties.
remove( key );
1639 if ( legend == mLegend )
1658 return mStyleManager;
static const char * QGIS_VERSION
virtual QStringList subLayers() const
Returns the sublayers of this layer (Useful for providers that manage their own layers, such as WMS)
virtual bool isEditable() const
True if the layer can be edited.
QString fromAscii(const char *str, int size)
QString toString(Qt::DateFormat format) const
virtual QString saveNamedStyle(const QString &theURI, bool &theResultFlag)
Save the properties of this layer as a named style (either as a .qml file on disk or as a record in t...
QString database() const
Returns the database.
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
A rectangle specified with double values.
Base class for all map layer types.
QString cap(int nth) const
QString writePath(const QString &filename, const QString &relativeBasePath=QString::null) const
Prepare a filename to save it to the project file.
QDomProcessingInstruction createProcessingInstruction(const QString &target, const QString &data)
QgsMapLayer::LayerType type() const
Get the type of the layer.
virtual QString metadata()
Obtain Metadata for this layer.
static QDomDocument asLayerDefinition(const QList< QgsMapLayer * > &layers, const QString &relativeBasePath=QString::null)
Returns the given layer as a layer definition document Layer definitions store the data source as wel...
virtual void drawLabels(QgsRenderContext &rendererContext)
Draw labels.
virtual QString loadSldStyle(const QString &theURI, bool &theResultFlag)
static QgsAuthManager * instance()
Enforce singleton pattern.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith="")
Read custom properties from project file.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
QString name() const
Get the display name of the layer.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
QDomNode appendChild(const QDomNode &newChild)
void readXml(const QDomNode &parentNode, const QString &keyStartsWith=QString())
Read store contents from XML.
void reset()
Reset the style manager to a basic state - with one default style which is set as current...
virtual ~QgsMapLayer()
Destructor.
QString attribute(const QString &name, const QString &defValue) const
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void validate()
Perform some validation on this CRS.
QString toString(int indent) const
static QString removePassword(const QString &aUri)
Removes password element from uris.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager.
virtual Q_DECL_DEPRECATED QString lastError()
QString password() const
Returns the password.
QList< QPair< QString, QString > > queryItems() const
void setFile(const QString &file)
virtual bool readSymbology(const QDomNode &node, QString &errorMessage)=0
Read the symbology for the current layer from the Dom node supplied.
void layerNameChanged()
Emit a signal that the layer name has been changed.
void setDatabase(const QString &database)
Set database.
const T & at(int i) const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
float minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
QString source() const
Returns the source for the layer.
QString join(const QString &separator) const
QString dataUrl() const
Get the DataUrl of the layer used by QGIS Server in GetCapabilities request DataUrl is a a link to th...
QString & remove(int position, int n)
static CUSTOM_CRS_VALIDATION customSrsValidation()
Gets custom function.
QDomElement createElementNS(const QString &nsURI, const QString &qName)
virtual QString saveDefaultStyle(bool &theResultFlag)
Save the properties of this layer as the default style (either as a .qml file on disk or as a record ...
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
bool writeLayerXML(QDomElement &layerElement, QDomDocument &document, const QString &relativeBasePath=QString::null)
Stores state in Dom node.
QgsMapLayer(QgsMapLayer::LayerType type=VectorLayer, const QString &lyrname=QString::null, const QString &source=QString::null)
Constructor.
QString tr(const char *sourceText, const char *disambiguation, int n)
QString readPath(QString filename) const
Turn filename read from the project file to an absolute path.
void remove(const QString &key)
Remove a key (entry) from the store.
QString mLayerName
Name of the layer - used for display.
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage) const =0
Write the symbology for the layer into the docment provided.
static void setCustomSrsValidation(CUSTOM_CRS_VALIDATION f)
Sets custom function to force valid CRS QGIS uses implementation in QgisGui::customSrsValidation.
virtual bool draw(QgsRenderContext &rendererContext)
This is the method that does the actual work of drawing the layer onto a paint device.
static QString capitaliseLayerName(const QString &name)
A convenience function to (un)capitalise the layer name.
QDomElement toElement() const
void setPath(const QString &path)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Return value for the given key. If the key is not stored, default value will be used.
int indexIn(const QString &str, int offset, CaretMode caretMode) const
QgsRectangle mExtent
Extent of the layer.
QString mMetadataUrl
MetadataUrl of the layer.
void setValidationHint(const QString &html)
Set user hint for validation.
QString number(int n, int base)
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
QString fromUtf8(const char *str, int size)
void setValue(const QString &key, const QVariant &value)
Add an entry to the store. If the entry with the keys exists already, it will be overwritten.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage) const
void layerCrsChanged()
Emit a signal that layer's CRS has been reset.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any).
virtual bool loadNamedStyleFromDb(const QString &db, const QString &theURI, QString &qml)
virtual bool writeXml(QDomNode &layer_node, QDomDocument &document)
Called by writeLayerXML(), used by children to write state specific to them to project files...
#define QgsDebugMsgLevel(str, level)
Q_DECL_DEPRECATED void setCacheImage(QImage *)
LayerType
Layers enum defining the types of layers that can be added to a map.
bool readXML(const QDomNode &theNode)
Restores state from the given Dom node.
void setParam(const QString &key, const QString &value)
Set generic param (generic mode)
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
void setAttribute(const QString &name, const QString &value)
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists).
A class to describe the version of a project.
float maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
static QList< QgsMapLayer * > fromLayerDefinition(QDomDocument &document, bool addToRegistry=false, bool addToLegend=false)
Creates a new layer from a layer defininition document.
int toInt(bool *ok, int base) const
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
void readXml(const QDomElement &mgrElement)
Read configuration (for project loading)
QDomNodeList elementsByTagName(const QString &tagname) const
QString absoluteFilePath() const
QString mDataUrl
DataUrl of the layer.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
void setScheme(const QString &scheme)
void triggerRepaint()
Will advice the map canvas (and any other interested party) that this layer requires to be repainted...
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Get the data source specification.
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
void setConnection(const QString &aHost, const QString &aPort, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SSLmode sslmode=SSLprefer, const QString &authConfigId=QString())
Set all connection related members at once.
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
bool setCurrent(const QString &path)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
QString attributionUrl() const
Get the attribution URL of the layer used by QGIS Server in GetCapabilities request Attribution indic...
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
QString dataUrlFormat() const
Get the DataUrl format of the layer used by QGIS Server in GetCapabilities request DataUrl is a a lin...
virtual Q_DECL_DEPRECATED QString lastErrorTitle()
QGis::GeometryType geometryType() const
Returns point, line or polygon.
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg)
Import the properties of this layer from a QDomDocument.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
virtual QString saveSldStyle(const QString &theURI, bool &theResultFlag)
bool isValid()
Return the status of the layer.
bool mValid
Indicates if the layer is valid and can be drawn.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
static QList< QgsMapLayer * > fromLayerDefinitionFile(const QString &qlrfile)
QString host() const
Returns the host.
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QString toLocalFile() const
QString mMetadataUrlFormat
QDomText createTextNode(const QString &value)
virtual void connectNotify(const char *signal)
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
static QString pkgDataPath()
Returns the common root path of all application data directories.
QDomNode namedItem(const QString &name) const
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void setMaximumScale(const float theMaxScale)
Sets the maximum scale denominator at which the layer will be visible.
QString mAttribution
Attribution of the layer.
QString mAbstract
Description of the layer.
void blendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode() ...
QString metadataUrl() const
Get the metadata URL of the layer used by QGIS Server in GetCapabilities request MetadataUrl is a a l...
QgsMapLayerLegend * legend() const
Can be null.
void setMinimumScale(const float theMinScale)
Sets the minimum scale denominator at which the layer will be visible.
virtual void exportNamedStyle(QDomDocument &doc, QString &errorMsg)
Export the properties of this layer as named style in a QDomDocument.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString providerType() const
Return the provider type for this layer.
QString & replace(int position, int n, QChar after)
QVariant value(const QString &key, const QVariant &defaultValue) const
bool writeXML(QDomNode &theNode, QDomDocument &theDoc) const
Stores state to the given Dom node in the given document.
Contains information about the context of a rendering operation.
QString legendUrlFormat() const
QDateTime currentDateTime()
void save(QTextStream &str, int indent) const
QDomNode firstChild() const
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QString mid(int position, int n) const
Q_DECL_DEPRECATED void clearCacheImage()
Clear cached image.
QString mDataSource
Data source description string, varies by layer type.
virtual QString loadDefaultStyle(bool &theResultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
void writeXml(QDomNode &parentNode, QDomDocument &doc) const
Write store contents to XML.
QString legendUrl() const
bool setMasterPassword(bool verify=false)
Main call to initially set or continually check master password is set.
float toFloat(bool *ok) const
virtual void invalidTransformInput()
Event handler for when a coordinate transform fails due to bad vertex error.
void repaintRequested()
By emitting this signal the layer tells that either appearance or content have been changed and any v...
static QgsProject * instance()
access to canonical QgsProject instance
QDomElement firstChildElement(const QString &tagName) const
virtual bool readXml(const QDomNode &layer_node)
Called by readLayerXML(), used by children to read state specific to them from project files...
QString mLegendUrl
WMS legend.
Class for storing a coordinate reference system (CRS)
QString originalName() const
Get the original name of the layer.
QString absoluteFilePath(const QString &fileName) const
void legendChanged()
Signal emitted when legend of the layer has changed.
QString metadataUrlType() const
Get the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
QString left(int n) const
void setQueryItems(const QList< QPair< QString, QString > > &query)
QString completeBaseName() const
bool readLayerXML(const QDomElement &layerElement)
Sets state from Dom document.
void setLayerName(const QString &name)
Set the display name of the layer.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
QByteArray encodedUri() const
return complete encoded uri (generic mode)
static QgsPluginLayerRegistry * instance()
Means of accessing canonical single instance.
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
QUndoStack * undoStack()
Return pointer to layer's undo stack.
virtual QDateTime timestamp() const
Time stamp of data source in the moment when data/metadata were loaded by provider.
void(* CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem &)
QgsVectorDataProvider * dataProvider()
Returns the data provider.
QgsMapLayer * addMapLayer(QgsMapLayer *theMapLayer, bool addToLegend=true, bool takeOwnership=true)
Add a layer to the map of loaded layers.
QDomElement createElement(const QString &tagName)
QString keywordList() const
Get the keyword list of the layer used by QGIS Server in GetCapabilities request. ...
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
QString uri(bool expandAuthConfig=true) const
return complete uri
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual QString styleURI()
Retrieve the style URI for this layer (either as a .qml file on disk or as a record in the users styl...
Management of styles for use with one map layer.
QDomDocumentType createDocumentType(const QString &qName, const QString &publicId, const QString &systemId)
virtual QgsRectangle extent()
Return the extent of the layer.
Represents a vector layer which manages a vector based data sets.
QString attribution() const
Get the attribution of the layer used by QGIS Server in GetCapabilities request Attribution indicates...
virtual void setLayerOrder(const QStringList &layers)
Reorders the previously selected sublayers of this layer from bottom to top (Useful for providers tha...
bool exactMatch(const QString &str) const
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QString mLayerOrigName
Original name of the layer.
void setValid(bool valid)
Set whether layer is valid or not - should be used in constructor.
QString username() const
Returns the username.
QgsPluginLayer * createLayer(const QString &typeName, const QString &uri=QString())
Return new layer if corresponding plugin has been found, else return NULL.
QString metadataUrlFormat() const
Get the metadata format of the layer used by QGIS Server in GetCapabilities request MetadataUrlType i...
virtual void exportSldStyle(QDomDocument &doc, QString &errorMsg)
Export the properties of this layer as SLD style in a QDomDocument.
QUrl fromEncoded(const QByteArray &input)
QByteArray toEncoded(QFlags< QUrl::FormattingOption > options) const
QString port() const
Returns the port.
QByteArray toAscii() const
QUrl fromLocalFile(const QString &localFile)
void setScaleBasedVisibility(const bool enabled)
Sets whether scale based visibility is enabled for the layer.
Q_DECL_DEPRECATED void toggleScaleBasedVisibility(bool theVisibilityFlag)
Accessor for the scale based visilibility flag.
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QDomNode at(int index) const
void writeXml(QDomElement &mgrElement) const
Write configuration (for project saving)
QByteArray toUtf8() const