Commit e73f189b authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Method to adjust the height of the cursor

parent 7218a1eb
......@@ -2,13 +2,13 @@
#include "GraphicsCursorItem.h"
GraphicsCursorItem::GraphicsCursorItem( int height, const QPen& pen )
: m_height( height ), m_pen( pen )
: m_pen( pen )
{
setFlags( QGraphicsItem::ItemIgnoresTransformations | QGraphicsItem::ItemIsMovable );
setCursor( QCursor( Qt::SizeHorCursor ) );
setZValue( 100 );
m_boundingRect = QRectF( -2, 0, 3, m_height );
m_boundingRect = QRectF( -2, 0, 3, height );
}
QRectF GraphicsCursorItem::boundingRect() const
......@@ -19,7 +19,7 @@ QRectF GraphicsCursorItem::boundingRect() const
void GraphicsCursorItem::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* )
{
painter->setPen( m_pen );
painter->drawLine( 0, 0, 0, m_height );
painter->drawLine( 0, 0, 0, m_boundingRect.height() );
}
QVariant GraphicsCursorItem::itemChange( GraphicsItemChange change, const QVariant& value )
......@@ -46,3 +46,9 @@ void GraphicsCursorItem::updateCursorPos( qint64 position )
{
setCursorPos( (qint64) position );
}
void GraphicsCursorItem::setHeight( int height )
{
m_boundingRect.setHeight( height );
update();
}
......@@ -17,13 +17,13 @@ public:
int cursorPos() const { return ( int )pos().x(); }
void setCursorPos( int position );
virtual QRectF boundingRect() const;
void setHeight( int height );
protected:
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
virtual QVariant itemChange( GraphicsItemChange change, const QVariant& value );
private:
int m_height;
QPen m_pen;
QRectF m_boundingRect;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment