Skip to content
Permalink
Browse files
save timestamp in project file
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15752 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Apr 17, 2011
1 parent 8817358 commit 0c463d38a383be82c418226c650a0649176fdb75
Showing with 41 additions and 9 deletions.
  1. +11 −0 src/core/qgsmaplayer.cpp
  2. +5 −2 src/core/qgsmaplayer.h
  3. +22 −7 src/core/raster/qgsrasterlayer.cpp
  4. +3 −0 src/core/raster/qgsrasterlayer.h
@@ -340,6 +340,17 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )

maplayer.appendChild( layerName );

// timestamp if supported
if ( timestamp() > QDateTime() )
{
QDomElement stamp = document.createElement( "timestamp" );
QDomText stampText = document.createTextNode( timestamp().toString( Qt::ISODate ) );
stamp.appendChild( stampText );
maplayer.appendChild( stamp );
}

maplayer.appendChild( layerName );

// zorder
// This is no longer stored in the project file. It is superfluous since the layers
// are written and read in the proper order.
@@ -19,7 +19,7 @@
#ifndef QGSMAPLAYER_H
#define QGSMAPLAYER_H


#include <QDateTime>
#include <QObject>
#include <QUndoStack>
#include <QVariant>
@@ -95,7 +95,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** This is the method that does the actual work of
* drawing the layer onto a paint device.
* @param rendererContext describes the extents,
* resolution etc. that should be used when rendering the
* resolumon etc. that should be used when rendering the
* layer.
*/
virtual bool draw( QgsRenderContext& rendererContext );
@@ -332,6 +332,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
* added in 1.5 */
void clearCacheImage();

/** Time stamp of data source in the moment when data/metadata were loaded by provider */
virtual QDateTime timestamp() const { return QDateTime() ; }

signals:

/** Emit a signal to notify of a progress event */
@@ -3257,9 +3257,8 @@ bool QgsRasterLayer::readXml( QDomNode & layer_node )
QDomNode rpNode = layer_node.namedItem( "rasterproperties" );

// Collect sublayer names and styles
QStringList layers;
QStringList styles;
QString format;
mLayers.clear();
mStyles.clear();

if ( mProviderKey == "wms" )
{
@@ -3269,20 +3268,21 @@ bool QgsRasterLayer::readXml( QDomNode & layer_node )
// TODO: sublayer visibility - post-0.8 release timeframe

// collect name for the sublayer
layers += layerElement.namedItem( "name" ).toElement().text();
mLayers += layerElement.namedItem( "name" ).toElement().text();

// collect style for the sublayer
styles += layerElement.namedItem( "style" ).toElement().text();
mStyles += layerElement.namedItem( "style" ).toElement().text();

layerElement = layerElement.nextSiblingElement( "wmsSublayer" );
}

// Collect format
format = rpNode.namedItem( "wmsFormat" ).toElement().text();
mFormat = rpNode.namedItem( "wmsFormat" ).toElement().text();
}

mCrs = crs().authid();
// Collect CRS
setDataProvider( mProviderKey, layers, styles, format, crs().authid() );
setDataProvider( mProviderKey, mLayers, mStyles, mFormat, mCrs );

QString theError;
bool res = readSymbology( layer_node, theError );
@@ -3299,6 +3299,21 @@ bool QgsRasterLayer::readXml( QDomNode & layer_node )
mGrayBandName = bandName( 1 );
}

// Check timestamp
QDomNode stampNode = layer_node.namedItem( "timestamp" );
if ( !stampNode.isNull() )
{
QDateTime stamp = QDateTime::fromString( stampNode.toElement().text(), Qt::ISODate );
// TODO: very bad, we have to load twice!!! Make QgsDataProvider::timestamp() static?
if ( stamp < mDataProvider->dataTimestamp() )
{
QgsDebugMsg( "data changed, reload provider" );
closeDataProvider();
init();
setDataProvider( mProviderKey, mLayers, mStyles, mFormat, mCrs );
}
}

return res;
} // QgsRasterLayer::readXml( QDomNode & layer_node )

@@ -658,6 +658,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
*/
virtual void setSubLayerVisibility( const QString & name, bool vis );

/** Time stamp of data source in the moment when data/metadata were loaded by provider */
virtual QDateTime timestamp() const { return mDataProvider->timestamp() ; }

public slots:
/** \brief Create GDAL pyramid overviews */
QString buildPyramids( const RasterPyramidList &,

0 comments on commit 0c463d3

Please sign in to comment.