25#include "moc_qgsprojecttimesettings.cpp"
46 if ( range == mRange )
55 const QDomElement temporalElement = element.firstChildElement( QStringLiteral(
"TemporalRange" ) );
56 if ( !temporalElement.isNull() )
58 const QDomNode begin = temporalElement.namedItem( QStringLiteral(
"start" ) );
59 const QDomNode end = temporalElement.namedItem( QStringLiteral(
"end" ) );
61 const QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
62 const QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
69 mTimeStep = element.attribute( QStringLiteral(
"timeStep" ),
"1" ).toDouble();
70 mFrameRate = element.attribute( QStringLiteral(
"frameRate" ),
"1" ).toDouble();
71 mCumulativeTemporalRange = element.attribute( QStringLiteral(
"cumulativeTemporalRange" ),
"0" ).toInt();
73 mTotalMovieFrames = element.attribute( QStringLiteral(
"totalMovieFrames" ),
"100" ).toLongLong();
80 QDomElement element = document.createElement( QStringLiteral(
"ProjectTimeSettings" ) );
82 if ( mRange.begin().isValid() && mRange.end().isValid() )
84 QDomElement temporalElement = document.createElement( QStringLiteral(
"TemporalRange" ) );
85 QDomElement startElement = document.createElement( QStringLiteral(
"start" ) );
86 QDomElement endElement = document.createElement( QStringLiteral(
"end" ) );
88 const QDomText startText = document.createTextNode( mRange.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
89 const QDomText endText = document.createTextNode( mRange.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
91 startElement.appendChild( startText );
92 endElement.appendChild( endText );
94 temporalElement.appendChild( startElement );
95 temporalElement.appendChild( endElement );
97 element.appendChild( temporalElement );
101 element.setAttribute( QStringLiteral(
"timeStep" ),
qgsDoubleToString( mTimeStep ) );
102 element.setAttribute( QStringLiteral(
"frameRate" ),
qgsDoubleToString( mFrameRate ) );
103 element.setAttribute( QStringLiteral(
"cumulativeTemporalRange" ), mCumulativeTemporalRange ? 1 : 0 );
104 element.setAttribute( QStringLiteral(
"totalMovieFrames" ), mTotalMovieFrames );
111 return mTimeStepUnit;
116 mTimeStepUnit = unit;
141 mCumulativeTemporalRange = state;
146 return mCumulativeTemporalRange;
151 return mTotalMovieFrames;
156 mTotalMovieFrames = frames;
TemporalUnit
Temporal units.
long long totalMovieFrames() const
Returns the total number of frames for the project's movie.
QgsDateTimeRange temporalRange() const
Returns the project's temporal range, which indicates the earliest and latest datetime ranges associa...
void setTotalMovieFrames(long long frames)
Sets the total number of frames for the movie.
void setTemporalRange(const QgsDateTimeRange &range)
Sets the project's temporal range, which indicates the earliest and latest datetime ranges associated...
double timeStep() const
Returns the project's time step (length of one animation frame), which is used as the default value w...
void setFramesPerSecond(double rate)
Sets the project's default animation frame rate, in frames per second.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the settings's state from a DOM element.
void temporalRangeChanged()
Emitted when the temporal range changes.
Qgis::TemporalUnit timeStepUnit() const
Returns the project's time step (length of one animation frame) unit, which is used as the default va...
QgsProjectTimeSettings(QObject *parent=nullptr)
Constructor for QgsProjectTimeSettings with the specified parent object.
bool isTemporalRangeCumulative() const
Returns the value of cumulative temporal range in animation settings.
void setTimeStepUnit(Qgis::TemporalUnit unit)
Sets the project's time step (length of one animation frame) unit, which is used as the default value...
void setIsTemporalRangeCumulative(bool state)
Sets the project's temporal range as cumulative in animation settings.
void reset()
Resets the settings to a default state.
QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const
Returns a DOM element representing the settings.
void setTimeStep(double step)
Sets the project's time step (length of one animation frame), which is used as the default value when...
double framesPerSecond() const
Returns the project's default animation frame rate, in frames per second.
A container for the context for various read/write operations on objects.
static Q_INVOKABLE Qgis::TemporalUnit decodeTemporalUnit(const QString &string, bool *ok=nullptr)
Decodes a temporal unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.