#include <QDebug>
#include <QGraphicsSceneMouseEvent>
+#include <QIcon>
#include "friendlocationitem.h"
#include "mapcommon.h"
bool FriendLocationItem::isPartOfGroup() const
{
+ qDebug() << __PRETTY_FUNCTION__;
+
return m_partOfGroup;
}
{
qDebug() << __PRETTY_FUNCTION__;
- m_mousePressPosition = event->pos().toPoint();
+ m_mousePressPosition = event->pos();
m_clickEvent = true;
+ update();
}
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;
+ if (m_clickEvent) {
+ if ((event->pos() - m_mousePressPosition).manhattanLength() > PRESS_MANHATTAN_LENGTH) {
+ m_clickEvent = false;
+ update();
+ }
}
}
Q_UNUSED(event);
if (m_clickEvent) {
+ m_clickEvent = false;
QList<QString> userIDs;
userIDs.append(m_userId);
emit locationItemClicked(userIDs);
}
+
+ update();
+}
+
+void FriendLocationItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_clickEvent) {
+ QIcon icon;
+ icon.addPixmap(pixmap());
+ painter->drawPixmap(offset(), icon.pixmap(pixmap().size(), QIcon::Selected,
+ QIcon::On));
+ } else {
+ BaseLocationItem::paint(painter, option, widget);
+ }
}
void FriendLocationItem::setPartOfGroup(bool value)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
m_partOfGroup = value;
if (value)
QString FriendLocationItem::userId() const
{
qDebug() << __PRETTY_FUNCTION__;
+
return m_userId;
}
void FriendLocationItem::setProfileImage(const QPixmap image, const QUrl &url)
{
qDebug() << __PRETTY_FUNCTION__;
+
setPixmap(image);
setOffset(-image.width()/2, -image.height()/2);
m_profileImageUrl = url;
QUrl FriendLocationItem::profileImageUrl() const
{
qDebug() << __PRETTY_FUNCTION__;
+
return m_profileImageUrl;
}