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

Revert "New slot for moving an item using its uuid"

This reverts commit b99c1c6e.
There's a blocker which needs to be fixed first.
parent b99c1c6e
...@@ -154,33 +154,16 @@ void TracksView::dragMoveEvent( QDragMoveEvent* event ) ...@@ -154,33 +154,16 @@ void TracksView::dragMoveEvent( QDragMoveEvent* event )
moveMediaItem( m_dragItem, event->pos() ); moveMediaItem( m_dragItem, event->pos() );
} }
void TracksView::moveMediaItem( const QUuid& uuid, int track, int time )
{
QList<QGraphicsItem*> sceneItems = m_scene->items();
for ( int i = 0; i < sceneItems.size(); ++i )
{
AbstractGraphicsMediaItem* item =
dynamic_cast<AbstractGraphicsMediaItem*>( sceneItems.at( i ) );
if ( !item || item->uuid() != uuid ) continue;
moveMediaItem( item, track, time );
}
}
void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position ) void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position )
{ {
int track = (unsigned int)( mapToScene( position ).y() / m_tracksHeight ); int track = (unsigned int)( mapToScene( position ).y() / m_tracksHeight );
qreal time = ( mapToScene( position ).x() + 0.5 );
moveMediaItem( item, track, (int)time);
}
void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, int time )
{
if ( track < 0 ) if ( track < 0 )
track = 0; track = 0;
else if ( track > m_numVideoTrack - 1) else if ( track > m_numVideoTrack - 1)
track = m_numVideoTrack - 1; track = m_numVideoTrack - 1;
qreal mappedXPos = ( mapToScene( position ).x() + 0.5 );
QPointF oldPos = item->pos(); QPointF oldPos = item->pos();
QGraphicsItem* oldParent = item->parentItem(); QGraphicsItem* oldParent = item->parentItem();
// Check for vertical collisions // Check for vertical collisions
...@@ -197,7 +180,7 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, int ...@@ -197,7 +180,7 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, int
{ {
// Collision with an item of the same type // Collision with an item of the same type
itemCollision = true; itemCollision = true;
if ( currentItem->trackNumber() > track ) if ( currentItem->pos().y() < position.y() )
{ {
if ( track < 1 ) if ( track < 1 )
{ {
...@@ -209,7 +192,7 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, int ...@@ -209,7 +192,7 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, int
Q_ASSERT( m_layout->itemAt( track )->graphicsItem() != NULL ); Q_ASSERT( m_layout->itemAt( track )->graphicsItem() != NULL );
item->setParentItem( m_layout->itemAt( track )->graphicsItem() ); item->setParentItem( m_layout->itemAt( track )->graphicsItem() );
} }
else if ( currentItem->trackNumber() < track ) else if ( currentItem->pos().y() > position.y() )
{ {
if ( track >= m_numVideoTrack - 1 ) if ( track >= m_numVideoTrack - 1 )
{ {
...@@ -227,7 +210,7 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, int ...@@ -227,7 +210,7 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, int
continueSearch = false; continueSearch = false;
} }
// Check for horizontal collisions // Check for horizontal collisions
int mappedXPos = qMax( time, 0 ); mappedXPos = qMax( mappedXPos, (qreal)0 );
item->setPos( mappedXPos, 0 ); item->setPos( mappedXPos, 0 );
QList<QGraphicsItem*> colliding = item->collidingItems( Qt::IntersectsItemShape ); QList<QGraphicsItem*> colliding = item->collidingItems( Qt::IntersectsItemShape );
for ( int i = 0; i < colliding.size(); ++i ) for ( int i = 0; i < colliding.size(); ++i )
......
...@@ -90,9 +90,6 @@ public: ...@@ -90,9 +90,6 @@ public:
void setScale( double scaleFactor ); void setScale( double scaleFactor );
QList<AbstractGraphicsMediaItem*> mediaItems( const QPoint& pos ); QList<AbstractGraphicsMediaItem*> mediaItems( const QPoint& pos );
public slots:
void moveMediaItem( const QUuid& uuid, int track, int time );
protected: protected:
virtual void resizeEvent( QResizeEvent* event ); virtual void resizeEvent( QResizeEvent* event );
virtual void drawBackground( QPainter* painter, const QRectF& rect ); virtual void drawBackground( QPainter* painter, const QRectF& rect );
...@@ -114,7 +111,6 @@ private: ...@@ -114,7 +111,6 @@ private:
void addVideoTrack(); void addVideoTrack();
void addAudioTrack(); void addAudioTrack();
void moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position ); void moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position );
void moveMediaItem( AbstractGraphicsMediaItem* item, int track, int time );
QGraphicsScene* m_scene; QGraphicsScene* m_scene;
int m_tracksHeight; int m_tracksHeight;
unsigned int m_tracksCount; unsigned int m_tracksCount;
......
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