]> git.sesse.net Git - kdenlive/blobdiff - src/projectlistview.cpp
Remove (old) LADSPA related code.
[kdenlive] / src / projectlistview.cpp
index 02e00f68dde0a9348f30bc85240f5466da004247..c6d6c40a757cea1070ed511f2b1f07e3e9893c70 100644 (file)
@@ -54,12 +54,14 @@ ProjectListView::ProjectListView(QWidget *parent) :
     headerView->setContextMenuPolicy(Qt::CustomContextMenu);
     connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
             this, SLOT(configureColumns(const QPoint&)));
+    connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(slotCollapsed(QTreeWidgetItem *)));
+    connect(this, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(slotExpanded(QTreeWidgetItem *)));
     headerView->setClickable(true);
     headerView->setSortIndicatorShown(true);
     headerView->setMovable(false);
     sortByColumn(0, Qt::AscendingOrder);
     setSortingEnabled(true);
-
+    installEventFilter(this);
     if (!KdenliveSettings::showdescriptioncolumn()) hideColumn(1);
     if (!KdenliveSettings::showratingcolumn()) hideColumn(2);
 }
@@ -68,6 +70,11 @@ ProjectListView::~ProjectListView()
 {
 }
 
+void ProjectListView::processLayout()
+{
+    executeDelayedItemsLayout();
+}
+
 void ProjectListView::configureColumns(const QPoint& pos)
 {
     KMenu popup(this);
@@ -114,13 +121,43 @@ void ProjectListView::contextMenuEvent(QContextMenuEvent * event)
     emit requestMenu(event->globalPos(), itemAt(event->pos()));
 }
 
-// virtual
-void ProjectListView::keyPressEvent(QKeyEvent * event)
+void ProjectListView::slotCollapsed(QTreeWidgetItem *item)
+{
+    if (item->type() == PROJECTFOLDERTYPE) {
+        blockSignals(true);
+        static_cast <FolderProjectItem *>(item)->switchIcon();
+        blockSignals(false);
+    }
+}
+
+void ProjectListView::slotExpanded(QTreeWidgetItem *item)
 {
-    if (event->key() == Qt::Key_Return) {
-        QTreeWidgetItem *it = currentItem();
-        if (it) it->setExpanded(!it->isExpanded());
-    } else QTreeWidget::keyPressEvent(event);
+    if (item->type() == PROJECTFOLDERTYPE) {
+        blockSignals(true);
+        static_cast <FolderProjectItem *>(item)->switchIcon();
+        blockSignals(false);
+    }
+}
+
+bool ProjectListView::eventFilter(QObject *obj, QEvent *event)
+{
+    if (event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride) {
+        QKeyEvent* ke = (QKeyEvent*) event;
+        if (ke->key() == Qt::Key_Plus) {
+            if (currentItem()) currentItem()->setExpanded(true);
+            event->accept();
+            return true;
+        } else if (ke->key() == Qt::Key_Minus) {
+            if (currentItem()) currentItem()->setExpanded(false);
+            event->accept();
+            return true;
+        } else {
+            return false;
+        }
+    } else {
+        // pass the event on to the parent class
+        return QTreeWidget::eventFilter(obj, event);
+    }
 }
 
 // virtual
@@ -177,14 +214,6 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
     emit showProperties(item->referencedClip());
 }
 
-// virtual
-void ProjectListView::dragEnterEvent(QDragEnterEvent *event)
-{
-    if (event->mimeData()->hasUrls() || event->mimeData()->hasText()) {
-        kDebug() << "////////////////  DRAG ENTR OK";
-    }
-    event->acceptProposedAction();
-}
 
 // virtual
 void ProjectListView::dropEvent(QDropEvent *event)
@@ -205,6 +234,7 @@ void ProjectListView::dropEvent(QDropEvent *event)
         emit addClip(event->mimeData()->urls(), groupName, groupId);
         event->setDropAction(Qt::CopyAction);
         event->accept();
+        QTreeWidget::dropEvent(event);
         return;
     } else if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
         if (item) {
@@ -249,6 +279,7 @@ void ProjectListView::dropEvent(QDropEvent *event)
         emit addClipCut(list.at(0), list.at(1).toInt(), list.at(2).toInt());
     }
     event->acceptProposedAction();
+    QTreeWidget::dropEvent(event);
 }
 
 // virtual
@@ -337,14 +368,11 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
 }
 
 // virtual
-void ProjectListView::dragMoveEvent(QDragMoveEvent * event)
+void ProjectListView::dragLeaveEvent(QDragLeaveEvent *event)
 {
-    //event->setDropAction(Qt::MoveAction);
-    if (event->mimeData()->hasText()) {
-        event->acceptProposedAction();
-    }
     // stop playing because we get a crash otherwise when fetching the thumbnails
     emit pauseMonitor();
+    QTreeWidget::dragLeaveEvent(event);
 }
 
 QStringList ProjectListView::mimeTypes() const
@@ -363,7 +391,7 @@ QStringList ProjectListView::mimeTypes() const
 Qt::DropActions ProjectListView::supportedDropActions() const
 {
     // returns what actions are supported when dropping
-    return Qt::MoveAction;
+    return Qt::MoveAction | Qt::CopyAction;
 }
 
 #include "projectlistview.moc"