Commit f0cc52c5 authored by Clement CHAVANCE's avatar Clement CHAVANCE Committed by Clement CHAVANCE
Browse files

fixed a graphical bug with the deletion of the clip

also added forgaotten files
parent f4066d3c
/*****************************************************************************
* ClipListViewController.cpp: controller for the library clip list
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <chavance.c@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 <QtDebug>
#include <QWidget>
#include "ClipListViewController.h"
#include "MediaCellView.h"
#include "Library.h"
ClipListViewController::ClipListViewController( StackViewController* nav, const QUuid& mediaId )
: ListViewController( nav ),
m_nav( nav ),
m_mediaId( mediaId ),
m_currentUuid()
{
}
ClipListViewController::~ClipListViewController()
{
clean();
}
void ClipListViewController::addClipsFromMedia( Media* media )
{
foreach( Clip* clip, *media->clips() )
addClip( clip );
}
void ClipListViewController::addClip( Clip* clip )
{
MediaCellView* cell = new MediaCellView( clip->getUuid() );
connect( cell, SIGNAL( cellSelected( QUuid ) ), this, SLOT( cellSelection( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SLOT( clipDeletion( const QUuid& ) ) );
cell->setThumbnail( clip->getParent()->getSnapshot() );
QString number;
number.setNum( m_cells.size() + 1 );
cell->setTitle( clip->getParent()->getFileName() + number );
cell->setLength( clip->getLengthSecond(), false );
addCell( cell );
m_cells.insert( clip->getUuid(), cell );
}
void ClipListViewController::clean()
{
foreach ( QWidget* widg, m_cells )
{
removeCell( widg );
delete widg;
}
m_cells.clear();
}
void ClipListViewController::cellSelection( const QUuid& uuid )
{
qDebug() << "cell selected";
if ( m_currentUuid == uuid )
return;
if ( m_cells.contains( uuid ) )
{
qDebug() << "uuid found" << uuid;
if ( !m_currentUuid.isNull() && m_cells.contains( m_currentUuid ) )
m_cells.value( m_currentUuid )->setPalette( m_cells.value( uuid )->palette() );
QPalette p = m_cells.value( uuid )->palette();
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_cells.value( uuid )->setPalette( p );
m_currentUuid = uuid;
emit clipSelected( uuid );
}
}
void ClipListViewController::clipDeletion( const QUuid& uuid )
{
if ( m_cells.contains( uuid ) )
{
QWidget* cell = m_cells.value( uuid );
removeCell( cell );
m_cells.remove( uuid );
m_currentUuid = QUuid();
Library::getInstance()->getMedia( m_mediaId )->removeClip( uuid );
m_cells.remove( uuid );
}
}
/*****************************************************************************
* ClipListViewController.h: controller for the library clip list
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <chavance.c@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 CLIPLISTVIEWCONTROLLER_H
#define CLIPLISTVIEWCONTROLLER_H
#include "ListViewController.h"
#include "Media.h"
#include "Clip.h"
class ClipListViewController : public ListViewController
{
Q_OBJECT
public:
explicit ClipListViewController( StackViewController* nav, const QUuid& uuid);
~ClipListViewController();
void addClipsFromMedia( Media* media );
private:
void addClip( Clip* clip );
void clean();
StackViewController* m_nav;
QHash<QUuid, QWidget*> m_cells;
QUuid m_mediaId;
QUuid m_currentUuid;
public slots:
void cellSelection( const QUuid& uuid );
void clipDeletion( const QUuid& uuid );
signals:
void clipSelected( const QUuid& uuid );
void clipDeleted( const QUuid& uuid );
};
#endif
......@@ -38,8 +38,8 @@ MediaLibraryWidget::MediaLibraryWidget( QWidget* parent ) : QWidget( parent )
connect( library, SIGNAL( mediaRemoved( QUuid ) ), list, SLOT( mediaRemoved( const QUuid& ) ) );
connect( m_nav, SIGNAL( importRequired() ), this, SIGNAL( importRequired() ) );
//Clip
connect( list, SIGNAL( clipSelected( Clip* clip ) ), this, SIGNAL( clipSelected( Clip* ) ) );
connect( list, SIGNAL( clipRemoved( const QUuid&, const QUuid& ) ), library, SLOT( removeClip( const QUuid&, const QUuid& ) ) );
//connect( list, SIGNAL( clipSelected( Clip* clip ) ), this, SIGNAL( clipSelected( Clip* ) ) );
//connect( list, SIGNAL( clipRemoved( const QUuid&, const QUuid& ) ), library, SLOT( removeClip( const QUuid&, const QUuid& ) ) );
m_nav->pushViewController( list );
}
......
......@@ -93,19 +93,17 @@ void MediaListViewController::updateCell( Media* media )
void MediaListViewController::showClipList( const QUuid& uuid )
{
qDebug() << Library::getInstance()->getMedia( uuid )->clips()->size();
if ( Library::getInstance()->getMedia( uuid )->clips()->size() == 0 )
return ;
m_clipsListView = new ClipListViewController( m_nav, uuid );
m_clipsListView->addClipsFromMedia( Library::getInstance()->getMedia( uuid ) );
qDebug() << "Clips added";
connect( m_clipsListView, SIGNAL( clipSelected( const QUuid& ) ), this, SIGNAL( clipSelected( const QUuid& ) ) );
m_nav->pushViewController( m_clipsListView );
qDebug() << "View Pushed";
}
void MediaListViewController::restoreContext()
{
qDebug() << "context restored";
if ( m_clipsListView != 0 )
delete m_clipsListView;
m_clipsListView = 0;
......
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