[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Thu Jun 7 20:41:16 CEST 2007
SVN commit 672636 by treat:
* Post some cursors for resizing
M +66 -0 viewitem.cpp
M +1 -0 viewitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #672635:672636
@@ -22,6 +22,7 @@
ViewItem::ViewItem(View *parent)
: QObject(parent) {
+ setAcceptsHoverEvents(true);
setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
#ifdef DEBUG_GEOMETRY
QColor semiRed(QColor(255, 0, 0, 50));
@@ -122,6 +123,71 @@
}
+void ViewItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
+ QGraphicsRectItem::hoverMoveEvent(event);
+
+ QRectF r;
+ r.setSize(QSizeF(14,14)); //gives us corners of 7x7
+
+ //Look for corners
+ r.moveCenter(rect().bottomRight());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeFDiagCursor);
+ return;
+ }
+
+ r.moveCenter(rect().topLeft());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeFDiagCursor);
+ return;
+ }
+
+ r.moveCenter(rect().bottomLeft());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeBDiagCursor);
+ return;
+ }
+
+ r.moveCenter(rect().topRight());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeBDiagCursor);
+ return;
+ }
+
+ //Now look for horizontal edges
+ r.setSize(QSizeF(rect().width(), 7));
+
+ r.moveTopRight(rect().topRight());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeVerCursor);
+ return;
+ }
+
+ r.moveBottomRight(rect().bottomRight());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeVerCursor);
+ return;
+ }
+
+ //Now look for vertical edges
+ r.setSize(QSizeF(7, rect().height()));
+
+ r.moveTopLeft(rect().topLeft());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeHorCursor);
+ return;
+ }
+
+ r.moveTopRight(rect().topRight());
+ if (r.contains(event->pos())) {
+ setCursor(Qt::SizeHorCursor);
+ return;
+ }
+
+ setCursor(Qt::ArrowCursor);
+}
+
+
void ViewItem::mouseModeChanged() {
if (parentView()->mouseMode() == View::Move)
_originalPosition = pos();
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #672635:672636
@@ -48,6 +48,7 @@
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
private Q_SLOTS:
void mouseModeChanged();
More information about the Kst
mailing list