21 #include <QDomDocument>
22 #include <QDomElement>
23 #include <QDomImplementation>
28 #include <QTextStream>
55 , mDataSource( source )
56 , mLayerOrigName( lyrname )
59 , mBlendMode(
QPainter::CompositionMode_SourceOver )
72 mID = lyrname + dt.
toString(
"yyyyMMddhhmmsszzz" );
83 mMaxScale = 100000000;
84 mScaleBasedVisibility =
false;
108 QgsDebugMsg(
"new original name: '" + name +
"'" );
157 Q_UNUSED( rendererContext );
163 Q_UNUSED( rendererContext );
177 mnl = layerElement.
namedItem(
"provider" );
179 provider = mne.
text();
182 mnl = layerElement.
namedItem(
"datasource" );
187 QRegExp rx(
"authcfg=([a-z]|[A-Z]|[0-9]){7}" );
196 if ( provider ==
"spatialite" )
202 else if ( provider ==
"ogr" )
208 else if ( provider ==
"gpx" )
214 else if ( provider ==
"delimitedtext" )
229 else if ( provider ==
"wms" )
244 QgsDebugMsg(
"Old WMS URI format detected -> converting to new format" );
249 QStringListIterator iter( parts );
250 while ( iter.hasNext() )
269 if ( params.
size() == 2 )
274 else if ( params.
size() > 2 )
278 uri.
setParam(
"tileMatrixSet",
"" );
281 else if ( item.
startsWith(
"featureCount=" ) )
307 bool handled =
false;
309 if ( provider ==
"gdal" )
315 QRegExp r(
"NETCDF:(.+):([^:]+)" );
320 filename = filename.
mid( 1, filename.
length() - 2 );
329 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
334 filename = filename.
mid( 1, filename.
length() - 2 );
343 QRegExp r(
"HDF5:(.+):([^:]+)" );
348 filename = filename.
mid( 1, filename.
length() - 2 );
357 QRegExp r(
"([^:]+):([^:]+):(.+)" );
374 mnl = layerElement.
namedItem(
"layername" );
389 layerError = !
readXml( layerElement );
424 mnl = layerElement.
namedItem(
"layername" );
430 if ( !titleElem.isNull() )
432 mTitle = titleElem.text();
437 if ( !abstractElem.
isNull() )
444 if ( !keywordListElem.
isNull() )
449 kwdList << n.toElement().text();
456 if ( !dataUrlElem.
isNull() )
464 if ( !legendUrlElem.
isNull() )
472 if ( !attribElem.
isNull() )
480 if ( !metaUrlElem.
isNull() )
490 if ( ! transparencyNode.
isNull() )
495 setTransparency( myElement.
text().
toInt() );
507 Q_UNUSED( layer_node );
547 src = theURIParts.
join(
"|" );
553 src = theURIParts.
join(
"?" );
555 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
559 urlDest.setQueryItems( urlSource.
queryItems() );
564 bool handled =
false;
576 QRegExp r(
"NETCDF:(.+):([^:]+)" );
581 filename = filename.
mid( 1, filename.
length() - 2 );
590 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
595 filename = filename.
mid( 1, filename.
length() - 2 );
604 QRegExp r(
"HDF5:(.+):([^:]+)" );
609 filename = filename.
mid( 1, filename.
length() - 2 );
618 QRegExp r(
"([^:]+):([^:]+):(.+)" );
659 if ( keywordStringList.
size() > 0 )
662 for (
int i = 0; i < keywordStringList.
size(); ++i )
700 layerAttribution.
appendChild( layerAttributionText );
711 layerMetadataUrl.
appendChild( layerMetadataUrlText );
734 mCRS->
writeXML( mySrsElement, document );
741 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
742 maplayer.
appendChild( transparencyLevelIntElement );
749 return writeXml( layerElement, document );
773 for (
int i = 0; i < layernodes.
size(); ++i )
782 if ( type ==
"vector" )
786 else if ( type ==
"raster" )
790 else if ( type ==
"plugin" )
808 QFile file( qlrfile );
809 if ( !file.
open( QIODevice::ReadOnly ) )
830 Q_UNUSED( layer_node );
831 Q_UNUSED( document );
840 mCustomProperties.
readXml( layerNode, keyStartsWith );
845 mCustomProperties.
writeXml( layerNode, doc );
851 if ( !styleMgrElem.
isNull() )
852 mStyleManager->
readXml( styleMgrElem );
854 mStyleManager->
reset();
862 mStyleManager->
writeXml( styleMgrElem );
909 return mScaleBasedVisibility;
914 mMinScale = theMinScale;
925 mMaxScale = theMaxScale;
930 mScaleBasedVisibility = enabled;
984 if ( capitaliseLayerName )
995 if ( myURI.
startsWith(
"/vsigzip/", Qt::CaseInsensitive ) )
999 else if ( myURI.
startsWith(
"/vsizip/", Qt::CaseInsensitive ) &&
1000 myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1005 else if ( myURI.
startsWith(
"/vsitar/", Qt::CaseInsensitive ) &&
1006 ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) ||
1007 myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) ||
1008 myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) ) )
1017 if ( myFileInfo.
exists() )
1020 if ( myURI.
endsWith(
".gz", Qt::CaseInsensitive ) )
1022 else if ( myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1024 else if ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) )
1026 else if ( myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) )
1028 else if ( myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) )
1051 bool theResultFlag =
false;
1055 sqlite3_stmt *myPreparedStatement;
1059 QgsDebugMsg(
QString(
"Trying to load style for \"%1\" from \"%2\"" ).arg( theURI, db ) );
1064 myResult = sqlite3_open_v2( db.
toUtf8().
data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
1065 if ( myResult != SQLITE_OK )
1070 QString mySql =
"select qml from tbl_styles where style=?";
1071 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1072 if ( myResult == SQLITE_OK )
1076 if ( sqlite3_bind_text( myPreparedStatement, 1, param.
data(), param.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1077 sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1079 qml =
QString::fromUtf8((
char * )sqlite3_column_text( myPreparedStatement, 0 ) );
1080 theResultFlag =
true;
1083 sqlite3_finalize( myPreparedStatement );
1086 sqlite3_close( myDatabase );
1088 return theResultFlag;
1096 theResultFlag =
false;
1104 QFile myFile( theURI );
1105 if ( myFile.
open( QFile::ReadOnly ) )
1108 theResultFlag = myDocument.
setContent( &myFile, &myErrorMessage, &line, &column );
1109 if ( !theResultFlag )
1110 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1123 theResultFlag = myDocument.
setContent( qml, &myErrorMessage, &line, &column );
1124 if ( !theResultFlag )
1126 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1131 myErrorMessage =
tr(
"Style not found in database" );
1135 if ( !theResultFlag )
1137 return myErrorMessage;
1141 if ( !theResultFlag )
1142 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, myErrorMessage );
1144 return myErrorMessage;
1154 if ( thisVersion > fileVersion )
1157 "version of qgis (saved in " + fileVersion.text() +
1159 "). Problems may occur." );
1163 styleFile.updateRevision( thisVersion );
1172 myErrorMessage =
tr(
"Root <qgis> element could not be found" );
1184 if ( ! transparencyNode.isNull() )
1189 setTransparency( myElement.
text().
toInt() );
1214 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
1215 myRootNode.
appendChild( transparencyLevelIntElement );
1220 errorMsg =
QObject::tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1246 filename = theURIParts[0];
1251 filename = theURIParts[0];
1253 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
1263 if ( myFileInfo.
exists() || filename.
endsWith(
".qml", Qt::CaseInsensitive ) )
1266 if ( !myDirInfo.isWritable() )
1268 return tr(
"The directory containing your dataset needs to be writable!" );
1274 QFile myFile( myFileName );
1275 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1279 myDocument.
save( myFileStream, 2 );
1281 theResultFlag =
true;
1282 return tr(
"Created default style file as %1" ).
arg( myFileName );
1286 theResultFlag =
false;
1287 return tr(
"ERROR: Failed to created default style file as %1. Check file permissions and retry." ).
arg( myFileName );
1296 sqlite3_stmt *myPreparedStatement;
1301 if ( myResult != SQLITE_OK )
1303 return tr(
"User database could not be opened." );
1309 QString mySql =
"create table if not exists tbl_styles(style varchar primary key,qml varchar)";
1310 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1311 if ( myResult == SQLITE_OK )
1313 if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
1315 sqlite3_finalize( myPreparedStatement );
1316 sqlite3_close( myDatabase );
1317 theResultFlag =
false;
1318 return tr(
"The style table could not be created." );
1322 sqlite3_finalize( myPreparedStatement );
1324 mySql =
"insert into tbl_styles(style,qml) values (?,?)";
1325 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1326 if ( myResult == SQLITE_OK )
1328 if ( sqlite3_bind_text( myPreparedStatement, 1, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1329 sqlite3_bind_text( myPreparedStatement, 2, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1330 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1332 theResultFlag =
true;
1333 myErrorMessage =
tr(
"The style %1 was saved to database" ).
arg( theURI );
1337 sqlite3_finalize( myPreparedStatement );
1339 if ( !theResultFlag )
1341 QString mySql =
"update tbl_styles set qml=? where style=?";
1342 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1343 if ( myResult == SQLITE_OK )
1345 if ( sqlite3_bind_text( myPreparedStatement, 2, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1346 sqlite3_bind_text( myPreparedStatement, 1, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1347 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1349 theResultFlag =
true;
1350 myErrorMessage =
tr(
"The style %1 was updated in the database." ).
arg( theURI );
1354 theResultFlag =
false;
1355 myErrorMessage =
tr(
"The style %1 could not be updated in the database." ).
arg( theURI );
1360 theResultFlag =
false;
1361 myErrorMessage =
tr(
"The style %1 could not be inserted into database." ).
arg( theURI );
1364 sqlite3_finalize( myPreparedStatement );
1367 sqlite3_close( myDatabase );
1370 return myErrorMessage;
1383 root.
setAttribute(
"xsi:schemaLocation",
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1384 root.
setAttribute(
"xmlns:ogc",
"http://www.opengis.net/ogc" );
1385 root.
setAttribute(
"xmlns:se",
"http://www.opengis.net/se" );
1386 root.
setAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink" );
1387 root.
setAttribute(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
1397 errorMsg =
tr(
"Could not save symbology because:\n%1" )
1398 .
arg(
"Non-vector layers not supported yet" );
1402 if ( !vlayer->
writeSld( namedLayerNode, myDocument, errorMsg ) )
1404 errorMsg =
tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1416 if ( !errorMsg.
isNull() )
1418 theResultFlag =
false;
1429 filename = theURIParts[0];
1434 filename = theURIParts[0];
1446 if ( myFileInfo.
exists() || filename.endsWith(
".sld", Qt::CaseInsensitive ) )
1449 if ( !myDirInfo.isWritable() )
1451 return tr(
"The directory containing your dataset needs to be writable!" );
1457 QFile myFile( myFileName );
1458 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1462 myDocument.
save( myFileStream, 2 );
1464 theResultFlag =
true;
1465 return tr(
"Created default style file as %1" ).
arg( myFileName );
1469 theResultFlag =
false;
1470 return tr(
"ERROR: Failed to created SLD style file as %1. Check file permissions and retry." ).
arg( filename );
1477 theResultFlag =
false;
1485 QFile myFile( theURI );
1486 if ( myFile.
open( QFile::ReadOnly ) )
1489 theResultFlag = myDocument.
setContent( &myFile,
true, &myErrorMessage, &line, &column );
1490 if ( !theResultFlag )
1491 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1496 myErrorMessage =
tr(
"Unable to open file %1" ).
arg( theURI );
1499 if ( !theResultFlag )
1501 return myErrorMessage;
1508 myErrorMessage =
QString(
"Error: StyledLayerDescriptor element not found in %1" ).
arg( theURI );
1509 theResultFlag =
false;
1510 return myErrorMessage;
1516 if ( namedLayerElem.
isNull() )
1518 myErrorMessage =
QLatin1String(
"Info: NamedLayer element not found." );
1519 theResultFlag =
false;
1520 return myErrorMessage;
1524 theResultFlag =
readSld( namedLayerElem, errorMsg );
1525 if ( !theResultFlag )
1527 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI, errorMsg );
1528 return myErrorMessage;
1543 mCustomProperties.
setValue( key, value );
1548 return mCustomProperties.
value( value, defaultValue );
1553 mCustomProperties.
remove( key );
1575 if ( legend == mLegend )
1594 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...
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
A rectangle specified with double values.
Base class for all map layer types.
QString cap(int nth) const
QString writePath(const QString &filename, const QString &relativeBasePath=QString::null) const
Prepare a filename to save it to the project file.
QDomProcessingInstruction createProcessingInstruction(const QString &target, const QString &data)
QgsMapLayer::LayerType type() const
Get the type of the layer.
virtual QString metadata()
Obtain Metadata for this layer.
static QDomDocument asLayerDefinition(const QList< QgsMapLayer * > &layers, const QString &relativeBasePath=QString::null)
Returns the given layer as a layer definition document Layer definitions store the data source as wel...
virtual void drawLabels(QgsRenderContext &rendererContext)
Draw labels.
virtual QString loadSldStyle(const QString &theURI, bool &theResultFlag)
static QgsAuthManager * instance()
Enforce singleton pattern.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith="")
Read custom properties from project file.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
LayerType
Layers enum defining the types of layers that can be added to a map.
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()
const QString & originalName() const
Get the original name of the layer.
static void warning(const QString &msg)
Goes to qWarning.
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.
void blendModeChanged(const QPainter::CompositionMode &blendMode)
Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode() ...
const QString & attribution() const
QString join(const QString &separator) const
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 ...
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.
void setBlendMode(const QPainter::CompositionMode &blendMode)
Set the blending mode used for rendering a layer.
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.
const QString & legendUrl() const
static QString capitaliseLayerName(const QString &name)
A convenience function to (un)capitalise the layer name.
QDomElement toElement() const
void setPath(const QString &path)
const QString & name() const
Get the display name of the layer.
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.
const QString & dataUrl() const
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...
const QString & metadataUrlType() const
#define QgsDebugMsgLevel(str, level)
Q_DECL_DEPRECATED void setCacheImage(QImage *)
const QString & source() const
Returns the source for the layer.
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.
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...
const QString & metadataUrl() const
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.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
virtual Q_DECL_DEPRECATED QString lastErrorTitle()
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)
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.
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
Find out whether this CRS is correctly initialised 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.
QDateTime currentDateTime()
void save(QTextStream &str, int indent) const
QDomNode firstChild() const
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.
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 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
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)
bool readXML(QDomNode &theNode)
Restores state from the given Dom node.
static QList< QgsMapLayer * > fromLayerDefinition(QDomDocument &document)
Creates a new layer from a layer defininition document.
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 &)
QDomElement createElement(const QString &tagName)
const QString & attributionUrl() const
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.
const QString & metadataUrlFormat() const
QDomDocumentType createDocumentType(const QString &qName, const QString &publicId, const QString &systemId)
const QString & legendUrlFormat() const
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
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
const QString & title() const
QString mLayerOrigName
Original name of the layer.
void setValid(bool valid)
Set whether layer is valid or not - should be used in constructor.
QgsPluginLayer * createLayer(const QString &typeName, const QString &uri=QString())
Return new layer if corresponding plugin has been found, else return NULL.
const QString & keywordList() const
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
const QString & dataUrlFormat() const
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