#define ENGINE_H
#include <QObject>
+#include <QTime>
#include <QPointF>
class QMainWindow;
class SituareService;
class User;
+class QTimer;
+
/**
* @brief Engine class for Situare Application
*
* @param status Status message
* @param publish Publish on Facebook
*/
- void requestUpdateLocation(const QString &status, bool publish);
+ void requestUpdateLocation(const QString &status = QString(), bool publish = false);
/**
* @brief Slot to refresh user data
private:
/**
- * @brief Read settings and determine whether to use GPS and autocentering.
- * When values does not found on the settings, GPS and autocentering are enabled as a default.
- */
+ * @brief Checks if user is moved enough for position auto update.
+ *
+ * @return true if moved engouh, false otherwise
+ */
+ bool isUserMoved();
+
+ /**
+ * @brief Read settings and determine whether to use GPS and autocentering.
+ * When values does not found on the settings, GPS and autocentering are enabled as a default.
+ */
void initializeGpsAndAutocentering();
/**
private slots:
/**
- * @brief Set auto centering feature enabled / disabled
- */
+ * @brief Automatic update interval timer timeout.
+ *
+ * Requests update location if user has moved.
+ */
+ void automaticUpdateIntervalTimerTimeout();
+
+ /**
+ * @brief Set auto centering feature enabled / disabled
+ *
+ * @param enabled true if enabled, false otherwise
+ */
void changeAutoCenteringSetting(bool enabled);
/**
- * @brief Slot for disabling automatic centering when map is scrolled manually
- */
+ * @brief Slot for disabling automatic centering when map is scrolled manually
+ */
void disableAutoCentering();
/**
void enableGPS(bool enabled);
/**
+ * @brief Enables automatic location update.
+ *
+ * @param enabled true if
+ */
+ void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
+
+ /**
* @brief Sets zoom level to default when first GPS location is received if autocentering
* is enabled.
*
*/
void invalidCredentials();
+ /**
+ * @brief Saves GPS position.
+ *
+ * Saves GPS position if it has changed enough and sets m_userMoved flag.
+ *
+ * @param position geo coordinates
+ */
+ void saveGPSPosition(QPointF position);
+
/*******************************************************************************
* SIGNALS
******************************************************************************/
MainWindow *m_ui; ///< Instance of the MainWindow UI
MapEngine *m_mapEngine; ///< MapEngine
SituareService *m_situareService; ///< Instance of the situare server communication service
+
+ QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
+ QPointF m_lastUpdatedGPSPosition; ///< Last updated GPS position
+ bool m_userMoved; ///< Flag for user moving
};
#endif // ENGINE_H