<file>res/images/sliding_bar_right.png</file>
<file>res/images/led_red.png</file>
<file>res/images/led_red_s.png</file>
- <file>res/images/friend_group.png</file>
<file>res/images/list_item.png</file>
<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/images/gps_pos_accurate.png</file>
+ <file>res/images/gps_pos_coarse.png</file>
+ <file>res/images/friend_group.png</file>
<file>res/images/sight.png</file>
</qresource>
</RCC>
#define COMMON_H
#include <QString>
+#include <QColor>
+#include <QFont>
// QSettings identifiers
const QString DIRECTORY_NAME = "Ixonos";
const QString FILE_NAME = "Situare";
+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
+
#endif // COMMON_H
* SIGNALS
******************************************************************************/
signals:
+
/**
* @brief Signals when new friends data is ready
*
--- /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"
QGeoCoordinate coordinate = m_gpsSource->lastKnownPosition().coordinate();
if (coordinate.isValid()) {
- qreal accuracy = biggerAccuracy(m_gpsSource->lastKnownPosition());
- emit position(QPointF(coordinate.longitude(), coordinate.latitude()), accuracy);
+ emit position(QPointF(coordinate.longitude(), coordinate.latitude()),
+ accuracy(m_gpsSource->lastKnownPosition()));
}
}
{
qDebug() << __PRETTY_FUNCTION__ << positionInfo;
- if (positionInfo.coordinate().isValid()) {
-
- qreal accuracy = biggerAccuracy(positionInfo);
-
+ if (positionInfo.coordinate().isValid())
emit position(QPointF(positionInfo.coordinate().longitude(),
- positionInfo.coordinate().latitude()), accuracy);
- }
+ positionInfo.coordinate().latitude()),
+ accuracy(positionInfo));
}
void GPSPosition::updateTimeout()
}
}
-qreal GPSPosition::biggerAccuracy(QGeoPositionInfo positionInfo)
+qreal GPSPosition::accuracy(QGeoPositionInfo positionInfo)
{
qDebug() << __PRETTY_FUNCTION__;
- qreal horizontalAccuracy = ACCURACY_UNDEFINED;
- qreal verticalAccuracy = ACCURACY_UNDEFINED;
+ if (!positionInfo.dateTime().isValid())
+ return GPS_ACCURACY_UNDEFINED;
if (positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
- horizontalAccuracy = positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy);
-
- if (positionInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
- verticalAccuracy = positionInfo.attribute(QGeoPositionInfo::VerticalAccuracy);
-
- int accuracy = verticalAccuracy;
-
- if (horizontalAccuracy > accuracy)
- accuracy = horizontalAccuracy;
-
- return accuracy;
+ return positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy);
+ else
+ return GPS_ACCURACY_UNDEFINED;
}
private:
/**
- * @brief Return bigger accuracy value from latitude and longitude values.
+ * @brief Return horizontal accuracy
*
* @param positionInfo geo position info
- * @return bigger accuracy value, -1 if undefined
+ * @return accuracy value, -1 if undefined. Returns -1 also is timestamp is not valid
+ * (when using network positioning)
*/
- qreal biggerAccuracy(QGeoPositionInfo positionInfo);
+ qreal accuracy(QGeoPositionInfo positionInfo);
private slots:
*/
void updateTimeout();
-/******************************************************************************
-* DATA MEMBERS
-******************************************************************************/
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
private:
QGeoPositionInfoSource *m_gpsSource; ///< GPS position info source
bool m_running; ///< GPS is running
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
#include "friendlocationitem.h"
#include "mapcommon.h"
-
#include "friendgroupitem.h"
+#include "common.h"
FriendGroupItem::FriendGroupItem(FriendLocationItem *item)
{
BaseLocationItem::paint(painter, option, widget);
- QFont font = painter->font();
- font.setPointSize(painter->font().pointSize() * 2); // double default font size
- painter->setFont(font);
- painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(m_friends.count()));
+ painter->setPen(Qt::black);
+ painter->setFont(NOKIA_FONT_SMALL);
+ painter->drawText(QRect(GROUP_ITEM_FRIENDS_COUNT_X, GROUP_ITEM_FRIENDS_COUNT_Y,
+ GROUP_ITEM_FRIENDS_COUNT_WIDTH, GROUP_ITEM_FRIENDS_COUNT_HEIGHT),
+ Qt::AlignCenter, QString::number(m_friends.count()));
}
--- /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.
+*/
+
+#include <QDebug>
+#include <QGraphicsPixmapItem>
+
+#include "../gps/gpscommon.h"
+#include "mapcommon.h"
+
+#include "gpslocationitem.h"
+
+GPSLocationItem::GPSLocationItem()
+ : m_currentAccuracy(NOT_SET)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ 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(-m_accuratePixmap.width() / 2, -m_accuratePixmap.height() / 2);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
+}
+
+void GPSLocationItem::setEnabled(bool enable)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (enable) {
+ show();
+ }
+ else {
+ m_currentAccuracy = NOT_SET;
+ hide();
+ setPixmap(QPixmap());
+ }
+
+}
+
+void GPSLocationItem::updatePosition(QPoint scenePosition, qreal accuracy)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ setPos(scenePosition);
+
+ if (accuracy == GPS_ACCURACY_UNDEFINED) { // fix is NOT accurate
+ if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
+ setPixmap(m_coarsePixmap);
+ m_currentAccuracy = COARSE;
+ }
+ }
+ else { // fix is accurate
+ if (m_currentAccuracy != ACCURATE) { // accurate pixmap not yet set
+ setPixmap(m_accuratePixmap);
+ m_currentAccuracy = ACCURATE;
+ }
+ }
+}
--- /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 GPSLOCATIONITEM_H
+#define GPSLOCATIONITEM_H
+
+#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
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ GPSLocationItem();
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+ /**
+ * @brief Enable / disable item
+ *
+ * @param enable True if item should be enabled, otherwise false
+ */
+ void setEnabled(bool enable);
+
+ /**
+ * @brief Update position item
+ *
+ * Use yellow led image when using network positioning and green led image when using GPS.
+ *
+ * @param scenePosition Scene coordinate
+ * @param accuracy Accuracy of the GPS fix
+ */
+ void updatePosition(QPoint scenePosition, qreal accuracy);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+ /**
+ * @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
*/
const int FRIEND_LOCATION_ICON_Z_LEVEL = MIN_MAP_SCENE_NORMAL_LEVEL + MAX_MAP_ZOOM_LEVEL + 1;
+const int GROUP_ITEM_FRIENDS_COUNT_X = 13; ///< Group item friends count x value
+const int GROUP_ITEM_FRIENDS_COUNT_Y = 13; ///< Group item friends count y value
+const int GROUP_ITEM_FRIENDS_COUNT_WIDTH = 17; ///< Group item friends count width value
+const int GROUP_ITEM_FRIENDS_COUNT_HEIGHT = 17; ///< Group item friends count height value
+
/**
* @var OWN_LOCATION_ICON_Z_LEVEL
* @brief layer of own location icon
#include <QRect>
#include "frienditemshandler.h"
+#include "gpslocationitem.h"
#include "mapcommon.h"
#include "mapengine.h"
#include "maptile.h"
m_ownLocation->hide(); // hide until first location info is received
m_mapScene->addItem(m_ownLocation);
+ m_gpsLocationItem = new GPSLocationItem();
+ m_mapScene->addItem(m_gpsLocationItem);
+
m_friendItemsHandler = new FriendItemsHandler(m_mapScene, this);
connect(this, SIGNAL(zoomLevelChanged(int)),
m_friendItemsHandler, SLOT(refactorFriendItems(int)));
+
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
m_friendItemsHandler, SLOT(friendListUpdated(QList<User*>&)));
}
return QRect(topLeftX, topLeftY, gridWidth, gridHeight);
}
-void MapEngine::alignImmovableItems(QPoint viewTopLeft)
-{
- qDebug() << __PRETTY_FUNCTION__ << "viewTopLeft:" << viewTopLeft;
-}
-
void MapEngine::setLocation(QPoint sceneCoordinate)
{
qDebug() << __PRETTY_FUNCTION__;
if (disableAutoCentering(sceneCoordinate))
- emit mapScrolled();
+ emit mapScrolledManually();
m_sceneCoordinate = sceneCoordinate;
emit locationChanged(m_sceneCoordinate);
m_zoomedIn = false;
m_mapScene->removeOutOfViewTiles();
}
+
+ if (m_zoomLevel == MAX_MAP_ZOOM_LEVEL)
+ emit maxZoomLevelReached();
+ else if (m_zoomLevel == MIN_VIEW_ZOOM_LEVEL)
+ emit minZoomLevelReached();
}
void MapEngine::zoomIn()
m_ownLocation->show();
}
+void MapEngine::gpsPositionUpdate(QPointF position, qreal accuracy)
+{
+ m_gpsLocationItem->updatePosition(convertLatLonToSceneCoordinate(position), accuracy);
+
+ if (m_autoCenteringEnabled)
+ setViewLocation(position);
+}
+
bool MapEngine::disableAutoCentering(QPoint sceneCoordinate)
{
if (isAutoCenteringEnabled()) {
m_autoCenteringEnabled = enabled;
}
+
+void MapEngine::gpsEnabled(bool enabled)
+{
+ m_gpsLocationItem->setEnabled(enabled);
+}
+
QPointF MapEngine::convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate)
{
qDebug() << __PRETTY_FUNCTION__;
#include "user/user.h"
class FriendItemsHandler;
+class GPSLocationItem;
/**
* @brief Map engine
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
public slots:
/**
- * @brief Slot for immovable scene items position correction
- *
- * @param viewTopLeft Scene coordinate of the viewport top left corner
- */
- void alignImmovableItems(QPoint viewTopLeft);
-
- /**
* @brief Slot for setting current view location
*
* Emits locationChanged signal.
private slots:
/**
+ * @brief Slot for enabling / disabling GPS
+ *
+ * GPS location item is disabled or enabled based on GPS state
+ *
+ * @param enabled True is GPS is enabled, otherwise false
+ */
+ void gpsEnabled(bool enabled);
+
+ /**
+ * @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);
+
+ /**
* @brief Slot for received map tile images
*
* Does add MapTile objects to MapScene.
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 to notify when map is zoomed in to the maxmimum.
+ */
+ void maxZoomLevelReached();
+
+ /**
+ * @brief Signal to notify when map is zoomed out to the minimum.
+ */
+ void minZoomLevelReached();
/**
* @brief Signal request mapView to update view port contents
* DATA MEMBERS
******************************************************************************/
private:
- bool m_autoCenteringEnabled; ///< Auto centering enabled
+ bool m_autoCenteringEnabled; ///< Auto centering enabled
QPoint m_centerTile; ///< Current center tile
FriendItemsHandler *m_friendItemsHandler; ///< Handler for friend and group items
+ 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
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_zoomAnimation = new QPropertyAnimation(this, "viewScale", this);
- connect(m_zoomAnimation, SIGNAL(finished()), this, SIGNAL(viewZoomFinished()));
+ connect(m_zoomAnimation, SIGNAL(finished()),
+ this, SIGNAL(viewZoomFinished()));
}
void MapView::setZoomLevel(int zoomLevel)
QTransform transform;
transform.scale(viewScale, viewScale);
setTransform(transform);
- emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
}
void MapView::mouseMoveEvent(QMouseEvent *event)
emit viewScrolled(m_scenePosition);
m_mousePosition = mapToScene(event->pos()).toPoint();
- emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
}
void MapView::mousePressEvent(QMouseEvent *event)
emit viewResized(event->size());
emit viewResizedNewSize(viewport()->width(), viewport()->height());
- //emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
}
-void MapView::showEvent(QShowEvent *event)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QGraphicsView::showEvent(event);
- //emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
-}
void MapView::updateViewPortContent()
{
*/
void resizeEvent(QResizeEvent *event);
- /**
- * @brief Called when view is displayed.
- *
- * @param event show event
- */
- void showEvent(QShowEvent *event);
-
private:
/**
* @brief Event handler for mouse move events
/**
* @brief Signal for informing that zooming animation is finished
- *
*/
void viewZoomFinished();
map/friendgroupitem.cpp \
map/frienditemshandler.cpp \
gps/gpspositioninterface.cpp \
+ map/gpslocationitem.cpp \
ui/zoombuttonpanel.cpp
HEADERS += ui/mainwindow.h \
ui/mapviewscreen.h \
map/friendgroupitem.h \
map/frienditemshandler.h \
gps/gpspositioninterface.h \
+ map/gpslocationitem.h \
+ gps/gpscommon.h \
ui/zoombuttonpanel.h \
common.h
QT += network \
QPixmap AvatarImage::create(const QPixmap &image)
{
- QPixmap avatarImage = QPixmap(60, 60);
+ QPixmap avatarImage = QPixmap(IMAGE_WIDTH, IMAGE_HEIGHT);
avatarImage.fill(Qt::transparent);
QPainter painter(&avatarImage);
#include "friendlistitem.h"
#include "../user/user.h"
#include "imagebutton.h"
+#include "common.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
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()));
m_autoCenteringAct->setCheckable(true);
m_autoCenteringAct->setChecked(true);
connect(m_autoCenteringAct, SIGNAL(toggled(bool)),
- this, SLOT(autoCenteringToggled(bool)));
-
+ this, SLOT(autoCenteringToggled(bool)));
+ connect(this, SIGNAL(enableGPS(bool)),
+ m_mapViewScreen, SIGNAL(gpsEnabled(bool)));
+
m_viewMenu = menuBar()->addMenu(tr("Main"));
m_viewMenu->addAction(m_toSettingsAct);
#include "panelsidebar.h"
MapViewScreen::MapViewScreen(QWidget *parent)
- : QWidget(parent),
- m_autoCenteringEnabled(false)
+ : QWidget(parent)
{
MapView *mapView = new MapView(this);
m_mapEngine = new MapEngine(this);
connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
- connect(m_zoomButtonPanel->m_zoomInBtn, SIGNAL(clicked()),
+ connect(m_zoomButtonPanel->m_zoomInButton, SIGNAL(clicked()),
m_mapEngine, SLOT(zoomIn()));
- connect(m_zoomButtonPanel->m_zoomOutBtn, SIGNAL(clicked()),
+ connect(m_zoomButtonPanel->m_zoomOutButton, SIGNAL(clicked()),
m_mapEngine, SLOT(zoomOut()));
+ connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
+ m_zoomButtonPanel, SLOT(resetButtons()));
+ connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
+ m_zoomButtonPanel, SLOT(disableZoomInButton()));
+ connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
+ m_zoomButtonPanel, SLOT(disableZoomOutButton()));
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
- connect(m_mapEngine, SIGNAL(mapScrolled()),
- this, SLOT(locationChanged()));
+ connect(m_mapEngine, SIGNAL(mapScrolledManually()),
+ this, SIGNAL(mapLocationChanged()));
+
+ connect(this, SIGNAL(positionReceived(QPointF,qreal)),
+ m_mapEngine, SLOT(gpsPositionUpdate(QPointF,qreal)));
+ connect(this, SIGNAL(enableAutoCentering(bool)),
+ m_mapEngine, SLOT(setAutoCentering(bool)));
+ connect(this, SIGNAL(gpsEnabled(bool)),
+ m_mapEngine, SLOT(gpsEnabled(bool)));
connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
this, SLOT(drawOwnLocationCrosshair(int, int)));
height - m_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)
- m_mapEngine->setViewLocation(position);
-}
-
-void MapViewScreen::enableAutoCentering(bool enabled)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_autoCenteringEnabled = enabled;
- m_mapEngine->setAutoCentering(enabled);
-}
void MapViewScreen::drawOwnLocationCrosshair(int width, int height)
{
/**
* @brief Map View class. Used to display Map
-*
-* @class MapViewScreen mainwindow.h "src/ui/mainwindow.h"
*/
class MapViewScreen : public QWidget
{
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
*
* @param width Width of the viewport
*/
void drawOwnLocationCrosshair(int width, int height);
- /**
- * @brief Slot for map location change.
- */
- void locationChanged();
+// /**
+// * @brief Slot for map location change.
+// */
+// void locationChanged();
/**
* @brief Set correnct view port size to datamembers
*/
void setViewPortSize(const int width, const int height);
- /**
- * @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
*/
void friendsLocationsReady(QList<User *> &friendsList);
- /**
+ /**
+ * @brief Signal for GPS enabling / disabling
+ *
+ * @param enabled True is GPS is enabled, otherwise false
+ */
+ void gpsEnabled(bool enabled);
+
+ /**
* @brief Signal for map location change.
*/
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 from MapEngine to SituareEngine is travelling here
*/
void ownLocation(QPointF ownLatitudeLongitudeLocation);
* DATA MEMBERS
******************************************************************************/
private:
- MapEngine *m_mapEngine; ///< MapEngine
- UserInfoPanel *m_userPanel; ///< Instance of the user information panel
- FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
- ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
- QLabel *m_osmLicense; ///< Label for Open Street Map license
- bool m_autoCenteringEnabled; ///< Enable
- QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
- bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
- int m_viewPortWidth; ///< Width of view port
- int m_viewPortHeight; ///< Height of view port
+ bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
+ FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
+ MapEngine *m_mapEngine; ///< MapEngine
+ QLabel *m_osmLicense; ///< Label for Open Street Map license
+ QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
+ UserInfoPanel *m_userPanel; ///< Instance of the user information panel
+ int m_viewPortHeight; ///< Height of view port
+ int m_viewPortWidth; ///< Width of view port
+ ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
};
#endif // MAPVIEWTAB_H
{
qDebug() << __PRETTY_FUNCTION__;
- m_zoomInBtn = new ImageButton(this, ":/res/images/zoom_in.png");
- m_zoomOutBtn = new ImageButton(this, ":/res/images/zoom_out.png");
+ m_zoomInButton = new ImageButton(this, ":/res/images/zoom_in.png");
+ m_zoomOutButton = new ImageButton(this, ":/res/images/zoom_out.png");
m_panelLayout.setMargin(0);
m_panelLayout.setSpacing(0);
m_panelLayout.setVerticalSpacing(ZOOM_BUTTON_PANEL_BUTTON_SPACING);
m_panelLayout.setSizeConstraint(QLayout::SetFixedSize);
- m_panelLayout.addWidget(m_zoomInBtn, 0, 0);
- m_panelLayout.addWidget(m_zoomOutBtn, 1, 0);
+ m_panelLayout.addWidget(m_zoomInButton, 0, 0);
+ m_panelLayout.addWidget(m_zoomOutButton, 1, 0);
move(m_x, m_y);
}
+
+void ZoomButtonPanel::disableZoomInButton()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_zoomInButton->setMode(QIcon::Disabled);
+}
+
+void ZoomButtonPanel::disableZoomOutButton()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_zoomOutButton->setMode(QIcon::Disabled);
+}
+
+void ZoomButtonPanel::resetButtons()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_zoomInButton->setMode(QIcon::Normal);
+ m_zoomOutButton->setMode(QIcon::Normal);
+}
#include "imagebutton.h"
/**
-* @brief Panel for zoom buttons
-*
-* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
-*/
+ * @brief Panel for zoom buttons
+ *
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+ */
class ZoomButtonPanel : public QWidget
{
Q_OBJECT
public:
/**
- * @brief Constructor
- *
- * @param parent Parent
- * @param x Panel x coordinate
- * @param y Panel y coordinate
- */
+ * @brief Constructor
+ *
+ * @param parent Parent
+ * @param x Panel x coordinate
+ * @param y Panel y coordinate
+ */
ZoomButtonPanel(QWidget *parent = 0, int x = 0, int y = 0);
/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public slots:
+ /**
+ * @brief Disables the Zoom In button
+ */
+ void disableZoomInButton();
+
+ /**
+ * @brief Disables the Zoom Out button
+ */
+ void disableZoomOutButton();
+
+ /**
+ * @brief Reset Zoom button states to normal
+ */
+ void resetButtons();
+
+/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
public:
- ImageButton *m_zoomInBtn; ///< Button for zoom in
- ImageButton *m_zoomOutBtn; ///< Button for zoom out
+ ImageButton *m_zoomInButton; ///< Button for zoom in
+ ImageButton *m_zoomOutButton; ///< Button for zoom out
private:
QGridLayout m_panelLayout; ///< Panel layout
--- /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.
+*/
+
+#include <QtTest/QtTest>
+
+#include "map/mapcommon.h"
+#include "map/gpslocationitem.h"
+
+class TestGPSLocationItem: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void constructor();
+ void enable();
+ void position();
+};
+
+void TestGPSLocationItem::constructor()
+{
+ QPixmap accurate(":/res/images/gps_pos_accurate.png");
+
+ GPSLocationItem item;
+
+ // pixmap should not be set
+ QVERIFY(item.pixmap().isNull());
+
+ // position should be UNDEFINED
+ QCOMPARE(item.pos(), QPointF(UNDEFINED, UNDEFINED));
+
+ // zValue should be set
+ QCOMPARE(item.zValue(), static_cast<qreal>(OWN_LOCATION_ICON_Z_LEVEL));
+
+ // icon offset should be set based on accurate pixmap
+ QCOMPARE(item.offset(), QPointF(-accurate.width() / 2, -accurate.height() / 2));
+
+ // ItemIgnoresTransformations flag should be set
+ QVERIFY(item.flags() & QGraphicsItem::ItemIgnoresTransformations);
+}
+
+void TestGPSLocationItem::enable()
+{
+ // create item and update it's position so pixmap is set
+ GPSLocationItem item;
+ item.updatePosition(QPoint(100, 100), 10);
+
+ // item should be visible and pixmap set
+ QCOMPARE(item.isVisible(), true);
+ QCOMPARE(item.pixmap().isNull(), false);
+
+ item.setEnabled(false);
+
+ // item should be hidden and pixmap unset
+ QCOMPARE(item.isVisible(), false);
+ QCOMPARE(item.pixmap().isNull(), true);
+
+ item.setEnabled(true);
+
+ // item should be visible, but pixmap still unset until first position update is received
+ QCOMPARE(item.isVisible(), true);
+ QCOMPARE(item.pixmap().isNull(), true);
+
+ item.updatePosition(QPoint(500, 500), 10);
+
+ // pixmam should be set after first position update
+ QCOMPARE(item.pixmap().isNull(), false);
+}
+
+void TestGPSLocationItem::position()
+{
+ GPSLocationItem item;
+ item.updatePosition(QPoint(123, 321), 10);
+
+ QCOMPARE(item.pos(), QPointF(123, 321));
+}
+
+QTEST_MAIN(TestGPSLocationItem)
+
+#include "testgpslocationitem.moc"
--- /dev/null
+# #####################################################################
+# Automatically generated by qmake (2.01a) Fri Mar 26 15:09:16 2010
+# #####################################################################
+CONFIG += qtestlib
+QT += network
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += . \
+ ../../../src/
+
+# Input
+SOURCES += testgpslocationitem.cpp \
+ ../../../src/map/gpslocationitem.cpp
+HEADERS += \
+ ../../../src/map/gpslocationitem.h
+DEFINES += QT_NO_DEBUG_OUTPUT
+RESOURCES += ../../../images.qrc