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(
"([^:]+):([^:]+):(.+)" );
682 if ( !keywordStringList.
isEmpty() )
685 for (
int i = 0; i < keywordStringList.
size(); ++i )
723 layerAttribution.
appendChild( layerAttributionText );
734 layerMetadataUrl.
appendChild( layerMetadataUrlText );
757 mCRS->
writeXML( mySrsElement, document );
764 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
765 maplayer.
appendChild( transparencyLevelIntElement );
772 return writeXml( layerElement, document );
796 for (
int i = 0; i < layernodes.
size(); ++i )
805 if ( type ==
"vector" )
809 else if ( type ==
"raster" )
813 else if ( type ==
"plugin" )
835 QFile file( qlrfile );
836 if ( !file.
open( QIODevice::ReadOnly ) )
843 if ( !doc.setContent( &file ) )
857 Q_UNUSED( layer_node );
858 Q_UNUSED( document );
867 mCustomProperties.
readXml( layerNode, keyStartsWith );
872 mCustomProperties.
writeXml( layerNode, doc );
878 if ( !styleMgrElem.
isNull() )
879 mStyleManager->
readXml( styleMgrElem );
881 mStyleManager->
reset();
889 mStyleManager->
writeXml( styleMgrElem );
936 return mScaleBasedVisibility;
941 mMinScale = theMinScale;
952 mMaxScale = theMaxScale;
957 mScaleBasedVisibility = enabled;
1011 if ( capitaliseLayerName )
1022 if ( myURI.
startsWith(
"/vsigzip/", Qt::CaseInsensitive ) )
1026 else if ( myURI.
startsWith(
"/vsizip/", Qt::CaseInsensitive ) &&
1027 myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1032 else if ( myURI.
startsWith(
"/vsitar/", Qt::CaseInsensitive ) &&
1033 ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) ||
1034 myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) ||
1035 myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) ) )
1044 if ( myFileInfo.
exists() )
1047 if ( myURI.
endsWith(
".gz", Qt::CaseInsensitive ) )
1049 else if ( myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1051 else if ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) )
1053 else if ( myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) )
1055 else if ( myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) )
1078 bool theResultFlag =
false;
1082 sqlite3_stmt *myPreparedStatement;
1086 QgsDebugMsg(
QString(
"Trying to load style for \"%1\" from \"%2\"" ).arg( theURI, db ) );
1091 myResult = sqlite3_open_v2( db.
toUtf8().
data(), &myDatabase, SQLITE_OPEN_READONLY, nullptr );
1092 if ( myResult != SQLITE_OK )
1097 QString mySql =
"select qml from tbl_styles where style=?";
1098 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1099 if ( myResult == SQLITE_OK )
1103 if ( sqlite3_bind_text( myPreparedStatement, 1, param.
data(), param.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1104 sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1106 qml =
QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 0 ) ) );
1107 theResultFlag =
true;
1110 sqlite3_finalize( myPreparedStatement );
1113 sqlite3_close( myDatabase );
1115 return theResultFlag;
1123 theResultFlag =
false;
1131 QFile myFile( theURI );
1132 if ( myFile.
open( QFile::ReadOnly ) )
1135 theResultFlag = myDocument.
setContent( &myFile, &myErrorMessage, &line, &column );
1136 if ( !theResultFlag )
1137 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1150 theResultFlag = myDocument.
setContent( qml, &myErrorMessage, &line, &column );
1151 if ( !theResultFlag )
1153 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1158 myErrorMessage =
tr(
"Style not found in database" );
1162 if ( !theResultFlag )
1164 return myErrorMessage;
1168 if ( !theResultFlag )
1169 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, myErrorMessage );
1171 return myErrorMessage;
1180 myErrorMessage =
tr(
"Root <qgis> element could not be found" );
1188 if ( thisVersion > fileVersion )
1201 myErrorMessage =
tr(
"Cannot apply style to layer with a different geometry type" );
1214 if ( ! transparencyNode.isNull() )
1219 setTransparency( myElement.
text().
toInt() );
1244 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
1245 myRootNode.
appendChild( transparencyLevelIntElement );
1250 errorMsg =
QObject::tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1295 filename = theURIParts[0];
1300 filename = theURIParts[0];
1302 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
1315 if ( myFileInfo.
exists() || filename.
endsWith(
".qml", Qt::CaseInsensitive ) )
1318 if ( !myDirInfo.isWritable() )
1320 return tr(
"The directory containing your dataset needs to be writable!" );
1326 QFile myFile( myFileName );
1327 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1331 myDocument.
save( myFileStream, 2 );
1333 theResultFlag =
true;
1334 return tr(
"Created default style file as %1" ).
arg( myFileName );
1338 theResultFlag =
false;
1339 return tr(
"ERROR: Failed to created default style file as %1. Check file permissions and retry." ).
arg( myFileName );
1348 sqlite3_stmt *myPreparedStatement;
1353 if ( myResult != SQLITE_OK )
1355 return tr(
"User database could not be opened." );
1361 QString mySql =
"create table if not exists tbl_styles(style varchar primary key,qml varchar)";
1362 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1363 if ( myResult == SQLITE_OK )
1365 if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
1367 sqlite3_finalize( myPreparedStatement );
1368 sqlite3_close( myDatabase );
1369 theResultFlag =
false;
1370 return tr(
"The style table could not be created." );
1374 sqlite3_finalize( myPreparedStatement );
1376 mySql =
"insert into tbl_styles(style,qml) values (?,?)";
1377 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1378 if ( myResult == SQLITE_OK )
1380 if ( sqlite3_bind_text( myPreparedStatement, 1, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1381 sqlite3_bind_text( myPreparedStatement, 2, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1382 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1384 theResultFlag =
true;
1385 myErrorMessage =
tr(
"The style %1 was saved to database" ).
arg( theURI );
1389 sqlite3_finalize( myPreparedStatement );
1391 if ( !theResultFlag )
1393 QString mySql =
"update tbl_styles set qml=? where style=?";
1394 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1395 if ( myResult == SQLITE_OK )
1397 if ( sqlite3_bind_text( myPreparedStatement, 2, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1398 sqlite3_bind_text( myPreparedStatement, 1, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1399 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1401 theResultFlag =
true;
1402 myErrorMessage =
tr(
"The style %1 was updated in the database." ).
arg( theURI );
1406 theResultFlag =
false;
1407 myErrorMessage =
tr(
"The style %1 could not be updated in the database." ).
arg( theURI );
1412 theResultFlag =
false;
1413 myErrorMessage =
tr(
"The style %1 could not be inserted into database." ).
arg( theURI );
1416 sqlite3_finalize( myPreparedStatement );
1419 sqlite3_close( myDatabase );
1422 return myErrorMessage;
1436 root.
setAttribute(
"xsi:schemaLocation",
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1437 root.
setAttribute(
"xmlns:ogc",
"http://www.opengis.net/ogc" );
1438 root.
setAttribute(
"xmlns:se",
"http://www.opengis.net/se" );
1439 root.
setAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink" );
1440 root.
setAttribute(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
1450 errorMsg =
tr(
"Could not save symbology because:\n%1" )
1451 .
arg(
"Non-vector layers not supported yet" );
1455 if ( !vlayer->
writeSld( namedLayerNode, myDocument, errorMsg ) )
1457 errorMsg =
tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1469 if ( !errorMsg.
isNull() )
1471 theResultFlag =
false;
1482 filename = theURIParts[0];
1487 filename = theURIParts[0];
1493 if ( filename.isEmpty() )
1502 if ( myFileInfo.
exists() || filename.endsWith(
".sld", Qt::CaseInsensitive ) )
1505 if ( !myDirInfo.isWritable() )
1507 return tr(
"The directory containing your dataset needs to be writable!" );
1513 QFile myFile( myFileName );
1514 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1518 myDocument.
save( myFileStream, 2 );
1520 theResultFlag =
true;
1521 return tr(
"Created default style file as %1" ).
arg( myFileName );
1525 theResultFlag =
false;
1526 return tr(
"ERROR: Failed to created SLD style file as %1. Check file permissions and retry." ).
arg( filename );
1533 theResultFlag =
false;
1541 QFile myFile( theURI );
1542 if ( myFile.
open( QFile::ReadOnly ) )
1545 theResultFlag = myDocument.
setContent( &myFile,
true, &myErrorMessage, &line, &column );
1546 if ( !theResultFlag )
1547 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1552 myErrorMessage =
tr(
"Unable to open file %1" ).
arg( theURI );
1555 if ( !theResultFlag )
1557 return myErrorMessage;
1564 myErrorMessage =
QString(
"Error: StyledLayerDescriptor element not found in %1" ).
arg( theURI );
1565 theResultFlag =
false;
1566 return myErrorMessage;
1572 if ( namedLayerElem.
isNull() )
1574 myErrorMessage =
QLatin1String(
"Info: NamedLayer element not found." );
1575 theResultFlag =
false;
1576 return myErrorMessage;
1580 theResultFlag =
readSld( namedLayerElem, errorMsg );
1581 if ( !theResultFlag )
1583 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, errorMsg );
1584 return myErrorMessage;
1599 mCustomProperties.
setValue( key, value );
1604 return mCustomProperties.
value( value, defaultValue );
1609 mCustomProperties.
remove( key );
1631 if ( legend == mLegend )
1650 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.
QString shortName() const
Get the short name of the layer used by QGIS Server to identify 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 title() const
Get the title of the layer used by QGIS Server in GetCapabilities request.
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