Commit fb8e8f02 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

TracksView/AbstractGraphicsMediaItem: Fixing signedness warnings.

When a trackId is stored, we should use a signed type, as it can be
initialized in some error cases. My apologies to etix :)
parent 90c22bc8
......@@ -106,7 +106,7 @@ void AbstractGraphicsMediaItem::setHeight( qint64 height )
m_height = height;
}
quint32 AbstractGraphicsMediaItem::trackNumber()
qint32 AbstractGraphicsMediaItem::trackNumber()
{
if ( parentItem() )
{
......@@ -114,9 +114,7 @@ quint32 AbstractGraphicsMediaItem::trackNumber()
if ( graphicsTrack )
return graphicsTrack->trackNumber();
}
//FIXME We should probably return a negative number here (using a signed type!)
qWarning( "Things can go wrong beyond that point!" );
return 0;
return -1;
}
void AbstractGraphicsMediaItem::setTrack( GraphicsTrack* track )
......@@ -189,17 +187,18 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent
scene()->askRemoveSelectedItems();
else if ( selectedAction == muteAction )
{
qint32 trackId = trackNumber();
Q_ASSERT( trackId >= 0 );
if ( ( m_muted = muteAction->isChecked() ) )
{
tracksView()->m_mainWorkflow->muteClip( uuid(),
trackNumber(),
trackId,
mediaType() );
}
else
{
tracksView()->m_mainWorkflow->unmuteClip( uuid(),
trackNumber(),
trackId,
mediaType() );
}
}
......@@ -222,8 +221,10 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent
if ( item1->mediaType() != mediaType() )
{
qint32 item1TrackId = item1->trackNumber();
Q_ASSERT( item1TrackId >= 0 );
item1->group( this );
tracksView()->moveMediaItem( item1, item1->trackNumber(), startPos() );
tracksView()->moveMediaItem( item1, item1TrackId , startPos() );
track()->trackWorkflow()->moveClip( item1->clipHelper()->uuid(), startPos() );
}
}
......
......@@ -88,7 +88,7 @@ public:
void ungroup();
/// Return the current track of the item
quint32 trackNumber();
qint32 trackNumber();
/// Set the item's parent track
void setTrack( GraphicsTrack* track );
......
......@@ -231,7 +231,7 @@ TracksView::addMediaItem( TrackWorkflow *tw, ClipHelper *ch, qint64 start )
//already be created (by the drag and drop operation)
if ( m_clipsLoaded.contains( ch->uuid() ) )
return ;
quint32 track = tw->trackId();
qint32 track = tw->trackId();
Workflow::TrackType trackType = tw->type();
// If there is not enough tracks to insert
......@@ -385,7 +385,7 @@ TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, QPoint position )
}
void
TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, quint32 track, qint64 time )
TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, qint32 track, qint64 time )
{
// Add missing tracks
if ( item->mediaType() == Workflow::AudioTrack )
......@@ -480,7 +480,7 @@ TracksView::moveMediaItem( AbstractGraphicsMediaItem *item, quint32 track, qint6
}
ItemPosition
TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64 time )
TracksView::findPosition( AbstractGraphicsMediaItem *item, qint32 track, qint64 time )
{
// Create a fake item for computing collisions
......@@ -502,9 +502,12 @@ TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64
AbstractGraphicsMediaItem *currentItem = dynamic_cast<AbstractGraphicsMediaItem*>( colliding.at( i ) );
if ( currentItem && currentItem != item )
{
qint32 trackId = currentItem->trackNumber();
Q_ASSERT( trackId >= 0 );
// Collision with an item of the same type
itemCollision = true;
if ( currentItem->trackNumber() > track )
if ( trackId > track )
{
if ( track < 1 )
{
......@@ -514,7 +517,7 @@ TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64
}
track -= 1;
}
else if ( currentItem->trackNumber() <= track )
else if ( trackId <= track )
{
int higherTrack = 0;
if ( item->mediaType() == Workflow::VideoTrack )
......@@ -790,8 +793,11 @@ TracksView::mouseMoveEvent( QMouseEvent *event )
QPointF itemPos = m_actionItem->mapToScene( 0, 0 );
QPointF itemNewSize = mapToScene( event->pos() ) - itemPos;
qint32 trackId = m_actionItem->trackNumber();
Q_ASSERT( trackId >= 0 );
//FIXME: BEGIN UGLY
GraphicsTrack *track = getTrack( m_actionItem->mediaType(), m_actionItem->trackNumber() );
GraphicsTrack *track = getTrack( m_actionItem->mediaType(), trackId );
Q_ASSERT( track );
QPointF collidePos = track->sceneBoundingRect().topRight();
......
......@@ -306,9 +306,9 @@ private:
* \param time The new position (in frames) of the item.
* \sa moveMediaItem( const QUuid& uuid, unsigned int track, qint64 time );
*/
void moveMediaItem( AbstractGraphicsMediaItem *item, quint32 track, qint64 time );
void moveMediaItem( AbstractGraphicsMediaItem *item, qint32 track, qint64 time );
ItemPosition findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64 time );
ItemPosition findPosition( AbstractGraphicsMediaItem *item, qint32 track, qint64 time );
/**
* \brief Return a pointer to the specified track.
......@@ -322,8 +322,8 @@ private:
int m_projectDuration;
GraphicsCursorItem *m_cursorLine;
QGraphicsLinearLayout *m_layout;
quint32 m_numVideoTrack;
quint32 m_numAudioTrack;
qint32 m_numVideoTrack;
qint32 m_numAudioTrack;
MainWorkflow *m_mainWorkflow;
GraphicsMovieItem *m_dragVideoItem;
GraphicsAudioItem *m_dragAudioItem;
......
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