listView->setDragEnabled(true);
listView->setAcceptDrops(true);
listView->setDropIndicatorShown(true);
- listView->setDragDropMode(QAbstractItemView::InternalMove);
+ listView->setDragDropMode(QAbstractItemView::DragDrop);
// cosmetics
listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
videoWidget = new Phonon::VideoWidget(this);
videoAreaWidget->setVideoWidget(videoWidget);
+ videoAreaWidget->setListModel(listModel);
loadingWidget = new LoadingWidget(this);
videoAreaWidget->setLoadingWidget(loadingWidget);
#include "videoareawidget.h"
+#include "videomimedata.h"
VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
stackedLayout = new QStackedLayout(this);
setLayout(stackedLayout);
+ setAcceptDrops(true);
}
void VideoAreaWidget::setVideoWidget(QWidget *videoWidget) {
switch(event->button() == Qt::RightButton)
emit rightClicked();
}
+
+void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) {
+ qDebug() << event->mimeData()->formats();
+ if (event->mimeData()->hasFormat("application/x-minitube-video")) {
+ event->acceptProposedAction();
+ }
+}
+
+void VideoAreaWidget::dropEvent(QDropEvent *event) {
+
+ const VideoMimeData* videoMimeData = dynamic_cast<const VideoMimeData*>( event->mimeData() );
+ if(!videoMimeData ) return;
+
+ QList<Video*> droppedVideos = videoMimeData->videos();
+ foreach( Video *video, droppedVideos) {
+ int row = listModel->rowForVideo(video);
+ if (row != -1)
+ listModel->setActiveRow(row);
+ }
+ event->acceptProposedAction();
+}
#include <QWidget>
#include "video.h"
#include "loadingwidget.h"
+#include "ListModel.h"
class VideoAreaWidget : public QWidget {
void setLoadingWidget(LoadingWidget *loadingWidget);
void showLoading(Video* video);
void showVideo();
+ void setListModel(ListModel *listModel) {
+ this->listModel = listModel;
+ }
signals:
void doubleClicked();
protected:
void mouseDoubleClickEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
private:
QStackedLayout *stackedLayout;
QWidget *videoWidget;
LoadingWidget *loadingWidget;
+ ListModel *listModel;
};