<file>res/images/list_item_bottom.png</file>
<file>res/images/list_item_middle.png</file>
<file>res/images/list_item_top.png</file>
- <file>res/dummy/nmealog.txt</file>
<file>res/images/gps_pos_accurate.png</file>
<file>res/images/gps_pos_coarse.png</file>
</qresource>
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Sami Rämö - sami.ramo@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+
+#ifndef GPSCOMMON_H
+#define GPSCOMMON_H
+
+const int GPS_ACCURACY_UNDEFINED = -1; ///< Value used when accuracy is undefined
+
+#endif // GPSCOMMON_H
#include <QDebug>
#include <QTimer>
+#include "gpscommon.h"
#include "gpsposition.h"
#include "gpspositioninterface.h"
{
qDebug() << __PRETTY_FUNCTION__;
- qreal horizontalAccuracy = ACCURACY_UNDEFINED;
- qreal verticalAccuracy = ACCURACY_UNDEFINED;
+ qreal horizontalAccuracy = GPS_ACCURACY_UNDEFINED;
+ qreal verticalAccuracy = GPS_ACCURACY_UNDEFINED;
if (positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
horizontalAccuracy = positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy);
if (horizontalAccuracy > accuracy)
accuracy = horizontalAccuracy;
+ qWarning() << __PRETTY_FUNCTION__ << "accuracy, h:" << horizontalAccuracy
+ << "v:" << verticalAccuracy
+ << "return:" << accuracy;
+
return accuracy;
}
int m_updateInterval; ///< GPS update interval
};
-const int ACCURACY_UNDEFINED = 1; ///< Undefined accuracy
const int DEFAULT_UPDATE_INTERVAL = 5000; ///< Default update interval
#endif // GPSPOSITION_H
USA.
*/
-const int ACCURATE_LIMIT = 10; // this and lower values (in meter) are considered as accurate
+const int ACCURATE_LIMIT = 250; // this and lower values (in meters) are considered as accurate
+
+#include <QDebug>
+#include <QGraphicsPixmapItem>
+
+#include "../gps/gpscommon.h"
+#include "mapcommon.h"
#include "gpslocationitem.h"
-GPSLocationItem::GPSLocationItem(QObject *parent) :
- QGraphicsPixmapItem(parent)
+GPSLocationItem::GPSLocationItem()
+ : m_currentAccuracy(NOT_SET)
{
qDebug() << __PRETTY_FUNCTION__;
- accuratePixmap = QPixmap(":/res/images/gps_pos_accurate.png");
- coarsePixmap = QPixmap(":/res/images/gps_pos_coarse.png");
+ m_accuratePixmap = QPixmap(":/res/images/gps_pos_accurate.png");
+ m_coarsePixmap = QPixmap(":/res/images/gps_pos_coarse.png");
setPos(QPoint(UNDEFINED, UNDEFINED));
setZValue(OWN_LOCATION_ICON_Z_LEVEL);
- setOffset(-accuratePixmap.width()/2, -accuratePixmap.height()/2);
+ setOffset(-m_accuratePixmap.width() / 2, -m_accuratePixmap.height() / 2);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
}
-GPSLocationItem::updatePosition(QPoint scenePosition, qreal accuracy)
+void GPSLocationItem::updatePosition(QPoint scenePosition, qreal accuracy)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
setPos(scenePosition);
- /// @todo MAGIC NUMBER
- if (accuracy != -1 && accuracy <= ACCURATE_LIMIT) {
- setPixmap(accuratePixmap);
+ if (accuracy != GPS_ACCURACY_UNDEFINED // accuracy must be defined
+ && accuracy <= ACCURATE_LIMIT // and smaller than limit
+ && m_currentAccuracy != ACCURATE) { // and accurate pixmap not yet set
+ setPixmap(m_accuratePixmap);
+ m_currentAccuracy = ACCURATE;
}
- else {
- setPixmap(coarsePixmap);
+ else if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
+ setPixmap(m_coarsePixmap);
+ m_currentAccuracy = COARSE;
}
}
#include <QGraphicsPixmapItem>
+/**
+ * @brief Class for indicating current position accuired from GPS on the map.
+ *
+ * Also GPS fix accuracy is indicated by using two different color indicator images
+ * based on current accuracy
+ */
class GPSLocationItem : public QGraphicsPixmapItem
{
- Q_OBJECT
public:
- explicit GPSLocationItem(QObject *parent = 0);
+ /**
+ * @brief Constructor
+ */
+ GPSLocationItem();
-public slots:
+public:
+ /**
+ * @brief Update position item
+ *
+ * @param scenePosition Scene coordinate
+ * @param accuracy Accuracy of the GPS fix
+ */
void updatePosition(QPoint scenePosition, qreal accuracy);
private:
- QPixmap accuratePixmap;
- QPixmap coarsePixmap;
+ /**
+ * @brief Enum for current pixmap state
+ */
+ enum Accuracy { NOT_SET, ACCURATE, COARSE };
+
+ QPixmap m_accuratePixmap; ///< pixmap used when GPS fix is accurate
+ QPixmap m_coarsePixmap; ///< pixmap used when GPS fix is coarse
+ Accuracy m_currentAccuracy; ///< current accuracy
};
#endif // GPSLOCATIONITEM_H
qDebug() << __PRETTY_FUNCTION__;
if (disableAutoCentering(sceneCoordinate))
- emit mapScrolled();
+ emit mapScrolledManually();
m_sceneCoordinate = sceneCoordinate;
emit locationChanged(m_sceneCoordinate);
QGraphicsScene* scene();
/**
- * @brief Set auto centering.
- *
- * @param enabled true if enabled, false otherwise
- */
- void setAutoCentering(bool enabled);
-
- /**
* @brief Return tile path created from tile values.
*
* @param zoomLevel tile's zoom level
void updateViewTilesSceneRect();
private slots:
+ /**
+ * @brief Slot for GPS position updates
+ *
+ * GPS location item is updated and map centered to new location (if automatic
+ * centering is enabled).
+ *
+ * @param position New coordinates from GPS
+ * @param accuracy Accuracy of the GPS fix
+ */
void gpsPositionUpdate(QPointF position, qreal accuracy);
/**
void mapImageReceived(int zoomLevel, int x, int y, const QPixmap &image);
/**
+ * @brief Set auto centering.
+ *
+ * @param enabled true if enabled, false otherwise
+ */
+ void setAutoCentering(bool enabled);
+
+ /**
* @brief Slot for actions after view zoom is finished
*
* Does run removeOutOfViewTiles
/**
* @brief Signal to notify map scrolling.
*/
- void mapScrolled();
+ void mapScrolledManually();
/**
* @brief Signal for zoom level change
bool m_autoCenteringEnabled; ///< Auto centering enabled
QPoint m_centerTile; ///< Current center tile
FriendItemsHandler *m_friendItemsHandler; ///< Handler for friend and group items
- GPSLocationItem *m_gpsLocationItem;
+ GPSLocationItem *m_gpsLocationItem; ///< Item pointing current location from GPS
QPoint m_lastManualPosition; ///< Last manually set position in scene coordinate
MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
MapScene *m_mapScene; ///< Scene for map tiles
map/frienditemshandler.h \
gps/gpspositioninterface.h \
map/gpslocationitem.h \
- situarecommon.h
+ situarecommon.h \
+ gps/gpscommon.h
QT += network \
webkit
DEFINES += QT_NO_DEBUG_OUTPUT
m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
connect(this, SIGNAL(autoCentering(bool)),
- m_mapViewScreen, SLOT(enableAutoCentering(bool)));
+ m_mapViewScreen, SIGNAL(enableAutoCentering(bool)));
connect(this, SIGNAL(positionReceived(QPointF, qreal)),
- m_mapViewScreen, SLOT(positionReceived(QPointF, qreal)));
+ m_mapViewScreen, SIGNAL(positionReceived(QPointF, qreal)));
connect(m_mapViewScreen, SIGNAL(mapLocationChanged()), this, SLOT(mapLocationChanged()));
connect(this, SIGNAL(zoomInKeyPressed()),
#include "panelsidebar.h"
MapViewScreen::MapViewScreen(QWidget *parent)
- : QWidget(parent),
- m_autoCenteringEnabled(false)
+ : QWidget(parent)
{
MapView *mapView = new MapView(this);
mapEngine = new MapEngine(this);
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
- connect(mapEngine, SIGNAL(mapScrolled()), this, SLOT(locationChanged()));
+ connect(mapEngine, SIGNAL(mapScrolledManually()),
+ this, SIGNAL(mapLocationChanged()));
+
+ connect(this, SIGNAL(positionReceived(QPointF,qreal)),
+ mapEngine, SLOT(gpsPositionUpdate(QPointF,qreal)));
+ connect(this, SIGNAL(enableAutoCentering(bool)),
+ mapEngine, SLOT(setAutoCentering(bool)));
QHBoxLayout *mapViewLayout = new QHBoxLayout;
osmLicense->move(width - osmLicense->fontMetrics().width(OSM_LICENSE) - PANEL_PEEK_AMOUNT,
height - osmLicense->fontMetrics().height());
}
-
-void MapViewScreen::locationChanged()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if (m_autoCenteringEnabled)
- emit mapLocationChanged();
-}
-
-void MapViewScreen::positionReceived(QPointF position, qreal accuracy)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if (m_autoCenteringEnabled)
- mapEngine->setViewLocation(position);
-}
-
-void MapViewScreen::enableAutoCentering(bool enabled)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_autoCenteringEnabled = enabled;
- mapEngine->setAutoCentering(enabled);
-}
/**
* @brief Map View class. Used to display Map
-*
-* @class MapViewScreen mainwindow.h "src/ui/mainwindow.h"
*/
class MapViewScreen : public QWidget
{
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
private slots:
-
- /**
- * @brief Slot for enabling auto centering.
- *
- * @param enabled true if map should center to GPS position, false otherwise
- */
- void enableAutoCentering(bool enabled);
-
/**
* @brief Slot for drawing the Open Street Map license text
*
*/
void drawOsmLicense(int width, int height);
- /**
- * @brief Slot for map location change.
- */
- void locationChanged();
-
- /**
- * @brief Slot for GPS position.
- *
- * @param position latitude and longitude values
- * @param accuracy coordinate accuracy in metres
- */
- void positionReceived(QPointF position, qreal accuracy);
-
/*******************************************************************************
* SIGNALS
******************************************************************************/
signals:
/**
+ * @brief Signal for enabling auto centering.
+ *
+ * @param enabled true if map should center to GPS position, false otherwise
+ */
+ void enableAutoCentering(bool enabled);
+
+ /**
* @brief Signal when friend list locations are fetched
*
* Forwarded to map engine and friends list panel
/**
* @brief Signal for map location change.
*/
- void mapLocationChanged();
+ void mapLocationChanged();
+
+ /**
+ * @brief Slot for GPS position.
+ *
+ * @param position latitude and longitude values
+ * @param accuracy coordinate accuracy in metres
+ */
+ void positionReceived(QPointF position, qreal accuracy);
/**
* @brief Signal when user location is fetched
* DATA MEMBERS
******************************************************************************/
private:
- bool m_autoCenteringEnabled; ///< Enable
FriendListPanel *friendsListPanel; ///< Instance of friends list panel
MapEngine *mapEngine; ///< MapEngine
QLabel *osmLicense; ///< Label for Open Street Map license