21 #include <QDomDocument> 22 #include <QDomElement> 23 #include <QDomImplementation> 28 #include <QTextStream> 58 , mDataSource( source )
59 , mLayerOrigName( lyrname )
62 , mBlendMode(
QPainter::CompositionMode_SourceOver )
78 mID = lyrname + dt.
toString(
"yyyyMMddhhmmsszzz" );
89 mMaxScale = 100000000;
90 mScaleBasedVisibility =
false;
114 QgsDebugMsg(
"new original name: '" + name +
'\'' );
116 QgsDebugMsg(
"new display name: '" + name +
'\'' );
163 Q_UNUSED( rendererContext );
169 Q_UNUSED( rendererContext );
183 mnl = layerElement.
namedItem(
"provider" );
185 provider = mne.
text();
188 mnl = layerElement.
namedItem(
"datasource" );
193 QRegExp rx(
"authcfg=([a-z]|[A-Z]|[0-9]){7}" );
202 if ( provider ==
"spatialite" )
208 else if ( provider ==
"ogr" )
214 else if ( provider ==
"gpx" )
220 else if ( provider ==
"delimitedtext" )
235 else if ( provider ==
"wms" )
250 QgsDebugMsg(
"Old WMS URI format detected -> converting to new format" );
255 QStringListIterator iter( parts );
256 while ( iter.hasNext() )
275 if ( params.
size() == 2 )
280 else if ( params.
size() > 2 )
284 uri.
setParam(
"tileMatrixSet",
"" );
287 else if ( item.
startsWith(
"featureCount=" ) )
313 bool handled =
false;
315 if ( provider ==
"gdal" )
321 QRegExp r(
"NETCDF:(.+):([^:]+)" );
326 filename = filename.
mid( 1, filename.
length() - 2 );
335 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
340 filename = filename.
mid( 1, filename.
length() - 2 );
349 QRegExp r(
"HDF5:(.+):([^:]+)" );
354 filename = filename.
mid( 1, filename.
length() - 2 );
363 QRegExp r(
"([^:]+):([^:]+):(.+)" );
380 mnl = layerElement.
namedItem(
"layername" );
395 layerError = !
readXml( layerElement );
430 if ( !extentNode.isNull() )
436 mnl = layerElement.
namedItem(
"layername" );
442 if ( !shortNameElem.isNull() )
449 if ( !titleElem.
isNull() )
456 if ( !abstractElem.
isNull() )
463 if ( !keywordListElem.
isNull() )
468 kwdList << n.toElement().text();
475 if ( !dataUrlElem.
isNull() )
483 if ( !legendUrlElem.
isNull() )
491 if ( !attribElem.
isNull() )
499 if ( !metaUrlElem.
isNull() )
509 if ( ! transparencyNode.
isNull() )
514 setTransparency( myElement.
text().
toInt() );
526 Q_UNUSED( layer_node );
571 src = theURIParts.
join(
"|" );
577 src = theURIParts.
join(
"?" );
579 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
583 urlDest.setQueryItems( urlSource.
queryItems() );
586 else if ( vlayer && vlayer->
providerType() ==
"memory" )
593 bool handled =
false;
605 QRegExp r(
"NETCDF:(.+):([^:]+)" );
610 filename = filename.
mid( 1, filename.
length() - 2 );
619 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
624 filename = filename.
mid( 1, filename.
length() - 2 );
633 QRegExp r(
"HDF5:(.+):([^:]+)" );
638 filename = filename.
mid( 1, filename.
length() - 2 );
647 QRegExp r(
"([^:]+):([^:]+):(.+)" );
702 if ( !keywordStringList.
isEmpty() )
705 for (
int i = 0; i < keywordStringList.
size(); ++i )
743 layerAttribution.
appendChild( layerAttributionText );
754 layerMetadataUrl.
appendChild( layerMetadataUrlText );
777 mCRS->
writeXML( mySrsElement, document );
784 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
785 maplayer.
appendChild( transparencyLevelIntElement );
792 return writeXml( layerElement, document );
816 for (
int i = 0; i < layernodes.
size(); ++i )
825 if ( type ==
"vector" )
829 else if ( type ==
"raster" )
833 else if ( type ==
"plugin" )
855 QFile file( qlrfile );
856 if ( !file.
open( QIODevice::ReadOnly ) )
863 if ( !doc.setContent( &file ) )
877 Q_UNUSED( layer_node );
878 Q_UNUSED( document );
887 mCustomProperties.
readXml( layerNode, keyStartsWith );
892 mCustomProperties.
writeXml( layerNode, doc );
898 if ( !styleMgrElem.
isNull() )
899 mStyleManager->
readXml( styleMgrElem );
901 mStyleManager->
reset();
909 mStyleManager->
writeXml( styleMgrElem );
956 return mScaleBasedVisibility;
961 mMinScale = theMinScale;
972 mMaxScale = theMaxScale;
977 mScaleBasedVisibility = enabled;
1031 if ( capitaliseLayerName )
1042 if ( myURI.
startsWith(
"/vsigzip/", Qt::CaseInsensitive ) )
1046 else if ( myURI.
startsWith(
"/vsizip/", Qt::CaseInsensitive ) &&
1047 myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1052 else if ( myURI.
startsWith(
"/vsitar/", Qt::CaseInsensitive ) &&
1053 ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) ||
1054 myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) ||
1055 myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) ) )
1064 if ( myFileInfo.
exists() )
1067 if ( myURI.
endsWith(
".gz", Qt::CaseInsensitive ) )
1069 else if ( myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1071 else if ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) )
1073 else if ( myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) )
1075 else if ( myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) )
1098 bool theResultFlag =
false;
1102 sqlite3_stmt *myPreparedStatement;
1106 QgsDebugMsg(
QString(
"Trying to load style for \"%1\" from \"%2\"" ).arg( theURI, db ) );
1111 myResult = sqlite3_open_v2( db.
toUtf8().
data(), &myDatabase, SQLITE_OPEN_READONLY, nullptr );
1112 if ( myResult != SQLITE_OK )
1117 QString mySql =
"select qml from tbl_styles where style=?";
1118 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1119 if ( myResult == SQLITE_OK )
1123 if ( sqlite3_bind_text( myPreparedStatement, 1, param.
data(), param.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1124 sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1126 qml =
QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 0 ) ) );
1127 theResultFlag =
true;
1130 sqlite3_finalize( myPreparedStatement );
1133 sqlite3_close( myDatabase );
1135 return theResultFlag;
1143 theResultFlag =
false;
1151 QFile myFile( theURI );
1152 if ( myFile.
open( QFile::ReadOnly ) )
1155 theResultFlag = myDocument.
setContent( &myFile, &myErrorMessage, &line, &column );
1156 if ( !theResultFlag )
1157 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1170 theResultFlag = myDocument.
setContent( qml, &myErrorMessage, &line, &column );
1171 if ( !theResultFlag )
1173 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1178 myErrorMessage =
tr(
"Style not found in database" );
1182 if ( !theResultFlag )
1184 return myErrorMessage;
1188 if ( !theResultFlag )
1189 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, myErrorMessage );
1191 return myErrorMessage;
1200 myErrorMessage =
tr(
"Root <qgis> element could not be found" );
1208 if ( thisVersion > fileVersion )
1221 myErrorMessage =
tr(
"Cannot apply style to layer with a different geometry type" );
1234 if ( ! transparencyNode.isNull() )
1239 setTransparency( myElement.
text().
toInt() );
1264 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
1265 myRootNode.
appendChild( transparencyLevelIntElement );
1270 errorMsg =
QObject::tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1315 filename = theURIParts[0];
1320 filename = theURIParts[0];
1322 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
1335 if ( myFileInfo.
exists() || filename.
endsWith(
".qml", Qt::CaseInsensitive ) )
1338 if ( !myDirInfo.isWritable() )
1340 return tr(
"The directory containing your dataset needs to be writable!" );
1346 QFile myFile( myFileName );
1347 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1351 myDocument.
save( myFileStream, 2 );
1353 theResultFlag =
true;
1354 return tr(
"Created default style file as %1" ).
arg( myFileName );
1358 theResultFlag =
false;
1359 return tr(
"ERROR: Failed to created default style file as %1. Check file permissions and retry." ).
arg( myFileName );
1368 sqlite3_stmt *myPreparedStatement;
1373 if ( myResult != SQLITE_OK )
1375 return tr(
"User database could not be opened." );
1381 QString mySql =
"create table if not exists tbl_styles(style varchar primary key,qml varchar)";
1382 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1383 if ( myResult == SQLITE_OK )
1385 if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
1387 sqlite3_finalize( myPreparedStatement );
1388 sqlite3_close( myDatabase );
1389 theResultFlag =
false;
1390 return tr(
"The style table could not be created." );
1394 sqlite3_finalize( myPreparedStatement );
1396 mySql =
"insert into tbl_styles(style,qml) values (?,?)";
1397 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1398 if ( myResult == SQLITE_OK )
1400 if ( sqlite3_bind_text( myPreparedStatement, 1, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1401 sqlite3_bind_text( myPreparedStatement, 2, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1402 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1404 theResultFlag =
true;
1405 myErrorMessage =
tr(
"The style %1 was saved to database" ).
arg( theURI );
1409 sqlite3_finalize( myPreparedStatement );
1411 if ( !theResultFlag )
1413 QString mySql =
"update tbl_styles set qml=? where style=?";
1414 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1415 if ( myResult == SQLITE_OK )
1417 if ( sqlite3_bind_text( myPreparedStatement, 2, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1418 sqlite3_bind_text( myPreparedStatement, 1, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1419 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1421 theResultFlag =
true;
1422 myErrorMessage =
tr(
"The style %1 was updated in the database." ).
arg( theURI );
1426 theResultFlag =
false;
1427 myErrorMessage =
tr(
"The style %1 could not be updated in the database." ).
arg( theURI );
1432 theResultFlag =
false;
1433 myErrorMessage =
tr(
"The style %1 could not be inserted into database." ).
arg( theURI );
1436 sqlite3_finalize( myPreparedStatement );
1439 sqlite3_close( myDatabase );
1442 return myErrorMessage;
1455 root.
setAttribute(
"xsi:schemaLocation",
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1456 root.
setAttribute(
"xmlns:ogc",
"http://www.opengis.net/ogc" );
1457 root.
setAttribute(
"xmlns:se",
"http://www.opengis.net/se" );
1458 root.
setAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink" );
1459 root.
setAttribute(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
1469 errorMsg =
tr(
"Could not save symbology because:\n%1" )
1470 .
arg(
"Non-vector layers not supported yet" );
1480 if ( !vlayer->
writeSld( namedLayerNode, myDocument, errorMsg, props ) )
1482 errorMsg =
tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1494 if ( !errorMsg.
isNull() )
1496 theResultFlag =
false;
1507 filename = theURIParts[0];
1512 filename = theURIParts[0];
1518 if ( filename.isEmpty() )
1527 if ( myFileInfo.
exists() || filename.endsWith(
".sld", Qt::CaseInsensitive ) )
1530 if ( !myDirInfo.isWritable() )
1532 return tr(
"The directory containing your dataset needs to be writable!" );
1538 QFile myFile( myFileName );
1539 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1543 myDocument.
save( myFileStream, 2 );
1545 theResultFlag =
true;
1546 return tr(
"Created default style file as %1" ).
arg( myFileName );
1550 theResultFlag =
false;
1551 return tr(
"ERROR: Failed to created SLD style file as %1. Check file permissions and retry." ).
arg( filename );
1558 theResultFlag =
false;
1566 QFile myFile( theURI );
1567 if ( myFile.
open( QFile::ReadOnly ) )
1570 theResultFlag = myDocument.
setContent( &myFile,
true, &myErrorMessage, &line, &column );
1571 if ( !theResultFlag )
1572 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1577 myErrorMessage =
tr(
"Unable to open file %1" ).
arg( theURI );
1580 if ( !theResultFlag )
1582 return myErrorMessage;
1589 myErrorMessage =
QString(
"Error: StyledLayerDescriptor element not found in %1" ).
arg( theURI );
1590 theResultFlag =
false;
1591 return myErrorMessage;
1597 if ( namedLayerElem.
isNull() )
1599 myErrorMessage =
QLatin1String(
"Info: NamedLayer element not found." );
1600 theResultFlag =
false;
1601 return myErrorMessage;
1605 theResultFlag =
readSld( namedLayerElem, errorMsg );
1606 if ( !theResultFlag )
1608 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, errorMsg );
1609 return myErrorMessage;
1624 mCustomProperties.
setValue( key, value );
1629 return mCustomProperties.
value( value, defaultValue );
1634 mCustomProperties.
remove( key );
1656 if ( legend == mLegend )
1675 return mStyleManager;
static const char * QGIS_VERSION
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.
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)
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.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
QString writePath(const QString &filename, const QString &relativeBasePath=QString::null) const
Prepare a filename to save it to the project file.
static QDomElement writeRectangle(const QgsRectangle &rect, QDomDocument &doc)
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 ...
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.
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.
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.
float maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
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)
A class to describe the version of a project.
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
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 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 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)
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QString legendUrlFormat() const
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 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 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.
QString & replace(int position, int n, QChar after)
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.
float toFloat(bool *ok) const
virtual void invalidTransformInput()
Event handler for when a coordinate transform fails due to bad vertex error.
QString host() const
Returns the host.
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)
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
QString absoluteFilePath(const QString &fileName) const
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...
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 readPath(QString filename) const
Turn filename read from the project file to an absolute path.
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.
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 ...
static QgsPluginLayerRegistry * instance()
Means of accessing canonical single instance.
float minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
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
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
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QByteArray toUtf8() const