Commit 2b2cd492 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Removed old library.

There may be remaining references in commented code.
parent 818e2054
......@@ -2,7 +2,6 @@ FORMS += ui/About.ui \
ui/ClipProperty.ui \
ui/FileBrowser.ui \
ui/Import.ui \
ui/LibraryWidget.ui \
ui/LoadPage.ui \
ui/MainWindow.ui \
ui/PreviewWidget.ui \
......@@ -26,7 +25,6 @@ HEADERS += About.h \
ImportMediaListController.h \
LanguagePreferences.h \
LCDTimecode.h \
LibraryWidget.h \
ListViewMediaItem.h \
MainWindow.h \
MediaListWidget.h \
......@@ -55,7 +53,6 @@ SOURCES += About.cpp \
ImportMediaListController.cpp \
LanguagePreferences.cpp \
LCDTimecode.cpp \
LibraryWidget.cpp \
ListViewMediaItem.cpp \
MainWindow.cpp \
MediaListWidget.cpp \
......
/*****************************************************************************
* LibraryWidget.cpp: Multimedia library
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <chavance.c@gmail.com>
* Christophe Courtaut <christophe.courtaut@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 <QDir>
#include <QUrl>
#include "LibraryWidget.h"
LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent ), m_firstDirectoryBrowsing(true)
{
m_ui.setupUi( this );
m_ui.listWidgetAudio->setType( Media::Audio );
m_ui.listWidgetImage->setType( Media::Image );
m_ui.listWidgetVideo->setType( Media::Video );
setAcceptDrops( true );
// *Always* force the selection of the first tab
m_ui.LibraryTabs->setCurrentIndex( 0 );
m_clips = new QList<ListViewMediaItem*>;
connect( m_ui.filterInput, SIGNAL( textChanged( QString ) ), this, SLOT( updateFilter( QString ) ) );
connect( m_ui.clearFilterButton, SIGNAL( clicked() ), m_ui.filterInput, SLOT( clear() ) );
connect( m_ui.LibraryTabs, SIGNAL( currentChanged( int ) ), this, SLOT( tabChanged( int ) ) );
}
LibraryWidget::~LibraryWidget()
{
while ( m_clips->isEmpty() == false )
delete m_clips->takeLast();
delete m_clips;
}
ListViewMediaItem* LibraryWidget::addClip( Clip* clip )
{
Media::FileType fileType = clip->getParent()->getFileType();
ListViewMediaItem* item = new ListViewMediaItem( clip, fileType );
m_clips->append( item );
switch ( fileType )
{
case Media::Audio:
m_ui.listWidgetAudio->addItem( item );
break;
case Media::Video:
m_ui.listWidgetVideo->addItem( item );
break;
case Media::Image:
m_ui.listWidgetImage->addItem( item );
break;
}
return item;
}
void LibraryWidget::mediaRemoved( const QUuid& uuid )
{
removeMedia( uuid );
}
void LibraryWidget::removeMedia( const QUuid& uuid )
{
ListViewMediaItem* item;
foreach (item, *m_clips)
{
if ( item->getClip()->getParent()->getUuid() == uuid )
{
switch( item->getFileType() )
{
case Media::Audio:
m_ui.listWidgetAudio->removeItemWidget( item );
m_ui.listWidgetAudio->unsetSelectedClip();
break;
case Media::Image:
m_ui.listWidgetImage->removeItemWidget( item );
m_ui.listWidgetImage->unsetSelectedClip();
break;
case Media::Video:
m_ui.listWidgetVideo->removeItemWidget( item );
m_ui.listWidgetVideo->unsetSelectedClip();
break;
}
m_clips->removeOne( item );
delete item;
return ;
}
}
}
//
//ListViewMediaItem* LibraryWidget::insertNewMedia( QString fileName, ListViewMediaItem::fType fileType )
//{
// ListViewMediaItem* item = NULL;
// foreach( item, *m_medias )
// {
// if ( item->getClip()->getFileInfo()->absoluteFilePath() == fileName )
// return item;
// }
// QFileInfo* fileInfo = new QFileInfo( fileName );
// item = addMedia( fileInfo, fileType );
// delete fileInfo;
// return item;
//}
void LibraryWidget::newClipLoaded( Clip* clip )
{
addClip( clip );
m_ui.LibraryTabs->setCurrentIndex( (int) clip->getParent()->getFileType() );
}
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, Media::FileType fileType )
{
Q_UNUSED( fileType );
QSettings settings;
QString path;
if ( m_firstDirectoryBrowsing == true )
path = settings.value( "mediaLibraryDialogPath", QDir::homePath() ).toString();
else
path = m_lastDirectoryBrowsed;
QStringList fileNames = QFileDialog::getOpenFileNames( this, title, path, filter );
if ( fileNames.isEmpty() )
return ;
m_lastDirectoryBrowsed = QFileInfo( fileNames.front() ).absolutePath();
m_firstDirectoryBrowsing = false;
QString filePath;
// ListViewMediaItem* item = NULL;
foreach ( filePath, fileNames )
{
// item = insertNewMedia( fileName, filetype );
// if( fileType == Media::Video )
emit newMediaLoadingAsked( filePath );
}
// if ( item != NULL )
// settings.setValue( "mediaLibraryDialogPath" , item->getClip()->getFileInfo()->absoluteDir().absolutePath() );
// return ;
}
void LibraryWidget::on_pushButtonAddMedia_clicked()
{
switch( m_ui.LibraryTabs->currentIndex() )
{
case 0:
insertNewMediasFromFileDialog( tr( "Open Audios" ),
tr( "Audio Files" ) + " (" + Media::AudioExtensions + ")" ,
Media::Audio );
break;
case 1:
insertNewMediasFromFileDialog( tr( "Open Videos" ),
tr( "Video Files" ) + " (" + Media::VideoExtensions + ")" ,
Media::Video );
break;
case 2:
insertNewMediasFromFileDialog( tr( "Open Images" ),
tr( "Images Files" ) + " (" + Media::ImageExtensions + ")" ,
Media::Image );
break;
}
}
void LibraryWidget::on_pushButtonRemoveMedia_clicked()
{
QListWidget* mediaList = ( QListWidget* )( m_ui.LibraryTabs->currentWidget()->children().back() );
ListViewMediaItem* item = ( ListViewMediaItem* ) mediaList->currentItem();
if ( !item ) return;
// removeMedia( item );
emit removingMediaAsked( item->getClip()->getParent()->getUuid() );
}
void LibraryWidget::changeEvent( QEvent *e )
{
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui.retranslateUi( this );
break;
default:
break;
}
}
void LibraryWidget::dragEnterEvent( QDragEnterEvent* event )
{
if ( event->mimeData()->urls().count() >= 1 )
event->acceptProposedAction();
}
void LibraryWidget::dropEvent( QDropEvent* event )
{
QUrl url;
Library* lib = Library::getInstance();
foreach ( url, event->mimeData()->urls() )
{
lib->newMediaLoadingAsked( url.path() );
}
}
const MediaListWidget* LibraryWidget::getVideoListWidget() const
{
return m_ui.listWidgetVideo;
}
const MediaListWidget* LibraryWidget::getAudioListWidget() const
{
return m_ui.listWidgetAudio;
}
void LibraryWidget::updateFilter( const QString& filter )
{
QListWidget* mediaList = ( QListWidget* )( m_ui.LibraryTabs->currentWidget()->children().back() );
unsigned int count = mediaList->count();
for ( unsigned int i = 0; i < count; ++i )
{
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( mediaList->item( i ) );
if ( item != NULL )
{
QString filename = item->getClip()->getParent()->getFileInfo()->fileName();
if ( !filename.contains( filter, Qt::CaseInsensitive ) && !item->getClip()->matchMetaTag( filter ) )
item->setHidden( true );
else
item->setHidden( false );
}
}
}
void LibraryWidget::tabChanged( int )
{
updateFilter( m_ui.filterInput->text() );
}
/*****************************************************************************
* LibraryWidget.h: Multimedia library GUI
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <chavance.c@gmail.com>
* Christophe Courtaut <christophe.courtaut@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 LIBRARYWIDGET_H
#define LIBRARYWIDGET_H
#include <QTabWidget>
#include <QListWidget>
#include <QFileInfoList>
#include <QMessageBox>
#include <QFileDialog>
#include <QtDebug>
#include <QMimeData>
#include <QDrag>
#include <QList>
#include <QSettings>
#include "Library.h"
#include "Media.h"
#include "ListViewMediaItem.h"
#include "ui_LibraryWidget.h"
class LibraryWidget : public QWidget
{
Q_OBJECT
public:
explicit LibraryWidget( QWidget *parent = 0 );
virtual ~LibraryWidget();
ListViewMediaItem* addClip( Clip* clip );
void removeMedia( const QUuid& uuid );
int getIndex( ListViewMediaItem* media );
const MediaListWidget* getVideoListWidget() const;
const MediaListWidget* getAudioListWidget() const;
protected:
virtual void changeEvent( QEvent *e );
virtual void dragEnterEvent( QDragEnterEvent* event );
virtual void dropEvent( QDropEvent* event );
private:
ListViewMediaItem* insertNewMedia( QString filename, Media::FileType fileType );
void insertNewMediasFromFileDialog( QString title, QString filter, Media::FileType fileType );
Ui::LibraryWidget m_ui;
QList<ListViewMediaItem*>* m_clips;
QString m_lastDirectoryBrowsed;
bool m_firstDirectoryBrowsing;
public slots:
void newClipLoaded( Clip* );
void mediaRemoved( const QUuid& );
void updateFilter( const QString& );
private slots:
void on_pushButtonAddMedia_clicked();
void on_pushButtonRemoveMedia_clicked();
void tabChanged( int );
signals:
// void listViewMediaAdded(Clip* clip);
void newMediaLoadingAsked( const QString& );
void removingMediaAsked( const QUuid& );
};
#endif /* !LIBRARYWIDGET_H */
......@@ -35,7 +35,6 @@
#include "MainWindow.h"
#include "MediaListWidget.h"
#include "LibraryWidget.h"
#include "Library.h"
#include "Timeline.h"
#include "About.h"
......@@ -122,11 +121,7 @@ void MainWindow::changeEvent( QEvent *e )
void MainWindow::setupLibrary()
{
//Library part :
//Library* library = Library::getInstance();
//GUI part :
//LibraryWidget* libraryWidget = new LibraryWidget( this );
MediaLibraryWidget* mediaLibraryWidget = new MediaLibraryWidget( this );
......@@ -136,39 +131,6 @@ void MainWindow::setupLibrary()
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
/*DockWidgetManager::instance()->addDockedWidget( libraryWidget,
tr( "Old Media Library" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );*/
//Connecting GUI and Frontend :
/*connect( libraryWidget,
SIGNAL( newMediaLoadingAsked(const QString& ) ),
library,
SLOT( newMediaLoadingAsked( const QString& ) ) );*/
/*connect( library,
SIGNAL( newClipLoaded( Clip* ) ),
libraryWidget,
SLOT( newClipLoaded( Clip* ) ) );*/
/*connect( libraryWidget,
SIGNAL( removingMediaAsked( const QUuid& ) ),
library,
SLOT( removingMediaAsked( const QUuid& ) ) );
connect( library,
SIGNAL( mediaRemoved( const QUuid& ) ),
libraryWidget,
SLOT( mediaRemoved( const QUuid& ) ), Qt::DirectConnection );*/
/*connect( libraryWidget->getVideoListWidget(), SIGNAL( selectedClipChanged( Clip* ) ),
m_clipPreview->getGenericRenderer(), SLOT( setClip( Clip* ) ) );
connect( libraryWidget->getVideoListWidget(), SIGNAL( itemDoubleClicked( QListWidgetItem* ) ),
this, SLOT( mediaListItemDoubleClicked( QListWidgetItem* ) ) );*/
connect( mediaLibraryWidget, SIGNAL( mediaSelected( Media* ) ),
m_clipPreview->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
......
......@@ -112,6 +112,7 @@ bool Library::mediaAlreadyLoaded( const QString& filePath )
void Library::loadProject( const QDomElement& medias )
{
qDebug() << "Loading (library part) project";
if ( medias.isNull() == true || medias.tagName() != "medias" )
{
qWarning() << "Invalid medias node";
......@@ -122,6 +123,7 @@ void Library::loadProject( const QDomElement& medias )
m_nbMediasToLoad = 0;
while ( elem.isNull() == false )
{
qDebug() << "Iterating over element";
QDomElement mediaProperty = elem.firstChild().toElement();
QString path;
QString uuid;
......
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