Commit f5edbac0 authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

[Import]: Refactor

Add of a delete button on the media cell and an hightlight selection.
parent 79e1d04f
......@@ -26,6 +26,7 @@
#include "ui_ImportController.h"
#include "ClipRenderer.h"
#include "Library.h"
#include "QPalette"
ImportController::ImportController(QWidget *parent) :
QDialog(parent),
......@@ -74,9 +75,13 @@ ImportController::ImportController(QWidget *parent) :
connect( m_ui->forwardButton, SIGNAL( clicked() ), this, SLOT( forwardButtonClicked() ) );
connect( m_model, SIGNAL( newMediaLoaded( Media* ) ), this, SLOT( newMediaLoaded( Media* ) ) );
connect( m_model, SIGNAL( updateMediaRequested( Media* ) ), this, SLOT( updateMediaRequested( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_preview->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tag, SLOT( mediaSelected( Media* ) ) );
connect( m_mediaListController, SIGNAL( mediaSelected( QUuid ) ), this, SLOT( mediaSelection( QUuid ) ) );
connect( m_mediaListController, SIGNAL( mediaDeleted( QUuid ) ), this, SLOT( mediaDeletion( QUuid ) ) );
}
ImportController::~ImportController()
......@@ -103,12 +108,19 @@ void ImportController::changeEvent( QEvent *e )
void ImportController::newMediaLoaded( Media* media )
{
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 ) );
if ( !m_currentUuid.isNull() )
m_mediaListController->getCell( m_currentUuid )->setPalette( palette() );
QPalette p = m_mediaListController->getCell( uuid )->palette();
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_mediaListController->getCell( uuid )->setPalette( p );
setUIMetaData( m_model->getMedia( uuid ) );
emit mediaSelected( m_model->getMedia( uuid ) );
m_currentUuid = uuid;
}
void ImportController::clipSelection( const QUuid& uuid )
......@@ -118,24 +130,33 @@ void ImportController::clipSelection( const QUuid& uuid )
void ImportController::updateMediaRequested( Media* media )
{
setUIMetaData( media );
emit mediaSelected( media );
m_mediaListController->getCell( media->getUuid() )->setThumbnail( media->getSnapshot() );
}
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() ) );
if ( media != NULL )
{
//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() ) );
}
else
{
m_ui->durationValueLabel->setText( "--:--:--" );
m_ui->nameValueLabel->setText( "none" );
m_ui->resolutionValueLabel->setText( "-- x --" );
m_ui->fpsValueLabel->setText( "--" );
}
}
......@@ -171,3 +192,16 @@ void ImportController::accept()
}
done( Accepted );
}
void ImportController::mediaDeletion( const QUuid& uuid )
{
m_mediaListController->removeMedia( uuid );
m_model->getMedias()->remove( uuid );
if ( uuid == m_currentUuid )
setUIMetaData( NULL );
}
void ImportController::clipDeletion( const QUuid& uuid )
{
}
......@@ -63,6 +63,7 @@ class ImportController : public QDialog
QDirModel* m_filesModel;
QFileSystemWatcher* m_fsWatcher;
QString m_currentlyWatchedDir;
QUuid m_currentUuid;
public slots:
void newMediaLoaded( Media* media );
......@@ -70,6 +71,8 @@ class ImportController : public QDialog
void accept();
void mediaSelection( const QUuid& uuid );
void clipSelection( const QUuid& uuid );
void mediaDeletion( const QUuid& uuid );
void clipDeletion( const QUuid& uuid );
private slots:
void forwardButtonClicked();
......
......@@ -69,7 +69,7 @@ void ImportModel::cutClip( const QUuid& mediaId, const QUuid& clipId,
void ImportModel::metaDataComputed( Media* media )
{
emit newMediaLoaded( media );
emit updateMediaRequested( media );
}
void ImportModel::loadMedia( Media* media )
......@@ -77,6 +77,7 @@ void ImportModel::loadMedia( Media* media )
if ( !m_medias->contains( media->getUuid() ) )
{
m_medias->insert( media->getUuid(), media );
emit newMediaLoaded( media );
connect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ) );
m_metaDataWorker = new MetaDataWorker( media );
m_metaDataWorker->start();
......
......@@ -46,7 +46,7 @@ public:
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; }
QHash<QUuid, Media*>* getMedias() const { return m_medias; }
signals:
void newMediaLoaded( Media* media );
......
......@@ -34,8 +34,10 @@ void ImportMediaCellView::mouseDoubleClickEvent( QMouseEvent* )
void ImportMediaCellView::mousePressEvent( QMouseEvent* )
{
emit cellSelected( uuid() );
this->focusWidget();
}
void ImportMediaCellView::mouseMoveEvent( QMouseEvent* )
{
}
#include "ImportMediaListController.h"
#include <QDebug>
ImportMediaListController::ImportMediaListController( StackViewController* nav ) : ListViewController( nav ), m_nav( nav )
......@@ -16,6 +15,7 @@ void ImportMediaListController::addMedia( Media* media )
{
ImportMediaCellView* cell = new ImportMediaCellView( media->getUuid() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ), this, SLOT( mediaSelection( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SLOT( mediaDeletion( const QUuid& ) ) );
cell->setTitle( media->getFileName() );
cell->setThumbnail( media->getSnapshot() );
......@@ -44,6 +44,7 @@ void ImportMediaListController::addClip( Clip* clip )
{
ImportMediaCellView* cell = new ImportMediaCellView( clip->getUuid() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ), this, SLOT( clipSelection( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SLOT( clipDeletion( const QUuid& ) ) );
cell->setTitle( clip->getParent()->getFileName() + " " + m_mediaCellList->size() + 1 );
cell->setThumbnail( clip->getParent()->getSnapshot() );
......@@ -87,3 +88,13 @@ void ImportMediaListController::clipSelection( const QUuid& uuid )
{
emit clipSelected( uuid );
}
void ImportMediaListController::clipDeletion( const QUuid& uuid )
{
emit clipDeleted( uuid );
}
void ImportMediaListController::mediaDeletion( const QUuid& uuid )
{
emit mediaDeleted( uuid );
}
......@@ -32,10 +32,14 @@ class ImportMediaListController : public ListViewController
void metaDataComputed( Media* media );
void clipSelection( const QUuid& uuid );
void mediaSelection( const QUuid& uuid );
void clipDeletion( const QUuid& uuid );
void mediaDeletion( const QUuid& uuid );
signals:
void mediaSelected( const QUuid& uuid );
void clipSelected( const QUuid& uuid );
void mediaDeleted( const QUuid& uuid );
void clipDeleted( const QUuid& uuid );
};
#endif // IMPORTMEDIALISTCONTROLLER_H
......@@ -24,12 +24,15 @@
#include "ui_MediaCellView.h"
#include "Library.h"
#include "ClipProperty.h"
#include <QDebug>
MediaCellView::MediaCellView( const QUuid& uuid, QWidget *parent ) :
QWidget( parent ), m_ui( new Ui::MediaCellView ), m_uuid( uuid )
{
m_ui->setupUi( this );
setFocusPolicy( Qt::ClickFocus );
setAutoFillBackground( true );
connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) );
}
MediaCellView::~MediaCellView()
......@@ -121,3 +124,13 @@ const ClickableLabel* MediaCellView::nextButton() const
{
return m_ui->arrow;
}
const ClickableLabel* MediaCellView::deleteButton() const
{
return m_ui->delLabel;
}
void MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
{
emit cellDeleted( uuid() );
}
......@@ -47,6 +47,7 @@ public:
QString title() const;
const QUuid& uuid() const;
const ClickableLabel* nextButton() const;
const ClickableLabel* deleteButton() const;
protected:
void changeEvent( QEvent *e );
......@@ -64,7 +65,10 @@ protected:
signals:
void cellSelected( const QUuid& uuid );
void arrowClicked( const QUuid& uuid );
void cellDeleted( const QUuid& uuid );
public slots:
void deleteButtonClicked( QWidget* sender, QMouseEvent* event );
};
......
......@@ -199,20 +199,34 @@
</layout>
</item>
<item>
<widget class="ClickableLabel" name="arrow">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../../ressources.qrc">:/images/images/marker_left.png</pixmap>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="ClickableLabel" name="delLabel">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../../ressources.qrc">:/images/images/clear.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="ClickableLabel" name="arrow">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../../ressources.qrc">:/images/images/marker_left.png</pixmap>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
......
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