proposed fix 821 Range-select in Song Editor
This commit is contained in:
@@ -35,6 +35,7 @@ class QPixmap;
|
||||
class QToolBar;
|
||||
class NStateButton;
|
||||
class TextFloat;
|
||||
class SongEditor;
|
||||
|
||||
|
||||
class TimeLineWidget : public QWidget, public JournallingObject
|
||||
@@ -171,6 +172,8 @@ private:
|
||||
|
||||
|
||||
TextFloat * m_hint;
|
||||
SongEditor *m_songEditor;
|
||||
int m_initalXSelect;
|
||||
|
||||
|
||||
enum actions
|
||||
@@ -178,7 +181,8 @@ private:
|
||||
NoAction,
|
||||
MovePositionMarker,
|
||||
MoveLoopBegin,
|
||||
MoveLoopEnd
|
||||
MoveLoopEnd,
|
||||
SelectSongTCO,
|
||||
} m_action;
|
||||
|
||||
int m_moveXOff;
|
||||
|
||||
@@ -92,6 +92,26 @@ public:
|
||||
return( QVector<selectableObject *>() );
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief selectRegionFromPixels
|
||||
/// \param x
|
||||
/// \param y
|
||||
/// Use the rubber band to select TCO from all tracks using x, y pixels
|
||||
void selectRegionFromPixels(int x, int y)
|
||||
{
|
||||
m_rubberBand->setEnabled( true );
|
||||
m_rubberBand->show();
|
||||
m_rubberBand->setGeometry( min( x, y ), 0, max( x, y ) - min( x, y ), std::numeric_limits<int>::max() );
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief stopRubberBand
|
||||
/// Removes the rubber band from display when finished with.
|
||||
void stopRubberBand()
|
||||
{
|
||||
m_rubberBand->hide();
|
||||
m_rubberBand->setEnabled( false );
|
||||
}
|
||||
|
||||
TrackContainer* model()
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "NStateButton.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "TextFloat.h"
|
||||
#include "SongEditor.h"
|
||||
|
||||
|
||||
#if QT_VERSION < 0x040800
|
||||
@@ -105,6 +106,7 @@ TimeLineWidget::TimeLineWidget( const int _xoff, const int _yoff, const float _p
|
||||
connect( update_timer, SIGNAL( timeout() ),
|
||||
this, SLOT( updatePosition() ) );
|
||||
update_timer->start( 50 );
|
||||
m_songEditor = dynamic_cast<SongEditor*>(_parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +282,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( event->button() == Qt::LeftButton )
|
||||
if( event->button() == Qt::LeftButton && !(event->modifiers() & Qt::ShiftModifier) )
|
||||
{
|
||||
m_action = MovePositionMarker;
|
||||
if( event->x() - m_xOffset < s_posMarkerPixmap->width() )
|
||||
@@ -292,6 +294,11 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
|
||||
m_moveXOff = s_posMarkerPixmap->width() / 2;
|
||||
}
|
||||
}
|
||||
else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) && m_songEditor )
|
||||
{
|
||||
m_action = SelectSongTCO;
|
||||
m_initalXSelect = event->x();
|
||||
}
|
||||
else if( event->button() == Qt::RightButton || event->button() == Qt::MiddleButton )
|
||||
{
|
||||
m_moveXOff = s_posMarkerPixmap->width() / 2;
|
||||
@@ -373,6 +380,12 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event )
|
||||
update();
|
||||
break;
|
||||
}
|
||||
case SelectSongTCO:
|
||||
if( m_songEditor )
|
||||
{
|
||||
m_songEditor->selectRegionFromPixels( m_initalXSelect , event->x() );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -386,6 +399,7 @@ void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event )
|
||||
{
|
||||
delete m_hint;
|
||||
m_hint = NULL;
|
||||
if(m_action == SelectSongTCO && m_songEditor ) { m_songEditor->stopRubberBand(); }
|
||||
m_action = NoAction;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user