Commit f22165db authored by Christophe Courtaut's avatar Christophe Courtaut

[UI] Added a functional (or seems to be) FileBrowser

parent 4e5b8788
......@@ -42,6 +42,17 @@ Media* Library::getClip( const QUuid& uuid )
return *it;
}
Media* Library::getClip( const QString& path )
{
QMutexLocker locker( &m_mutex );
QHash<QUuid, Media*>::iterator it;
QHash<QUuid, Media*>::iterator ite = m_medias.end();
for ( it = m_medias.begin(); it != ite; ++it )
if ( ((Media*)it.value())->getFileInfo()->absoluteFilePath() == path)
return it.value();
return NULL;
}
void Library::removingMediaAsked( const QUuid& uuid )
{
QMutexLocker locker( &m_mutex );
......
......@@ -55,6 +55,7 @@ public:
Image
};
Media* getClip( const QUuid& uuid );
Media* getClip( const QString& path );
private:
Library();
......
......@@ -22,6 +22,7 @@
*****************************************************************************/
#include <QDir>
#include <QUrl>
#include "LibraryWidget.h"
QList<ListViewMediaItem*>* LibraryWidget::m_medias = NULL;
......@@ -34,6 +35,8 @@ LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent )
m_ui.listWidgetImage->setType( Library::Image );
m_ui.listWidgetVideo->setType( Library::Video );
setAcceptDrops( true );
// *Always* force the selection of the first tab
m_ui.LibraryTabs->setCurrentIndex( 0 );
......@@ -120,6 +123,7 @@ void LibraryWidget::newMediaLoaded( Media* media )
{
//From here, the clip is const.
addMedia( media, Library::Video );
m_ui.LibraryTabs->setCurrentIndex( 1 );
}
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, Library::FileType fileType )
......@@ -185,3 +189,19 @@ void LibraryWidget::changeEvent( QEvent *e )
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() );
}
}
......@@ -54,6 +54,8 @@ public:
protected:
virtual void changeEvent( QEvent *e );
virtual void dragEnterEvent( QDragEnterEvent* event );
virtual void dropEvent( QDropEvent* event );
private:
ListViewMediaItem* insertNewMedia( QString filename, Library::FileType fileType );
......
......@@ -133,11 +133,11 @@ void MainWindow::m_initializeDockWidgets( void )
setCentralWidget( m_timeline );
DockWidgetManager *dockManager = DockWidgetManager::instance();
// dockManager->addDockedWidget( new FileBrowser( this ),
// tr( "FileBrowser" ),
// Qt::AllDockWidgetAreas,
// QDockWidget::AllDockWidgetFeatures,
// Qt::TopDockWidgetArea);
dockManager->addDockedWidget( new FileBrowser( this ),
tr( "FileBrowser" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea);
setupLibrary();
......
......@@ -22,6 +22,8 @@
#include <QSvgRenderer>
#include <QPainter>
#include <QUrl>
#include <QtDebug>
#include "MediaListWidget.h"
......@@ -29,6 +31,8 @@ MediaListWidget::MediaListWidget( QWidget* parent ) : QListWidget( parent )
{
m_svgRenderer = new QSvgRenderer( this );
setIconSize( QSize( 128, 128 ) );
setContentsMargins( 2, 2,2, 2 );
setAcceptDrops( true );
}
void MediaListWidget::setType( Library::FileType fileType )
......
......@@ -21,12 +21,14 @@
*****************************************************************************/
#include <QtDebug>
#include <QUrl>
#include "PreviewWidget.h"
#include "ui_PreviewWidget.h"
#include "MediaListWidget.h"
#include "Library.h"
PreviewWidget::PreviewWidget( QWidget *parent ) :
QDialog( parent ),
m_ui( new Ui::PreviewWidget ), m_clipLoaded( false ), m_videoStopped( true )
......@@ -73,11 +75,21 @@ void PreviewWidget::dragEnterEvent( QDragEnterEvent* event )
{
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) )
event->acceptProposedAction();
else if ( event->mimeData()->urls().count() == 1 )
event->acceptProposedAction();
}
void PreviewWidget::dropEvent( QDropEvent* event )
{
Media* media = Library::getInstance()->getClip( QUuid( (const QString& )event->mimeData()->data( "vlmc/uuid" ) ) );
Media* media;
if ( event->mimeData()->urls().count() == 1 )
{
Library* lib = Library::getInstance();
lib->newMediaLoadingAsked( event->mimeData()->urls()[0].path() );
media = lib->getClip( event->mimeData()->urls()[0].path() );
}
else
media = Library::getInstance()->getClip( QUuid( (const QString& )event->mimeData()->data( "vlmc/uuid" ) ) );
media->flushParameters();
m_mediaPlayer->setMedia( media->getVLCMedia() );
......
......@@ -48,7 +48,14 @@
</widget>
</item>
<item row="2" column="7">
<widget class="QListView" name="listViewBrowser"/>
<widget class="QListView" name="listViewBrowser">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="pushButtonParent">
......
......@@ -16,11 +16,14 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4">
<widget class="QTabWidget" name="LibraryTabs">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
......@@ -47,6 +50,9 @@
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
......@@ -77,11 +83,14 @@
<bool>true</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
......@@ -108,6 +117,9 @@
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
......
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