From: lampehe-local Date: Fri, 14 May 2010 12:10:06 +0000 (+0300) Subject: Merge branch 'master' of https://vcs.maemo.org/git/situare X-Git-Tag: v0.4~4^2~7^2 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=6ab8f09e185056f1a612f87f20989466edc1bd78;hp=57b808d03096f932a9437db8cacf571c92021356;p=situare Merge branch 'master' of https://vcs.maemo.org/git/situare --- diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 1c43872..39c56e4 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -21,8 +21,8 @@ USA. */ -#include "situarecommon.h" #include "engine.h" +#include "situarecommon.h" #include "ui/mainwindow.h" #include "gps/gpspositioninterface.h" diff --git a/src/facebookservice/facebookauthentication.cpp b/src/facebookservice/facebookauthentication.cpp index 0f7d544..6e65072 100644 --- a/src/facebookservice/facebookauthentication.cpp +++ b/src/facebookservice/facebookauthentication.cpp @@ -31,9 +31,9 @@ #include #endif // Q_WS_MAEMO_5 -#include "situarecommon.h" #include "facebookauthentication.h" #include "facebookcommon.h" +#include "situarecommon.h" #include "parser.h" FacebookAuthentication::FacebookAuthentication(QObject *parent) diff --git a/src/map/mapbutton.cpp b/src/map/mapbutton.cpp deleted file mode 100644 index 55c6d24..0000000 --- a/src/map/mapbutton.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Pekka Nissinen - pekka.nissinen@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 -#include - -#include "mapbutton.h" -#include "mapcommon.h" - -MapButton::MapButton(QString fileName) - : m_buttonMode(QIcon::Normal) - , m_buttonWidth(MAP_ZOOM_PANEL_BUTTON_SIZE) - , m_buttonHeight(MAP_ZOOM_PANEL_BUTTON_SIZE) -{ - qDebug() << __PRETTY_FUNCTION__; - - addFile(fileName); -} - -void MapButton::draw(QPainter *painter, int x, int y) -{ - qDebug() << __PRETTY_FUNCTION__; - - paint(painter, x, y, m_buttonWidth, m_buttonHeight, NULL, m_buttonMode); -} - -void MapButton::setMode(QIcon::Mode mode) -{ - qDebug() << __PRETTY_FUNCTION__; - - m_buttonMode = mode; -} diff --git a/src/map/mapbutton.h b/src/map/mapbutton.h deleted file mode 100644 index 8b4872b..0000000 --- a/src/map/mapbutton.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Pekka Nissinen - pekka.nissinen@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 MAPBUTTON_H -#define MAPBUTTON_H - -#include -#include -#include - -/** -* @brief A simple class for icon button -* -* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com -*/ -class MapButton : public QIcon -{ -public: - /** - * @brief Constructor - * - * @param fileName Icon image file name - */ - MapButton(QString fileName); - -/******************************************************************************* - * MEMBER FUNCTIONS AND SLOTS - ******************************************************************************/ -public: - /** - * @brief Draws the button - * - * @param painter Painter - * @param x Button x coordinate - * @param y Button y coordinate - */ - void draw(QPainter *painter, int x, int y); - - /** - * @brief Sets the button icon mode - * - * @param mode Button icon mode - */ - void setMode(QIcon::Mode mode); - -/******************************************************************************* - * DATA MEMBERS - ******************************************************************************/ -private: - QIcon::Mode m_buttonMode; ///< Button mode (Normal, Selected etc...) - int m_buttonWidth; ///< Button width - int m_buttonHeight; ///< Button height -}; - -#endif // MAPBUTTON_H diff --git a/src/map/mapcommon.h b/src/map/mapcommon.h index 85a9e44..b8349cb 100644 --- a/src/map/mapcommon.h +++ b/src/map/mapcommon.h @@ -49,12 +49,6 @@ const int MAP_OWN_LOCATION_ICON_SIZE = 24; ///< Size of own location item icon const int ZOOM_FPS = 30; ///< FPS for the zoom effect const qreal ZOOM_TIME = 250; ///< Length of the zoom effect (ms) -const int MAP_ZOOM_PANEL_POSITION_X = 10 + 25; ///< Horizontal position of zoom panel -const int MAP_ZOOM_PANEL_POSITION_Y = 10; ///< Vertical position of zoom panel -const int MAP_ZOOM_PANEL_LEVEL = OWN_LOCATION_ICON_Z_LEVEL + 1; ///< Zepth of zoom panel (Z-axis) -const int MAP_ZOOM_PANEL_BUTTON_SIZE = 74; ///< Size of a zoom panel button -const int MAP_ZOOM_PANEL_BUTTON_SPACING = 4; ///< Size of a zoom button spacing - const qreal MAX_LATITUDE = 85.05112877980659237802; ///< Maximum latitude value const qreal MIN_LATITUDE = -MAX_LATITUDE; ///< Minimum latitude value const qreal MIN_LONGITUDE = -180.0; ///< Minimum longitude value diff --git a/src/map/mapengine.cpp b/src/map/mapengine.cpp index fce2881..256f0a2 100644 --- a/src/map/mapengine.cpp +++ b/src/map/mapengine.cpp @@ -32,6 +32,7 @@ #include #include "frienditemshandler.h" +#include "mapcommon.h" #include "mapengine.h" #include "maptile.h" @@ -43,22 +44,16 @@ MapEngine::MapEngine(QObject *parent) , m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT)) , m_zoomedIn(false) , m_zoomLevel(DEFAULT_ZOOM_LEVEL) - { qDebug() << __PRETTY_FUNCTION__; m_mapScene = new MapScene(this); m_mapFetcher = new MapFetcher(new QNetworkAccessManager(this), this); - connect(this, SIGNAL(fetchImage(int,int,int)), - m_mapFetcher, SLOT(enqueueFetchMapImage(int,int,int))); - connect(m_mapFetcher, SIGNAL(mapImageReceived(int,int,int,QPixmap)), - this, SLOT(mapImageReceived(int,int,int,QPixmap))); - - m_mapZoomPanel = new MapZoomPanel(NULL, MAP_ZOOM_PANEL_POSITION_X, MAP_ZOOM_PANEL_POSITION_Y); - m_mapScene->addItem(m_mapZoomPanel); - connect(m_mapZoomPanel, SIGNAL(zoomInPressed()), this, SLOT(zoomIn())); - connect(m_mapZoomPanel, SIGNAL(zoomOutPressed()), this, SLOT(zoomOut())); + connect(this, SIGNAL(fetchImage(int, int, int)), + m_mapFetcher, SLOT(enqueueFetchMapImage(int, int, int))); + connect(m_mapFetcher, SIGNAL(mapImageReceived(int, int, int, QPixmap)), + this, SLOT(mapImageReceived(int, int, int, QPixmap))); m_ownLocation = new OwnLocationItem(); m_ownLocation->hide(); // hide until first location info is received @@ -67,7 +62,6 @@ MapEngine::MapEngine(QObject *parent) m_friendItemsHandler = new FriendItemsHandler(m_mapScene, this); connect(this, SIGNAL(zoomLevelChanged(int)), m_friendItemsHandler, SLOT(refactorFriendItems(int))); - connect(this, SIGNAL(friendsLocationsReady(QList&)), m_friendItemsHandler, SLOT(friendListUpdated(QList&))); } @@ -128,10 +122,10 @@ QRect MapEngine::calculateTileGrid(QPoint sceneCoordinate) qDebug() << __PRETTY_FUNCTION__; QPoint tileCoordinate = convertSceneCoordinateToTileNumber(m_zoomLevel, sceneCoordinate); - int gridWidth = (m_viewSize.width()/TILE_SIZE_X + 1) + (GRID_PADDING*2); - int gridHeight = (m_viewSize.height()/TILE_SIZE_Y + 1) + (GRID_PADDING*2); - int topLeftX = tileCoordinate.x() - (gridWidth/2); - int topLeftY = tileCoordinate.y() - (gridHeight/2); + int gridWidth = (m_viewSize.width() / TILE_SIZE_X + 1) + (GRID_PADDING * 2); + int gridHeight = (m_viewSize.height() / TILE_SIZE_Y + 1) + (GRID_PADDING * 2); + int topLeftX = tileCoordinate.x() - (gridWidth / 2); + int topLeftY = tileCoordinate.y() - (gridHeight / 2); m_mapFetcher->setDownloadQueueSize(gridWidth * gridHeight); @@ -141,8 +135,6 @@ QRect MapEngine::calculateTileGrid(QPoint sceneCoordinate) void MapEngine::alignImmovableItems(QPoint viewTopLeft) { qDebug() << __PRETTY_FUNCTION__ << "viewTopLeft:" << viewTopLeft; - - m_mapZoomPanel->setPos(viewTopLeft); } void MapEngine::setLocation(QPoint sceneCoordinate) @@ -289,8 +281,8 @@ QPoint MapEngine::convertSceneCoordinateToTileNumber(int zoomLevel, QPoint scene qDebug() << __PRETTY_FUNCTION__; int pow = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel); - int x = static_cast(sceneCoordinate.x() / (TILE_SIZE_X*pow)); - int y = static_cast(sceneCoordinate.y() / (TILE_SIZE_Y*pow)); + int x = static_cast(sceneCoordinate.x() / (TILE_SIZE_X * pow)); + int y = static_cast(sceneCoordinate.y() / (TILE_SIZE_Y * pow)); return QPoint(x, y); } @@ -324,7 +316,7 @@ QPoint MapEngine::convertLatLonToSceneCoordinate(QPointF latLonCoordinate) qreal y = static_cast((1.0 - log(tan(latitude * M_PI / 180.0) + 1.0 / cos(latitude * M_PI / 180.0)) / M_PI) / 2.0); - return QPointF(x*z*TILE_SIZE_X, y*z*TILE_SIZE_Y).toPoint(); + return QPointF(x * z * TILE_SIZE_X, y * z * TILE_SIZE_Y).toPoint(); } void MapEngine::receiveOwnLocation(User *user) diff --git a/src/map/mapengine.h b/src/map/mapengine.h index 1aaefae..e773169 100644 --- a/src/map/mapengine.h +++ b/src/map/mapengine.h @@ -27,11 +27,9 @@ #include -#include "mapcommon.h" #include "mapfetcher.h" #include "mapscene.h" #include "maptile.h" -#include "mapzoompanel.h" #include "ownlocationitem.h" #include "user/user.h" @@ -42,6 +40,7 @@ class FriendItemsHandler; * * Logic for controlling map functionality. Does also include static methods for * converting coordinates. +* * @author Sami Rämö - sami.ramo (at) ixonos.com * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com @@ -299,7 +298,6 @@ private: QPoint m_lastManualPosition; ///< Last manually set position in scene coordinate MapFetcher *m_mapFetcher; ///< Fetcher for map tiles MapScene *m_mapScene; ///< Scene for map tiles - MapZoomPanel *m_mapZoomPanel; ///< Toolbar for zoom buttons OwnLocationItem *m_ownLocation; ///< Item to show own location QPoint m_sceneCoordinate; ///< Current center coordinate QRect m_viewTilesGrid; ///< Current grid of tiles in view (includes margin) diff --git a/src/map/mapview.cpp b/src/map/mapview.cpp index 351e714..baaafe1 100644 --- a/src/map/mapview.cpp +++ b/src/map/mapview.cpp @@ -3,6 +3,7 @@ Copyright (C) 2010 Ixonos Plc. Authors: Sami Rämö - sami.ramo@ixonos.com + Pekka Nissinen - pekka.nissinen@ixonos.com Situare is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/map/mapview.h b/src/map/mapview.h index 128543e..8ddff7c 100644 --- a/src/map/mapview.h +++ b/src/map/mapview.h @@ -3,6 +3,7 @@ Copyright (C) 2010 Ixonos Plc. Authors: Sami Rämö - sami.ramo@ixonos.com + Pekka Nissinen - pekka.nissinen@ixonos.com Situare is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,6 +30,7 @@ * @brief Map view widget * * @author Sami Rämö - sami.ramo (at) ixonos.com +* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com */ class MapView : public QGraphicsView { diff --git a/src/map/mapzoompanel.cpp b/src/map/mapzoompanel.cpp deleted file mode 100644 index 812077d..0000000 --- a/src/map/mapzoompanel.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Pekka Nissinen - pekka.nissinen@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 - -#include "mapcommon.h" -#include "mapzoompanel.h" - -MapZoomPanel::MapZoomPanel(QGraphicsItem *parent, int x, int y) : QGraphicsItem(parent) -{ - qDebug() << __PRETTY_FUNCTION__; - - m_x = x; - m_y = y; - m_width = MAP_ZOOM_PANEL_BUTTON_SIZE; - m_height = MAP_ZOOM_PANEL_BUTTON_SIZE + MAP_ZOOM_PANEL_BUTTON_SPACING - + MAP_ZOOM_PANEL_BUTTON_SIZE; - - m_zoomInBtn = new MapButton(":/res/images/zoom_in.png"); - m_zoomOutBtn = new MapButton(":/res/images/zoom_out.png"); - - setFlag(QGraphicsItem::ItemIgnoresTransformations); - setZValue(static_cast(MAP_ZOOM_PANEL_LEVEL)); -} - -MapZoomPanel::~MapZoomPanel() -{ - qDebug() << __PRETTY_FUNCTION__; - - delete m_zoomInBtn; - delete m_zoomOutBtn; - m_zoomInBtn = 0; - m_zoomOutBtn = 0; -} - -QRectF MapZoomPanel::boundingRect() const -{ - qDebug() << __PRETTY_FUNCTION__; - - return QRectF(m_x, m_y, m_width, m_height); -} - -void MapZoomPanel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - qDebug() << __PRETTY_FUNCTION__; - - Q_UNUSED(option); - Q_UNUSED(widget); - - m_zoomInBtn->draw(painter, m_x, m_y); - m_zoomOutBtn->draw(painter, m_x, m_y + MAP_ZOOM_PANEL_BUTTON_SPACING - + MAP_ZOOM_PANEL_BUTTON_SIZE); -} - -void MapZoomPanel::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - qDebug() << __PRETTY_FUNCTION__; - - if ( event->pos().y() < (m_y + MAP_ZOOM_PANEL_BUTTON_SPACING + MAP_ZOOM_PANEL_BUTTON_SIZE) ) - m_zoomInBtn->setMode(QIcon::Selected); - else - m_zoomOutBtn->setMode(QIcon::Selected); - - update(); -} - -void MapZoomPanel::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - qDebug() << __PRETTY_FUNCTION__; - - Q_UNUSED(event); - - m_zoomInBtn->setMode(QIcon::Normal); - m_zoomOutBtn->setMode(QIcon::Normal); - - if ( event->pos().y() < (m_y + MAP_ZOOM_PANEL_BUTTON_SPACING + MAP_ZOOM_PANEL_BUTTON_SIZE) ) - emit zoomInPressed(); - else - emit zoomOutPressed(); - - update(); -} diff --git a/src/map/mapzoompanel.h b/src/map/mapzoompanel.h deleted file mode 100644 index da8cae4..0000000 --- a/src/map/mapzoompanel.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Pekka Nissinen - pekka.nissinen@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 MAPZOOMPANEL_H -#define MAPZOOMPANEL_H - -#include -#include -#include -#include -#include -#include - -#include "mapbutton.h" - -/** -* @brief Panel for zoom buttons -* -* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com -*/ -class MapZoomPanel : public QObject, public QGraphicsItem -{ - Q_OBJECT - -public: - /** - * @brief Constructor - * - * @param parent Parent - * @param x Panel x coordinate - * @param y Panel y coordinate - */ - MapZoomPanel(QGraphicsItem *parent = 0, int x = 0, int y = 0); - - /** - * @brief Destructor - */ - ~MapZoomPanel(); - -/******************************************************************************* - * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS - ******************************************************************************/ -public: - /** - * @brief Returns the outer bounds of the panel - */ - QRectF boundingRect() const; - - /** - * @brief Paints the panel and its content - * - * @param painter Painter - * @param option Style options - * @param widget Widget - */ - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -protected: - /** - * @brief Event handler for mouse press events - * - * @param event Mouse event - */ - void mousePressEvent(QGraphicsSceneMouseEvent *event); - - /** - * @brief Event handler for mouse release events - * - * @param event Mouse event - */ - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - -/******************************************************************************* - * SIGNALS - ******************************************************************************/ -signals: - /** - * @brief Signal for zoom in button click - */ - void zoomInPressed(); - - /** - * @brief Signal for zoom out button click - */ - void zoomOutPressed(); - -/******************************************************************************* - * DATA MEMBERS - ******************************************************************************/ -private: - MapButton *m_zoomInBtn; ///< Button for zoom in - MapButton *m_zoomOutBtn; ///< Button for zoom out - qreal m_x; ///< Panel x coordinate - qreal m_y; ///< Panel y coordinate - qreal m_width; ///< Panel width - qreal m_height; ///< Panel height -}; - -#endif // MAPZOOMPANEL_H diff --git a/src/src.pro b/src/src.pro index 44cda87..06b4362 100644 --- a/src/src.pro +++ b/src/src.pro @@ -18,8 +18,6 @@ SOURCES += main.cpp \ map/mapscene.cpp \ map/maptile.cpp \ map/mapfetcher.cpp \ - map/mapzoompanel.cpp \ - map/mapbutton.cpp \ map/ownlocationitem.cpp \ map/baselocationitem.cpp \ map/friendlocationitem.cpp \ @@ -40,7 +38,8 @@ SOURCES += main.cpp \ ui/panelsliderbar.cpp \ map/friendgroupitem.cpp \ map/frienditemshandler.cpp \ - gps/gpspositioninterface.cpp + gps/gpspositioninterface.cpp \ + ui/zoombuttonpanel.cpp HEADERS += ui/mainwindow.h \ ui/mapviewscreen.h \ map/mapengine.h \ @@ -49,8 +48,6 @@ HEADERS += ui/mainwindow.h \ map/maptile.h \ map/mapfetcher.h \ map/mapcommon.h \ - map/mapzoompanel.h \ - map/mapbutton.h \ map/ownlocationitem.h \ map/baselocationitem.h \ map/friendlocationitem.h \ @@ -79,6 +76,7 @@ HEADERS += ui/mainwindow.h \ map/friendgroupitem.h \ map/frienditemshandler.h \ gps/gpspositioninterface.h \ + ui/zoombuttonpanel.h \ situarecommon.h QT += network \ webkit diff --git a/src/ui/friendlistitem.cpp b/src/ui/friendlistitem.cpp index ee7e8eb..e3e5996 100644 --- a/src/ui/friendlistitem.cpp +++ b/src/ui/friendlistitem.cpp @@ -123,7 +123,8 @@ FriendListItem::FriendListItem(QWidget *parent) m_backgroundMiddleImage.load(":/res/images/list_item_middle.png"); m_backgroundBottomImage.load(":/res/images/list_item_bottom.png"); - connect(m_findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); + connect(m_findButton, SIGNAL(clicked()), + this, SLOT(findButtonClicked())); } void FriendListItem::setData(User *user) diff --git a/src/ui/friendlistpanel.cpp b/src/ui/friendlistpanel.cpp index 47e4b8e..27e2814 100644 --- a/src/ui/friendlistpanel.cpp +++ b/src/ui/friendlistpanel.cpp @@ -83,7 +83,8 @@ void FriendListPanel::friendInfoReceived(QList &friendList) foreach (User *user, friendList) { FriendListItem *item = new FriendListItem(m_friendListView); item->setData(user); - connect(item, SIGNAL(findFriend(QPointF)), this, SIGNAL(findFriend(QPointF))); + connect(item, SIGNAL(findFriend(QPointF)), + this, SIGNAL(findFriend(QPointF))); m_friendListView->addWidget(item); } } diff --git a/src/ui/imagebutton.cpp b/src/ui/imagebutton.cpp index 7a9f003..0c3bf40 100644 --- a/src/ui/imagebutton.cpp +++ b/src/ui/imagebutton.cpp @@ -50,20 +50,20 @@ void ImageButton::mousePressEvent(QMouseEvent *event) { qDebug() << __PRETTY_FUNCTION__; - QAbstractButton::mousePressEvent(event); - - m_buttonMode = QIcon::Selected; - update(); + if(m_buttonMode != QIcon::Disabled) { + QAbstractButton::mousePressEvent(event); + setMode(QIcon::Selected); + } } void ImageButton::mouseReleaseEvent(QMouseEvent *event) { qDebug() << __PRETTY_FUNCTION__; - QAbstractButton::mouseReleaseEvent(event); - - m_buttonMode = QIcon::Normal; - update(); + if(m_buttonMode != QIcon::Disabled) { + QAbstractButton::mouseReleaseEvent(event); + setMode(QIcon::Normal); + } } void ImageButton::paintEvent(QPaintEvent *event) @@ -75,3 +75,11 @@ void ImageButton::paintEvent(QPaintEvent *event) QPainter painter(this); icon().paint(&painter, this->rect(), NULL, m_buttonMode); } + +void ImageButton::setMode(QIcon::Mode mode) +{ + qDebug() << __PRETTY_FUNCTION__ << "Button icon mode:" << mode; + + m_buttonMode = mode; + update(); +} diff --git a/src/ui/imagebutton.h b/src/ui/imagebutton.h index b748d41..be7852e 100644 --- a/src/ui/imagebutton.h +++ b/src/ui/imagebutton.h @@ -30,52 +30,63 @@ #include /** -* @brief A simple class for icon button -* -* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com -*/ + * @brief A simple class for icon button + * + * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com + */ class ImageButton : public QPushButton { Q_OBJECT public: /** - * @brief Constructor - * - * @param parent Parent - * @param normalIconPictureFileName Normal state Icon image file name - * @param selectedIconPictureFileName Selected state Icon image file name (optional) - */ + * @brief Constructor + * + * @param parent Parent + * @param normalIconPictureFileName Normal state Icon image file name + * @param selectedIconPictureFileName Selected state Icon image file name (optional) + */ ImageButton(QWidget *parent = 0, QString normalIconPictureFileName = "", - QString selectedIconPictureFileName = ""); + QString selectedIconPictureFileName = ""); /******************************************************************************* * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS ******************************************************************************/ protected: /** - * @brief Event handler for mouse press events - * - * @param event Mouse event - */ + * @brief Event handler for mouse press events + * + * @param event Mouse event + */ void mousePressEvent(QMouseEvent *event); /** - * @brief Event handler for mouse release events - * - * @param event Mouse event - */ + * @brief Event handler for mouse release events + * + * @param event Mouse event + */ void mouseReleaseEvent(QMouseEvent *event); /** - * @brief Event handler for paint events - * - * Paints the button and its icon - * @param event Paint event - */ + * @brief Event handler for paint events + * + * Paints the button and its icon + * @param event Paint event + */ void paintEvent(QPaintEvent *event); /******************************************************************************* + * MEMBER FUNCTIONS AND SLOTS + ******************************************************************************/ +public: + /** + * @brief Sets the button icon mode + * + * @param mode Button icon mode + */ + void setMode(QIcon::Mode mode); + +/******************************************************************************* * DATA MEMBERS ******************************************************************************/ private: diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index f9ba87c..46c04d5 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -57,8 +57,8 @@ MainWindow::MainWindow(QWidget *parent) connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString))); - connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this, - SIGNAL(statusUpdate(QString,bool))); + connect(m_locationDialog, SIGNAL(statusUpdate(QString, bool)), + this, SIGNAL(statusUpdate(QString, bool))); connect(this, SIGNAL(userLocationReady(User*)), m_mapViewScreen, SIGNAL(userLocationReady(User*))); @@ -69,7 +69,8 @@ MainWindow::MainWindow(QWidget *parent) m_mapViewScreen, SLOT(enableAutoCentering(bool))); connect(this, SIGNAL(positionReceived(QPointF, qreal)), m_mapViewScreen, SLOT(positionReceived(QPointF, qreal))); - connect(m_mapViewScreen, SIGNAL(mapLocationChanged()), this, SLOT(mapLocationChanged())); + connect(m_mapViewScreen, SIGNAL(mapLocationChanged()), + this, SLOT(mapLocationChanged())); connect(this, SIGNAL(zoomInKeyPressed()), m_mapViewScreen, SIGNAL(zoomInKeyPressed())); @@ -107,17 +108,20 @@ void MainWindow::createMenus() m_toSettingsAct = new QAction(tr("Settings"), this); m_toSettingsAct->setObjectName(tr("Settings")); - connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog())); - m_gpsToggleAct = new QAction(tr("GPS"), this); + connect(m_toSettingsAct, SIGNAL(triggered()), + this, SLOT(openSettingsDialog())); + m_gpsToggleAct = new QAction(tr("GPS"), this); m_gpsToggleAct->setCheckable(true); m_gpsToggleAct->setChecked(true); - connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsToggled(bool))); + connect(m_gpsToggleAct, SIGNAL(toggled(bool)), + this, SLOT(gpsActionToggled(bool))); m_autoCenteringAct = new QAction(tr("Auto centering"), this); m_autoCenteringAct->setCheckable(true); m_autoCenteringAct->setChecked(true); - connect(m_autoCenteringAct, SIGNAL(toggled(bool)), this, SLOT(autoCenteringToggled(bool))); - - m_viewMenu = menuBar()->addMenu(tr("Main")); + connect(m_autoCenteringAct, SIGNAL(toggled(bool)), + this, SLOT(autoCenteringToggled(bool))); + + m_viewMenu = menuBar()->addMenu(tr("Main")); m_viewMenu->addAction(m_toSettingsAct); m_viewMenu->addAction(m_gpsToggleAct); diff --git a/src/ui/mapviewscreen.cpp b/src/ui/mapviewscreen.cpp index 3f0eeee..c9dff1c 100644 --- a/src/ui/mapviewscreen.cpp +++ b/src/ui/mapviewscreen.cpp @@ -20,12 +20,8 @@ */ #include "mapviewscreen.h" -#include "../map/mapview.h" -#include "../map/mapengine.h" -#include "friendlistpanel.h" -#include "userpanel.h" +#include "map/mapview.h" #include "panelcommon.h" - #include "panelsidebar.h" MapViewScreen::MapViewScreen(QWidget *parent) @@ -33,76 +29,85 @@ MapViewScreen::MapViewScreen(QWidget *parent) m_autoCenteringEnabled(false) { MapView *mapView = new MapView(this); - mapEngine = new MapEngine(this); - mapView->setScene(mapEngine->scene()); + m_mapEngine = new MapEngine(this); + mapView->setScene(m_mapEngine->scene()); - FriendListPanel *friendsListPanel = new FriendListPanel(this); - UserInfoPanel *userPanel = new UserInfoPanel(this); + m_friendsListPanel = new FriendListPanel(this); + m_userPanel = new UserInfoPanel(this); PanelSideBar *userPanelSidebar = new PanelSideBar(this, LEFT); PanelSideBar *friendsListPanelSidebar = new PanelSideBar(this, RIGHT); + m_zoomButtonPanel = new ZoomButtonPanel(this, ZOOM_BUTTON_PANEL_POSITION_X, + ZOOM_BUTTON_PANEL_POSITION_Y); + connect(mapView, SIGNAL(viewScrolled(QPoint)), - mapEngine, SLOT(setLocation(QPoint))); - connect(mapEngine, SIGNAL(locationChanged(QPoint)), + m_mapEngine, SLOT(setLocation(QPoint))); + connect(m_mapEngine, SIGNAL(locationChanged(QPoint)), mapView, SLOT(centerToSceneCoordinates(QPoint))); - connect(mapEngine, SIGNAL(zoomLevelChanged(int)), + connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)), mapView, SLOT(setZoomLevel(int))); connect(mapView, SIGNAL(viewResized(QSize)), - mapEngine, SLOT(viewResized(QSize))); + m_mapEngine, SLOT(viewResized(QSize))); connect(mapView, SIGNAL(viewContentChanged(QPoint)), - mapEngine, SLOT(alignImmovableItems(QPoint))); + m_mapEngine, SLOT(alignImmovableItems(QPoint))); connect(mapView, SIGNAL(viewZoomFinished()), - mapEngine, SLOT(viewZoomFinished())); + m_mapEngine, SLOT(viewZoomFinished())); connect(this, SIGNAL(zoomInKeyPressed()), - mapEngine, SLOT(zoomIn())); + m_mapEngine, SLOT(zoomIn())); connect(this, SIGNAL(zoomOutKeyPressed()), - mapEngine, SLOT(zoomOut())); + m_mapEngine, SLOT(zoomOut())); - connect(mapView, SIGNAL(viewResizedNewSize(int,int)), + connect(mapView, SIGNAL(viewResizedNewSize(int, int)), this, SLOT(drawOsmLicense(int, int))); - - connect(mapView, SIGNAL(viewResizedNewSize(int,int)), - friendsListPanel, SLOT(reDrawFriendsPanel(int,int))); - connect(mapView, SIGNAL(viewResizedNewSize(int,int)), - userPanel, SLOT(reDrawUserPanel(int,int))); - connect(mapView, SIGNAL(viewResizedNewSize(int,int)), - friendsListPanelSidebar, SLOT(reDrawSidebar(int,int))); + connect(mapView, SIGNAL(viewResizedNewSize(int, int)), + m_friendsListPanel, SLOT(reDrawFriendsPanel(int, int))); + connect(mapView, SIGNAL(viewResizedNewSize(int, int)), + m_userPanel, SLOT(reDrawUserPanel(int, int))); + connect(mapView, SIGNAL(viewResizedNewSize(int, int)), + friendsListPanelSidebar, SLOT(reDrawSidebar(int, int))); + + connect(m_zoomButtonPanel->m_zoomInBtn, SIGNAL(clicked()), + m_mapEngine, SLOT(zoomIn())); + connect(m_zoomButtonPanel->m_zoomOutBtn, SIGNAL(clicked()), + m_mapEngine, SLOT(zoomOut())); connect(this, SIGNAL(friendsLocationsReady(QList&)), - friendsListPanel, SLOT(friendInfoReceived(QList&))); - connect(friendsListPanel, SIGNAL(findFriend(QPointF)), - mapEngine, SLOT(setViewLocation(QPointF))); + m_friendsListPanel, SLOT(friendInfoReceived(QList&))); + connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)), + m_mapEngine, SLOT(setViewLocation(QPointF))); connect(this, SIGNAL(userLocationReady(User*)), - mapEngine, SLOT(receiveOwnLocation(User*))); + m_mapEngine, SLOT(receiveOwnLocation(User*))); connect(this, SIGNAL(friendsLocationsReady(QList&)), - mapEngine, SIGNAL(friendsLocationsReady(QList&))); + m_mapEngine, SIGNAL(friendsLocationsReady(QList&))); - connect(mapEngine, SIGNAL(mapScrolled()), this, SLOT(locationChanged())); + connect(m_mapEngine, SIGNAL(mapScrolled()), + this, SLOT(locationChanged())); QHBoxLayout *mapViewLayout = new QHBoxLayout; - osmLicense = new QLabel(this); - osmLicense->setAttribute(Qt::WA_TranslucentBackground, true); - osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true); - osmLicense->setText(""+OSM_LICENSE+""); - osmLicense->setFont(QFont("Nokia Sans", 9)); - osmLicense->resize(osmLicense->fontMetrics().width(OSM_LICENSE), - osmLicense->fontMetrics().height()); - - friendsListPanel->stackUnder(friendsListPanelSidebar); - userPanelSidebar->stackUnder(friendsListPanel); - userPanel->stackUnder(userPanelSidebar); - osmLicense->stackUnder(userPanel); - mapView->stackUnder(osmLicense); + m_osmLicense = new QLabel(this); + m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true); + m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true); + m_osmLicense->setText("" + OSM_LICENSE + ""); + m_osmLicense->setFont(QFont("Nokia Sans", 9)); + m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE), + m_osmLicense->fontMetrics().height()); + + m_friendsListPanel->stackUnder(friendsListPanelSidebar); + userPanelSidebar->stackUnder(m_friendsListPanel); + m_userPanel->stackUnder(userPanelSidebar); + m_zoomButtonPanel->stackUnder(m_userPanel); + m_osmLicense->stackUnder(m_zoomButtonPanel); + mapView->stackUnder(m_osmLicense); mapViewLayout->addWidget(mapView); setLayout(mapViewLayout); mapViewLayout->setMargin(0); - mapEngine->init(); + m_mapEngine->init(); setObjectName("Map view"); } @@ -110,8 +115,8 @@ MapViewScreen::MapViewScreen(QWidget *parent) void MapViewScreen::drawOsmLicense(int width, int height) { qDebug() << __PRETTY_FUNCTION__ << width << "x" << height; - osmLicense->move(width - osmLicense->fontMetrics().width(OSM_LICENSE) - PANEL_PEEK_AMOUNT, - height - osmLicense->fontMetrics().height()); + m_osmLicense->move(width - m_osmLicense->fontMetrics().width(OSM_LICENSE) - PANEL_PEEK_AMOUNT, + height - m_osmLicense->fontMetrics().height()); } void MapViewScreen::locationChanged() @@ -127,7 +132,7 @@ void MapViewScreen::positionReceived(QPointF position, qreal accuracy) qDebug() << __PRETTY_FUNCTION__; if (m_autoCenteringEnabled) - mapEngine->setViewLocation(position); + m_mapEngine->setViewLocation(position); } void MapViewScreen::enableAutoCentering(bool enabled) @@ -135,5 +140,5 @@ void MapViewScreen::enableAutoCentering(bool enabled) qDebug() << __PRETTY_FUNCTION__; m_autoCenteringEnabled = enabled; - mapEngine->setAutoCentering(enabled); + m_mapEngine->setAutoCentering(enabled); } diff --git a/src/ui/mapviewscreen.h b/src/ui/mapviewscreen.h index d9a3de9..e5959a3 100644 --- a/src/ui/mapviewscreen.h +++ b/src/ui/mapviewscreen.h @@ -28,6 +28,7 @@ #include "map/mapengine.h" #include "friendlistpanel.h" #include "userpanel.h" +#include "zoombuttonpanel.h" /** * @brief Map View class. Used to display Map @@ -50,7 +51,6 @@ public: * MEMBER FUNCTIONS AND SLOTS ******************************************************************************/ private slots: - /** * @brief Slot for enabling auto centering. * @@ -118,11 +118,12 @@ signals: * 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 - UserInfoPanel *userPanel; ///< Instance of the user information panel + 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 }; #endif // MAPVIEWTAB_H diff --git a/src/ui/panelcommon.h b/src/ui/panelcommon.h index 97bed57..17a330d 100644 --- a/src/ui/panelcommon.h +++ b/src/ui/panelcommon.h @@ -25,7 +25,6 @@ #include #include "map/mapcommon.h" - enum Side{LEFT, RIGHT}; ///< Enumerator for panel sideness const int PANEL_PEEK_AMOUNT = 25; ///< Amount of pixels shown when panel is closed @@ -58,4 +57,8 @@ const int SIDEBAR_HEIGHT = 424; const int SLIDINGBAR_WIDTH = 24; const int SLIDINGBAR_HEIGHT = 424; +const int ZOOM_BUTTON_PANEL_POSITION_X = 10 + PANEL_PEEK_AMOUNT; ///< Horizontal position of zoom panel +const int ZOOM_BUTTON_PANEL_POSITION_Y = 10; ///< Vertical position of zoom panel +const int ZOOM_BUTTON_PANEL_BUTTON_SPACING = 4; ///< Size of a zoom button spacing + #endif // PANELCOMMON_H diff --git a/src/ui/panelsidebar.h b/src/ui/panelsidebar.h index c1293af..0550b64 100644 --- a/src/ui/panelsidebar.h +++ b/src/ui/panelsidebar.h @@ -35,7 +35,6 @@ class PanelSideBar : public QWidget { Q_OBJECT - public: /** * @brief Constructor diff --git a/src/ui/zoombuttonpanel.cpp b/src/ui/zoombuttonpanel.cpp new file mode 100644 index 0000000..59b0327 --- /dev/null +++ b/src/ui/zoombuttonpanel.cpp @@ -0,0 +1,48 @@ +/* + Situare - A location system for Facebook + Copyright (C) 2010 Ixonos Plc. Authors: + + Pekka Nissinen - pekka.nissinen@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 +#include + +#include "zoombuttonpanel.h" +#include "panelcommon.h" + +ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y) + : QWidget(parent), + m_panelLayout(this), + m_x(x), + m_y(y) +{ + qDebug() << __PRETTY_FUNCTION__; + + m_zoomInBtn = new ImageButton(this, ":/res/images/zoom_in.png"); + m_zoomOutBtn = 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); + + move(m_x, m_y); +} diff --git a/src/ui/zoombuttonpanel.h b/src/ui/zoombuttonpanel.h new file mode 100644 index 0000000..c55d593 --- /dev/null +++ b/src/ui/zoombuttonpanel.h @@ -0,0 +1,64 @@ +/* + Situare - A location system for Facebook + Copyright (C) 2010 Ixonos Plc. Authors: + + Pekka Nissinen - pekka.nissinen@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 ZOOMBUTTONPANEL_H +#define ZOOMBUTTONPANEL_H + +#include +#include +#include +#include + +#include "imagebutton.h" + +/** +* @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 + */ + ZoomButtonPanel(QWidget *parent = 0, int x = 0, int y = 0); + +/******************************************************************************* + * DATA MEMBERS + ******************************************************************************/ +public: + ImageButton *m_zoomInBtn; ///< Button for zoom in + ImageButton *m_zoomOutBtn; ///< Button for zoom out + +private: + QGridLayout m_panelLayout; ///< Panel layout + int m_x; ///< Panel x coordinate + int m_y; ///< Panel y coordinate +}; + +#endif // ZOOMBUTTONPANEL_H