Commit 7a5ca340 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Remove old medialibrary views

parent 44889f9f
......@@ -189,12 +189,7 @@ vlmc_SOURCES += \
src/Gui/export/RendererSettings.cpp \
src/Gui/export/ShareOnInternet.cpp \
src/Gui/import/TagWidget.cpp \
src/Gui/library/ListViewController.cpp \
src/Gui/library/MediaCellView.cpp \
src/Gui/library/MediaLibraryView.cpp \
src/Gui/library/MediaListView.cpp \
src/Gui/library/StackViewController.cpp \
src/Gui/library/StackViewNavController.cpp \
src/Gui/media/ClipMetadataDisplayer.cpp \
src/Gui/preview/LCDTimecode.cpp \
src/Gui/preview/PreviewRuler.cpp \
......@@ -260,12 +255,7 @@ vlmc_SOURCES += \
src/Gui/timeline/ThumbnailImageProvider.h \
src/Gui/About.h \
src/Gui/LanguageHelper.h \
src/Gui/library/ListViewController.h \
src/Gui/library/StackViewController.h \
src/Gui/library/MediaListView.h \
src/Gui/library/MediaLibraryView.h \
src/Gui/library/MediaCellView.h \
src/Gui/library/StackViewNavController.h \
src/Gui/library/ViewController.h \
src/Gui/media/ClipMetadataDisplayer.h \
src/Gui/preview/RenderWidget.h \
......@@ -300,25 +290,21 @@ vlmc_SOURCES += \
nodist_vlmc_SOURCES += \
src/Gui/wizard/WelcomePage.moc.cpp \
src/Gui/library/ListViewController.moc.cpp \
src/Gui/settings/SettingsDialog.moc.cpp \
src/Gui/export/ShareOnInternet.moc.cpp \
src/Gui/widgets/FramelessButton.moc.cpp \
src/Gui/wizard/OpenPage.moc.cpp \
src/Gui/settings/ColorWidget.moc.cpp \
src/Gui/library/StackViewController.moc.cpp \
src/Gui/library/MediaLibraryView.moc.cpp \
src/Gui/wizard/firstlaunch/FirstLaunchPage.moc.cpp \
src/Gui/settings/Panel.moc.cpp \
src/Gui/preview/RenderWidget.moc.cpp \
src/Gui/settings/BoolWidget.moc.cpp \
src/Gui/WorkflowFileRendererDialog.moc.cpp \
src/Gui/library/MediaListView.moc.cpp \
src/Gui/wizard/firstlaunch/Done.moc.cpp \
src/Gui/wizard/VideoPage.moc.cpp \
src/Gui/settings/ISettingsCategoryWidget.moc.cpp \
src/Gui/wizard/GeneralPage.moc.cpp \
src/Gui/library/MediaCellView.moc.cpp \
src/Gui/MainWindow.moc.cpp \
src/Gui/settings/KeyboardShortcut.moc.cpp \
src/Gui/preview/PreviewWidget.moc.cpp \
......@@ -347,7 +333,6 @@ nodist_vlmc_SOURCES += \
src/Gui/IntroDialog.moc.cpp \
src/Gui/settings/KeyboardShortcutInput.moc.cpp \
src/Gui/widgets/SearchLineEdit.moc.cpp \
src/Gui/library/StackViewNavController.moc.cpp \
src/Gui/settings/PathWidget.moc.cpp \
src/Gui/settings/IntWidget.moc.cpp \
src/Gui/settings/StringWidget.moc.cpp \
......@@ -362,10 +347,8 @@ vlmc_UI = \
src/Gui/ui/RendererSettings.ui \
src/Gui/ui/ShareOnInternet.ui \
src/Gui/ui/TagWidget.ui \
src/Gui/ui/MediaCellView.ui \
src/Gui/ui/MediaLibraryView.ui \
src/Gui/ui/FolderListWidget.ui \
src/Gui/ui/StackViewNavController.ui \
src/Gui/ui/ClipMetadataDisplayer.ui \
src/Gui/ui/PreviewWidget.ui \
src/Gui/ui/About.ui \
......
/*****************************************************************************
* ListViewController.h:
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
* Authors: 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <QPushButton>
#include <QScrollArea>
#include <QVBoxLayout>
#include "ListViewController.h"
#include "MediaCellView.h"
#include "Library/Library.h"
#include "StackViewController.h"
ListViewController::ListViewController( StackViewController* nav ) : m_nav( nav )
{
m_title = tr( "Media List" );
m_scrollArea = new QScrollArea();
m_layout = new QVBoxLayout();
m_container = new QWidget( nav );
m_layout->setAlignment( Qt::AlignTop );
m_layout->setSpacing( 0 );
m_layout->setContentsMargins( 0, 0, 0, 0 );
m_container->setLayout( m_layout );
m_scrollArea->setWidget( m_container );
m_scrollArea->setWidgetResizable( true );
m_scrollArea->setAcceptDrops( true );
}
ListViewController::~ListViewController()
{
delete m_container;
delete m_scrollArea;
}
// ViewController method implementation
const QString&
ListViewController::title() const
{
return m_title;
}
QWidget*
ListViewController::view() const
{
return m_scrollArea;
}
void
ListViewController::addCell( QWidget* cell )
{
m_layout->addWidget( cell );
}
void
ListViewController::removeCell( QWidget* cell )
{
m_layout->removeWidget( cell );
delete cell;
}
/*****************************************************************************
* ListViewController.h:
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
* Authors: 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 LISTVIEWCONTROLLER_H
#define LISTVIEWCONTROLLER_H
#include "ViewController.h"
#include <QObject>
class StackViewController;
class QVBoxLayout;
class QScrollArea;
class ListViewController : public ViewController
{
Q_OBJECT
public:
ListViewController( StackViewController* nav );
~ListViewController();
QWidget* view() const;
const QString& title() const;
void addCell( QWidget* cell );
void removeCell( QWidget* cell );
protected:
QVBoxLayout* m_layout;
QWidget* m_container;
private:
QString m_title;
QScrollArea* m_scrollArea;
StackViewController* m_nav;
};
#endif // LISTVIEWCONTROLLER_H
/*****************************************************************************
* MediaCellView.cpp
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
* Authors: Thomas Boquet <thomas.boquet@gmail.com>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "MediaCellView.h"
#include "ui/MediaCellView.h"
#include "Project/Project.h"
#include "Main/Core.h"
#include "Media/Clip.h"
#include "ClipProperty.h"
#include "Library/Library.h"
#include "Media/Media.h"
#include "Workflow/MainWorkflow.h"
#include "Project/Workspace.h"
#include <QMenu>
#include <QMessageBox>
#include <QTime>
#include <QMimeData>
#include <QDrag>
MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
QWidget( parent ),
m_ui( new Ui::MediaCellView ),
m_clip( clip )
{
m_ui->setupUi( this );
setFocusPolicy( Qt::ClickFocus );
setAutoFillBackground( true );
connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) );
connect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
m_ui->clipCount->setText( QString::number( clip->mediaContainer()->count() ) );
connect( clip->mediaContainer(), SIGNAL( newClipLoaded( Clip* ) ),
this, SLOT( nbClipUpdated() ) );
connect( clip->mediaContainer(), SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( nbClipUpdated() ) );
if ( clip->mediaContainer()->count() == 0 )
{
m_ui->clipCount->hide();
m_ui->clipCountLabel->hide();
m_ui->arrow->hide();
}
connect( clip->media(), SIGNAL( metaDataComputed() ),
this, SLOT( metadataUpdated() ) );
// Snapshot generation will generate a QPixmap, which has to be done on GUI thread
connect( clip->media(), SIGNAL( snapshotAvailable() ),
this, SLOT( snapshotUpdated() ), Qt::QueuedConnection );
setThumbnail( clip->media()->snapshot() );
setTitle( clip->media()->fileName() );
setLength( clip->lengthSecond() * 1000 );
}
MediaCellView::~MediaCellView()
{
delete m_ui;
}
void
MediaCellView::metadataComputingStarted( const Media *media )
{
if ( media != m_clip->media() )
return ;
//Disable the delete button to avoid deleting the media while metadata are computed.
m_ui->delLabel->setEnabled( false );
}
void
MediaCellView::metadataUpdated()
{
setLength( m_clip->media()->input()->length() );
m_ui->thumbnail->setEnabled( true );
//If the media is a Video or an Image, we must wait for the snapshot to be computer
//before allowing deletion.
if ( m_clip->media()->fileType() == Media::Audio )
m_ui->delLabel->setEnabled( true );
}
void
MediaCellView::snapshotUpdated()
{
setThumbnail( m_clip->media()->snapshot() );
m_ui->delLabel->setEnabled( true );
}
void
MediaCellView::changeEvent( QEvent *e )
{
QWidget::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
nbClipUpdated();
setLength( m_clip->lengthSecond() * 1000 );
break;
default:
break;
}
}
void
MediaCellView::setTitle( const QString& title )
{
m_ui->title->setText( title );
}
void
MediaCellView::nbClipUpdated()
{
quint32 nbClips;
if ( m_clip->isRootClip() == true )
nbClips = m_clip->mediaContainer()->count();
else
nbClips = m_clip->parent()->mediaContainer()->count();
if ( nbClips == 0 )
{
m_ui->clipCount->hide();
m_ui->clipCountLabel->hide();
m_ui->arrow->hide();
}
else
{
m_ui->clipCount->show();
m_ui->clipCountLabel->show();
m_ui->arrow->show();
}
//Use QString::number in any case, so we use the current locale.
m_ui->clipCount->setText( QString::number( nbClips ) );
}
void
MediaCellView::setThumbnail( const QPixmap &pixmap )
{
m_ui->thumbnail->setScaledContents( false );
m_ui->thumbnail->setPixmap( pixmap.scaled( 64, 64, Qt::KeepAspectRatio ) );
}
const QPixmap*
MediaCellView::getThumbnail() const
{
return m_ui->thumbnail->pixmap();
}
QString
MediaCellView::title() const
{
return m_ui->title->text();
}
void
MediaCellView::mouseDoubleClickEvent( QMouseEvent* event )
{
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
{
ClipProperty* cp = new ClipProperty( m_clip, this );
cp->setModal( true );
cp->exec();
delete cp;
}
}
void
MediaCellView::mousePressEvent( QMouseEvent* event )
{
QWidget::mousePressEvent( event );
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
{
m_dragStartPos = event->pos();
emit cellSelected( m_clip->uuid() );
}
}
void
MediaCellView::mouseMoveEvent( QMouseEvent* event )
{
if ( ( event->buttons() | Qt::LeftButton ) != Qt::LeftButton )
return;
if ( ( event->pos() - m_dragStartPos ).manhattanLength()
< QApplication::startDragDistance() )
return;
QMimeData* mimeData = new QMimeData;
mimeData->setData( "vlmc/uuid", m_clip->uuid().toString().toLatin1() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
Media* parent = m_clip->media();
drag->setPixmap( parent->snapshot().scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
void
MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
{
if ( Core::instance()->workflow()->contains( m_clip->uuid() ) == true )
{
QMessageBox msgBox;
msgBox.setText( tr( "This clip or some of its children are contained in the timeline." ) );
msgBox.setInformativeText( tr( "Removing it will delete it from the timeline. Do you want to proceed?" ) );
msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
msgBox.setDefaultButton( QMessageBox::Ok );
int ret = msgBox.exec();
switch ( ret )
{
case QMessageBox::Ok:
break ;
case QMessageBox::Cancel:
default:
return ;
}
}
emit cellDeleted( m_clip );
}
void
MediaCellView::arrowButtonClicked( QWidget*, QMouseEvent* )
{
emit arrowClicked( m_clip->uuid() );
}
void
MediaCellView::setLength( qint64 length )
{
QTime duration( 0, 0 );
duration = duration.addMSecs( length );
m_ui->length->setText( duration.toString( "hh:mm:ss" ) );
}
const QUuid&
MediaCellView::uuid() const
{
return m_clip->uuid();
}
const Clip*
MediaCellView::clip() const
{
return m_clip;
}
void
MediaCellView::contextMenuEvent( QContextMenuEvent *event )
{
QMenu menu( this );
//For now, as we only have the copy to workspace option, don't do anything if the clip
//is not the root clip. Obviously, this will have to be removed if other actions are to be added.
if ( m_clip->isRootClip() == false )
return ;
QAction* copyInWorkspace = menu.addAction( "Copy in workspace" );
QAction* selectedAction = menu.exec( event->globalPos() );
if ( selectedAction == nullptr )
return ;
if ( copyInWorkspace == selectedAction )
{
if ( Core::instance()->workspace()->copyToWorkspace( m_clip->media() ) == false )
{
QMessageBox::warning( nullptr, tr( "Can't copy to workspace" ),
tr( "Can't copy this media to workspace: %1" ).arg( Core::instance()->workspace()->lastError() ) );
}
}
}
/*****************************************************************************
* MediaCellView.h
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
* Authors: Thomas Boquet <thomas.boquet@gmail.com>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* 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 MEDIACELLVIEW_H
#define MEDIACELLVIEW_H
#include <QWidget>
#include <QUuid>
#include <QMouseEvent>
class Clip;
class Media;
namespace Ui
{
class MediaCellView;
}
class MediaCellView : public QWidget
{
Q_OBJECT
public:
MediaCellView( Clip *clip, QWidget *parent = 0 );
~MediaCellView();
void setTitle( const QString &title );
void setThumbnail( const QPixmap &pixmap );
const QPixmap *getThumbnail() const;
/**
* \brief Set the length displayed in the cell
* \param length The media length, in ms.
*/
void setLength( qint64 length );
QString title() const;
const QUuid &uuid() const;
const Clip* clip() const;
private:
Ui::MediaCellView *m_ui;
Clip *m_clip;
QPoint m_dragStartPos;
protected:
void changeEvent( QEvent *e );
void mouseDoubleClickEvent( QMouseEvent* );
void mousePressEvent( QMouseEvent* );
void mouseMoveEvent( QMouseEvent* );
void contextMenuEvent( QContextMenuEvent * );
public slots:
void deleteButtonClicked( QWidget *sender, QMouseEvent *event );
void arrowButtonClicked( QWidget *sender, QMouseEvent *event );
private slots:
void snapshotUpdated();
void metadataComputingStarted( const Media *media );
void metadataUpdated();
void nbClipUpdated();
signals:
void cellSelected( const QUuid& uuid );
void arrowClicked( const QUuid& uuid );
void cellDeleted( const Clip* );
};
#endif // MEDIACELLVIEW_H
......@@ -32,11 +32,10 @@
#include "Main/Core.h"
#include "Media/Media.h"
#include "MediaCellView.h"
#include "MediaListView.h"
#include "StackViewController.h"
#include "ViewController.h"
#include "Tools/VlmcDebug.h"
#include <QListView>
#include <QUrl>
#include <QMimeData>
......@@ -44,20 +43,6 @@ MediaLibraryView::MediaLibraryView(QWidget *parent) : QWidget(parent),
m_ui( new Ui::MediaLibraryView() )
{
m_ui->setupUi( this );
setAcceptDrops( true );
StackViewController *nav = new StackViewController( m_ui->mediaListContainer );
m_mediaListView = new MediaListView( nav );
nav->pushViewController( m_mediaListView );
connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
this, SIGNAL( clipSelected( Clip* ) ) );
connect( m_ui->filterInput, SIGNAL( textChanged( const QString& ) ),
this, SLOT( filterUpdated( const QString& ) ) );
connect( nav, SIGNAL( viewChanged( ViewController* ) ),
this, SLOT( viewChanged( ViewController* ) ) );
connect( m_ui->filterType, SIGNAL( currentIndexChanged( int ) ),
this, SLOT( filterTypeChanged() ) );
}
MediaLibraryView::~MediaLibraryView()
......@@ -78,120 +63,3 @@ MediaLibraryView::changeEvent( QEvent *e )
break;
}
}
void
MediaLibraryView::filterUpdated( const QString &filter )
{
const MediaListView::MediaList &medias = m_mediaListView->mediaList();
MediaListView::MediaList::const_iterator it = medias.begin();
MediaListView::MediaList::const_iterator ite = medias.end();
while ( it != ite )
{
MediaCellView *mcv = it.value();
mcv->setVisible( currentFilter()( mcv->clip(), filter ) );
++it;
}
}
MediaLibraryView::Filter
MediaLibraryView::currentFilter()
{
switch ( m_ui->filterType->currentIndex() )
{
case 0:
return &filterByName;
case 1:
return &filterByTags;
default:
return &filterByName;
}
}
void
MediaLibraryView::viewChanged( ViewController *view )
{
MediaListView *mlv = qobject_cast<MediaListView*>( view );
if ( mlv == nullptr )
return ;
m_mediaListView = mlv;
//Force an update as the media has changed
filterUpdated( m_ui->filterInput->text() );
}
bool
MediaLibraryView::filterByName( const Clip *clip, const QString &filter )
{
return ( clip->media()->fileName().contains( filter, Qt::CaseInsensitive ) );
}
bool
MediaLibraryView::filterByTags( const Clip *clip, const QString &filter )
{
return ( clip->matchMetaTag( filter ) );
}
void
MediaLibraryView::filterTypeChanged()
{
filterUpdated( m_ui->filterInput->text() );
}
void
MediaLibraryView::dragEnterEvent( QDragEnterEvent *event )
{
if ( event->mimeData()->hasFormat( "text/uri-list" ) )
{
event->acceptProposedAction();
}
else
event->ignore();
}
void
MediaLibraryView::dragMoveEvent( QDragMoveEvent *event )
{
event->acceptProposedAction();
}
void
MediaLibraryView::dragLeaveEvent( QDragLeaveEvent *event )
{
event->accept();
}
void
MediaLibraryView::dropEvent( QDropEvent *event )
{
const QList<QUrl> &fileList = event->mimeData()->urls();
if ( fileList.isEmpty() )
{
event->ignore();
return;
}
foreach ( const QUrl &url, fileList )
{
const QString &fileName = url.toLocalFile();
if ( fileName.isEmpty() )
continue;