7#include "ScreenGraphicsItem.h"
8#include "ScreenGraphicsItem_p.h"
11#include "MarbleDebug.h"
19ScreenGraphicsItem::ScreenGraphicsItem(MarbleGraphicsItem *parent)
20 : MarbleGraphicsItem(new ScreenGraphicsItemPrivate(this, parent))
24ScreenGraphicsItem::ScreenGraphicsItem(ScreenGraphicsItemPrivate *dd)
25 : MarbleGraphicsItem(dd)
29ScreenGraphicsItem::~ScreenGraphicsItem() =
default;
31QPointF ScreenGraphicsItem::position()
const
33 Q_D(
const ScreenGraphicsItem);
37void ScreenGraphicsItem::setPosition(
const QPointF &position)
39 Q_D(ScreenGraphicsItem);
40 d->m_position = position;
43QPointF ScreenGraphicsItem::positivePosition()
const
45 Q_D(
const ScreenGraphicsItem);
46 return d->positivePosition();
51 Q_D(
const ScreenGraphicsItem);
52 return d->absolutePositions();
57 Q_D(
const ScreenGraphicsItem);
63 Q_D(ScreenGraphicsItem);
67bool ScreenGraphicsItem::eventFilter(
QObject *
object,
QEvent *e)
71 return MarbleGraphicsItem::eventFilter(
object, e);
74 Q_D(ScreenGraphicsItem);
75 if (!d->m_floatItemMoving) {
76 if (MarbleGraphicsItem::eventFilter(
object, e)) {
80 if (!visible() || !d->isMovable()) {
93 if (contains(
event->pos())) {
95 d->m_floatItemMoveStartPos =
event->pos();
96 d->m_floatItemMoving =
true;
112 const QPoint &point =
event->pos();
113 QPointF position = positivePosition();
114 qreal newX = qMax<qreal>(0, position.
x() + point.
x() - d->m_floatItemMoveStartPos.x());
115 qreal newY = qMax<qreal>(0, position.
y() + point.
y() - d->m_floatItemMoveStartPos.y());
118 const qreal dockArea = 60.0;
119 const qreal dockJump = 30.0;
120 if (widget->width() - size().width() - newX < dockArea) {
121 newX = qMin(qreal(-1.0), size().width() + newX - widget->
width());
122 if (d->m_floatItemMoveStartPos.x() <
event->pos().x()) {
124 newX = qMax(newX, -(dockArea - dockJump));
127 if (widget->height() - size().height() - newY < dockArea) {
128 newY = qMin(qreal(-1.0), size().height() + newY - widget->
height());
129 if (d->m_floatItemMoveStartPos.y() <
event->pos().y()) {
131 newY = qMax(newY, -(dockArea - dockJump));
135 setPosition(
QPointF(newX, newY));
139 d->m_floatItemMoveStartPos =
event->pos();
141 dirtyRegion = dirtyRegion.united(newFloatItemRect);
144 widget->update(dirtyRegion);
150 d->m_floatItemMoving =
false;
154 if (d->m_floatItemMoving) {
160 return MarbleGraphicsItem::eventFilter(
object, e);
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
Binds a QML item to a specific geodetic location in screen coordinates.
QRect toRect() const const
qreal height() const const
qreal width() const const