Commit 2636c6cf authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

The medias can now be removed from the listView in the import menu.

Add of a clip list inside a media.
This list can now be shown by the arrow in the MediaCellView. This arrow is a generic clickableLabel.
parent 83c0c239
#include "ClickableLabel.h"
ClickableLabel::ClickableLabel( QWidget* parent ) : QLabel( parent )
{
}
void ClickableLabel::mousePressEvent( QMouseEvent* ev )
{
emit clicked( this, ev );
}
#ifndef CLICKABLELABEL_H
#define CLICKABLELABEL_H
#include <QLabel>
class ClickableLabel : public QLabel
{
Q_OBJECT
public:
ClickableLabel( QWidget* parent = NULL );
void mousePressEvent( QMouseEvent* ev );
signals:
void clicked( QWidget* sender, QMouseEvent* ev );
};
#endif // CLICKABLELABEL_H
......@@ -35,10 +35,11 @@ Import::Import(QWidget *parent) :
m_tagWidget = new TagWidget( m_ui->TagWidget, 6 );
connect( m_importBrowser, SIGNAL( mediaAdded( Media*, ImportMediaCellView* ) ), this, SLOT( addMedia( Media*, ImportMediaCellView* ) ) );
//connect( m_importBrowser, SIGNAL( mediaRemoved( Media* ) ), this, SLOT( removeMedia( Media* ) ) );
connect( m_importBrowser, SIGNAL( mediaRemoved() ), this, SLOT( removeMedia() ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_previewWidget->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tagWidget, SLOT( mediaSelected( Media* ) ) );
}
Import::~Import()
......@@ -53,29 +54,33 @@ void Import::addMedia( Media* media, ImportMediaCellView* cell )
{
m_mediaList.insert( media->getUuid(), media );
connect( cell, SIGNAL( mediaSelected( QUuid ) ), this, SLOT( setUIMetaData( QUuid ) ) );
connect( cell->nextButton(), SIGNAL( clicked( QWidget*,QMouseEvent* ) ), this, SLOT( clipViewRequested( QWidget*,QMouseEvent* ) ) );
}
void Import::removeMedia( QUuid Uuid )
void Import::removeMedia()
{
m_mediaList.remove( Uuid );
m_mediaList.remove( m_currentUuid );
m_importBrowser->getMediaListView()->removeMedia( m_currentUuid );
}
void Import::setUIMetaData( QUuid Uuid )
void Import::setUIMetaData( QUuid uuid )
{
m_currentUuid = uuid;
//Duration
QTime duration;
duration = duration.addSecs( m_mediaList[Uuid]->getLength() );
duration = duration.addSecs( m_mediaList[uuid]->getLength() );
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( m_mediaList[Uuid]->getFileInfo()->fileName() );
setWindowTitle( m_mediaList[Uuid]->getFileInfo()->fileName() + " " + tr( "properties" ) );
m_ui->nameValueLabel->setText( m_mediaList[uuid]->getFileInfo()->fileName() );
setWindowTitle( m_mediaList[uuid]->getFileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( m_mediaList[Uuid]->getWidth() )
+ " x " + QString::number( m_mediaList[Uuid]->getHeight() ) );
m_ui->resolutionValueLabel->setText( QString::number( m_mediaList[uuid]->getWidth() )
+ " x " + QString::number( m_mediaList[uuid]->getHeight() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( m_mediaList[Uuid]->getFps() ) );
m_ui->fpsValueLabel->setText( QString::number( m_mediaList[uuid]->getFps() ) );
emit mediaSelected( m_mediaList[Uuid] );
emit mediaSelected( m_mediaList[uuid] );
}
void Import::accept()
......@@ -101,3 +106,14 @@ void Import::changeEvent( QEvent *e )
break;
}
}
void Import::clipViewRequested( QWidget* sender, QMouseEvent* ev )
{
MediaCellView* cell = qobject_cast<MediaCellView*>(sender->parent());
if ( cell == NULL )
return;
m_importBrowser->getClipListView()->cleanAll();
Media* media = m_mediaList[cell->uuid()];
m_importBrowser->getClipListView()->addClipsFromMedia( media );
m_importBrowser->getStackViewController()->pushViewController( m_importBrowser->getClipListView() );
}
......@@ -51,12 +51,14 @@ class Import : public QDialog
ImportBrowser* m_importBrowser;
TagWidget* m_tagWidget;
QHash<QUuid, Media*> m_mediaList;
QUuid m_currentUuid;
private slots:
void accept();
void addMedia( Media* media, ImportMediaCellView* cell );
void removeMedia( QUuid Uuid );
void setUIMetaData( QUuid Uuid );
void removeMedia();
void setUIMetaData( QUuid uuid );
void clipViewRequested( QWidget* sender, QMouseEvent* ev );
signals:
void mediaSelected( Media* );
......
......@@ -32,8 +32,9 @@ ImportBrowser::ImportBrowser( QWidget* parent ) : QWidget( parent )
{
m_ui.setupUi( this );
m_FilesModel = new QDirModel();
m_nav = new StackViewController( m_ui.MediaListWidget );
m_nav = new StackViewController( m_ui.MediaListWidget, false );
m_mediaList = new ImportMediaListController( m_nav );
m_clipList = new ImportMediaListController( m_nav );
m_nav->pushViewController( m_mediaList );
QStringList filters;
......@@ -93,8 +94,7 @@ void ImportBrowser::on_treeViewBrowser_doubleClicked( QModelIndex index)
void ImportBrowser::on_pushButtonBackward_clicked()
{
//emit mediaRemoved( m_currentCellSelected );
emit mediaRemoved();
if ( m_mediaList->getMediaCellList()->isEmpty() )
m_ui.pushButtonBackward->setEnabled( false );
}
......
......@@ -42,6 +42,9 @@ class ImportBrowser : public QWidget
public:
ImportBrowser( QWidget* parent = NULL );
virtual ~ImportBrowser();
ImportMediaListController* getMediaListView() { return m_mediaList; }
ImportMediaListController* getClipListView() { return m_clipList; }
StackViewController* getStackViewController() { return m_nav; }
private:
void TreeViewBrowserDirectoryChanged( QModelIndex& index );
......@@ -55,6 +58,7 @@ private:
MetaDataWorker* m_metaDataWorker;
StackViewController* m_nav;
ImportMediaListController* m_mediaList;
ImportMediaListController* m_clipList;
private slots:
void on_pushButtonForward_clicked();
......@@ -65,7 +69,7 @@ private slots:
signals:
void mediaSelected( QFileInfo fileInfos );
void mediaAdded( Media* media, ImportMediaCellView* );
void mediaRemoved( QFileInfo fileInfos );
void mediaRemoved();
};
#endif /* !IMPORTBROWSER_H */
/*****************************************************************************
* ImportMediaCellView.cpp: Inherited class of the MediaCellView
*****************************************************************************
* 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 "ImportMediaCellView.h"
ImportMediaCellView::ImportMediaCellView( const QUuid& uuid, QWidget *parent ) : MediaCellView( uuid, parent )
{
}
void ImportMediaCellView::mouseDoubleClickEvent( QMouseEvent* )
{
}
void ImportMediaCellView::mousePressEvent( QMouseEvent* )
{
emit mediaSelected( uuid() );
}
void ImportMediaCellView::mouseMoveEvent( QMouseEvent* )
{
}
......@@ -13,6 +13,7 @@ class ImportMediaCellView : public MediaCellView
protected:
void mouseDoubleClickEvent( QMouseEvent* );
void mousePressEvent( QMouseEvent* );
void mouseMoveEvent( QMouseEvent* );
signals:
void mediaSelected( QUuid );
......
......@@ -32,3 +32,46 @@ ImportMediaCellView* ImportMediaListController::getCell( QUuid uuid ) const
{
return m_mediaCellList->value( uuid );
}
void ImportMediaListController::removeMedia( const QUuid& uuid )
{
removeCell( m_mediaCellList->value( uuid ) );
m_mediaCellList->remove( uuid );
}
void ImportMediaListController::addClip( Clip* clip )
{
ImportMediaCellView* cell = new ImportMediaCellView( clip->getUuid() );
cell->setTitle( clip->getParent()->getFileName() + " " + m_mediaCellList->size() + 1 );
cell->setThumbnail( clip->getParent()->getSnapshot() );
addCell( cell );
m_mediaCellList->insert( clip->getUuid(), cell );
}
void ImportMediaListController::removeClip( const QUuid& uuid )
{
removeCell( m_mediaCellList->value( uuid ) );
m_mediaCellList->remove( uuid );
}
void ImportMediaListController::cleanAll()
{
QUuid uuid;
MediaCellView* cell;
foreach( uuid, m_mediaCellList->keys() )
{
cell = m_mediaCellList->value( uuid );
m_layout->removeWidget( cell );
delete cell;
}
m_mediaCellList->clear();
}
void ImportMediaListController::addClipsFromMedia( Media* media )
{
QUuid uuid;
foreach( uuid, media->clips()->keys() )
addClip( media->clips()->value( uuid ) );
}
......@@ -4,6 +4,7 @@
#include "StackViewController.h"
#include "ListViewController.h"
#include "Media.h"
#include "Clip.h"
#include "ImportMediaCellView.h"
class ImportMediaListController : public ListViewController
......@@ -14,6 +15,11 @@ class ImportMediaListController : public ListViewController
ImportMediaListController( StackViewController* nav );
~ImportMediaListController();
void addMedia( Media* media );
void removeMedia( const QUuid& uuid );
void addClip( Clip* media );
void removeClip( const QUuid& uuid );
void cleanAll();
void addClipsFromMedia( Media* media );
const QHash<QUuid, ImportMediaCellView*>* getMediaCellList() const { return m_mediaCellList; }
ImportMediaCellView* getCell( QUuid uuid ) const;
......
......@@ -69,6 +69,12 @@ void ListViewController::addCell( QWidget* cell )
m_layout->addWidget( cell );
}
void ListViewController::removeCell( QWidget* cell )
{
m_layout->removeWidget( cell );
delete cell;
}
void ListViewController::cellSelected( const QUuid& uuid )
{
if ( m_currentUuid == 0 || *m_currentUuid != uuid )
......
......@@ -46,12 +46,16 @@ public:
QWidget* view() const;
const QString& title() const;
void addCell( QWidget* cell );
void removeCell( QWidget* cell );
protected:
QVBoxLayout* m_layout;
private:
QString* m_title;
QScrollArea* m_scrollArea;
QWidget* m_container;
QVBoxLayout* m_layout;
StackViewController* m_nav;
QUuid* m_currentUuid;
......
......@@ -116,3 +116,8 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event )
drag->setPixmap( Library::getInstance()->getClip( m_uuid )->getParent()->getSnapshot().scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
const ClickableLabel* MediaCellView::nextButton() const
{
return m_ui->arrow;
}
......@@ -26,6 +26,7 @@
#include <QWidget>
#include <QUuid>
#include <QMouseEvent>
#include "ClickableLabel.h"
namespace Ui
{
......@@ -40,17 +41,18 @@ public:
MediaCellView( const QUuid& uuid, QWidget *parent = 0 );
~MediaCellView();
void setTitle( const QString& title );
void setThumbnail( const QPixmap& pixmap );
const QPixmap* getThumbnail() const;
QString title() const;
const QUuid& uuid() const;
void setTitle( const QString& title );
void setThumbnail( const QPixmap& pixmap );
const QPixmap* getThumbnail() const;
QString title() const;
const QUuid& uuid() const;
const ClickableLabel* nextButton() const;
protected:
void changeEvent( QEvent *e );
private:
Ui::MediaCellView *m_ui;
Ui::MediaCellView* m_ui;
const QUuid m_uuid;
QPoint m_dragStartPos;
......@@ -61,6 +63,7 @@ protected:
signals:
void cellSelected( const QUuid& uuid );
void arrowClicked( const QUuid& uuid );
};
......
......@@ -21,21 +21,30 @@
*****************************************************************************/
#include "StackViewController.h"
#include "Import.h"
StackViewController::StackViewController( QWidget* parent ) :
StackViewController::StackViewController( QWidget* parent, bool enableImport ) :
QWidget( parent ), m_current( 0 )
{
m_nav = new StackViewNavController( this );
m_footer = new QLabel( "Footer" );
m_layout = new QVBoxLayout;
m_controllerStack = new QStack<ViewController*>();
m_footer->setAlignment( Qt::AlignCenter );
QObject::connect( m_nav->previousButton(), SIGNAL( clicked() ),
connect( m_nav->previousButton(), SIGNAL( clicked() ),
this, SLOT( previous() ) );
m_layout->addWidget( m_nav );
m_layout->addWidget( m_footer );
if ( enableImport )
{
m_importButton = new QPushButton( "Import", parent );
m_layout->addWidget( m_importButton );
connect( m_importButton, SIGNAL( clicked() ), this, SLOT( displayImportMenu() ) );
}
parent->setLayout( m_layout );
}
......@@ -43,7 +52,7 @@ StackViewController::StackViewController( QWidget* parent ) :
StackViewController::~StackViewController()
{
delete m_nav;
delete m_footer;
delete m_importButton;
delete m_layout;
delete m_controllerStack;
}
......@@ -101,3 +110,9 @@ const ViewController* StackViewController::getCurrentViewController() const
{
return m_current;
}
void StackViewController::displayImportMenu()
{
Import* import = new Import( );
import->exec();
}
......@@ -38,7 +38,7 @@ class StackViewController : public QWidget
Q_OBJECT
public:
StackViewController( QWidget* parent = 0 );
StackViewController( QWidget* parent = 0, bool enableImport = true );
~StackViewController();
void pushViewController( ViewController* viewController,
......@@ -48,13 +48,14 @@ public:
private:
StackViewNavController* m_nav;
QLabel* m_footer;
QPushButton* m_importButton;
QVBoxLayout* m_layout;
ViewController* m_current;
QStack<ViewController*>* m_controllerStack;
public slots:
void previous();
void displayImportMenu();
};
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>274</width>
<height>81</height>
<height>69</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -199,7 +199,7 @@
</layout>
</item>
<item>
<widget class="QLabel" name="arrow">
<widget class="ClickableLabel" name="arrow">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -210,7 +210,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap>../../../../../../../Pictures/arrowRight.png</pixmap>
<pixmap resource="../../../../ressources.qrc">:/images/images/marker_left.png</pixmap>
</property>
</widget>
</item>
......@@ -225,6 +225,15 @@
</item>
</layout>
</widget>
<resources/>
<customwidgets>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>ClickableLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../ressources.qrc"/>
</resources>
<connections/>
</ui>
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>850</width>
<width>1000</width>
<height>730</height>
</rect>
</property>
......@@ -18,14 +18,14 @@
</property>
<property name="minimumSize">
<size>
<width>850</width>
<width>1000</width>
<height>730</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>850</width>
<height>730</height>
<width>1000</width>
<height>736</height>
</size>
</property>
<property name="windowTitle">
......@@ -35,11 +35,20 @@
<item row="0" column="0" rowspan="4">
<widget class="QWidget" name="ImportBrowserWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>83</horstretch>
<verstretch>116</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>500</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
......
......@@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>503</width>
<height>674</height>
<width>645</width>
<height>680</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -67,9 +67,15 @@
</item>
<item row="0" column="2">
<widget class="QWidget" name="MediaListWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<width>0</width>
<height>0</height>
</size>
</property>
......
......@@ -38,6 +38,8 @@
#define FPS 30
#endif
class Media;
class Clip : public QObject
{
Q_OBJECT
......
......@@ -282,3 +282,13 @@ bool Media::matchMetaTag( const QString& tag ) const
}
return false;
}
void Media::addClip( Clip* clip )
{
m_clips.insert( clip->getUuid(), clip );
}
void Media::removeClip( const QUuid& uuid )
{
m_clips.remove( uuid );
}
......@@ -35,8 +35,10 @@
#include <QUuid>
#include <QObject>
#include <QFileInfo>
#include <QHash>
#include "VLCMedia.h"
#include "Clip.h"
struct audioData
{
......@@ -51,6 +53,8 @@ struct audioData
QVector<int*> frameList;
};
class Clip;
/**
* Represents a basic container for media informations.
*/
......@@ -145,6 +149,12 @@ public:
bool hasMetadata() const;
void addClip( Clip* clip );
void removeClip( const QUuid& uuid );
Clip* clip( const QUuid& uuid ) const { return m_clips[uuid]; }
const QHash<QUuid, Clip*>* clips() const { return &m_clips; }
private:
void setFileType();
......@@ -169,6 +179,7 @@ protected:
bool m_metadataParsed;
QString m_fileName;
QStringList m_metaTags;
QHash<QUuid, Clip*> m_clips;
signals:
void metaDataComputed( Media* );
......
......@@ -75,7 +75,8 @@ SOURCES += src/main.cpp \
src/GUI/Library/MediaLibraryWidget.cpp \
src/GUI/Library/MediaListViewController.cpp \
src/GUI/ImportMediaListController.cpp \
src/GUI/ImportMediaCellView.cpp
src/GUI/ImportMediaCellView.cpp \
src/GUI/ClickableLabel.cpp
HEADERS += src/GUI/MainWindow.h \
src/GUI/DockWidgetManager.h \
src/GUI/LibraryWidget.h \
......@@ -144,7 +145,8 @@ HEADERS += src/GUI/MainWindow.h \
src/GUI/Library/MediaListViewController.h \
src/GUI/Library/ViewController.h \
src/GUI/ImportMediaListController.h \
src/GUI/ImportMediaCellView.h
src/GUI/ImportMediaCellView.h \
src/GUI/ClickableLabel.h
FORMS += src/GUI/ui/MainWindow.ui \
src/GUI/ui/PreviewWidget.ui \
src/GUI/ui/LanguagePreferences.ui \
......
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