Commit 1ad2c1f3 authored by Christophe Courtaut's avatar Christophe Courtaut

Added drag to mediaLibrary

parent be8dd28d
......@@ -113,21 +113,6 @@ void LibraryWidget::on_pushButtonAddMedia_clicked()
}
}
ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType fType, QListWidget* parent, int type ) : QListWidgetItem( parent, type )
{
fileInfo = fInfo;
fileType = fType;
setText( fileInfo->baseName() );
}
ListViewMediaItem::~ListViewMediaItem()
{
delete this->fileInfo;
}
void ListViewMediaItem::mousePressEvent( QMouseEvent* event )
{
}
void LibraryWidget::on_pushButtonRemoveMedia_clicked()
{
......
......@@ -33,26 +33,9 @@
#include <QMimeData>
#include <QDrag>
#include <QList>
#include "ListViewMediaItem.h"
#include "ui_LibraryWidget.h"
class ListViewMediaItem : public QListWidgetItem
{
public:
enum fType
{
Audio,
Video,
Image
};
ListViewMediaItem( QFileInfo* fileInfo, ListViewMediaItem::fType fType, QListWidget* parent = 0, int type = Type );
virtual ~ListViewMediaItem();
QFileInfo* fileInfo;
ListViewMediaItem::fType fileType;
protected:
void mousePressEvent( QMouseEvent* event );
};
class LibraryWidget : public QWidget
{
Q_OBJECT
......@@ -67,8 +50,9 @@ protected:
virtual void changeEvent( QEvent *e );
private:
QString getNewMediaFileName( QString title, QString filter, ListViewMediaItem::fType );
ListViewMediaItem* insertNewMediaFromFileDialog(QString title, QString filter, ListViewMediaItem::fType fileType);
Ui::LibraryWidget m_ui;
ListViewMediaItem* insertNewMediaFromFileDialog(QString title, QString filter, ListViewMediaItem::fType fileType);
Ui::LibraryWidget m_ui;
static QList<ListViewMediaItem*>* m_medias;
private slots:
......
/*****************************************************************************
* LibraryWidget.cpp: VLMC LibraryWidget
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: 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 "ListViewMediaItem.h"
ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType fType, QListWidget* parent, int type ) : QListWidgetItem( parent, type )
{
fileInfo = fInfo;
fileType = fType;
setText( fileInfo->baseName() );
}
ListViewMediaItem::~ListViewMediaItem()
{
delete this->fileInfo;
}
/*****************************************************************************
* ListViewMediaItem.h: VLMC library widget header
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: 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 LISTVIEWMEDIAITEM_H
#define LISTVIEWMEDIAITEM_H
#include <QFileInfo>
#include <QListWidgetItem>
class ListViewMediaItem : public QListWidgetItem
{
public:
enum fType
{
Audio,
Video,
Image
};
ListViewMediaItem( QFileInfo* fileInfo, ListViewMediaItem::fType fType, QListWidget* parent = 0, int type = Type );
virtual ~ListViewMediaItem();
QFileInfo* fileInfo;
ListViewMediaItem::fType fileType;
};
#endif /* !LISTVIEWMEDIAITEM_H */
#include "MediaListWidget.h"
MediaListWidget::MediaListWidget( QWidget* parent ) : QListWidget( parent )
{
}
void MediaListWidget::setType( QString fileType )
{
this->m_Type = fileType;
}
void MediaListWidget::mousePressEvent( QMouseEvent* event )
{
if ( event->button() == Qt::LeftButton)
this->m_dragStartPos = event->pos();
QListWidget::mousePressEvent( event );
}
void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
{
if ( this->currentItem() == NULL )
return;
if ( !( event->buttons() & Qt::LeftButton ) )
return;
if ( ( event->pos() - m_dragStartPos ).manhattanLength()
< QApplication::startDragDistance() )
return;
QMimeData *mimeData = new QMimeData;
mimeData->setText( ( ( ListViewMediaItem* )( currentItem() ))->fileInfo->absoluteFilePath() );
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}
/*****************************************************************************
* LibraryWidget.h: VLMC library widget header
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: 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 MEDIALISTWIDGET_H
#define MEDIALISTWIDGET_H
#include <QListWidget>
#include <QMouseEvent>
#include <QPoint>
#include <QMimeData>
#include <QDrag>
#include <QApplication>
#include "ListViewMediaItem.h"
class MediaListWidget : public QListWidget
{
Q_OBJECT
public:
MediaListWidget( QWidget* parent = 0 );
void setType( QString fileType );
protected:
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
private:
QString m_Type;
QPoint m_dragStartPos;
};
#endif // MEDIALISTWIDGET_H
......@@ -20,7 +20,7 @@
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
......@@ -34,7 +34,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QListWidget" name="listWidgetAudio">
<widget class="MediaListWidget" name="listWidgetAudio">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
......@@ -48,7 +48,7 @@
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DropOnly</enum>
<enum>QAbstractItemView::DragDrop</enum>
</property>
</widget>
</item>
......@@ -60,7 +60,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidgetVideo">
<widget class="MediaListWidget" name="listWidgetVideo">
<property name="acceptDrops">
<bool>true</bool>
</property>
......@@ -71,7 +71,7 @@
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DropOnly</enum>
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
......@@ -86,7 +86,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="listWidgetImage">
<widget class="MediaListWidget" name="listWidgetImage">
<property name="acceptDrops">
<bool>true</bool>
</property>
......@@ -94,7 +94,7 @@
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DropOnly</enum>
<enum>QAbstractItemView::DragDrop</enum>
</property>
</widget>
</item>
......@@ -146,6 +146,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MediaListWidget</class>
<extends>QListWidget</extends>
<header>src/gui/MediaListWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -24,7 +24,9 @@ SOURCES += src/main.cpp \
src/gui/TracksScene.cpp \
src/gui/PreviewWidget.cpp \
src/gui/TracksRuler.cpp \
src/gui/Preferences.cpp
src/gui/Preferences.cpp \
src/gui/ListViewMediaItem.cpp \
src/gui/MediaListWidget.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -40,16 +42,18 @@ HEADERS += src/gui/MainWindow.h \
src/gui/TracksScene.h \
src/gui/PreviewWidget.h \
src/gui/TracksRuler.h \
src/gui/Preferences.h
src/gui/Preferences.h \
src/gui/ListViewMediaItem.h \
src/gui/MediaListWidget.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/Timeline.ui \
src/gui/ui/LibraryWidget.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui
src/gui/ui/Preferences.ui
RESOURCES +=
INCLUDEPATH += src/LibVLCpp
LIBS = -L/usr/local/lib \
-lvlc
TRANSLATIONS = vlmc_es.ts \
vlmc_fr.ts
CODECFORTR = UTF-8
TRANSLATIONS = vlmc_es.ts \
vlmc_fr.ts
CODECFORTR = UTF-8
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