Added simple pointer tracking signals.
This commit is contained in:
+2
-2
@@ -513,8 +513,8 @@ namespace glabels
|
||||
updateCursorInfo();
|
||||
|
||||
connect( view, SIGNAL(zoomChanged()), this, SLOT(updateZoomInfo()) );
|
||||
|
||||
/* TODO: connect cursor signals to appropriate slots. */
|
||||
connect( view, SIGNAL(pointerMoved(double, double)), this, SLOT(updateCursorInfo(double, double)) );
|
||||
connect( view, SIGNAL(pointerExited()), this, SLOT(updateCursorInfo()) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "View.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
@@ -41,6 +42,8 @@ namespace glabels
|
||||
setZoomReal( 1, false );
|
||||
mModel = 0;
|
||||
|
||||
setMouseTracking( true );
|
||||
|
||||
mScene = new QGraphicsScene();
|
||||
setScene( mScene );
|
||||
}
|
||||
@@ -154,4 +157,17 @@ namespace glabels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void View::mouseMoveEvent( QMouseEvent* event )
|
||||
{
|
||||
QPointF pointer = mapToScene( event->x(), event->y() );
|
||||
emit pointerMoved( pointer.x(), pointer.y() );
|
||||
}
|
||||
|
||||
|
||||
void View::leaveEvent( QEvent* event )
|
||||
{
|
||||
emit pointerExited();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+34
-1
@@ -34,19 +34,40 @@ namespace glabels
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////////
|
||||
// Lifecycle
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
View( QWidget *parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////////
|
||||
signals:
|
||||
void zoomChanged();
|
||||
void pointerMoved( double x, double y );
|
||||
void pointerExited();
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Parameters
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
inline double zoom() const;
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Model
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
void setModel( LabelModel* model );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Zoom operations
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void zoom1To1();
|
||||
@@ -57,10 +78,18 @@ namespace glabels
|
||||
void setZoomReal( double zoom, bool zoomToFitFlag );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Event handlers
|
||||
/////////////////////////////////////
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent *event );
|
||||
void resizeEvent( QResizeEvent* event );
|
||||
void mouseMoveEvent( QMouseEvent* event );
|
||||
void leaveEvent( QEvent* event );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
QGraphicsScene* mScene;
|
||||
|
||||
@@ -72,6 +101,10 @@ namespace glabels
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// INLINE METHODS
|
||||
/////////////////////////////////
|
||||
|
||||
inline double View::zoom() const
|
||||
{
|
||||
return mZoom;
|
||||
|
||||
Reference in New Issue
Block a user