Reviewed by: Henri Lampela.
void GPSPositionPrivate::positionUpdated(const GeoPositionInfo &positionInfo)
{
- qDebug() << __PRETTY_FUNCTION__ << positionInfo;
+ qDebug() << __PRETTY_FUNCTION__;
if (positionInfo.coordinate().isValid()) {
GeoCoordinate coordinate = positionInfo.coordinate();
#include "common.h"
FriendGroupItem::FriendGroupItem(FriendLocationItem *item)
+ : m_clickEvent(false)
{
qDebug() << __PRETTY_FUNCTION__;
Qt::AlignCenter, QString::number(m_friends.count()));
}
+void FriendGroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if ((abs(m_mousePressPosition.y() - event->pos().toPoint().y()) > FRIEND_ITEM_PRESS_HEIGHT) ||
+ (abs(m_mousePressPosition.x() - event->pos().toPoint().x()) > FRIEND_ITEM_PRESS_WIDTH)) {
+
+ m_clickEvent = false;
+ }
+}
+
void FriendGroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- m_mousePressPosition = event->screenPos();
+ m_mousePressPosition = event->pos().toPoint();
+ m_clickEvent = true;
}
void FriendGroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- if ((abs(m_mousePressPosition.y() - event->screenPos().y()) <= FRIEND_ITEM_PRESS_HEIGHT) &&
- (abs(m_mousePressPosition.x() - event->screenPos().x()) <= FRIEND_ITEM_PRESS_WIDTH)) {
+ if (m_clickEvent) {
QList<QString> userIDs;
protected:
/**
+ * @brief Mouse move event.
+ *
+ * Disables m_clickEvent flag if press and release where not
+ * in same area.
+ *
+ * @param event QGraphicsSceneMouseEvent.
+ */
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+
+ /**
* @brief Mouse press event.
*
* Sets mouse press position.
private:
QList<FriendLocationItem *> m_friends; ///< List of joined FriendLocationItem items
QPoint m_mousePressPosition; ///< Mouse press position
+ bool m_clickEvent; ///< Mouse click event flag
};
#endif // FRIENDGROUPITEM_H
: BaseLocationItem(parent),
m_partOfGroup(false),
m_userId(userId),
- m_mousePressPosition(QPoint(0, 0))
+ m_mousePressPosition(QPoint(0, 0)),
+ m_clickEvent(false)
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
- m_mousePressPosition = event->screenPos();
+ m_mousePressPosition = event->pos().toPoint();
+ m_clickEvent = true;
+}
+
+void FriendLocationItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if ((abs(m_mousePressPosition.y() - event->pos().toPoint().y()) > FRIEND_ITEM_PRESS_HEIGHT) ||
+ (abs(m_mousePressPosition.x() - event->pos().toPoint().x()) > FRIEND_ITEM_PRESS_WIDTH)) {
+
+ m_clickEvent = false;
+ }
}
void FriendLocationItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- if ((abs(m_mousePressPosition.y() - event->screenPos().y()) <= FRIEND_ITEM_PRESS_HEIGHT) &&
- (abs(m_mousePressPosition.x() - event->screenPos().x()) <= FRIEND_ITEM_PRESS_WIDTH)) {
+ Q_UNUSED(event);
+
+ if (m_clickEvent) {
QList<QString> userIDs;
userIDs.append(m_userId);
protected:
/**
+ * @brief method that detects when friend icon is moved
+ *
+ * Disables m_clickEvent flag if press and release where not
+ * in same area.
+ *
+ * @param event detects the mouse move (or touch in Maemo)
+ */
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+
+ /**
* @brief method that detects when friend icon is clicked
*
* @param event detects the mouse click (or touch in Maemo)
const QString m_userId; ///< Friends user ID. Can't be changed afterwards
QUrl m_profileImageUrl; ///< Friends Facebook profile image URL
QPoint m_mousePressPosition; ///< Mouse press position
+ bool m_clickEvent; ///< Flag to mark click event
};
#endif // FRIENDLOCATIONITEM_H