File indexing completed on 2024-04-14 03:47:51

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007-2008 David Roberts <dvdr18@gmail.com>
0004 // SPDX-FileCopyrightText: 2010 Harshit Jain <hjain.itbhu@gmail.com>
0005 //
0006 
0007 #ifndef MARBLE_MARBLECLOCK_H
0008 #define MARBLE_MARBLECLOCK_H
0009 
0010 #include "geodata_export.h"
0011 
0012 #include <QObject>
0013 
0014 class QDateTime;
0015 
0016 namespace Marble
0017 {
0018 
0019 class MarbleClockPrivate;
0020 
0021 class GEODATA_EXPORT MarbleClock : public QObject
0022 {
0023     Q_OBJECT
0024 
0025  public:
0026     explicit MarbleClock( QObject* parent = nullptr );
0027 
0028     ~MarbleClock() override;
0029 
0030     /**
0031      * @brief Determine how much of the current day has elapsed
0032      * @return A value between 0 and 1 corresponding to the fraction of the day that has elapsed
0033      */
0034     qreal dayFraction() const;
0035 
0036  Q_SIGNALS:
0037     /**
0038      * @brief the timeChanged signal will be triggered at updateInterval() rate
0039      * or at most every second.
0040      **/
0041     void timeChanged();
0042 
0043     /**
0044      * @brief Emitted when setUpdateInterval() is called.
0045      */
0046     void updateIntervalChanged( int seconds );
0047 
0048 public:
0049 
0050     /**
0051      * @brief Sets the internal date and time a custom one
0052      * @param datetime The custom date and time
0053      **/
0054     void setDateTime( const QDateTime& datetime );
0055 
0056     /**
0057      * @brief Returns the internal date and time
0058      **/
0059     QDateTime dateTime() const;
0060 
0061     /**
0062      * @brief Set the interval at which dateTime() is updated and timeChanged() is emitted.
0063      * @param seconds The interval in seconds
0064      * @see updateInterval
0065      */
0066     void setUpdateInterval( int seconds );
0067 
0068     /**
0069      * @brief Returns the interval at which dateTime() is updated and timeChanged() is emitted,
0070      * The default is 60 seconds.
0071      * @return The interval in seconds.
0072      * @see setUpdateInterval
0073      */
0074     int updateInterval() const;
0075 
0076     /**
0077      * @brief Sets the speed of the timer which is how fast the marble clock can run relative to actual speed of time.
0078      * @param speed The new speed (integer)
0079      **/
0080     void setSpeed( int speed );
0081 
0082     /**
0083      * @brief Returns the speed of the timer
0084      **/
0085     int speed() const;
0086 
0087     /**
0088      * @brief Sets the timezone of the clock
0089      * @param timeInSec The new timezone ( in seconds w.r.t. UTC )
0090      **/
0091     void setTimezone( int timeInSec );
0092 
0093     /**
0094      * @brief Returns the timezone of the clock
0095      **/
0096     int timezone() const;
0097 
0098  private:
0099     Q_DISABLE_COPY( MarbleClock )
0100 
0101     Q_PRIVATE_SLOT( d,  void timerTimeout() )
0102 
0103     MarbleClockPrivate* const d;
0104 
0105     friend class MarbleClockPrivate;
0106 };
0107 
0108 }
0109 #endif