21 #include <QDomDocument>    22 #include <QDomElement>    23 #include <QDomImplementation>    28 #include <QTextStream>    58     , mDataSource( source )
    59     , mLayerOrigName( lyrname ) 
    62     , mBlendMode( 
QPainter::CompositionMode_SourceOver ) 
    74   mID = lyrname + dt.
toString( 
"yyyyMMddhhmmsszzz" );
    85   mMaxScale = 100000000;
    86   mScaleBasedVisibility = 
false;
   168   Q_UNUSED( rendererContext );
   174   Q_UNUSED( rendererContext );
   186   mnl = layerElement.
namedItem( 
"provider" );
   188   provider = mne.
text();
   191   mnl = layerElement.
namedItem( 
"datasource" );
   196   QRegExp rx( 
"authcfg=([a-z]|[A-Z]|[0-9]){7}" );
   205   if ( provider == 
"spatialite" )
   211   else if ( provider == 
"ogr" )
   217   else if ( provider == 
"gpx" )
   223   else if ( provider == 
"delimitedtext" )
   238   else if ( provider == 
"wms" )
   255       QgsDebugMsg( 
"Old WMS URI format detected -> converting to new format" );
   260         QStringListIterator iter( parts );
   261         while ( iter.hasNext() )
   280             if ( params.
size() == 2 ) 
   285             else if ( params.
size() > 2 ) 
   289               uri.
setParam( 
"tileMatrixSet", 
"" );
   292           else if ( item.
startsWith( 
"featureCount=" ) )
   318     bool handled = 
false;
   320     if ( provider == 
"gdal" )
   326         QRegExp r( 
"NETCDF:(.+):([^:]+)" );
   331             filename = filename.
mid( 1, filename.
length() - 2 );
   340         QRegExp r( 
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
   345             filename = filename.
mid( 1, filename.
length() - 2 );
   354         QRegExp r( 
"HDF5:(.+):([^:]+)" );
   359             filename = filename.
mid( 1, filename.
length() - 2 );
   368         QRegExp r( 
"([^:]+):([^:]+):(.+)" );
   385   mnl = layerElement.
namedItem( 
"layername" );
   403   layerError = !
readXml( layerElement );
   438   if ( !extentNode.isNull() )
   444   mnl = layerElement.
namedItem( 
"layername" );
   450   if ( !shortNameElem.isNull() )
   457   if ( !titleElem.
isNull() )
   464   if ( !abstractElem.
isNull() )
   471   if ( !keywordListElem.
isNull() )
   476       kwdList << n.toElement().text();
   483   if ( !dataUrlElem.
isNull() )
   491   if ( !legendUrlElem.
isNull() )
   499   if ( !attribElem.
isNull() )
   507   if ( !metaUrlElem.
isNull() )
   517   if ( ! transparencyNode.
isNull() )
   522     setTransparency( myElement.
text().
toInt() );
   534   Q_UNUSED( layer_node );
   579     src = theURIParts.
join( 
"|" );
   585     src = theURIParts.
join( 
"?" );
   587   else if ( vlayer && vlayer->
providerType() == 
"delimitedtext" )
   591     urlDest.setQueryItems( urlSource.
queryItems() );
   594   else if ( vlayer && vlayer->
providerType() == 
"memory" )
   601     bool handled = 
false;
   613           QRegExp r( 
"NETCDF:(.+):([^:]+)" );
   618               filename = filename.
mid( 1, filename.
length() - 2 );
   627           QRegExp r( 
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
   632               filename = filename.
mid( 1, filename.
length() - 2 );
   641           QRegExp r( 
"HDF5:(.+):([^:]+)" );
   646               filename = filename.
mid( 1, filename.
length() - 2 );
   655           QRegExp r( 
"([^:]+):([^:]+):(.+)" );
   710   if ( !keywordStringList.
isEmpty() )
   713     for ( 
int i = 0; i < keywordStringList.
size(); ++i )
   751     layerAttribution.
appendChild( layerAttributionText );
   762     layerMetadataUrl.
appendChild( layerMetadataUrlText );
   785   mCRS.
writeXML( mySrsElement, document );
   792   transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
   793   maplayer.
appendChild( transparencyLevelIntElement );
   800   return writeXml( layerElement, document );
   824   for ( 
int i = 0; i < layernodes.
size(); ++i )
   833     if ( type == 
"vector" )
   837     else if ( type == 
"raster" )
   841     else if ( type == 
"plugin" )
   850     bool ok = layer->
readLayerXML( layerElem, relativeBasePath );
   863   QFile file( qlrfile );
   864   if ( !file.
open( QIODevice::ReadOnly ) )
   871   if ( !doc.setContent( &file ) )
   885   Q_UNUSED( layer_node );
   886   Q_UNUSED( document );
   895   mCustomProperties.
readXml( layerNode, keyStartsWith );
   900   mCustomProperties.
writeXml( layerNode, doc );
   906   if ( !styleMgrElem.
isNull() )
   907     mStyleManager->
readXml( styleMgrElem );
   909     mStyleManager->
reset();
   917     mStyleManager->
writeXml( styleMgrElem );
   968   return mScaleBasedVisibility;
   973   mMinScale = theMinScale;
   984   mMaxScale = theMaxScale;
   989   mScaleBasedVisibility = enabled;
  1043   if ( capitaliseLayerName && !layerName.
isEmpty() )
  1044     layerName = layerName.
at( 0 ).
toUpper() + layerName.
mid( 1 );
  1054   if ( myURI.
startsWith( 
"/vsigzip/", Qt::CaseInsensitive ) )
  1058   else if ( myURI.
startsWith( 
"/vsizip/", Qt::CaseInsensitive ) &&
  1059             myURI.
endsWith( 
".zip", Qt::CaseInsensitive ) )
  1064   else if ( myURI.
startsWith( 
"/vsitar/", Qt::CaseInsensitive ) &&
  1065             ( myURI.
endsWith( 
".tar", Qt::CaseInsensitive ) ||
  1066               myURI.
endsWith( 
".tar.gz", Qt::CaseInsensitive ) ||
  1067               myURI.
endsWith( 
".tgz", Qt::CaseInsensitive ) ) )
  1076   if ( myFileInfo.
exists() )
  1079     if ( myURI.
endsWith( 
".gz", Qt::CaseInsensitive ) )
  1081     else if ( myURI.
endsWith( 
".zip", Qt::CaseInsensitive ) )
  1083     else if ( myURI.
endsWith( 
".tar", Qt::CaseInsensitive ) )
  1085     else if ( myURI.
endsWith( 
".tar.gz", Qt::CaseInsensitive ) )
  1087     else if ( myURI.
endsWith( 
".tgz", Qt::CaseInsensitive ) )
  1110   bool theResultFlag = 
false;
  1114   sqlite3_stmt *myPreparedStatement;
  1118   QgsDebugMsg( 
QString( 
"Trying to load style for \"%1\" from \"%2\"" ).arg( theURI, db ) );
  1123   myResult = sqlite3_open_v2( db.
toUtf8().
data(), &myDatabase, SQLITE_OPEN_READONLY, nullptr );
  1124   if ( myResult != SQLITE_OK )
  1129   QString mySql = 
"select qml from tbl_styles where style=?";
  1130   myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
  1131   if ( myResult == SQLITE_OK )
  1135     if ( sqlite3_bind_text( myPreparedStatement, 1, param.
data(), param.
length(), SQLITE_STATIC ) == SQLITE_OK &&
  1136          sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
  1138       qml = 
QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 0 ) ) );
  1139       theResultFlag = 
true;
  1142     sqlite3_finalize( myPreparedStatement );
  1145   sqlite3_close( myDatabase );
  1147   return theResultFlag;
  1155   theResultFlag = 
false;
  1163   QFile myFile( theURI );
  1164   if ( myFile.
open( QFile::ReadOnly ) )
  1167     theResultFlag = myDocument.
setContent( &myFile, &myErrorMessage, &line, &column );
  1168     if ( !theResultFlag )
  1169       myErrorMessage = 
tr( 
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
  1182       theResultFlag = myDocument.
setContent( qml, &myErrorMessage, &line, &column );
  1183       if ( !theResultFlag )
  1185         myErrorMessage = 
tr( 
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
  1190       myErrorMessage = 
tr( 
"Style not found in database" );
  1194   if ( !theResultFlag )
  1196     return myErrorMessage;
  1200   if ( !theResultFlag )
  1201     myErrorMessage = 
tr( 
"Loading style file %1 failed because:\n%2" ).
arg( theURI, myErrorMessage );
  1203   return myErrorMessage;
  1212     myErrorMessage = 
tr( 
"Root <qgis> element could not be found" );
  1220   if ( thisVersion > fileVersion )
  1233       myErrorMessage = 
tr( 
"Cannot apply style to layer with a different geometry type" );
  1246   if ( ! transparencyNode.isNull() )
  1251     setTransparency( myElement.
text().
toInt() );
  1276   transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
  1277   myRootNode.
appendChild( transparencyLevelIntElement );
  1282     errorMsg = 
QObject::tr( 
"Could not save symbology because:\n%1" ).
arg( errorMsg );
  1327     filename = theURIParts[0];
  1332     filename = theURIParts[0];
  1334   else if ( vlayer && vlayer->
providerType() == 
"delimitedtext" )
  1347   if ( myFileInfo.
exists() || filename.
endsWith( 
".qml", Qt::CaseInsensitive ) )
  1350     if ( !myDirInfo.isWritable() )
  1352       return tr( 
"The directory containing your dataset needs to be writable!" );
  1358     QFile myFile( myFileName );
  1359     if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
  1363       myDocument.
save( myFileStream, 2 );
  1365       theResultFlag = 
true;
  1366       return tr( 
"Created default style file as %1" ).
arg( myFileName );
  1370       theResultFlag = 
false;
  1371       return tr( 
"ERROR: Failed to created default style file as %1. Check file permissions and retry." ).
arg( myFileName );
  1380     sqlite3_stmt *myPreparedStatement;
  1385     if ( myResult != SQLITE_OK )
  1387       return tr( 
"User database could not be opened." );
  1393     QString mySql = 
"create table if not exists tbl_styles(style varchar primary key,qml varchar)";
  1394     myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
  1395     if ( myResult == SQLITE_OK )
  1397       if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
  1399         sqlite3_finalize( myPreparedStatement );
  1400         sqlite3_close( myDatabase );
  1401         theResultFlag = 
false;
  1402         return tr( 
"The style table could not be created." );
  1406     sqlite3_finalize( myPreparedStatement );
  1408     mySql = 
"insert into tbl_styles(style,qml) values (?,?)";
  1409     myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
  1410     if ( myResult == SQLITE_OK )
  1412       if ( sqlite3_bind_text( myPreparedStatement, 1, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
  1413            sqlite3_bind_text( myPreparedStatement, 2, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
  1414            sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
  1416         theResultFlag = 
true;
  1417         myErrorMessage = 
tr( 
"The style %1 was saved to database" ).
arg( theURI );
  1421     sqlite3_finalize( myPreparedStatement );
  1423     if ( !theResultFlag )
  1425       QString mySql = 
"update tbl_styles set qml=? where style=?";
  1426       myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
  1427       if ( myResult == SQLITE_OK )
  1429         if ( sqlite3_bind_text( myPreparedStatement, 2, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
  1430              sqlite3_bind_text( myPreparedStatement, 1, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
  1431              sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
  1433           theResultFlag = 
true;
  1434           myErrorMessage = 
tr( 
"The style %1 was updated in the database." ).
arg( theURI );
  1438           theResultFlag = 
false;
  1439           myErrorMessage = 
tr( 
"The style %1 could not be updated in the database." ).
arg( theURI );
  1444         theResultFlag = 
false;
  1445         myErrorMessage = 
tr( 
"The style %1 could not be inserted into database." ).
arg( theURI );
  1448       sqlite3_finalize( myPreparedStatement );
  1451     sqlite3_close( myDatabase );
  1454   return myErrorMessage;
  1467   root.
setAttribute( 
"xsi:schemaLocation", 
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
  1468   root.
setAttribute( 
"xmlns:ogc", 
"http://www.opengis.net/ogc" );
  1469   root.
setAttribute( 
"xmlns:se", 
"http://www.opengis.net/se" );
  1470   root.
setAttribute( 
"xmlns:xlink", 
"http://www.w3.org/1999/xlink" );
  1471   root.
setAttribute( 
"xmlns:xsi", 
"http://www.w3.org/2001/XMLSchema-instance" );
  1481     errorMsg = 
tr( 
"Could not save symbology because:\n%1" )
  1482                .
arg( 
"Non-vector layers not supported yet" );
  1492   if ( !vlayer->
writeSld( namedLayerNode, myDocument, errorMsg, props ) )
  1494     errorMsg = 
tr( 
"Could not save symbology because:\n%1" ).
arg( errorMsg );
  1506   if ( !errorMsg.
isNull() )
  1508     theResultFlag = 
false;
  1519     filename = theURIParts[0];
  1524     filename = theURIParts[0];
  1530     if ( filename.isEmpty() )
  1539   if ( myFileInfo.
exists() || filename.endsWith( 
".sld", Qt::CaseInsensitive ) )
  1542     if ( !myDirInfo.isWritable() )
  1544       return tr( 
"The directory containing your dataset needs to be writable!" );
  1550     QFile myFile( myFileName );
  1551     if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
  1555       myDocument.
save( myFileStream, 2 );
  1557       theResultFlag = 
true;
  1558       return tr( 
"Created default style file as %1" ).
arg( myFileName );
  1562   theResultFlag = 
false;
  1563   return tr( 
"ERROR: Failed to created SLD style file as %1. Check file permissions and retry." ).
arg( filename );
  1570   theResultFlag = 
false;
  1578   QFile myFile( theURI );
  1579   if ( myFile.
open( QFile::ReadOnly ) )
  1582     theResultFlag = myDocument.
setContent( &myFile, 
true, &myErrorMessage, &line, &column );
  1583     if ( !theResultFlag )
  1584       myErrorMessage = 
tr( 
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
  1589     myErrorMessage = 
tr( 
"Unable to open file %1" ).
arg( theURI );
  1592   if ( !theResultFlag )
  1594     return myErrorMessage;
  1601     myErrorMessage = 
QString( 
"Error: StyledLayerDescriptor element not found in %1" ).
arg( theURI );
  1602     theResultFlag = 
false;
  1603     return myErrorMessage;
  1609   if ( namedLayerElem.
isNull() )
  1611     myErrorMessage = 
QLatin1String( 
"Info: NamedLayer element not found." );
  1612     theResultFlag = 
false;
  1613     return myErrorMessage;
  1617   theResultFlag = 
readSld( namedLayerElem, errorMsg );
  1618   if ( !theResultFlag )
  1620     myErrorMessage = 
tr( 
"Loading style file %1 failed because:\n%2" ).
arg( theURI, errorMsg );
  1621     return myErrorMessage;
  1630   Q_UNUSED( errorMessage );
  1638   Q_UNUSED( errorMessage );
  1650   return &mUndoStackStyles;
  1656   mCustomProperties.
setValue( key, value );
  1661   return mCustomProperties.
value( value, defaultValue );
  1666   mCustomProperties.
remove( key );
  1688   if ( legend == mLegend )
  1707   return mStyleManager;
 QString attributionUrl() const
Get the attribution URL of the layer used by QGIS Server in GetCapabilities request Attribution indic...
 
virtual QStringList subLayers() const
Returns the sublayers of this layer (Useful for providers that manage their own layers, such as WMS) 
 
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 dataUrlFormat() const
Get the DataUrl format of the layer used by QGIS Server in GetCapabilities request DataUrl is a a lin...
 
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
 
QDomProcessingInstruction createProcessingInstruction(const QString &target, const QString &data)
 
virtual QString metadata()
Obtain Metadata for this layer. 
 
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. 
 
Q_DECL_DEPRECATED void layerNameChanged()
Emit a signal that the layer name has been changed. 
 
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...
 
QgsMapLayerLegend * legend() const
Can be null. 
 
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
 
QString dataUrl() const
Get the DataUrl of the layer used by QGIS Server in GetCapabilities request DataUrl is a a link to th...
 
static QString removePassword(const QString &aUri)
Removes password element from uris. 
 
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
 
virtual Q_DECL_DEPRECATED QString lastError()
 
QList< QPair< QString, QString > > queryItems() const
 
void setFile(const QString &file)
 
void emitStyleChanged()
Triggers an emission of the styleChanged() signal. 
 
virtual bool readSymbology(const QDomNode &node, QString &errorMessage)=0
Read the symbology for the current layer from the Dom node supplied. 
 
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. 
 
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system. 
 
static QList< QgsMapLayer * > fromLayerDefinition(QDomDocument &document, bool addToRegistry=false, bool addToLegend=false, const QString &relativeBasePath=QString())
Creates a new layer from a layer defininition document. 
 
static QDomElement writeRectangle(const QgsRectangle &rect, QDomDocument &doc)
 
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale. 
 
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. 
 
void writeXml(QDomNode &parentNode, QDomDocument &doc) const
Write store contents to XML. 
 
QString join(const QString &separator) const
 
QString & remove(int position, int n)
 
static CUSTOM_CRS_VALIDATION customSrsValidation()
Gets custom function. 
 
virtual QDateTime timestamp() const
Time stamp of data source in the moment when data/metadata were loaded by provider. 
 
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 ...
 
bool readLayerXML(const QDomElement &layerElement, const QString &relativeBasePath=QString())
Sets state from Dom document. 
 
double toDouble(bool *ok) const
 
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer. 
 
QgsMapLayer(QgsMapLayer::LayerType type=VectorLayer, const QString &lyrname=QString::null, const QString &source=QString::null)
Constructor. 
 
QgsMapLayer::LayerType type() const
Get the type of the layer. 
 
QString tr(const char *sourceText, const char *disambiguation, int n)
 
void remove(const QString &key)
Remove a key (entry) from the store. 
 
QString mLayerName
Name of the layer - used for display. 
 
void styleChanged()
Signal emitted whenever a change affects the layer's style. 
 
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage) const =0
Write the symbology for the layer into the docment provided. 
 
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file. 
 
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. 
 
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager. 
 
QString port() const
Returns the port. 
 
static QString capitaliseLayerName(const QString &name)
A convenience function to (un)capitalise the layer name. 
 
QDomElement toElement() const
 
void setPath(const QString &path)
 
int indexIn(const QString &str, int offset, CaretMode caretMode) const
 
QgsRectangle mExtent
Extent of the layer. 
 
static QDomDocument asLayerDefinition(const QList< QgsMapLayer *> &layers, const QString &relativeBasePath=QString())
Returns the given layer as a layer definition document Layer definitions store the data source as wel...
 
QString mMetadataUrl
MetadataUrl of the layer. 
 
QString password() const
Returns the password. 
 
QString metadataUrlFormat() const
Get the metadata format of the layer used by QGIS Server in GetCapabilities request MetadataUrlType i...
 
void setValidationHint(const QString &html)
Set user hint for validation. 
 
QString number(int n, int base)
 
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. 
 
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry. 
 
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...
 
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage) const
Writes the symbology of the layer into the document provided in SLD 1.1 format. 
 
QString originalName() const
Get the original name of the layer. 
 
#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. 
 
QString database() const
Returns the database. 
 
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 nameChanged()
Emitted when the name has been changed. 
 
A class to describe the version of a project. 
 
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer? 
 
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 keywordList() const
Get the keyword list of the layer used by QGIS Server in GetCapabilities request. ...
 
QString absoluteFilePath() const
 
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Get the data source specification. 
 
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...
 
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
 
virtual bool isEditable() const
True if the layer can be edited. 
 
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. 
 
QString legendUrl() const
 
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
 
bool setCurrent(const QString &path)
 
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
 
virtual Q_DECL_DEPRECATED QString lastErrorTitle()
 
QGis::GeometryType geometryType() const
Returns point, line or polygon. 
 
QString uri(bool expandAuthConfig=true) const
return complete uri 
 
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. 
 
virtual bool readStyle(const QDomNode &node, QString &errorMessage)
Read the style for the current layer from the Dom node supplied. 
 
virtual QString saveSldStyle(const QString &theURI, bool &theResultFlag)
 
double minimumScale() const
Returns the minimum scale denominator at which the layer is visible. 
 
bool isValid()
Return the status of the layer. 
 
double maximumScale() const
Returns the maximum scale denominator at which the layer is visible. 
 
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)
 
void setName(const QString &name)
Set the display name of the layer. 
 
static QString QGIS_VERSION
 
virtual bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage) const
Write just the style information for the layer into the document. 
 
virtual bool readSld(const QDomNode &node, QString &errorMessage)
 
QString legendUrlFormat() const
 
QString toLocalFile() const
 
QString mMetadataUrlFormat
 
QDomText createTextNode(const QString &value)
 
void setMinimumScale(double theMinScale)
Sets the minimum scale denominator at which the layer will be visible. 
 
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
 
QString username() const
Returns the username. 
 
QByteArray encodedUri() const
return complete encoded uri (generic mode) 
 
QString mAttribution
Attribution of the layer. 
 
QString mAbstract
Description of the layer. 
 
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). 
 
void blendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode() ...
 
void setMaximumScale(double theMaxScale)
Sets the maximum 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. 
 
QString & replace(int position, int n, QChar after)
 
bool writeLayerXML(QDomElement &layerElement, QDomDocument &document, const QString &relativeBasePath=QString())
Stores state in Dom node. 
 
QVariant value(const QString &key, const QVariant &defaultValue) const
 
Contains information about the context of a rendering operation. 
 
QString name() const
Get the display name of the layer. 
 
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...
 
QString source() const
Returns the source for the layer. 
 
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer. 
 
bool setMasterPassword(bool verify=false)
Main call to initially set or continually check master password is set. 
 
virtual void invalidTransformInput()
Event handler for when a coordinate transform fails due to bad vertex error. 
 
QString host() const
Returns the host. 
 
QString readPath(QString filename, const QString &relativeBasePath=QString()) const
Turn filename read from the project file to an absolute path. 
 
void repaintRequested()
By emitting this signal the layer tells that either appearance or content have been changed and any v...
 
const QChar at(int position) const
 
static QgsProject * instance()
Returns the QgsProject singleton 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) 
 
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()). 
 
QString absoluteFilePath(const QString &fileName) const
 
void legendChanged()
Signal emitted when legend of the layer has changed. 
 
QString left(int n) const
 
void setQueryItems(const QList< QPair< QString, QString > > &query)
 
QString completeBaseName() const
 
Q_DECL_DEPRECATED void setLayerName(const QString &name)
Set the display name of the layer. 
 
QString metadataUrl() const
Get the metadata URL of the layer used by QGIS Server in GetCapabilities request MetadataUrl is a a l...
 
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 ...
 
QUndoStack * undoStackStyles()
Return pointer to layer's style undo stack. 
 
static QgsPluginLayerRegistry * instance()
Means of accessing canonical single instance. 
 
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer. 
 
QUndoStack * undoStack()
Return pointer to layer's undo stack. 
 
void(* CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem &)
 
QgsVectorDataProvider * dataProvider()
Returns the data provider. 
 
QString providerType() const
Return the provider type for this layer. 
 
QgsMapLayer * addMapLayer(QgsMapLayer *theMapLayer, bool addToLegend=true, bool takeOwnership=true)
Add a layer to the map of loaded layers. 
 
bool writeXML(QDomNode &theNode, QDomDocument &theDoc) const
Stores state to the given Dom node in the given document. 
 
QDomElement createElement(const QString &tagName)
 
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer. 
 
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. 
 
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
 
void writeXml(QDomElement &mgrElement) const
Write configuration (for project saving) 
 
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
 
static double SCALE_PRECISION
Fudge factor used to compare two scales. 
 
QString mLayerOrigName
Original name of the layer. 
 
void setValid(bool valid)
Set whether layer is valid or not - should be used in constructor. 
 
static QgsRectangle readRectangle(const QDomElement &element)
 
QgsPluginLayer * createLayer(const QString &typeName, const QString &uri=QString())
Return new layer if corresponding plugin has been found, else return NULL. 
 
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
 
QByteArray toAscii() const
 
QString attribution() const
Get the attribution of the layer used by QGIS Server in GetCapabilities request Attribution indicates...
 
QUrl fromLocalFile(const QString &localFile)
 
QString metadataUrlType() const
Get the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
 
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. 
 
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer. 
 
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
 
QDomNode at(int index) const
 
QString writePath(const QString &filename, const QString &relativeBasePath=QString()) const
Prepare a filename to save it to the project file. 
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable. 
 
QByteArray toUtf8() const