Commit 1f273a07 authored by Christophe Courtaut's avatar Christophe Courtaut

[Backend] Begining of Timeline Backend

parent 62c5aa51
/*****************************************************************************
* TimelineBackend.cpp: Backend for Timeline
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "TimelineBackend.h"
TimelineBackend::TimelineBackend()
{
m_audioTracks = new QMap<int, Track*>();
m_videoTracks = new QMap<int, Track*>();
}
Track* TimelineBackend::getTrack( TimelineBackend::TrackType type, int index ) const
{
if ( type == TimelineBackend::Audio )
return m_audioTracks->value( index, NULL );
else if ( type == TimelineBackend::Video)
return m_videoTracks->value( index, NULL );
return NULL;
}
int TimelineBackend::createNewTrack( TimelineBackend::TrackType type )
{
Track* track = new Track();
if ( type == TimelineBackend::Audio )
m_audioTracks->insert( findNewIndex( type ), track );
else
m_videoTracks->insert( findNewIndex( type ), track );
return getTrackIndex( type, track );
}
bool TimelineBackend::removeTrack( TimelineBackend::TrackType type, int index )
{
QMap<int, Track*>* map = ( type == TimelineBackend::Audio ) ? m_audioTracks : m_videoTracks;
return map->remove( index );
}
int TimelineBackend::getTrackIndex( TimelineBackend::TrackType type, Track* track ) const
{
QMap<int, Track*>* map = ( type == TimelineBackend::Audio ) ? m_audioTracks : m_videoTracks;
return map->key( track, -1 );
}
int TimelineBackend::findNewIndex( TimelineBackend::TrackType type ) const
{
QMap<int, Track*>* map = ( type == TimelineBackend::Audio ) ? m_audioTracks : m_videoTracks;
int index = 0;
while ( index < map->size() )
{
if ( !map->contains( index ) )
return index;
index++;
}
return index;
}
/*****************************************************************************
* TimelineBackend.h: Backend for Timeline
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef TIMELINEBACKEND_H
#define TIMELINEBACKEND_H
#include <QObject>
#include <QMap>
#include "Track.h"
class TimelineBackend : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( TimelineBackend );
public:
enum TrackType
{
Audio,
Video
};
TimelineBackend();
Track* getTrack( TimelineBackend::TrackType type , int index ) const;
int createNewTrack( TimelineBackend::TrackType type );
bool removeTrack( TimelineBackend::TrackType type, int index );
int getTrackIndex( TimelineBackend::TrackType type, Track* track) const;
private:
int findNewIndex( TimelineBackend::TrackType type ) const;
private:
QMap<int, Track*>* m_audioTracks;
QMap<int, Track*>* m_videoTracks;
};
#endif // TIMELINEBACKEND_H
/*****************************************************************************
* Track.cpp: Object Representation of Track
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Track.h"
Track::Track()
{
}
/*****************************************************************************
* Track.h: Object Representation of Track
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef TRACK_H
#define TRACK_H
#include <QObject>
class Track : public QObject
{
Q_OBJECT
public:
Track();
};
#endif // TRACK_H
......@@ -37,7 +37,9 @@ SOURCES += src/main.cpp \
src/gui/AbstractGraphicsMediaItem.cpp \
src/Media.cpp \
src/gui/FileBrowser.cpp \
src/gui/GraphicsCursorItem.cpp
src/gui/GraphicsCursorItem.cpp \
src/TimelineBackend.cpp \
src/Track.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -67,7 +69,9 @@ HEADERS += src/gui/MainWindow.h \
src/gui/GraphicsMovieItem.h \
src/Media.h \
src/gui/FileBrowser.h \
src/gui/GraphicsCursorItem.h
src/gui/GraphicsCursorItem.h \
src/TimelineBackend.h \
src/Track.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
......@@ -76,7 +80,7 @@ FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/About.ui \
src/gui/ui/Transcode.ui \
src/gui/ui/FileBrowser.ui
FORMS +=
FORMS +=
TRANSLATIONS = ts/vlmc_es.ts \
ts/vlmc_fr.ts \
ts/vlmc_sv.ts
......
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