Commit 79e1d04f authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

[Import]: Refactor:

The preview and the tag system are available again.
Some clean
parent 054f9c58
/*****************************************************************************
* ImportController.cpp
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@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 <QTime>
#include "ImportController.h"
#include "ui_ImportController.h"
#include "ClipRenderer.h"
......@@ -50,6 +74,9 @@ ImportController::ImportController(QWidget *parent) :
connect( m_ui->forwardButton, SIGNAL( clicked() ), this, SLOT( forwardButtonClicked() ) );
connect( m_model, SIGNAL( newMediaLoaded( Media* ) ), this, SLOT( newMediaLoaded( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_preview->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tag, SLOT( mediaSelected( Media* ) ) );
}
ImportController::~ImportController()
......@@ -63,29 +90,58 @@ ImportController::~ImportController()
void ImportController::changeEvent( QEvent *e )
{
QDialog::changeEvent( e );
switch ( e->type() ) {
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
}
}
void ImportController::newMediaLoaded( Media* media )
{
qDebug() << media->getFileName();
m_mediaListController->addMedia( media );
connect( m_mediaListController, SIGNAL( mediaSelected( QUuid ) ), this, SLOT( mediaSelection( QUuid ) ) );
}
void ImportController::mediaSelection( const QUuid& uuid )
{
updateMediaRequested( m_model->getMedia( uuid ) );
}
void ImportController::clipSelection( const QUuid& uuid )
{
Q_UNUSED( uuid );
}
void ImportController::updateMediaRequested( Media* media )
{
Q_UNUSED( media );
setUIMetaData( media );
emit mediaSelected( media );
}
void ImportController::setUIMetaData( Media* media )
{
//Duration
QTime duration;
duration = duration.addSecs( media->getLength() );
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( media->getFileInfo()->fileName() );
m_ui->nameValueLabel->setWordWrap( true );
setWindowTitle( media->getFileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( media->getWidth() )
+ " x " + QString::number( media->getHeight() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( media->getFps() ) );
}
void ImportController::forwardButtonClicked()
{
m_model->loadFile(m_filesModel->fileInfo( m_ui->treeView->selectionModel()->currentIndex() ).filePath());
m_model->loadFile( m_filesModel->fileInfo( m_ui->treeView->selectionModel()->currentIndex() ).filePath() );
}
void ImportController::treeViewClicked( const QModelIndex& index )
......
/*****************************************************************************
* ImportController.h
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@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 IMPORTCONTROLLER_H
#define IMPORTCONTROLLER_H
......@@ -13,40 +36,49 @@
#include "TagWidget.h"
#include "ImportMediaListController.h"
namespace Ui {
namespace Ui
{
class ImportController;
}
class ImportController : public QDialog {
class ImportController : public QDialog
{
Q_OBJECT
public:
ImportController(QWidget *parent = 0);
~ImportController();
protected:
void changeEvent(QEvent *e);
private:
Ui::ImportController* m_ui;
PreviewWidget* m_preview;
ImportModel* m_model;
StackViewController* m_stackNav;
TagWidget* m_tag;
ImportMediaListController* m_mediaListController;
QDirModel* m_filesModel;
QFileSystemWatcher* m_fsWatcher;
QString m_currentlyWatchedDir;
public slots:
void newMediaLoaded( Media* media );
void updateMediaRequested( Media* media );
void accept();
private slots:
void forwardButtonClicked();
void treeViewClicked( const QModelIndex& index );
void treeViewDoubleClicked( const QModelIndex& index);
public:
ImportController(QWidget *parent = 0);
~ImportController();
void setUIMetaData( Media* media );
protected:
void changeEvent(QEvent *e);
private:
Ui::ImportController* m_ui;
PreviewWidget* m_preview;
ImportModel* m_model;
StackViewController* m_stackNav;
TagWidget* m_tag;
ImportMediaListController* m_mediaListController;
QDirModel* m_filesModel;
QFileSystemWatcher* m_fsWatcher;
QString m_currentlyWatchedDir;
public slots:
void newMediaLoaded( Media* media );
void updateMediaRequested( Media* media );
void accept();
void mediaSelection( const QUuid& uuid );
void clipSelection( const QUuid& uuid );
private slots:
void forwardButtonClicked();
void treeViewClicked( const QModelIndex& index );
void treeViewDoubleClicked( const QModelIndex& index );
signals:
void mediaSelected( Media* );
void clipSelected( Clip* );
};
#endif // IMPORTCONTROLLER_H
/*****************************************************************************
* ImportModel.cpp
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@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 <QDebug>
#include <QDir>
......@@ -16,17 +39,12 @@ ImportModel::~ImportModel()
delete m_medias->value( id );
}
const Media* ImportModel::getMedia( const QUuid& mediaId ) const
Media* ImportModel::getMedia( const QUuid& mediaId ) const
{
return m_medias->value( mediaId );
}
const QHash<QUuid, Media*>* ImportModel::getMedias() const
{
return m_medias;
}
const Clip* ImportModel::getClip( const QUuid& mediaId, const QUuid& clipId ) const
Clip* ImportModel::getClip( const QUuid& mediaId, const QUuid& clipId ) const
{
Media* media = m_medias->value( mediaId );
......@@ -51,7 +69,6 @@ void ImportModel::cutClip( const QUuid& mediaId, const QUuid& clipId,
void ImportModel::metaDataComputed( Media* media )
{
qDebug() << "Meta computed";
emit newMediaLoaded( media );
}
......@@ -60,8 +77,6 @@ void ImportModel::loadMedia( Media* media )
if ( !m_medias->contains( media->getUuid() ) )
{
m_medias->insert( media->getUuid(), media );
//emit mediaAdded( media, m_mediaList->getCell( media->getUuid() ) );
connect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ) );
m_metaDataWorker = new MetaDataWorker( media );
m_metaDataWorker->start();
......@@ -82,13 +97,11 @@ void ImportModel::loadFile( const QFileInfo& fileInfo )
else
{
QDir dir = QDir( fileInfo.filePath() );
for( int i = 0; i < dir.count() ; i++)
for( uint i = 0; i < dir.count() ; i++)
{
QFileInfo info = QFileInfo(dir.filePath( dir[i] ) );
//qDebug() << info.filePath();
if ( info.isDir() )
continue ;
//qDebug() << "not a dir [" << info.fileName() << "]";
media = new Media( info.filePath() );
loadMedia( media );
}
......
/*****************************************************************************
* ImportModel.h
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@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 IMPORTMODEL_H
#define IMPORTMODEL_H
......@@ -16,14 +39,14 @@ public:
ImportModel();
~ImportModel();
const Media* getMedia( const QUuid& mediaId ) const;
const QHash<QUuid, Media*>* getMedias() const;
const Clip* getClip( const QUuid& mediaId, const QUuid& clipId ) const;
Media* getMedia( const QUuid& mediaId ) const;
Clip* getClip( const QUuid& mediaId, const QUuid& clipId ) const;
void cutMedia( const QUuid& mediaId, int frame );
void cutClip( const QUuid& mediaId, const QUuid& clipId, int frame );
void loadFile( const QFileInfo& fileInfo );
void removeMedia( const QUuid& mediaId );
void removeClip( const QUuid& mediaId, const QUuid& clipId );
const QHash<QUuid, Media*>* getMedias() const { return m_medias; }
signals:
void newMediaLoaded( Media* media );
......
......@@ -33,7 +33,7 @@ void ImportMediaCellView::mouseDoubleClickEvent( QMouseEvent* )
void ImportMediaCellView::mousePressEvent( QMouseEvent* )
{
emit mediaSelected( uuid() );
emit cellSelected( uuid() );
}
void ImportMediaCellView::mouseMoveEvent( QMouseEvent* )
......
......@@ -14,9 +14,6 @@ class ImportMediaCellView : public MediaCellView
void mouseDoubleClickEvent( QMouseEvent* );
void mousePressEvent( QMouseEvent* );
void mouseMoveEvent( QMouseEvent* );
signals:
void mediaSelected( QUuid );
};
#endif // IMPORTMEDIACELLVIEW_H
......@@ -15,6 +15,7 @@ ImportMediaListController::~ImportMediaListController()
void ImportMediaListController::addMedia( Media* media )
{
ImportMediaCellView* cell = new ImportMediaCellView( media->getUuid() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ), this, SLOT( mediaSelection( const QUuid& ) ) );
cell->setTitle( media->getFileName() );
cell->setThumbnail( media->getSnapshot() );
......@@ -42,6 +43,7 @@ void ImportMediaListController::removeMedia( const QUuid& uuid )
void ImportMediaListController::addClip( Clip* clip )
{
ImportMediaCellView* cell = new ImportMediaCellView( clip->getUuid() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ), this, SLOT( clipSelection( const QUuid& ) ) );
cell->setTitle( clip->getParent()->getFileName() + " " + m_mediaCellList->size() + 1 );
cell->setThumbnail( clip->getParent()->getSnapshot() );
......@@ -75,3 +77,13 @@ void ImportMediaListController::addClipsFromMedia( Media* media )
foreach( uuid, media->clips()->keys() )
addClip( media->clips()->value( uuid ) );
}
void ImportMediaListController::mediaSelection( const QUuid& uuid )
{
emit mediaSelected( uuid );
}
void ImportMediaListController::clipSelection( const QUuid& uuid )
{
emit clipSelected( uuid );
}
......@@ -16,7 +16,7 @@ class ImportMediaListController : public ListViewController
~ImportMediaListController();
void addMedia( Media* media );
void removeMedia( const QUuid& uuid );
void addClip( Clip* media );
void addClip( Clip* clip );
void removeClip( const QUuid& uuid );
void cleanAll();
void addClipsFromMedia( Media* media );
......@@ -25,11 +25,17 @@ class ImportMediaListController : public ListViewController
ImportMediaCellView* getCell( QUuid uuid ) const;
private:
StackViewController* m_nav;
QHash<QUuid, ImportMediaCellView*>* m_mediaCellList;
StackViewController* m_nav;
QHash<QUuid, ImportMediaCellView*>* m_mediaCellList;
public slots:
void metaDataComputed( Media* media );
void clipSelection( const QUuid& uuid );
void mediaSelection( const QUuid& uuid );
signals:
void mediaSelected( const QUuid& uuid );
void clipSelected( const QUuid& uuid );
};
#endif // IMPORTMEDIALISTCONTROLLER_H
......@@ -26,8 +26,7 @@
#include "MediaCellView.h"
#include "Library.h"
ListViewController::ListViewController( StackViewController* nav ) : m_nav( nav ),
m_currentUuid( 0 )
ListViewController::ListViewController( StackViewController* nav ) : m_nav( nav )
{
m_title = new QString( "Media List" );
m_scrollArea = new QScrollArea();
......@@ -74,14 +73,3 @@ void ListViewController::removeCell( QWidget* cell )
m_layout->removeWidget( cell );
delete cell;
}
void ListViewController::cellSelected( const QUuid& uuid )
{
if ( m_currentUuid == 0 || *m_currentUuid != uuid )
{
if ( m_currentUuid != 0 )
delete m_currentUuid;
m_currentUuid = new QUuid( uuid );
emit selectedClipChanged( Library::getInstance()->getClip( uuid ) );
}
}
......@@ -57,13 +57,6 @@ private:
QWidget* m_container;
StackViewController* m_nav;
QUuid* m_currentUuid;
public slots:
void cellSelected( const QUuid& );
signals:
void selectedClipChanged( Clip* );
};
#endif // LISTVIEWCONTROLLER_H
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