]> git.sur5r.net Git - minitube/blobdiff - src/videoareawidget.cpp
Keyboard shortcuts for the sortBar
[minitube] / src / videoareawidget.cpp
index 00d1b6f5f9634808a8114965858a08425915e567..9300b9ea4af7eb6b98647e4c544757c539749b0c 100644 (file)
@@ -1,8 +1,10 @@
 #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) {
@@ -19,28 +21,43 @@ void VideoAreaWidget::showVideo() {
     stackedLayout->setCurrentWidget(videoWidget);
 }
 
+void VideoAreaWidget::showError(QString message) {
+    loadingWidget->setError(message);
+    stackedLayout->setCurrentWidget(loadingWidget);
+}
+
 void VideoAreaWidget::showLoading(Video *video) {
     this->loadingWidget->setVideo(video);
     stackedLayout->setCurrentWidget(loadingWidget);
 }
 
 void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) {
-    switch(event->button()) {
-             case Qt::LeftButton:
+    if (event->button() == Qt::LeftButton)
         emit doubleClicked();
-        break;
-             case Qt::RightButton:
+}
+
+void VideoAreaWidget::mousePressEvent(QMouseEvent *event) {
+    switch(event->button() == Qt::RightButton)
+            emit rightClicked();
+}
 
-        break;
+void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) {
+    qDebug() << event->mimeData()->formats();
+    if (event->mimeData()->hasFormat("application/x-minitube-video")) {
+        event->acceptProposedAction();
     }
 }
 
-void VideoAreaWidget::mousePressEvent(QMouseEvent *event) {
-    switch(event->button()) {
-             case Qt::LeftButton:
-        break;
-             case Qt::RightButton:
-        emit rightClicked();
-        break;
+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();
 }