Commit c7f780d7 authored by Ludovic Fauvet's avatar Ludovic Fauvet

TracksView is now a singleton

parent d976963c
......@@ -39,7 +39,7 @@ Timeline::Timeline( QWidget *parent ) :
m_mainWorkflow = new MainWorkflow( MAX_TRACKS );
m_tracksScene = new TracksScene( this );
m_tracksView = new TracksView( m_tracksScene, m_mainWorkflow, m_ui.tracksFrame );
m_tracksView = TracksView::instance( m_tracksScene, m_mainWorkflow, m_ui.tracksFrame );
m_tracksView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_tracksView->scale(1, 1);
m_tracksView->setAlignment( Qt::AlignLeft | Qt::AlignTop );
......
......@@ -35,9 +35,26 @@
#include "GraphicsCursorItem.h"
#include "Commands.hpp"
TracksView* TracksView::m_instance = NULL;
TracksView* TracksView::instance( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent )
{
if ( m_instance ) return m_instance;
m_instance = new TracksView( scene, mainWorkflow, parent );
return m_instance;
}
TracksView* TracksView::instance()
{
Q_ASSERT( m_instance );
return m_instance;
}
TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent )
: QGraphicsView( scene, parent ), m_scene( scene ), m_mainWorkflow( mainWorkflow )
{
connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( deleteLater() ) );
//TODO should be defined by the settings
m_tracksHeight = 25;
......
......@@ -81,7 +81,8 @@ class TracksView : public QGraphicsView
Q_OBJECT
public:
TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent = 0 );
static TracksView* instance( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent = 0 );
static TracksView* instance();
void setDuration( int duration );
int duration() const { return m_projectDuration; }
int tracksHeight() const { return m_tracksHeight; }
......@@ -112,11 +113,14 @@ private slots:
void updateDuration();
private:
TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent = 0 );
virtual ~TracksView() { }
void createLayout();
void addVideoTrack();
void addAudioTrack();
void moveMediaItem( AbstractGraphicsMediaItem* item, QPoint position );
void moveMediaItem( AbstractGraphicsMediaItem* item, int track, int time );
static TracksView* m_instance;
QGraphicsScene* m_scene;
int m_tracksHeight;
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