]> git.sesse.net Git - kdenlive/blobdiff - src/projectlistview.cpp
Correctly focus clips / folders when they are created:
[kdenlive] / src / projectlistview.cpp
index 4451fe0f8a369886dec4cee75bce7491806e0563..8ff5485ec5c14a3b4a352a14b7a29acc91435e8b 100644 (file)
@@ -30,8 +30,9 @@
 #include <QHeaderView>
 #include <QAction>
 
-ProjectListView::ProjectListView(QWidget *parent)
-        : QTreeWidget(parent), m_dragStarted(false)
+ProjectListView::ProjectListView(QWidget *parent) :
+        QTreeWidget(parent),
+        m_dragStarted(false)
 {
     setSelectionMode(QAbstractItemView::ExtendedSelection);
     setDragDropMode(QAbstractItemView::DragDrop);
@@ -114,8 +115,12 @@ void ProjectListView::contextMenuEvent(QContextMenuEvent * event)
 void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
 {
     ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
-    if (!item) emit addClip();
-    else if (item->isGroup()) {
+    if (!item) {
+        emit addClip();
+        return;
+    }
+    if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
+    if (item->isGroup()) {
         if ((columnAt(event->pos().x()) == 1)) QTreeWidget::mouseDoubleClickEvent(event);
     } else {
         if ((columnAt(event->pos().x()) == 1) && (item->clipType() == SLIDESHOW || item->clipType() == TEXT || item->clipType() == COLOR)) QTreeWidget::mouseDoubleClickEvent(event);
@@ -138,15 +143,17 @@ void ProjectListView::dropEvent(QDropEvent *event)
 {
     kDebug() << "////////////////  DROPPED EVENT";
     if (event->mimeData()->hasUrls()) {
-        QTreeWidgetItem *item = itemAt(event->pos());
+        ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
         QString groupName;
+        QString groupId;
         if (item) {
-            if (((ProjectItem *) item)->isGroup()) groupName = item->text(1);
-            else if (item->parent() && ((ProjectItem *) item->parent())->isGroup())
-                groupName = item->parent()->text(1);
+            if (item->parent()) item = static_cast <ProjectItem *>(item->parent());
+            if (item->isGroup()) {
+                groupName = item->groupName();
+                groupId = item->clipId();
+            }
         }
-        emit addClip(event->mimeData()->urls(), groupName);
-
+        emit addClip(event->mimeData()->urls(), groupName, groupId);
     } else if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
         ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
         if (item) {
@@ -201,12 +208,18 @@ void ProjectListView::mousePressEvent(QMouseEvent *event)
     if (event->button() == Qt::LeftButton) {
         m_DragStartPosition = event->pos();
         m_dragStarted = true;
-        QTreeWidgetItem *underMouse = itemAt(event->pos());
-        if (underMouse && underMouse->isSelected()) emit focusMonitor();
+        /*QTreeWidgetItem *underMouse = itemAt(event->pos());
+        if (underMouse && underMouse->isSelected()) emit focusMonitor();*/
     }
     QTreeWidget::mousePressEvent(event);
 }
 
+// virtual
+void ProjectListView::mouseReleaseEvent(QMouseEvent *event)
+{
+    QTreeWidget::mouseReleaseEvent(event);
+    emit focusMonitor();
+}
 
 // virtual
 void ProjectListView::mouseMoveEvent(QMouseEvent *event)
@@ -219,8 +232,8 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
         return;
 
     {
-        ProjectItem *clickItem = (ProjectItem *) itemAt(m_DragStartPosition); //event->pos());
-        if (clickItem) {
+        ProjectItem *clickItem = static_cast <ProjectItem *>(itemAt(m_DragStartPosition));
+        if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) {
             QDrag *drag = new QDrag(this);
             QMimeData *mimeData = new QMimeData;
             const QList <QTreeWidgetItem *> list = selectedItems();