21 #include <QDomDocument>
22 #include <QDomElement>
23 #include <QDomImplementation>
28 #include <QTextStream>
54 , mDataSource( source )
55 , mLayerOrigName( lyrname )
58 , mBlendMode(
QPainter::CompositionMode_SourceOver )
71 mID = lyrname + dt.
toString(
"yyyyMMddhhmmsszzz" );
82 mMaxScale = 100000000;
83 mScaleBasedVisibility =
false;
107 QgsDebugMsg(
"new original name: '" + name +
"'" );
156 Q_UNUSED( rendererContext );
162 Q_UNUSED( rendererContext );
176 mnl = layerElement.
namedItem(
"provider" );
178 provider = mne.
text();
181 mnl = layerElement.
namedItem(
"datasource" );
186 if ( provider ==
"spatialite" )
192 else if ( provider ==
"ogr" )
198 else if ( provider ==
"gpx" )
204 else if ( provider ==
"delimitedtext" )
219 else if ( provider ==
"wms" )
234 QgsDebugMsg(
"Old WMS URI format detected -> converting to new format" );
239 QStringListIterator iter( parts );
240 while ( iter.hasNext() )
259 if ( params.
size() == 2 )
264 else if ( params.
size() > 2 )
268 uri.
setParam(
"tileMatrixSet",
"" );
271 else if ( item.
startsWith(
"featureCount=" ) )
297 bool handled =
false;
299 if ( provider ==
"gdal" )
305 QRegExp r(
"NETCDF:(.+):([^:]+)" );
310 filename = filename.
mid( 1, filename.
length() - 2 );
319 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
324 filename = filename.
mid( 1, filename.
length() - 2 );
333 QRegExp r(
"HDF5:(.+):([^:]+)" );
338 filename = filename.
mid( 1, filename.
length() - 2 );
347 QRegExp r(
"([^:]+):([^:]+):(.+)" );
364 mnl = layerElement.
namedItem(
"layername" );
379 layerError = !
readXml( layerElement );
414 mnl = layerElement.
namedItem(
"layername" );
420 if ( !titleElem.isNull() )
422 mTitle = titleElem.text();
427 if ( !abstractElem.
isNull() )
434 if ( !keywordListElem.
isNull() )
439 kwdList << n.toElement().text();
446 if ( !dataUrlElem.
isNull() )
454 if ( !legendUrlElem.
isNull() )
462 if ( !attribElem.
isNull() )
470 if ( !metaUrlElem.
isNull() )
480 if ( ! transparencyNode.
isNull() )
485 setTransparency( myElement.
text().
toInt() );
497 Q_UNUSED( layer_node );
537 src = theURIParts.
join(
"|" );
543 src = theURIParts.
join(
"?" );
545 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
549 urlDest.setQueryItems( urlSource.
queryItems() );
554 bool handled =
false;
566 QRegExp r(
"NETCDF:(.+):([^:]+)" );
571 filename = filename.
mid( 1, filename.
length() - 2 );
580 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
585 filename = filename.
mid( 1, filename.
length() - 2 );
594 QRegExp r(
"HDF5:(.+):([^:]+)" );
599 filename = filename.
mid( 1, filename.
length() - 2 );
608 QRegExp r(
"([^:]+):([^:]+):(.+)" );
649 if ( keywordStringList.
size() > 0 )
652 for (
int i = 0; i < keywordStringList.
size(); ++i )
690 layerAttribution.
appendChild( layerAttributionText );
701 layerMetadataUrl.
appendChild( layerMetadataUrlText );
724 mCRS->
writeXML( mySrsElement, document );
731 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
732 maplayer.
appendChild( transparencyLevelIntElement );
739 return writeXml( layerElement, document );
763 for (
int i = 0; i < layernodes.
size(); ++i )
772 if ( type ==
"vector" )
776 else if ( type ==
"raster" )
780 else if ( type ==
"plugin" )
798 QFile file( qlrfile );
799 if ( !file.
open( QIODevice::ReadOnly ) )
820 Q_UNUSED( layer_node );
821 Q_UNUSED( document );
830 mCustomProperties.
readXml( layerNode, keyStartsWith );
835 mCustomProperties.
writeXml( layerNode, doc );
841 if ( !styleMgrElem.
isNull() )
842 mStyleManager->
readXml( styleMgrElem );
844 mStyleManager->
reset();
852 mStyleManager->
writeXml( styleMgrElem );
899 return mScaleBasedVisibility;
904 mMinScale = theMinScale;
915 mMaxScale = theMaxScale;
920 mScaleBasedVisibility = enabled;
974 if ( capitaliseLayerName )
985 if ( myURI.
startsWith(
"/vsigzip/", Qt::CaseInsensitive ) )
989 else if ( myURI.
startsWith(
"/vsizip/", Qt::CaseInsensitive ) &&
990 myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
995 else if ( myURI.
startsWith(
"/vsitar/", Qt::CaseInsensitive ) &&
996 ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) ||
997 myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) ||
998 myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) ) )
1007 if ( myFileInfo.
exists() )
1010 if ( myURI.
endsWith(
".gz", Qt::CaseInsensitive ) )
1012 else if ( myURI.
endsWith(
".zip", Qt::CaseInsensitive ) )
1014 else if ( myURI.
endsWith(
".tar", Qt::CaseInsensitive ) )
1016 else if ( myURI.
endsWith(
".tar.gz", Qt::CaseInsensitive ) )
1018 else if ( myURI.
endsWith(
".tgz", Qt::CaseInsensitive ) )
1041 bool theResultFlag =
false;
1045 sqlite3_stmt *myPreparedStatement;
1049 QgsDebugMsg(
QString(
"Trying to load style for \"%1\" from \"%2\"" ).arg( theURI ).arg( db ) );
1054 myResult = sqlite3_open_v2( db.
toUtf8().
data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
1055 if ( myResult != SQLITE_OK )
1060 QString mySql =
"select qml from tbl_styles where style=?";
1061 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1062 if ( myResult == SQLITE_OK )
1066 if ( sqlite3_bind_text( myPreparedStatement, 1, param.
data(), param.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1067 sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
1069 qml =
QString::fromUtf8((
char * )sqlite3_column_text( myPreparedStatement, 0 ) );
1070 theResultFlag =
true;
1073 sqlite3_finalize( myPreparedStatement );
1076 sqlite3_close( myDatabase );
1078 return theResultFlag;
1086 theResultFlag =
false;
1094 QFile myFile( theURI );
1095 if ( myFile.
open( QFile::ReadOnly ) )
1098 theResultFlag = myDocument.
setContent( &myFile, &myErrorMessage, &line, &column );
1099 if ( !theResultFlag )
1100 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1113 theResultFlag = myDocument.
setContent( qml, &myErrorMessage, &line, &column );
1114 if ( !theResultFlag )
1116 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1121 myErrorMessage =
tr(
"Style not found in database" );
1125 if ( !theResultFlag )
1127 return myErrorMessage;
1131 if ( !theResultFlag )
1132 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI ).
arg( myErrorMessage );
1134 return myErrorMessage;
1144 if ( thisVersion > fileVersion )
1147 "version of qgis (saved in " + fileVersion.text() +
1149 "). Problems may occur." );
1153 styleFile.updateRevision( thisVersion );
1162 myErrorMessage =
tr(
"Root <qgis> element could not be found" );
1174 if ( ! transparencyNode.isNull() )
1179 setTransparency( myElement.
text().
toInt() );
1204 transparencyLevelIntElement.
appendChild( transparencyLevelIntText );
1205 myRootNode.
appendChild( transparencyLevelIntElement );
1210 errorMsg =
QObject::tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1236 filename = theURIParts[0];
1241 filename = theURIParts[0];
1243 else if ( vlayer && vlayer->
providerType() ==
"delimitedtext" )
1253 if ( myFileInfo.
exists() || filename.
endsWith(
".qml", Qt::CaseInsensitive ) )
1256 if ( !myDirInfo.isWritable() )
1258 return tr(
"The directory containing your dataset needs to be writable!" );
1264 QFile myFile( myFileName );
1265 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1269 myDocument.
save( myFileStream, 2 );
1271 theResultFlag =
true;
1272 return tr(
"Created default style file as %1" ).
arg( myFileName );
1276 theResultFlag =
false;
1277 return tr(
"ERROR: Failed to created default style file as %1. Check file permissions and retry." ).
arg( myFileName );
1286 sqlite3_stmt *myPreparedStatement;
1291 if ( myResult != SQLITE_OK )
1293 return tr(
"User database could not be opened." );
1299 QString mySql =
"create table if not exists tbl_styles(style varchar primary key,qml varchar)";
1300 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1301 if ( myResult == SQLITE_OK )
1303 if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
1305 sqlite3_finalize( myPreparedStatement );
1306 sqlite3_close( myDatabase );
1307 theResultFlag =
false;
1308 return tr(
"The style table could not be created." );
1312 sqlite3_finalize( myPreparedStatement );
1314 mySql =
"insert into tbl_styles(style,qml) values (?,?)";
1315 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1316 if ( myResult == SQLITE_OK )
1318 if ( sqlite3_bind_text( myPreparedStatement, 1, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1319 sqlite3_bind_text( myPreparedStatement, 2, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1320 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1322 theResultFlag =
true;
1323 myErrorMessage =
tr(
"The style %1 was saved to database" ).
arg( theURI );
1327 sqlite3_finalize( myPreparedStatement );
1329 if ( !theResultFlag )
1331 QString mySql =
"update tbl_styles set qml=? where style=?";
1332 myResult = sqlite3_prepare( myDatabase, mySql.
toUtf8().
data(), mySql.
toUtf8().
length(), &myPreparedStatement, &myTail );
1333 if ( myResult == SQLITE_OK )
1335 if ( sqlite3_bind_text( myPreparedStatement, 2, param0.
data(), param0.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1336 sqlite3_bind_text( myPreparedStatement, 1, param1.
data(), param1.
length(), SQLITE_STATIC ) == SQLITE_OK &&
1337 sqlite3_step( myPreparedStatement ) == SQLITE_DONE )
1339 theResultFlag =
true;
1340 myErrorMessage =
tr(
"The style %1 was updated in the database." ).
arg( theURI );
1344 theResultFlag =
false;
1345 myErrorMessage =
tr(
"The style %1 could not be updated in the database." ).
arg( theURI );
1350 theResultFlag =
false;
1351 myErrorMessage =
tr(
"The style %1 could not be inserted into database." ).
arg( theURI );
1354 sqlite3_finalize( myPreparedStatement );
1357 sqlite3_close( myDatabase );
1360 return myErrorMessage;
1373 root.
setAttribute(
"xsi:schemaLocation",
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1374 root.
setAttribute(
"xmlns:ogc",
"http://www.opengis.net/ogc" );
1375 root.
setAttribute(
"xmlns:se",
"http://www.opengis.net/se" );
1376 root.
setAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink" );
1377 root.
setAttribute(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
1387 errorMsg =
tr(
"Could not save symbology because:\n%1" )
1388 .
arg(
"Non-vector layers not supported yet" );
1392 if ( !vlayer->
writeSld( namedLayerNode, myDocument, errorMsg ) )
1394 errorMsg =
tr(
"Could not save symbology because:\n%1" ).
arg( errorMsg );
1406 if ( !errorMsg.
isNull() )
1408 theResultFlag =
false;
1419 filename = theURIParts[0];
1424 filename = theURIParts[0];
1436 if ( myFileInfo.
exists() || filename.endsWith(
".sld", Qt::CaseInsensitive ) )
1439 if ( !myDirInfo.isWritable() )
1441 return tr(
"The directory containing your dataset needs to be writable!" );
1447 QFile myFile( myFileName );
1448 if ( myFile.
open( QFile::WriteOnly | QFile::Truncate ) )
1452 myDocument.
save( myFileStream, 2 );
1454 theResultFlag =
true;
1455 return tr(
"Created default style file as %1" ).
arg( myFileName );
1459 theResultFlag =
false;
1460 return tr(
"ERROR: Failed to created SLD style file as %1. Check file permissions and retry." ).
arg( filename );
1467 theResultFlag =
false;
1475 QFile myFile( theURI );
1476 if ( myFile.
open( QFile::ReadOnly ) )
1479 theResultFlag = myDocument.
setContent( &myFile,
true, &myErrorMessage, &line, &column );
1480 if ( !theResultFlag )
1481 myErrorMessage =
tr(
"%1 at line %2 column %3" ).
arg( myErrorMessage ).
arg( line ).
arg( column );
1486 myErrorMessage =
tr(
"Unable to open file %1" ).
arg( theURI );
1489 if ( !theResultFlag )
1491 return myErrorMessage;
1498 myErrorMessage =
QString(
"Error: StyledLayerDescriptor element not found in %1" ).
arg( theURI );
1499 theResultFlag =
false;
1500 return myErrorMessage;
1506 if ( namedLayerElem.
isNull() )
1508 myErrorMessage =
QString(
"Info: NamedLayer element not found." );
1509 theResultFlag =
false;
1510 return myErrorMessage;
1514 theResultFlag =
readSld( namedLayerElem, errorMsg );
1515 if ( !theResultFlag )
1517 myErrorMessage =
tr(
"Loading style file %1 failed because:\n%2" ).
arg( theURI ).
arg( errorMsg );
1518 return myErrorMessage;
1533 mCustomProperties.
setValue( key, value );
1538 return mCustomProperties.
value( value, defaultValue );
1543 mCustomProperties.
remove( key );
1565 if ( legend == mLegend )
1584 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.
static const QString pkgDataPath()
Returns the common root path of all application data directories.
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(QString filename, 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.
void setValidationHint(QString html)
virtual void drawLabels(QgsRenderContext &rendererContext)
Draw labels.
virtual QString loadSldStyle(const QString &theURI, bool &theResultFlag)
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith="")
Read custom properties from project file.
QString publicSource() const
QDomNode appendChild(const QDomNode &newChild)
void readXml(const QDomNode &parentNode, const QString &keyStartsWith=QString())
Read store contents from XML.
bool writeLayerXML(QDomElement &layerElement, QDomDocument &document, QString relativeBasePath=QString::null)
stores state in Dom node
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.
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 ...
static const QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
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.
QgsPluginLayer * createLayer(QString typeName, const QString &uri=QString())
return new layer if corresponding plugin has been found, else return NULL.
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)
void setConnection(const QString &aHost, const QString &aPort, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SSLmode sslmode=SSLprefer)
Set all connection related members at once.
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.
QgsRectangle mExtent
Extent of the layer.
QString mMetadataUrl
MetadataUrl of the layer.
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...
QString uri() const
return complete uri
const QString & metadataUrlType() const
#define QgsDebugMsgLevel(str, level)
Q_DECL_DEPRECATED void setCacheImage(QImage *)
const QString & source() const
Returns the source for the layer.
LayerType
Layers enum defining the types of layers that can be added to a map.
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...
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.
virtual void setSubLayerVisibility(QString name, bool vis)
Set the visibility of the given sublayer name.
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 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)
static QDomDocument asLayerDefinition(QList< QgsMapLayer * > layers, QString relativeBasePath=QString::null)
Returns the given layer as a layer definition document Layer definitions store the data source as wel...
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QString toLocalFile() const
QString mMetadataUrlFormat
QDomText createTextNode(const QString &value)
virtual void connectNotify(const char *signal)
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
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.
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
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.
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)
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.
QDomElement createElement(const QString &tagName)
const QString & attributionUrl() const
void(* CUSTOM_CRS_VALIDATION)(QgsCoordinateReferenceSystem &)
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.
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.
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.
QgsMapLayer(QgsMapLayer::LayerType type=VectorLayer, QString lyrname=QString::null, QString source=QString::null)
Constructor.
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