connect(m_ui, SIGNAL(searchForLocation(QString)),
this, SLOT(locationSearch(QString)));
+
+ connect(m_ui, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
+ m_mapEngine, SLOT(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
}
void SituareEngine::signalsFromMapEngine()
qDebug() << __PRETTY_FUNCTION__ << "distance:" << m_route.totalDistance();
qDebug() << __PRETTY_FUNCTION__ << "estimated time:" << m_route.totalTime();
- foreach (QPointF point, m_route.geometryPoints())
- qDebug() << __PRETTY_FUNCTION__ << "geometry point:" << point.x() << point.y();
+ foreach (GeoCoordinate point, m_route.geometryPoints())
+ qDebug() << __PRETTY_FUNCTION__ << "geometry point:" << point;
foreach (RouteSegment segment, m_route.segments()) {
qDebug() << __PRETTY_FUNCTION__ << "segment:" << segment.instruction();
zoomed();
}
}
+
+void MapEngine::locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ centerAndZoomTo(QRect(SceneCoordinate(swBound).toPointF().toPoint(),
+ SceneCoordinate(neBound).toPointF().toPoint()));
+}
*/
void zoomOut();
+ void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+
/*******************************************************************************
* SIGNALS
******************************************************************************/
pen.setColor(LINE_COLOR);
pen.setCosmetic(true);
- QList<QPointF> points = route->geometryPoints();
+ QList<GeoCoordinate> points = route->geometryPoints();
for (int i = 1; i < points.count(); i++) {
- GeoCoordinate begin = GeoCoordinate(points.at(i - 1).y(), points.at(i - 1).x());
- SceneCoordinate sceneBegin = SceneCoordinate(begin);
- GeoCoordinate end = GeoCoordinate(points.at(i).y(), points.at(i).x());
- SceneCoordinate sceneEnd = SceneCoordinate(end);
- QGraphicsLineItem *line = new QGraphicsLineItem(QLineF(sceneBegin.toPointF(),
- sceneEnd.toPointF()));
+ SceneCoordinate begin = SceneCoordinate(points.at(i - 1));
+ SceneCoordinate end = SceneCoordinate(points.at(i));
+ QGraphicsLineItem *line = new QGraphicsLineItem(QLineF(begin.toPointF(),
+ end.toPointF()));
line->setPen(pen);
addToGroup(line);
}
*/
#include <QDebug>
+#include <QStringList>
#include "routingcommon.h"
#include "location.h"
Location::Location()
- : m_postalCode(0),
- m_streetNumber(0)
{
qDebug() << __PRETTY_FUNCTION__;
}
-const GeoCoordinate& Location::coordinates() const
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_coordinates;
-}
-
-const QString& Location::country() const
+QStringList Location::addressComponents()
{
qDebug() << __PRETTY_FUNCTION__;
- return m_country;
-}
+ QStringList list = m_formattedAddress.split(",");
+ QStringList trimmedList;
-const QString& Location::formattedAddress() const
-{
- qDebug() << __PRETTY_FUNCTION__;
+ foreach(QString str, list) {
+ trimmedList.append(str.trimmed());
+ }
- return m_formattedAddress;
+ return trimmedList;
}
-const QString& Location::locality() const
+void Location::bounds(GeoCoordinate &swBound, GeoCoordinate &neBound)
{
qDebug() << __PRETTY_FUNCTION__;
- return m_locality;
+ swBound = m_swBound;
+ neBound = m_neBound;
}
-const QString& Location::locationType() const
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_locationType;
-}
-
-int Location::postalCode() const
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_postalCode;
-}
-
-const QString& Location::street() const
+const GeoCoordinate& Location::coordinates() const
{
qDebug() << __PRETTY_FUNCTION__;
- return m_street;
+ return m_coordinates;
}
-int Location::streetNumber() const
+const QString& Location::formattedAddress() const
{
qDebug() << __PRETTY_FUNCTION__;
- return m_streetNumber;
+ return m_formattedAddress;
}
void Location::setCoordinates(double latitude, double longitude)
m_coordinates = GeoCoordinate(latitude, longitude);
}
-void Location::setCountry(QString country)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_country = country;
-}
-
void Location::setFormattedAddress(QString formattedAddress)
{
qDebug() << __PRETTY_FUNCTION__;
m_formattedAddress = formattedAddress;
}
-void Location::setLocality(QString locality)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_locality = locality;
-}
-
-void Location::setLocationType(QString locationType)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_locationType = locationType;
-}
-
-void Location::setPostalCode(int postalCode)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_postalCode = postalCode;
-}
-
-void Location::setStreet(QString street)
+void Location::setNEBound(double latitude, double longitude)
{
qDebug() << __PRETTY_FUNCTION__;
- m_street = street;
+ m_neBound = GeoCoordinate(latitude, longitude);
}
-void Location::setStreetNumber(int streetNumber)
+void Location::setSWBound(double latitude, double longitude)
{
qDebug() << __PRETTY_FUNCTION__;
- m_streetNumber = streetNumber;
+ m_swBound = GeoCoordinate(latitude, longitude);
}
Location();
/**
- * @brief Gets the coordinates of the location
+ * @brief Gets the address components of the location
*
- * @returns coordinates of the location
+ * @returns list of address components
*/
- const GeoCoordinate& coordinates() const;
+ QStringList addressComponents();
/**
- * @brief Gets the country of the location
+ * @brief Gets the bounds of the location
*
- * @returns country of the location
+ * @param swBound coordinates of the southwest bound
+ * @param neBound coordinates of the northeast bound
*/
- const QString& country() const;
+ void bounds(GeoCoordinate &swBound, GeoCoordinate &neBound);
/**
- * @brief Gets the formatted address of the location
- * e.g. Oxford street 1, London W1, United kingdom
+ * @brief Gets the coordinates of the location
*
* @returns coordinates of the location
*/
- const QString& formattedAddress() const;
-
- /**
- * @brief Gets the locality (city) of the location
- *
- * @returns locality of the location
- */
- const QString& locality() const;
-
- /**
- * @brief Gets the location type of the location
- * e.g. street_address
- *
- * @returns locationType of the location
- */
- const QString& locationType() const;
-
- /**
- * @brief Gets the postal code of the location
- *
- * @returns postalCode of the location (or zero)
- */
- int postalCode() const;
-
- /**
- * @brief Gets the street of the location
- *
- * @returns street of the location (or empty QString)
- */
- const QString& street() const;
+ const GeoCoordinate& coordinates() const;
/**
- * @brief Gets the street number of the location
+ * @brief Gets the formatted address of the location
+ * e.g. Oxford street 1, London W1, United kingdom
*
- * @returns streetNumber of the location (or zero)
+ * @returns coordinates of the location
*/
- int streetNumber() const;
+ const QString& formattedAddress() const;
/**
* @brief Sets the coordinates of the location
void setCoordinates(double latitude, double longitude);
/**
- * @brief Sets the country of the location
- *
- */
- void setCountry(QString country);
-
- /**
* @brief Sets the formatted address of the location
*
*/
void setFormattedAddress(QString formattedAddress);
/**
- * @brief Sets the locality of the location
- *
- */
- void setLocality(QString locality);
-
- /**
- * @brief Sets the location type of the location
- *
- */
- void setLocationType(QString locationType);
-
- /**
- * @brief Sets the postal code of the location
- *
- */
- void setPostalCode(int postalCode);
-
- /**
- * @brief Sets the street of the location
+ * @brief Sets the northeast bound of the location
+ * creates GeoCoordinate object from given parameters
*
+ * @param latitude latitude value (double)
+ * @param longitude longitude value (double)
*/
- void setStreet(QString street);
+ void setNEBound(double latitude, double longitude);
/**
- * @brief Sets the street number of the location
+ * @brief Sets the southwest bound of the location
+ * creates GeoCoordinate object from given parameters
*
+ * @param latitude latitude value (double)
+ * @param longitude longitude value (double)
*/
- void setStreetNumber(int streetNumber);
+ void setSWBound(double latitude, double longitude);
private:
- int m_postalCode; ///< Placeholder for postal code
- int m_streetNumber; ///< Placeholder for street number
-
- QString m_country; ///< Placeholder for county
QString m_formattedAddress; ///< Placeholder for formatted address
- QString m_locality; ///< Placeholcer for locality
- QString m_locationType; ///< Placeholcer for location type
- QString m_street; ///< Placeholcer for street
GeoCoordinate m_coordinates; ///< Placeholcer for coordinates
+ GeoCoordinate m_neBound; ///< Placeholder for northeast bound
+ GeoCoordinate m_swBound; ///< Placeholder for southwest bound
};
#endif // LOCATION_H
qDebug() << __PRETTY_FUNCTION__;
}
-void Route::appendGeometryPoint(QPointF geometryPoint)
+void Route::appendGeometryPoint(GeoCoordinate geometryPoint)
{
qDebug() << __PRETTY_FUNCTION__;
return m_endPointName;
}
-const QList<QPointF>& Route::geometryPoints() const
+const QList<GeoCoordinate>& Route::geometryPoints() const
{
qDebug() << __PRETTY_FUNCTION__;
#define ROUTE_H
#include <QList>
-#include <QPointF>
#include <QString>
+#include "coordinates/geocoordinate.h"
#include "routesegment.h"
/**
*
* @param geometryPoint Geometry point
*/
- void appendGeometryPoint(QPointF geometryPoint);
+ void appendGeometryPoint(GeoCoordinate geometryPoint);
/**
* @brief Append a route segment to the route
*
* @returns Reference to list of geometry points
*/
- const QList<QPointF>& geometryPoints() const;
+ const QList<GeoCoordinate>& geometryPoints() const;
/**
* @brief Get list of route segments
int m_totalDistance; ///< route total distance in meters
int m_totalTime; ///< estimated route total time in seconds
- QList<QPointF> m_geometryPoints; ///< lat/lon coordinates of the route points
+ QList<GeoCoordinate> m_geometryPoints; ///< lat/lon coordinates of the route points
QList<RouteSegment> m_segments; ///< route segments
QString m_endPointName; ///< name of the route end point
#include <QtGlobal>
#include <QStringList>
#include <QNetworkReply>
-#include <QPointF>
#include <QCryptographicHash>
#if defined(Q_WS_MAEMO_5) & defined(ARMEL)
#endif
#include "common.h"
-#include "network/networkaccessmanager.h"
+#include "coordinates/geocoordinate.h"
#include "parser.h"
#include "location.h"
+#include "network/networkaccessmanager.h"
#include "route.h"
#include "routesegment.h"
foreach(QVariant routeGeometry, result["route_geometry"].toList()) {
QStringList list = routeGeometry.toStringList();
- route.appendGeometryPoint(QPointF(list.at(1).toDouble(), list.at(0).toDouble()));
+ route.appendGeometryPoint(GeoCoordinate(list.at(0).toDouble(),
+ list.at(1).toDouble()));
}
foreach(QVariant routeInstructions, result["route_instructions"].toList()) {
foreach(QVariant hitVariant, result["results"].toList()) {
Location location;
QMap<QString, QVariant> hitMap = hitVariant.toMap();
- foreach(QVariant hitTypeVariant, hitMap["types"].toList()) {
- QStringList hitTypeList = hitTypeVariant.toStringList();
- foreach(QString hitType, hitTypeList) {
- if(hitType != "political")
- location.setLocationType(hitType);
- }
- }
+
location.setFormattedAddress(hitMap["formatted_address"].toString());
- foreach(QVariant addrComponent, hitMap["address_components"].toList()) {
- QMap<QString, QVariant> addrComponentMap = addrComponent.toMap();
- foreach(QVariant addrType, addrComponentMap["types"].toList()) {
- QStringList addrTypeList = addrType.toStringList();
- foreach(QString type, addrTypeList) {
- if(type == "street_number")
- location.setStreetNumber(addrComponentMap["long_name"].toInt());
- else if(type == "route")
- location.setStreet(addrComponentMap["long_name"].toString());
- else if(type == "locality")
- location.setLocality(addrComponentMap["long_name"].toString());
- else if(type == "country")
- location.setCountry(addrComponentMap["long_name"].toString());
- else if(type == "postal_code")
- location.setPostalCode(addrComponentMap["long_name"].toInt());
- }
- }
- }
+
QVariant geometryVariant = hitMap["geometry"];
QMap<QString, QVariant> geometryMap = geometryVariant.toMap();
QVariant locationVariant = geometryMap["location"];
location.setCoordinates(locationMap["lat"].toDouble(),
locationMap["lng"].toDouble());
+ QVariant boundsVariant = geometryMap["bounds"];
+ QMap<QString, QVariant> boundsMap = boundsVariant.toMap();
+ QVariant swVariant = boundsMap["southwest"];
+ QMap<QString, QVariant> swMap = swVariant.toMap();
+ location.setSWBound(swMap["lat"].toDouble(),
+ swMap["lng"].toDouble());
+ QVariant neVariant = boundsMap["northeast"];
+ QMap<QString, QVariant> neMap = neVariant.toMap();
+ location.setNEBound(neMap["lat"].toDouble(),
+ neMap["lng"].toDouble());
+
m_searchResults.append(location);
}
emit locationDataParsed(m_searchResults);
sendRequest(url);
}
-void RoutingService::requestRoute(QPointF from, QPointF to)
+void RoutingService::requestRoute(GeoCoordinate from, GeoCoordinate to)
{
qDebug() << __PRETTY_FUNCTION__;
QString url = "http://routes.cloudmade.com/";
url.append(CLOUDMADE_API_KEY);
url.append("/api/0.3/");
- url.append(QString::number(from.x()) + "," + QString::number(from.y()) + ",");
- url.append(QString::number(to.x()) + "," + QString::number(to.y()));
+ url.append(QString::number(from.latitude()) + "," + QString::number(from.longitude()) + ",");
+ url.append(QString::number(to.latitude()) + "," + QString::number(to.longitude()));
url.append("/car/fastest.js?lang=en&units=km&token=");
if(m_token.isEmpty()) {
class QNetworkRequest;
class QUrl;
+class GeoCoordinate;
+
/**
* @brief RoutingService class for communicating with CloudMade server
* and parsing routing data
* @param from Start point of the route
* @param to End point of the route
*/
- void requestRoute(QPointF from, QPointF to);
+ void requestRoute(GeoCoordinate from, GeoCoordinate to);
/**
* @brief Request location information from the server
{
qDebug() << __PRETTY_FUNCTION__;
+ QString urlParameters = formUrlParameters(coordinates, status, publish);
+ QUrl url = formUrl(SITUARE_URL, UPDATE_LOCATION, urlParameters);
+
QString cookie = formCookie(API_KEY, m_credentials.expires(), m_credentials.userID(),
m_credentials.sessionKey(), m_credentials.sessionSecret(),
m_credentials.sig(), EN_LOCALE);
-
- QString publishValue;
- if(publish) {
- publishValue = PUBLISH_TRUE;
- }
- else {
- publishValue = PUBLISH_FALSE;
- }
- QString urlParameters = formUrlParameters(coordinates, status, publishValue);
- QUrl url = formUrl(SITUARE_URL, UPDATE_LOCATION, urlParameters);
-
sendRequest(url, COOKIE, cookie);
}
}
QString SituareService::formUrlParameters(const GeoCoordinate &coordinates, QString status,
- QString publish)
+ bool publish)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ // one scene pixel is about 5.4e-6 degrees, the integer part is max three digits and one
+ // additional digit is added for maximum precision
+ const int COORDINATE_PRECISION = 10;
+
QString parameters;
parameters.append(QUESTION_MARK);
parameters.append(LATITUDE);
parameters.append(EQUAL_MARK);
- parameters.append(QString::number(coordinates.latitude()));
+ parameters.append(QString::number(coordinates.latitude(), 'f', COORDINATE_PRECISION));
parameters.append(AMBERSAND_MARK);
parameters.append(LONGTITUDE);
parameters.append(EQUAL_MARK);
- parameters.append(QString::number(coordinates.longitude()));
+ parameters.append(QString::number(coordinates.longitude(), 'f', COORDINATE_PRECISION));
- if(publish.compare(PUBLISH_TRUE) == 0) {
- parameters.append(AMBERSAND_MARK);
- parameters.append(PUBLISH);
- parameters.append(EQUAL_MARK);
+ parameters.append(AMBERSAND_MARK);
+ parameters.append(PUBLISH);
+ parameters.append(EQUAL_MARK);
+
+ if(publish)
parameters.append(PUBLISH_TRUE);
- } else if(publish.compare(PUBLISH_FALSE) == 0) {
- parameters.append(AMBERSAND_MARK);
- parameters.append(PUBLISH);
- parameters.append(EQUAL_MARK);
+ else
parameters.append(PUBLISH_FALSE);
- }
if(!status.isEmpty()) {
parameters.append(AMBERSAND_MARK);
*
* @param coordinates current cordinates
* @param status message
- * @param publish publish location on Facebook wall (true/false)
+ * @param publish publish location on Facebook wall
*/
void updateLocation(const GeoCoordinate &coordinates, const QString &status, const bool &publish);
*
* @param coordinates current coordinates
* @param status optional status message
- * @param publish optional publish location on Facebook wall (true/false)
+ * @param publish optional publish location on Facebook wall
* @return QString
*/
QString formUrlParameters(const GeoCoordinate &coordinates, QString status = QString(),
- QString publish = QString());
+ bool publish = false);
/**
* @brief Parses user and friend data from JSON string
ui/locationlistitem.cpp \
ui/extendedlistitem.cpp \
ui/extendedlistitemstore.cpp \
- ui/extendedlistitemdelegate.cpp
+ ui/extendedlistitemdelegate.cpp \
+ ui/locationlistview.cpp
HEADERS += application.h \
common.h \
engine/engine.h \
ui/locationlistitem.h \
ui/extendedlistitem.h \
ui/extendedlistitemstore.h \
- ui/extendedlistitemdelegate.h
+ ui/extendedlistitemdelegate.h \
+ ui/locationlistview.h
QT += network \
webkit
#include "sidepanel.h"
#include "../routing/location.h"
#include "locationlistitem.h"
+#include "locationlistview.h"
#include "extendedlistitemdelegate.h"
#include "friendlistpanel.h"
//REMOVE
m_friendListView->hide();
- m_locationListView = new ListView(this);
+ m_locationListView = new LocationListView(this);
m_locationListView->setAutoFillBackground(false);
m_locationListView->viewport()->setAutoFillBackground(false);
m_locationListView->setItemDelegate(new ExtendedListItemDelegate());
this, SLOT(clearFriendListFilter()));
connect(this, SIGNAL(panelOpened()),
this, SLOT(clearFriendListFilter()));
+
+ connect(m_locationListView, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
+ this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
}
void FriendListPanel::friendImageReady(User *user)
{
qWarning() << __PRETTY_FUNCTION__;
+ m_locationListView->clearList();
+
for (int i = 0; i < result.size(); ++i) {
LocationListItem *item = new LocationListItem();
item->setLocationData(result.at(i));
class ListView;
class User;
class Location;
+class LocationListView;
/**
* @brief Class for sliding friends list panel
*/
void findFriend(const GeoCoordinate &coordinates);
+ void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
QLabel *m_friendListLabel; ///< Friend list label
QPushButton *m_clearFilterButton; ///< Button to clear list filtering
ListView *m_friendListView; ///< Friend list view
- ListView *m_locationListView;
+ LocationListView *m_locationListView;
FriendListItemDelegate *m_friendListItemDelegate; ///< Friend list item delegate
};
- /*
+/*
Situare - A location system for Facebook
Copyright (C) 2010 Ixonos Plc. Authors:
Kaj Wallin - kaj.wallin@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
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 <QPainter>
-#include "fullscreenbutton.h"
#include "math.h"
-const int ROUNDING_RADIUS = 5; ///< Roundness of the rounded edge
-const qreal OPACITY = 0.13; ///< Opacity of the background in percents
+#include "fullscreenbutton.h"
+
+const int ROUNDING_ARC_START_ANGLE = 90; ///< Start angle of the arc
+const int ROUNDING_ARC_LENGTH = 90; ///< Length of the arc (degree)
+const int ROUNDING_ARC_RADIUS = 5; ///< Roundness of the rounded edge
+
+const qreal OPACITY = 0.13; ///< Opacity of the background in percents
FullScreenButton::FullScreenButton(QWidget *parent) :
QToolButton(parent)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
setFixedSize(sizeHint());
- QPalette pal = palette();
- QColor backgroundColor = pal.color(backgroundRole());
- backgroundColor.setAlpha(floor(OPACITY * 255)); //
- pal.setColor(backgroundRole(), backgroundColor);
- setPalette(pal);
+ // Normal background
+ m_normalColor = new QColor(Qt::black);
+ m_normalColor->setAlpha(floor(OPACITY * 255));
+
+ // Selected bakcground
+ m_selectedGradient = new QLinearGradient(0, 0, 0, this->height());
+ m_selectedGradient->setColorAt(0.02, QColor(0, 113, 181));
+ m_selectedGradient->setColorAt(0.25, QColor(24, 142, 214));
+ m_selectedGradient->setColorAt(0.5, QColor(41, 162, 239));
+ m_selectedGradient->setColorAt(0.75, QColor(82, 195, 255));
+ m_selectedGradient->setColorAt(0.98, QColor(115, 215, 255));
+
+ // Item shape path
+ m_backgroundPath.moveTo(this->width(), 0); // Top right corner
+ m_backgroundPath.lineTo(ROUNDING_ARC_RADIUS, 0);
+ m_backgroundPath.arcTo(0, 0, ROUNDING_ARC_RADIUS * 2, ROUNDING_ARC_RADIUS * 2,
+ ROUNDING_ARC_START_ANGLE, ROUNDING_ARC_LENGTH);
+ m_backgroundPath.lineTo(0, this->height()); // Bottom left corner
+ m_backgroundPath.lineTo(width(), this->height()); // Bottom right corner
+ m_backgroundPath.closeSubpath(); // Back to the beginning
+}
+
+FullScreenButton::~FullScreenButton()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ delete m_normalColor;
+ delete m_selectedGradient;
+}
+
+void FullScreenButton::paintEvent(QPaintEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ Q_UNUSED(event);
- setAutoFillBackground(true);
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
- // Create mask to round the top left corner of the background
- QRegion maskbase(rect());
- QRegion cookiecutterbase(QRect(QPoint(0,0),QPoint(ROUNDING_RADIUS, ROUNDING_RADIUS)));
- QRegion cookiecuttersplice(QRect(0,0,2*ROUNDING_RADIUS, 2*ROUNDING_RADIUS),QRegion::Ellipse);
- QRegion cookiecutter = cookiecutterbase.subtract(cookiecuttersplice);
- QRegion mask = maskbase.subtract(cookiecutter);
+ if(isDown())
+ painter.fillPath(m_backgroundPath, QBrush(*m_selectedGradient));
+ else
+ painter.fillPath(m_backgroundPath, QBrush(*m_normalColor));
- setMask(mask);
+ icon().paint(&painter, this->rect());
}
- /*
+/*
Situare - A location system for Facebook
Copyright (C) 2010 Ixonos Plc. Authors:
Kaj Wallin - kaj.wallin@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
along with Situare; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
- */
-
+*/
#ifndef FULLSCREENBUTTON_H
#define FULLSCREENBUTTON_H
#include <QToolButton>
/**
-* @brief Fullscreen button class
-*
-* @author Kaj Wallin - kaj.wallin (at) ixonos.com
-*
-* @class FullScreenButton fullscreenbutton.h "ui/fullscreenbutton.h"
-*/
+ * @brief Fullscreen button class
+ *
+ * @author Kaj Wallin - kaj.wallin (at) ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+ *
+ * @class FullScreenButton fullscreenbutton.h "ui/fullscreenbutton.h"
+ */
class FullScreenButton : public QToolButton
{
Q_OBJECT
+
public:
/**
* @brief Constructor
* @param parent Parent widget
*/
FullScreenButton(QWidget *parent = 0);
+
+ /**
+ * @brief Desctructor
+ */
+ ~FullScreenButton();
+
+/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+ /**
+ * @brief Event handler for paint events
+ *
+ * Paints the button and its icon
+ * @param event Paint event
+ */
+ void paintEvent(QPaintEvent *event);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+ QColor *m_normalColor; ///< Normal background color
+ QLinearGradient *m_selectedGradient; ///< Selected background
+ QPainterPath m_backgroundPath; ///< Item shape path
};
#endif // FULLSCREENBUTTON_H
******************************************************************************/
public:
/**
- * @brief Set button icon.
- *
- * @param image image pixmap
- */
+ * @brief Set button icon.
+ *
+ * @param image image pixmap
+ */
void setButtonIcon(const QPixmap &image);
/**
#include <QSettings>
#include "math.h"
+
+#include "indicatorbutton.h"
+
#include "common.h"
#include "panelcommon.h"
-#include "indicatorbutton.h"
-enum State {OFF, ON}; ///< Enumerator for led state
+enum State {OFF, ON}; ///< Enumerator for led state
-const qreal OPACITY = 0.50; ///< Opacity of the background in percents
-const int ROUNDING_RADIUS = 9; ///< Roundness of the rounded edge
-const int BUTTON_WIDTH = 66; ///< Button width
-const int BUTTON_HEIGHT = 66; ///< Button height
+const int ROUNDING_RADIUS = 9; ///< Roundness of the rounded edge
+const int BUTTON_WIDTH = 66; ///< Button width
+const int BUTTON_HEIGHT = 66; ///< Button height
+
+const qreal OPACITY = 0.50; ///< Opacity of the background in percents
IndicatorButton::IndicatorButton(QWidget *parent)
: QToolButton(parent),
m_selectedGradient->setColorAt(0.75, QColor(82, 195, 255));
m_selectedGradient->setColorAt(0.98, QColor(115, 215, 255));
- // Item shape path
- m_backgroundPath.addRoundedRect(0, 0, this->rect().width(), this->rect().height(),
- ROUNDING_RADIUS, ROUNDING_RADIUS);
-
m_dragStartTimer = new QTimer(this);
m_dragStartTimer->setSingleShot(true);
m_dragStartTimer->setInterval(DRAG_INIT_TIME);
connect(this, SIGNAL(pressed()),
m_dragStartTimer, SLOT(start()));
-
connect(this, SIGNAL(released()),
m_dragStartTimer, SLOT(stop()));
+ connect(this, SIGNAL(clicked(bool)),
+ this, SIGNAL(autoCenteringTriggered(bool)));
connect(m_dragStartTimer, SIGNAL(timeout()),
this, SLOT(timerExpired()));
-
connect(m_forceReleaseTimer, SIGNAL(timeout()),
this, SLOT(forceMouseRelease()));
- connect(this, SIGNAL(clicked(bool)),
- this, SIGNAL(autoCenteringTriggered(bool)));
-
setCheckable(true);
}
delete m_normalColor;
delete m_selectedGradient;
-
}
void IndicatorButton::mousePressEvent(QMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- if (event->button() == Qt::LeftButton) {
+ if (event->button() == Qt::LeftButton)
m_dragPosition = event->pos();
- }
+
m_eventPosition = mapToParent(event->pos());
m_dragStartTimer->start();
+ setDown(true);
}
void IndicatorButton::mouseMoveEvent(QMouseEvent *event)
move(newLocation);
}
- } else
- if(!rect().contains(event->pos()))
+ } else {
+ if(!rect().contains(event->pos())) {
m_dragStartTimer->stop();
-
- QToolButton::mouseMoveEvent(event);
+ setDown(false);
+ }
+ }
}
void IndicatorButton::mouseReleaseEvent(QMouseEvent *event)
m_dragStartTimer->stop();
- Q_UNUSED(event);
if(m_isDraggable) {
setDraggable(false);
QSettings settings(DIRECTORY_NAME, FILE_NAME);
settings.setValue(DIRECTION_INDICATOR_BUTTON_POSITION, pos());
- releaseMouse();
-
} else {
-
- if(isChecked()) {
- setChecked(false);
- emit autoCenteringTriggered(false);
- } else {
- setChecked(true);
- emit autoCenteringTriggered(true);
+ if(this->rect().contains(event->pos())) {
+ if(isChecked()) {
+ setChecked(false);
+ emit autoCenteringTriggered(false);
+ } else {
+ setChecked(true);
+ emit autoCenteringTriggered(true);
+ }
}
}
-
- QToolButton::mouseReleaseEvent(event);
+ setDown(false);
}
void IndicatorButton::setDraggable(bool mode, QPoint eventPosition)
m_isDraggable = mode;
if(mode) {
- grabMouse();
m_forceReleaseTimer->start();
m_dragPosition = eventPosition;
} else {
- releaseMouse();
m_forceReleaseTimer->stop();
}
-
update();
}
QPoint resizedPosition = pos();
+#ifdef Q_WS_MAEMO_5
if(newSize.height() < DEFAULT_SCREEN_HEIGHT)
resizedPosition.ry() -= SCREEN_HEIGHT_DIFFERENCE;
else
resizedPosition.ry() += SCREEN_HEIGHT_DIFFERENCE;
+#endif // Q_WS_MAEMO_5
move(resizedPosition);
}
Q_UNUSED(event);
+ QPainterPath backgroundPath;
+ backgroundPath.addRoundedRect(this->rect(), ROUNDING_RADIUS, ROUNDING_RADIUS);
+
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
if(m_isDraggable)
- painter.fillPath(m_backgroundPath, QBrush(Qt::Dense4Pattern));
+ painter.fillPath(backgroundPath, QBrush(Qt::Dense4Pattern));
else if (isDown())
- painter.fillPath(m_backgroundPath, QBrush(*m_selectedGradient));
+ painter.fillPath(backgroundPath, QBrush(*m_selectedGradient));
else
- painter.fillPath(m_backgroundPath, QBrush(*m_normalColor));
+ painter.fillPath(backgroundPath, QBrush(*m_normalColor));
if(isChecked())
painter.drawPixmap((this->width() / 2) - (m_indicatorLeds[ON].width() / 2),
{
qDebug() << __PRETTY_FUNCTION__;
- if(this->isDown())
- m_dragPosition = this->eventPosition();
-
setDraggable(true, m_dragPosition);
}
-
-
/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
- Kaj Wallin - kaj.wallin@ixonos.com
- Katri Kaikkonen - katri.kaikkonen@ixonos.com
+ Kaj Wallin - kaj.wallin@ixonos.com
+ Katri Kaikkonen - katri.kaikkonen@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 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.
+ 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.
+ 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 INDICATORBUTTON_H
#define INDICATORBUTTON_H
-#include <QWidget>
-#include <QToolButton>
-#include <QTimer>
#include <QMouseEvent>
-#include "../user/user.h"
+#include <QTimer>
+#include <QToolButton>
+#include <QWidget>
/**
-* @brief Indicator button class
-*
-* @class IndicatorButton indicatorbutton.h "ui/indicatorbutton.h"
-* @author Katri Kaikkonen - katri.kaikkonen (at) ixonos.com
-*/
+ * @brief Indicator button class
+ *
+ * @author Katri Kaikkonen - katri.kaikkonen (at) ixonos.com
+ *
+ * @class IndicatorButton indicatorbutton.h "ui/indicatorbutton.h"
+ */
class IndicatorButton : public QToolButton
{
- Q_OBJECT
+ Q_OBJECT
public:
+ /**
+ * @brief Constructor
+ *
+ * @param parent Parent widget
+ */
+ IndicatorButton(QWidget *parent = 0);
- /**
- * @brief Constructor
- *
- * @param parent Parent widget
- */
- IndicatorButton(QWidget *parent = 0);
-
- /**
- * @brief Desctructor
- *
- */
- ~IndicatorButton();
+ /**
+ * @brief Desctructor
+ */
+ ~IndicatorButton();
/*******************************************************************************
-* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
-******************************************************************************/
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
protected:
+ /**
+ * @brief Move event for the distance indicator button
+ *
+ * @param event Mouse event
+ */
+ void mouseMoveEvent(QMouseEvent *event);
- /**
- * @brief Move event for the distance indicator button
- *
- * @param event Mouse event
- */
- void mouseMoveEvent(QMouseEvent *event);
-
- /**
- * @brief Press event for the distance indicator button
- *
- * @param event Mouse event
- */
- void mousePressEvent(QMouseEvent *event);
-
- /**
- * @brief Event handler for mouse release events
- *
- * @param event Mouse event
- */
- void mouseReleaseEvent(QMouseEvent *event);
+ /**
+ * @brief Press event for the distance indicator button
+ *
+ * @param event Mouse event
+ */
+ void mousePressEvent(QMouseEvent *event);
+
+ /**
+ * @brief Event handler for mouse release events
+ *
+ * @param event Mouse event
+ */
+ void mouseReleaseEvent(QMouseEvent *event);
/**
* @brief Event handler for paint events
void paintEvent(QPaintEvent *event);
/*******************************************************************************
-* MEMBER FUNCTIONS AND SLOTS
-******************************************************************************/
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
public slots:
-
/**
- * @brief Relative position of the event inside the widget
- */
+ * @brief Relative position of the event inside the widget
+ */
const QPoint& eventPosition();
/**
- * @brief Slot to redraw the panel after window resize event
- *
- * @param size Size of the new screen
- */
+ * @brief Slot to redraw the panel after window resize event
+ *
+ * @param size Size of the new screen
+ */
void screenResized(const QSize &size);
/**
void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
private slots:
-
/**
* @brief Safeguard slot to release mouse grab if something goes horribly wrong
*/
* SIGNALS
******************************************************************************/
signals:
-
/**
- * @brief Automatic centering setting changed by user
- *
- * @param enabled True if automatic centering is enabled, otherwise false
- */
+ * @brief Automatic centering setting changed by user
+ *
+ * @param enabled True if automatic centering is enabled, otherwise false
+ */
void autoCenteringTriggered(bool enabled);
/*******************************************************************************
-* DATA MEMBERS
-******************************************************************************/
+ * DATA MEMBERS
+ ******************************************************************************/
private:
-
bool m_isDraggable; ///< Boolean for tracking the draggability state
QColor *m_normalColor; ///< Normal background color
QLinearGradient *m_selectedGradient; ///< Selected background
- QPainterPath m_backgroundPath; ///< Item shape path
-
QPixmap m_indicatorLeds[2]; ///< Placeholder for images
QPoint m_dragPosition; ///< Location from where the widget is grabbed
QTimer *m_dragStartTimer; ///< Timer to init draggability of the distance indicator button
QTimer *m_forceReleaseTimer; ///< Timer to run forceMouseRelease
-
};
#endif // INDICATORBUTTON_H
bool selected = currentItem->toggleSelection();
if (selected)
- emit listItemClicked(currentItem->coordinates());
+ ;//emit listItemClicked(currentItem->coordinates());
} else {
qWarning() << __PRETTY_FUNCTION__ << "previousItem != currentItem";
m_previousItem->setSelected(false);
currentItem->setSelected(true);
- emit listItemClicked(currentItem->coordinates());
+ //emit listItemClicked(currentItem->coordinates());
}
m_previousItem = currentItem;
}
}
+
+
ListItem *ListView::listItem(const QString &userID)
{
qDebug() << __PRETTY_FUNCTION__;
*/
ListItem *listItem(const QString &userID);
-private slots:
+protected slots:
/**
* @brief Slot for list item clicked.
*
* Toggles items selection state and emits listItemClicked signal.
*/
- void listItemClicked(QListWidgetItem *item);
+ virtual void listItemClicked(QListWidgetItem *item);
/******************************************************************************
* SIGNALS
qDebug() << __PRETTY_FUNCTION__;
setSubitemTextWidth(LOCATION_SUBITEM_TEXT_MAX_WIDTH);
- addSubItem(QString("Hei pitka teksti hep hep hep hep hep hep hep hep hep hep hep hep"),
- QPixmap(":/res/images/clock.png"));
- addSubItem(QString("Hep"));
- addSubItem(QString("Jep"), QPixmap(":/res/images/compass.png"));
}
GeoCoordinate LocationListItem::coordinates()
{
m_location = location;
- setName(shortenText("blaah bavlsdfasdfhldsaf dsafldsaf ldsa lfadsl fl sadf",
- ITEM_WIDTH - 3*MARGIN, ListItem::TEXT_SIZE_NORMAL));
+ QStringList addressComponents = m_location.addressComponents();
+
+ if (addressComponents.count() > 0)
+ setName(shortenText(addressComponents.at(0), ITEM_WIDTH - 3*MARGIN,
+ ListItem::TEXT_SIZE_NORMAL));
+
+ QString addressTail;
+
+ for (int i = 1; i < addressComponents.count(); ++i) {
+ addressTail.append(addressComponents.at(i));
+
+ if (i < (addressComponents.count() - 1))
+ addressTail.append(", ");
+ }
+
+ addSubItem(addressTail, QPixmap(":/res/images/compass.png"));
+
+}
+
+void LocationListItem::bounds(GeoCoordinate &swBound, GeoCoordinate &neBound)
+{
+ m_location.bounds(swBound, neBound);
}
*/
QString id() const;
+ void bounds(GeoCoordinate &swBound, GeoCoordinate &neBound);
+
/******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
--- /dev/null
+#include "locationlistitem.h"
+
+#include "locationlistview.h"
+
+LocationListView::LocationListView(QWidget *parent)
+ : ListView(parent)
+{
+ qWarning() << __PRETTY_FUNCTION__;
+}
+
+void LocationListView::listItemClicked(QListWidgetItem *item)
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ ListView::listItemClicked(item);
+
+ LocationListItem *locationItem = static_cast<LocationListItem*>(item);
+
+ if (locationItem) {
+ qWarning() << __PRETTY_FUNCTION__ << "locationItem != null";
+ GeoCoordinate swBound;
+ GeoCoordinate neBound;
+ locationItem->bounds(swBound, neBound);
+ emit locationItemClicked(swBound, neBound);
+ }
+}
--- /dev/null
+#ifndef LOCATIONLISTVIEW_H
+#define LOCATIONLISTVIEW_H
+
+#include "listview.h"
+
+class LocationListView : public ListView
+{
+ Q_OBJECT
+
+public:
+ LocationListView(QWidget *parent = 0);
+
+private slots:
+ void listItemClicked(QListWidgetItem *item);
+
+signals:
+ void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+};
+
+#endif // LOCATIONLISTVIEW_H
connect(this, SIGNAL(locationDataParsed(QList<Location>&)),
m_friendsListPanel, SLOT(locationDataReady(QList<Location>&)));
+
+ connect(m_friendsListPanel, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
+ this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
}
void MainWindow::buildIndicatorButton()
/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Henri Lampela - henri.lampela@ixonos.com
- Kaj Wallin - kaj.wallin@ixonos.com
- Sami Rämö - sami.ramo@ixonos.com
- Katri Kaikkonen - katri.kaikkonen@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.
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Henri Lampela - henri.lampela@ixonos.com
+ Kaj Wallin - kaj.wallin@ixonos.com
+ Sami Rämö - sami.ramo@ixonos.com
+ Katri Kaikkonen - katri.kaikkonen@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 MAINWINDOW_H
public:
/**
- * @brief Constructor
- *
- * @param parent Parent
- */
+ * @brief Constructor
+ *
+ * @param parent Parent
+ */
MainWindow(QWidget *parent = 0);
/**
- * @brief Destructor
- *
- */
+ * @brief Destructor
+ *
+ */
~MainWindow();
/*******************************************************************************
******************************************************************************/
private:
/**
- * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
- */
+ * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
+ */
void keyPressEvent(QKeyEvent* event);
/*******************************************************************************
******************************************************************************/
public:
/**
- * @brief Clears cookie jar
- *
- */
+ * @brief Clears cookie jar
+ *
+ */
void clearCookieJar();
/**
- * @brief
- *
- * @param logged
- */
+ * @brief
+ *
+ * @param logged
+ */
void loggedIn(bool logged);
/**
- * @brief Gets the login state (logged in/logged out)
- *
- * @return bool Login state
- */
+ * @brief Gets the login state (logged in/logged out)
+ *
+ * @return bool Login state
+ */
bool loginState();
/**
- * @brief Reads automatic location update settings.
- */
+ * @brief Reads automatic location update settings.
+ */
void readAutomaticLocationUpdateSettings();
// /**
-// * @brief Enable / disable auto centering button.
-// *
-// * @param enabled true if shoud be enabled, false otherwise
-// */
+// * @brief Enable / disable auto centering button.
+// *
+// * @param enabled true if shoud be enabled, false otherwise
+// */
// void setAutoCenteringButtonEnabled(bool enabled);
/**
- * @brief Enable / disable GPS button.
- *
- * Does set visibilities for manual location cursor and auto centering menu button.
- *
- * @param enabled true if enabled, false otherwise
- */
+ * @brief Enable / disable GPS button.
+ *
+ * Does set visibilities for manual location cursor and auto centering menu button.
+ *
+ * @param enabled true if enabled, false otherwise
+ */
void setGPSButtonEnabled(bool enabled);
/**
- * @brief Enable / disable direction indicator button.
- *
- * @param enabled true if shoud be enabled, false otherwise
- */
+ * @brief Enable / disable direction indicator button.
+ *
+ * @param enabled true if shoud be enabled, false otherwise
+ */
void setIndicatorButtonEnabled(bool enabled);
/**
- * @brief Set scene for MapView
- *
- * @param scene Scene to be set
- */
+ * @brief Set scene for MapView
+ *
+ * @param scene Scene to be set
+ */
void setMapViewScene(QGraphicsScene *scene);
/**
- * Shows dialog with enable automatic location update question.
- *
- * @param text text to show in dialog
- */
+ * Shows dialog with enable automatic location update question.
+ *
+ * @param text text to show in dialog
+ */
void showEnableAutomaticUpdateLocationDialog(const QString &text);
/**
- * @brief Gets the username from member variable for saving purposes
- *
- * @return QString Username
- */
+ * @brief Gets the username from member variable for saving purposes
+ *
+ * @return QString Username
+ */
const QString username();
public slots:
/**
- * @brief Build direction indicator button and connect slots
- */
+ * @brief Build direction indicator button and connect slots
+ */
void buildIndicatorButton();
/**
- * @brief Builds information box with message.
- *
- * @param message Information message
- * @param modal Modal = true, non-modal false
- */
+ * @brief Builds information box with message.
+ *
+ * @param message Information message
+ * @param modal Modal = true, non-modal false
+ */
void buildInformationBox(const QString &message, bool modal=false);
/**
- * @brief Slot for failed login
- *
- */
+ * @brief Slot for failed login
+ */
void loginFailed();
/**
- * @brief Slot to intercept signal when login with cookies is requested
- *
- */
+ * @brief Slot to intercept signal when login with cookies is requested
+ */
void loginUsingCookies();
/**
- * @brief Public slot, which open settings dialog
- */
+ * @brief Public slot, which open settings dialog
+ */
void openSettingsDialog();
/**
- * @brief Set own location crosshair visibility
- *
- * @param visible
- */
+ * @brief Set own location crosshair visibility
+ *
+ * @param visible
+ */
void setOwnLocationCrosshairVisibility(bool visible);
/**
- * @brief Sets username to member variable for login dialog
- *
- * @param username Username to be set
- */
+ * @brief Sets username to member variable for login dialog
+ *
+ * @param username Username to be set
+ */
void setUsername(const QString &username);
/**
- * @brief Method to show panels
- *
- */
+ * @brief Method to show panels
+ */
void showPanels();
/**
- * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
- * doesn't exist yet
- *
- */
+ * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
+ * doesn't exist yet
+ *
+ */
void startLoginProcess();
/**
- * @brief Toggle progress indicator.
- *
- * @param state true if progress indicator should be shown, false otherwise
- */
+ * @brief Toggle progress indicator.
+ *
+ * @param state true if progress indicator should be shown, false otherwise
+ */
void toggleProgressIndicator(bool state);
/**
- * @brief Shows / hides Situare related UI items
- *
- */
+ * @brief Shows / hides Situare related UI items
+ *
+ */
void updateItemVisibility();
private:
/**
- * @brief Build fullscreen toggle button and connect slots
- */
+ * @brief Build fullscreen toggle button and connect slots
+ */
void buildFullScreenButton();
/**
- * @brief Build friend list panel and connect slots
- */
+ * @brief Build friend list panel and connect slots
+ */
void buildFriendListPanel();
/**
- * @brief Build manual location setting cross hair and connect slots
- */
+ * @brief Build manual location setting cross hair and connect slots
+ */
void buildManualLocationCrosshair();
/**
- * @brief Build map and connect slots
- */
+ * @brief Build map and connect slots
+ */
void buildMap();
/**
void buildMapScale();
/**
- * @brief Build OSM license and connect slots
- */
+ * @brief Build OSM license and connect slots
+ */
void buildOsmLicense();
/**
- * @brief Build user info panel and connect slots
- */
+ * @brief Build user info panel and connect slots
+ */
void buildUserInfoPanel();
/**
- * @brief Build webview and connect slots
- *
- */
+ * @brief Build webview and connect slots
+ */
void buildWebView();
/**
- * @brief Build zoom button panel and connect slots
- */
+ * @brief Build zoom button panel and connect slots
+ */
void buildZoomButtonPanel();
/**
- * @brief Private method to create the Menu items
- */
+ * @brief Private method to create the Menu items
+ */
void createMenus();
/**
- * @brief Grab or release HW increase and decrease buttons.
- *
- * @param grab Use true for grabbing and false for releasing the keys
- */
+ * @brief Grab or release HW increase and decrease buttons.
+ *
+ * @param grab Use true for grabbing and false for releasing the keys
+ */
void grabZoomKeys(bool grab);
/**
- * @brief Queues dialog/information box
- *
- * @param dialog Dialog to be added into queue
- */
+ * @brief Queues dialog/information box
+ *
+ * @param dialog Dialog to be added into queue
+ */
void queueDialog(QDialog *dialog);
/**
- * @brief Shows queued error information box
- *
- */
+ * @brief Shows queued error information box
+ *
+ */
void showErrorInformationBox();
/**
- * @brief Shows queued information box
- *
- * @fn showInformationBox
- */
+ * @brief Shows queued information box
+ *
+ * @fn showInformationBox
+ */
void showInformationBox();
private slots:
/**
- * @brief Slot for automatic update dialog finished.
- *
- * @result result code
- */
+ * @brief Slot for automatic update dialog finished.
+ *
+ * @result result code
+ */
void automaticUpdateDialogFinished(int result);
/**
- * @brief Slot to intercept signal when dialog/information note is processed
- *
- * @param status Status of the dialog
- */
+ * @brief Slot to intercept signal when dialog/information note is processed
+ *
+ * @param status Status of the dialog
+ */
void dialogFinished(int status);
/**
- * @brief Slot for drawing the fullscreen toggle button
- *
- * @param size Size of the screen
- */
+ * @brief Slot for drawing the fullscreen toggle button
+ *
+ * @param size Size of the screen
+ */
void drawFullScreenButton(const QSize &size);
/**
- * @brief Slot for drawing the map distance scale
- *
- * @param size Size of the screen
- */
+ * @brief Slot for drawing the map distance scale
+ *
+ * @param size Size of the screen
+ */
void drawMapScale(const QSize &size);
/**
- * @brief Slot for drawing the Open Street Map license text
- *
- * @param size Size of the screen
- */
+ * @brief Slot for drawing the Open Street Map license text
+ *
+ * @param size Size of the screen
+ */
void drawOsmLicense(const QSize &size);
/**
- * @brief Slot for drawing the own location crosshair
- *
- * @param size Size of the screen
- */
+ * @brief Slot for drawing the own location crosshair
+ *
+ * @param size Size of the screen
+ */
void drawOwnLocationCrosshair(const QSize &size);
/**
- * @brief Slot to intercept signal when error dialog/information note is processed
- *
- * @param status Status of the dialog
- */
+ * @brief Slot to intercept signal when error dialog/information note is processed
+ *
+ * @param status Status of the dialog
+ */
void errorDialogFinished(int status);
/**
- * @brief Slot for gps timeout.
- *
- * Called when request timeout occurs.
- */
+ * @brief Slot for gps timeout.
+ *
+ * Called when request timeout occurs.
+ */
void gpsTimeout();
/**
- * @brief Slot to load cookies from settings
- *
- */
+ * @brief Slot to load cookies from settings
+ */
void loadCookies();
/**
- * @brief Slot to intercept signal when webview has finished loading webpage
- *
- * @param done Status of the loading
- */
+ * @brief Slot to intercept signal when webview has finished loading webpage
+ *
+ * @param done Status of the loading
+ */
void loadDone(bool done);
/**
- * @brief Slot to save cookies to settings
- *
- */
+ * @brief Slot to save cookies to settings
+ */
void saveCookies();
/**
- * @brief Slot for settings dialog accepted.
- */
+ * @brief Slot for settings dialog accepted.
+ */
void settingsDialogAccepted();
/**
- * @brief Set correnct view port size to datamembers
- *
- * @param size Size of the screen
- */
+ * @brief Set correnct view port size to datamembers
+ *
+ * @param size Size of the screen
+ */
void setViewPortSize(const QSize &size);
/**
- * @brief Start location search (open search dialog)
- */
+ * @brief Start location search (open search dialog)
+ */
void startLocationSearch();
/**
- * @brief Toggle between fullscreen and normal window mode
- */
+ * @brief Toggle between fullscreen and normal window mode
+ */
void toggleFullScreen();
/**
- * @brief Slot to intercept signal from webview's networkaccessmanager
- *
- * @param reply Network reply (contains errors)
- */
+ * @brief Slot to intercept signal from webview's networkaccessmanager
+ *
+ * @param reply Network reply (contains errors)
+ */
void webViewRequestFinished(QNetworkReply* reply);
-
/*******************************************************************************
* SIGNALS
******************************************************************************/
signals:
/**
- * @brief Automatic centering setting changed by user
- *
- * @param enabled True if automatic centering is enabled, otherwise false
- */
+ * @brief Automatic centering setting changed by user
+ *
+ * @param enabled True if automatic centering is enabled, otherwise false
+ */
void autoCenteringTriggered(bool enabled);
/**
- * @brief Signal that indicates when user has cancelled login process
- *
- */
+ * @brief Signal that indicates when user has cancelled login process
+ *
+ */
void cancelLoginProcess();
/**
- * @brief View should be centered to new location
- *
- * @param coordinate Scene coordinates of the new center point
- */
+ * @brief View should be centered to new location
+ *
+ * @param coordinate Scene coordinates of the new center point
+ */
void centerToSceneCoordinates(const SceneCoordinate &coordinate);
/**
- * @brief Signal for enabling automatic location update.
- *
- * @param enabled true if enabled, false otherwise
- * @param updateIntervalMsecs update interval in milliseconds
- */
+ * @brief Signal for enabling automatic location update.
+ *
+ * @param enabled true if enabled, false otherwise
+ * @param updateIntervalMsecs update interval in milliseconds
+ */
void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
/**
- * @brief Signals error
- *
- * @param context error context
- * @param error error code
- */
+ * @brief Signals error
+ *
+ * @param context error context
+ * @param error error code
+ */
void error(const int context, const int error);
/**
- * @brief Signal for requesting username from settings
- *
- */
+ * @brief Signal for requesting username from settings
+ *
+ */
void fetchUsernameFromSettings();
/**
- * @brief Signal for finding user.
- *
- * @param coordinates user geo coordinates
- */
+ * @brief Signal for finding user.
+ *
+ * @param coordinates user geo coordinates
+ */
void findUser(const GeoCoordinate &coordinates);
/**
- * @brief Signals when friend's profile image is ready
- *
- * @param user Friend
- */
+ * @brief Signals when friend's profile image is ready
+ *
+ * @param user Friend
+ */
void friendImageReady(User *user);
/**
- * @brief GPS setting changed
- *
- * @param enabled True if GPS is enabled, otherwise false
- */
+ * @brief GPS setting changed
+ *
+ * @param enabled True if GPS is enabled, otherwise false
+ */
void gpsTriggered(bool enabled);
/**
- * @brief Signal for finding friend.
- *
- * @param coordinates friend's geo coordinates
- */
+ * @brief Signal for finding friend.
+ *
+ * @param coordinates friend's geo coordinates
+ */
void findFriend(const GeoCoordinate &coordinates);
/**
- * @brief Signal for friend location ready.
- *
- * @param friendsList
- */
+ * @brief Signal for friend location ready.
+ *
+ * @param friendsList
+ */
void friendsLocationsReady(QList<User *> &friendsList);
/**
void locationDataParsed(QList<Location> &result);
/**
- * @brief Signal is emitted when location item is clicked.
- *
- * @param userIDs list of friends user IDs in the group
- */
+ * @brief Signal is emitted when location item is clicked.
+ *
+ * @param userIDs list of friends user IDs in the group
+ */
void locationItemClicked(const QList<QString> &userIDs);
+ void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+
/**
- * @brief Signals when Login/Logout action is pressed
- *
- */
+ * @brief Signals when Login/Logout action is pressed
+ *
+ */
void loginActionPressed();
/**
- * @brief MapView has been resized
- *
- * @param size view size
- */
+ * @brief MapView has been resized
+ *
+ * @param size view size
+ */
void mapViewResized(const QSize &size);
/**
- * @brief Forwarding signal from MapView to MapEngine
- *
- * @param coordinate
- */
+ * @brief Forwarding signal from MapView to MapEngine
+ *
+ * @param coordinate
+ */
void mapViewScrolled(const SceneCoordinate &coordinate);
/**
- * @brief Forwarding signal from MapEngine to MapView
- */
+ * @brief Forwarding signal from MapEngine to MapView
+ */
void maxZoomLevelReached();
/**
- * @brief Forwarding signal from MapEngine to MapView
- */
+ * @brief Forwarding signal from MapEngine to MapView
+ */
void minZoomLevelReached();
/**
void newMapResolution(qreal scale);
/**
- * @brief Signal for refreshing user data.
- *
- */
+ * @brief Signal for refreshing user data.
+ *
+ */
void refreshUserData();
/**
- * @brief Signal for requesting reverseGeo from SituareEngine
- *
- */
+ * @brief Signal for requesting reverseGeo from SituareEngine
+ *
+ */
void requestReverseGeo();
/**
- * @brief Signals, when address data is ready
- *
- * @param address Street address
- */
+ * @brief Signals, when address data is ready
+ *
+ * @param address Street address
+ */
void reverseGeoReady(const QString &address);
/**
- * @brief Signal to save username to settings
- *
- * @param username Username
- */
+ * @brief Signal to save username to settings
+ *
+ * @param username Username
+ */
void saveUsername(const QString &username);
/**
- * @brief Signal for location search
- *
- * @param location QString location
- */
+ * @brief Signal for location search
+ *
+ * @param location QString location
+ */
void searchForLocation(QString location);
/**
- * @brief Signal for requestLocationUpdate from SituareEngine
- *
- * @param status Status message
- * @param publish Publish on Facebook
- */
+ * @brief Signal for requestLocationUpdate from SituareEngine
+ *
+ * @param status Status message
+ * @param publish Publish on Facebook
+ */
void statusUpdate(const QString &status, const bool &publish);
/**
- * @brief Signals when webview's urlChanged signal is emitted
- *
- * @param url New url
- */
+ * @brief Signals when webview's urlChanged signal is emitted
+ *
+ * @param url New url
+ */
void updateCredentials(const QUrl &url);
/**
- * @brief Signals when updateLocationDialog's data must be cleared
- *
- */
+ * @brief Signals when updateLocationDialog's data must be cleared
+ *
+ */
void clearUpdateLocationDialogData();
/**
- * @brief MapView has finished zooming
- */
+ * @brief MapView has finished zooming
+ */
void viewZoomFinished();
/**
- * @brief Signal for use location ready.
- *
- * @param user User object
- */
+ * @brief Signal for use location ready.
+ *
+ * @param user User object
+ */
void userLocationReady(User *user);
/**
- * @brief Map zoom in request
- */
+ * @brief Map zoom in request
+ */
void zoomIn();
/**
- * @brief Forwarding signal from MapEngine to MapView
- */
+ * @brief Forwarding signal from MapEngine to MapView
+ */
void zoomLevelChanged(int zoomLevel);
/**
- * @brief Map zoom out request
- */
+ * @brief Map zoom out request
+ */
void zoomOut();
/*******************************************************************************
FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
- IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
+ IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
MapScale *m_mapScale; ///< Instance of the map scale
MapView *m_mapView; ///< Instance of the map view
NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
Kaj Wallin - kaj.wallin@ixonos.com
Katri Kaikkonen - katri.kaikkonen@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
#define PANELCOMMON_H
#include <QString>
+
#include "../common.h"
// Dragging settings
- PANEL_BOTTOM_PADDING; ///< Height of the friends list panel
/**
-* @brief Friend list panel inner margin (left)
-*
-* @var FRIENDPANEL_MARGIN_LEFT
-*/
+ * @brief Friend list panel inner margin (left)
+ *
+ * @var FRIENDPANEL_MARGIN_LEFT
+ */
const int FRIENDPANEL_MARGIN_LEFT = SLIDER_BUTTON_OFFSET
+ MAEMO5_SCROLLBAR_WIDTH;
const int FRIENDPANEL_MARGIN_RIGHT = SIDEBAR_WIDTH; ///< Friend list panel inner margin (right)
const int FRIENDPANEL_MARGIN_BOTTOM = 0; ///< Friend list panel inner margin (bottom)
/**
-* @brief Friend list filter bar margin (left)
-*
-* @var FRIENDPANEL_FILTER_MARGIN_LEFT
-*/
+ * @brief Friend list filter bar margin (left)
+ *
+ * @var FRIENDPANEL_FILTER_MARGIN_LEFT
+ */
const int FRIENDPANEL_FILTER_MARGIN_LEFT = FRIENDPANEL_MARGIN_LEFT + 4;
/**
-* @brief Friend list filter bar margin (right)
-*
-* @var FRIENDPANEL_FILTER_MARGIN_RIGHT
-*/
+ * @brief Friend list filter bar margin (right)
+ *
+ * @var FRIENDPANEL_FILTER_MARGIN_RIGHT
+ */
const int FRIENDPANEL_FILTER_MARGIN_RIGHT = FRIENDPANEL_MARGIN_RIGHT
+ MAEMO5_SCROLLBAR_WIDTH + 4;
const int SHOW_ALL_BUTTON_RIGHT_MARGIN = SIDEBAR_WIDTH * 2 - 7; ///< Show all button right margin
/**
-* @brief Horizontal position of a closed friend list panel
-*
-* @var FRIENDPANEL_CLOSED_X
-*/
+ * @brief Horizontal position of a closed friend list panel
+ *
+ * @var FRIENDPANEL_CLOSED_X
+ */
const int FRIENDPANEL_CLOSED_X = DEFAULT_SCREEN_WIDTH - SLIDER_BUTTON_OFFSET
- PANEL_PEEK_AMOUNT;
/**
-* @brief Horizontal position of a open friend list panel
-*
-* @var FRIENDPANEL_OPENED_X
-*/
+ * @brief Horizontal position of a open friend list panel
+ *
+ * @var FRIENDPANEL_OPENED_X
+ */
const int FRIENDPANEL_OPENED_X = DEFAULT_SCREEN_WIDTH - SLIDER_BUTTON_OFFSET - SLIDER_BAR_WIDTH
- FRIENDPANEL_WIDTH;
const int USERPANEL_MARGIN_LEFT = SIDEBAR_WIDTH
+ MAEMO5_SCROLLBAR_WIDTH; ///< User info panel inner margin (left)
-const int USERPANEL_MARGIN_RIGHT = SLIDER_BUTTON_OFFSET; ///< User info panel inner margin (right)
-const int USERPANEL_MARGIN_TOP = 0; ///< User info panel inner margin (top)
-const int USERPANEL_MARGIN_BOTTOM = 0; ///< User info panel inner margin (bottom)
+const int USERPANEL_MARGIN_RIGHT = SLIDER_BUTTON_OFFSET; ///< User info panel inner margin (right)
+const int USERPANEL_MARGIN_TOP = 0; ///< User info panel inner margin (top)
+const int USERPANEL_MARGIN_BOTTOM = 0; ///< User info panel inner margin (bottom)
/**
-* @brief Horizontal position of a closed user info panel
-*
-* @var USERPANEL_CLOSED_X
-*/
+ * @brief Horizontal position of a closed user info panel
+ *
+ * @var USERPANEL_CLOSED_X
+ */
const int USERPANEL_CLOSED_X = - USERPANEL_WIDTH + PANEL_PEEK_AMOUNT
- SLIDER_BAR_WIDTH;
const int USERPANEL_OPENED_X = 0; ///< Horizontal position of a open user info panel
// Direction indicator button settings
/**
-* @brief Horizontal position of direction indicator button
-*
-* @var DIRECTION_INDICATOR_POSITION_X
-*/
+ * @brief Horizontal position of direction indicator button
+ *
+ * @var DIRECTION_INDICATOR_POSITION_X
+ */
const int DIRECTION_INDICATOR_POSITION_X = 10 + PANEL_PEEK_AMOUNT;
const int DIRECTION_INDICATOR_POSITION_Y = 315; ///< Vertical position of direction indicator button
USA.
*/
-
-#include "zoombutton.h"
#include <QDebug>
#include <QTimer>
+
+#include "zoombutton.h"
+
#include "panelcommon.h"
ZoomButton::ZoomButton(QWidget *parent, QString normalIconPictureFileName,
QString selectedIconPictureFileName)
: ImageButton(parent, normalIconPictureFileName, selectedIconPictureFileName)
{
+ qDebug() << __PRETTY_FUNCTION__;
}
void ZoomButton::mouseMoveEvent(QMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- if(rect().contains(event->pos())) {
+ if(rect().contains(event->pos()))
m_eventPosition = mapToParent(event->pos());
- }
+
ImageButton::mouseMoveEvent(event);
}
USA.
*/
-#include "imagebutton.h"
-
#ifndef ZOOMBUTTON_H
#define ZOOMBUTTON_H
class QTimer;
+#include "imagebutton.h"
+
/**
* @brief A class for Zoom Buttons
*
#include <QSettings>
#include "zoombuttonpanel.h"
+
+#include "common.h"
#include "panelcommon.h"
#include "zoombutton.h"
-#include "common.h"
+
+const int ROUNDING_RADIUS = 9; ///< Roundness of the background edges
ZoomButtonPanel::ZoomButtonPanel(QWidget *parent)
: QWidget(parent),
QPoint(ZOOM_BUTTON_PANEL_POSITION_X,
ZOOM_BUTTON_PANEL_POSITION_Y)).toPoint());
- QPalette pal = palette();
- pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
- setPalette(pal);
-
m_dragStartTimer = new QTimer(this);
m_dragStartTimer->setSingleShot(true);
m_dragStartTimer->setInterval(DRAG_INIT_TIME);
if(!rect().contains(event->pos()))
m_dragStartTimer->stop();
}
- QWidget::mouseMoveEvent(event);
}
void ZoomButtonPanel::mousePressEvent(QMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- if (event->button() == Qt::LeftButton) {
+ if (event->button() == Qt::LeftButton)
m_dragPosition = event->pos();
- }
+
m_dragStartTimer->start();
- QWidget::mousePressEvent(event);
}
void ZoomButtonPanel::mouseReleaseEvent(QMouseEvent *event)
Q_UNUSED(event);
if(m_isDraggable) {
setDraggable(false);
+
QSettings settings(DIRECTORY_NAME, FILE_NAME);
settings.setValue(ZOOMPANEL_POSITION, pos());
+
releaseMouse();
+
m_zoomInButton->setDown(false);
m_zoomOutButton->setDown(false);
}
- QWidget::mouseReleaseEvent(event);
+}
+
+void ZoomButtonPanel::paintEvent(QPaintEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ Q_UNUSED(event);
+
+ QPainter painter(this);
+
+ if(m_isDraggable) {
+ QPainterPath backgroundPath;
+ backgroundPath.addRoundedRect(this->rect(), ROUNDING_RADIUS, ROUNDING_RADIUS);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillPath(backgroundPath, QBrush(Qt::Dense4Pattern));
+ }
}
const ZoomButton* ZoomButtonPanel::zoomInButton()
m_isDraggable = mode;
if(mode) {
- setAutoFillBackground(true);
-
m_zoomInMode = m_zoomInButton->mode();
m_zoomOutMode = m_zoomOutButton->mode();
-
m_zoomInButton->setMode(QIcon::Disabled);
m_zoomOutButton->setMode(QIcon::Disabled);
+
grabMouse();
+
m_forceReleaseTimer->start();
m_dragPosition = eventPosition;
} else {
- setAutoFillBackground(false);
if(m_zoomInMode == QIcon::Selected)
m_zoomInButton->setMode(QIcon::Normal);
else
m_zoomInButton->setMode(m_zoomInMode);
+
if(m_zoomOutMode == QIcon::Selected)
m_zoomOutButton->setMode(QIcon::Normal);
else
m_zoomOutButton->setMode(m_zoomOutMode);
+
releaseMouse();
+
m_forceReleaseTimer->stop();
m_zoomInButton->setDown(false);
m_zoomOutButton->setDown(false);
}
+ update();
}
void ZoomButtonPanel::screenResized(const QSize &newSize)
m_screenSize = newSize;
QPoint resizedPosition = pos();
- if(resizedPosition.x() > (newSize.width() - rect().width()))
- resizedPosition.rx() = newSize.width() - rect().width();
- else if (resizedPosition.x() < SIDEBAR_WIDTH)
+
+ if (resizedPosition.x() < SIDEBAR_WIDTH)
resizedPosition.rx() = SIDEBAR_WIDTH;
+ else if(resizedPosition.x() > (newSize.width() - rect().width()))
+ resizedPosition.rx() = newSize.width() - rect().width();
+
if(resizedPosition.y() > (newSize.height() - rect().height()))
resizedPosition.ry() = newSize.height() - rect().height();
else if (resizedPosition.y() < 0)
resizedPosition.ry() = 0;
+
move(resizedPosition);
}
if(m_zoomInButton->isDown())
m_dragPosition = m_zoomInButton->eventPosition();
+
if(m_zoomOutButton->isDown())
m_dragPosition = m_zoomOutButton->eventPosition();
*/
void mouseReleaseEvent(QMouseEvent *event);
+ /**
+ * @brief Event handler for paint events
+ *
+ * Paints the panel
+ * @param event Paint event
+ */
+ void paintEvent(QPaintEvent *event);
+
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
public:
/**
- * @brief Getter for the zoom in button
- *
- * @return Pointer to the zoomInButton
- */
+ * @brief Getter for the zoom in button
+ *
+ * @return Pointer to the zoomInButton
+ */
const ZoomButton* zoomInButton();
/**
- * @brief Getter for the zoom out button
- *
- * @return Pointer to the zoomOutButton
- */
+ * @brief Getter for the zoom out button
+ *
+ * @return Pointer to the zoomOutButton
+ */
const ZoomButton* zoomOutButton();
public slots:
void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
/**
- * @brief Slot to redraw the panel after window resize event
- *
- * @param size Size of the new screen
- */
+ * @brief Slot to redraw the panel after window resize event
+ *
+ * @param size Size of the new screen
+ */
void screenResized(const QSize &size);
private slots:
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-07-13T15:37:49
+#
+#-------------------------------------------------
+
+QT += testlib \
+ gui
+
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+
+SOURCES += testmaprouteitem.cpp \
+ ../../../src/map/maprouteitem.cpp \
+ ../../../src/routing/route.cpp \
+ ../../../src/coordinates/scenecoordinate.cpp \
+ ../../../src/coordinates/geocoordinate.cpp
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += . \
+ ../../../src/
+
+HEADERS += \
+ ../../../src/map/maprouteitem.h \
+ ../../../src/routing/route.h \
+ ../../../src/coordinates/scenecoordinate.h \
+ ../../../src/coordinates/geocoordinate.h
--- /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 <QtCore/QString>
+#include <QPen>
+#include <QtTest/QtTest>
+
+#include "coordinates/geocoordinate.h"
+#include "coordinates/scenecoordinate.h"
+#include "map/maprouteitem.h"
+#include "routing/route.h"
+
+class TestMapRouteItem : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestMapRouteItem();
+
+private Q_SLOTS:
+ void testCase1();
+
+private:
+ Route route;
+
+ GeoCoordinate coordinates[3];
+};
+
+TestMapRouteItem::TestMapRouteItem()
+{
+ // test points
+ coordinates[0] = GeoCoordinate(12.3456, 54.3210);
+ coordinates[1] = GeoCoordinate(65.5000, 25.0000);
+ coordinates[2] = GeoCoordinate(-23.4567, 43.0987);
+
+ // append points to route
+ route.appendGeometryPoint(coordinates[0]);
+ route.appendGeometryPoint(coordinates[1]);
+ route.appendGeometryPoint(coordinates[2]);
+}
+
+void TestMapRouteItem::testCase1()
+{
+ MapRouteItem item;
+ item.setRoute(&route);
+
+ // check amount of lines
+ QList<QGraphicsItem *> lines = item.childItems();
+ QCOMPARE(lines.count(), 2);
+
+ // test each line
+ for (int i = 0; i < lines.count(); i++) {
+ // check if the item really is a line item
+ QGraphicsLineItem *lineItem = dynamic_cast<QGraphicsLineItem *>(lines.at(i));
+ QVERIFY(lineItem);
+
+ // check begin and end point scene coordinates of the line
+ QLineF line = lineItem->line();
+ QCOMPARE(line.p1(), SceneCoordinate(coordinates[i]).toPointF());
+ QCOMPARE(line.p2(), SceneCoordinate(coordinates[i + 1]).toPointF());
+
+ // check visual properties of the line
+ QPen pen = lineItem->pen();
+ QVERIFY(pen.isCosmetic());
+ QCOMPARE(pen.width(), 5);
+ QCOMPARE(pen.color(), QColor(Qt::red));
+ }
+}
+
+QTEST_APPLESS_MAIN(TestMapRouteItem);
+
+#include "testmaprouteitem.moc"
SOURCES += testroute.cpp \
../../../src/routing/route.cpp \
- ../../../src/routing/routesegment.cpp
+ ../../../src/routing/routesegment.cpp \
+ ../../../src/coordinates/scenecoordinate.cpp \
+ ../../../src/coordinates/geocoordinate.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
INCLUDEPATH += . \
HEADERS += \
../../../src/routing/route.h \
../../../src/routing/routingcommon.h \
- ../../../src/routing/routesegment.h
+ ../../../src/routing/routesegment.h \
+ ../../../src/coordinates/scenecoordinate.h \
+ ../../../src/coordinates/geocoordinate.h
DEFINES += QT_NO_DEBUG_OUTPUT
#include <QtCore/QString>
#include <QtTest/QtTest>
+#include "coordinates/geocoordinate.h"
#include "routing/routesegment.h"
#include "routing/route.h"
void TestRoute::geometryPoints()
{
// test points
- QPointF point1(12.3456, 54.3210);
- QPointF point2(65.5000, 25.0000);
- QPointF point3(-123.4567, 43.0987);
+ GeoCoordinate point1(12.3456, 54.3210);
+ GeoCoordinate point2(65.5000, 25.0000);
+ GeoCoordinate point3(-23.4567, 43.0987);
// create route with points
Route route;
route.appendGeometryPoint(point3);
// test points
- const QList<QPointF> &points = route.geometryPoints();
+ const QList<GeoCoordinate> &points = route.geometryPoints();
QVERIFY(points.count() == 3);
- QCOMPARE(points.at(0), point1);
- QCOMPARE(points.at(1), point2);
- QCOMPARE(points.at(2), point3);
+
+ QCOMPARE(points.at(0).latitude(), point1.latitude());
+ QCOMPARE(points.at(0).longitude(), point1.longitude());
+
+ QCOMPARE(points.at(1).latitude(), point2.latitude());
+ QCOMPARE(points.at(1).longitude(), point2.longitude());
+
+ QCOMPARE(points.at(2).latitude(), point3.latitude());
+ QCOMPARE(points.at(2).longitude(), point3.longitude());
}
void TestRoute::segments()
map/friendgroupitem \
map/mapscene \
map/friendlocationitem \
+ map/maprouteitem \
ui/listview \
ui/friendlistitem \
ui/sidepanel \