#include "gps/gpspositionmockup.h"
#endif
+const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED";
+const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";
+
SituareEngine::SituareEngine(QMainWindow *parent)
: QObject(parent),
m_autoCenteringEnabled(false),
m_ui, SLOT(loginFailed()));
QSettings settings(DIRECTORY_NAME, FILE_NAME);
- QVariant gpsEnabled = settings.value(GPS_ENABLED);
- QVariant autoCenteringEnabled = settings.value(AUTO_CENTERING_ENABLED);
+ QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
+ QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
enableGPS(gpsEnabled.toBool());
enableAutoCentering(autoCenteringEnabled.toBool());
QSettings settings(DIRECTORY_NAME, FILE_NAME);
qDebug() << __PRETTY_FUNCTION__ << m_gpsEnabled;
qDebug() << __PRETTY_FUNCTION__ << m_autoCenteringEnabled;
- settings.setValue(GPS_ENABLED, m_gpsEnabled);
- settings.setValue(AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
+ settings.setValue(SETTINGS_GPS_ENABLED, m_gpsEnabled);
+ settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
}
void SituareEngine::loginProcessCancelled()
{
qDebug() << __PRETTY_FUNCTION__;
- QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
+ QPointF coordinates;
+
+ if (m_gpsEnabled)
+ coordinates = m_gps->lastPosition();
+ else
+ coordinates = QPointF(0, 0); //Manual position from map
+
m_situareService->reverseGeo(coordinates);
}
m_ui->toggleProgressIndicator(true);
- QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
+ QPointF coordinates;
+
+ if (m_gpsEnabled)
+ coordinates = m_gps->lastPosition();
+ else
+ coordinates = QPointF(0, 0); //Manual position from map
+
m_situareService->updateLocation(coordinates, status, publish);
}
m_gpsEnabled = enabled;
if (enabled) {
- m_gps->lastPosition();
+ m_gps->requestLastPosition();
m_gps->start();
m_ui->setGPSButton(true);
}
if (enabled) {
m_ui->setAutoCenteringButton(true);
m_ui->autoCenteringEnabled(true);
- m_gps->lastPosition();
+ m_gps->requestLastPosition();
}
else {
m_ui->setAutoCenteringButton(false);
emit m_gpsSource->requestUpdate(DEFAULT_UPDATE_INTERVAL);
}
-void GPSPosition::lastPosition()
+QPointF GPSPosition::lastPosition()
+{
+ QGeoCoordinate coordinate = m_gpsSource->lastKnownPosition().coordinate();
+ return QPointF(coordinate.longitude(), coordinate.latitude());
+}
+
+void GPSPosition::requestLastPosition()
{
qDebug() << __PRETTY_FUNCTION__;
void GPSPosition::positionUpdated(QGeoPositionInfo positionInfo)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__ << positionInfo;
if (positionInfo.coordinate().isValid()) {
bool isRunning();
/**
+ * @brief Return last known position.
+ */
+ QPointF lastPosition();
+
+ /**
* @brief Informs gps to emit last known position.
*/
- void lastPosition();
+ void requestLastPosition();
/**
* @brief Set GPS mode.
int m_updateInterval; ///< GPS update interval
};
-const int ACCURACY_UNDEFINED = 1; ///< Undefined accuracy
+const int ACCURACY_UNDEFINED = -1; ///< Undefined accuracy
const int DEFAULT_UPDATE_INTERVAL = 5000; ///< Default update interval
#endif // GPSPOSITION_H
virtual bool isRunning() = 0;
/**
+ * @brief Return last known position.
+ */
+ virtual QPointF lastPosition() = 0;
+
+ /**
* @brief Informs gps to emit last known position.
*/
- virtual void lastPosition() = 0;
+ virtual void requestLastPosition() = 0;
/**
* @brief Set GPS mode.
bool isRunning();
/**
+ * @brief Return last known position.
+ */
+ QPointF lastPosition();
+
+ /**
* @brief Informs gps to emit last known position.
- *
- * DOES NOTHING.
*/
- void lastPosition();
+ void requestLastPosition();
/**
* @brief Set GPS update interval.
const QString DIRECTORY_NAME = "Ixonos";
const QString FILE_NAME = "Situare";
-const QString GPS_ENABLED = "GPS_ENABLED";
-const QString AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";
-
#endif // SITUARECOMMON_H
#include "avatarimage.h"
#include "imagebutton.h"
+const int BACKGROUND_TOP_HEIGHT = 20;
+const int BACKGROUND_BOTTOM_HEIGHT = 15;
+const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
+const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
+const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
+const int ICON_HEIGHT = 24; ///< Icon height
+const int ICON_WIDTH = 24; ///< Icon width
+const int IMAGE_HEIGHT = 60; ///< Friend image height
+const int IMAGE_WIDTH = 60; ///< Friend image width
+const int ITEM_MAX_HEIGHT = 240; ///< Maximum height for item
+const int ITEM_MAX_WIDTH = 368; ///< Maximum width for item
+const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item
+const int ITEM_MIN_WIDTH = 368; ///< Minimum width for item
+const int MARGIN = 5; ///< Icon margin
+const int MOUSE_PRESS_AREA_WIDTH = 20; ///< Area width for item height toggling
+const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
+/**
+* @var NAME_LABEL_MAX_WIDTH
+*
+* @brief Name label's maximum width
+*/
+const int NAME_LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH;
+/**
+* @var LABEL_MAX_WIDTH
+*
+* @brief All label's maximum width
+*/
+const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH;
+
FriendListItem::FriendListItem(QWidget *parent)
: QWidget(parent)
, m_expanded(false)
void FriendListItem::mousePressEvent(QMouseEvent *event)
{
- qDebug() << __PRETTY_FUNCTION__ << " " << event->pos();
+ qDebug() << __PRETTY_FUNCTION__;
m_mousePosition = event->pos();
}
void FriendListItem::mouseReleaseEvent(QMouseEvent *event)
{
- qDebug() << __PRETTY_FUNCTION__ << " " << event->pos();
+ qDebug() << __PRETTY_FUNCTION__;
if ((abs(m_mousePosition.y() - event->pos().y()) <= MOUSE_PRESS_AREA_WIDTH) &&
(abs(m_mousePosition.x() - event->pos().x()) <= MOUSE_PRESS_AREA_HEIGHT)) {
void FriendListItem::paintEvent(QPaintEvent *event)
{
- qDebug() << __PRETTY_FUNCTION__ << " " << event->rect();
+ qDebug() << __PRETTY_FUNCTION__;
+
+ Q_UNUSED(event);
QPainter painter(this);
User *m_user; ///< User data
};
-const int BACKGROUND_TOP_HEIGHT = 20;
-const int BACKGROUND_BOTTOM_HEIGHT = 15;
-const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
-const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
-const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
-const int ICON_HEIGHT = 24; ///< Icon height
-const int ICON_WIDTH = 24; ///< Icon width
-const int IMAGE_HEIGHT = 60; ///< Friend image height
-const int IMAGE_WIDTH = 60; ///< Friend image width
-const int ITEM_MAX_HEIGHT = 240; ///< Maximum height for item
-const int ITEM_MAX_WIDTH = 368; ///< Maximum width for item
-const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item
-const int ITEM_MIN_WIDTH = 368; ///< Minimum width for item
-const int MARGIN = 5; ///< Icon margin
-const int MOUSE_PRESS_AREA_WIDTH = 20; ///< Area width for item height toggling
-const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
-/**
-* @var NAME_LABEL_MAX_WIDTH
-*
-* @brief Name label's maximum width
-*/
-const int NAME_LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH;
-/**
-* @var LABEL_MAX_WIDTH
-*
-* @brief All label's maximum width
-*/
-const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH;
-
#endif // FRIENDLISTITEM_H