]> git.sesse.net Git - kdenlive/blobdiff - src/projectlistview.cpp
Try to fix audio mixing bug ( http://www.kdenlive.org:80/mantis/view.php?id=228 )
[kdenlive] / src / projectlistview.cpp
index f51c0b2330e5f9e4f0434aebec754b5d9cec639d..d7de11cce011aa95489109d525a23744ae22554f 100644 (file)
@@ -50,7 +50,7 @@ ProjectListView::ProjectListView(QWidget *parent)
     connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
             this, SLOT(configureColumns(const QPoint&)));
 
-    connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(slotFocusOut(QTreeWidgetItem *, QTreeWidgetItem *)));
+    //connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(slotFocusOut(QTreeWidgetItem *, QTreeWidgetItem *)));
 
     if (!KdenliveSettings::showdescriptioncolumn()) hideColumn(2);
     if (!KdenliveSettings::showratingcolumn()) hideColumn(3);
@@ -112,8 +112,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->clipType() == FOLDER && columnAt(event->pos().x()) == 1) || columnAt(event->pos().x()) == 2) QTreeWidget::mouseDoubleClickEvent(event);
-    else emit showProperties(item->referencedClip());
+    else if (item->isGroup()) {
+        if ((columnAt(event->pos().x()) == 1)) QTreeWidget::mouseDoubleClickEvent(event);
+    } else {
+        if ((columnAt(event->pos().x()) == 2)) QTreeWidget::mouseDoubleClickEvent(event);
+        else emit showProperties(item->referencedClip());
+    }
 }
 
 // virtual
@@ -135,9 +139,8 @@ void ProjectListView::dropEvent(QDropEvent *event) {
             else if (item->parent() && ((ProjectItem *) item->parent())->isGroup())
                 groupName = item->parent()->text(1);
         }
-        QList <QUrl> list;
-        list = event->mimeData()->urls();
-        foreach(QUrl url, list) {
+        const QList <QUrl> list = event->mimeData()->urls();
+        foreach(const QUrl &url, list) {
             emit addClip(url, groupName);
         }
 
@@ -148,18 +151,20 @@ void ProjectListView::dropEvent(QDropEvent *event) {
             if (item->isGroup()) {
                 //emit addClip(event->mimeData->text());
                 kDebug() << "////////////////  DROPPED RIGHT 1 ";
-                QList <QTreeWidgetItem *> list;
-                list = selectedItems();
+                const QList <QTreeWidgetItem *> list = selectedItems();
                 ProjectItem *clone;
-                int parentId = item->clipId();
+                QString parentId = item->clipId();
                 foreach(QTreeWidgetItem *it, list) {
                     // TODO allow dragging of folders ?
-                    if (!((ProjectItem *) it)->isGroup() && ((ProjectItem *) it)->clipId() < 10000) {
+                    if (!((ProjectItem *) it)->isGroup()/* && ((ProjectItem *) it)->clipId() < 10000*/) {
                         if (it->parent()) clone = (ProjectItem*) it->parent()->takeChild(it->parent()->indexOfChild(it));
                         else clone = (ProjectItem*) takeTopLevelItem(indexOfTopLevelItem(it));
                         if (clone) {
                             item->addChild(clone);
-                            clone->setGroup(item->groupName(), QString::number(parentId));
+                            QMap <QString, QString> props;
+                            props.insert("groupname", item->groupName());
+                            props.insert("groupid", parentId);
+                            clone->setProperties(props);
                         }
                     }
                 }
@@ -168,15 +173,18 @@ void ProjectListView::dropEvent(QDropEvent *event) {
         if (!item) {
             kDebug() << "////////////////  DROPPED ON EMPTY ZONE";
             // item dropped in empty zone, move it to top level
-            QList <QTreeWidgetItem *> list;
-            list = selectedItems();
+            const QList <QTreeWidgetItem *> list = selectedItems();
             ProjectItem *clone;
             foreach(QTreeWidgetItem *it, list) {
                 QTreeWidgetItem *parent = it->parent();
-                if (parent && ((ProjectItem *) it)->clipId() < 10000)  {
+                if (parent/* && ((ProjectItem *) it)->clipId() < 10000*/)  {
                     kDebug() << "++ item parent: " << parent->text(1);
-                    clone = (ProjectItem*) parent->takeChild(parent->indexOfChild(it));
-                    if (clone) addTopLevelItem(clone);
+                    clone = static_cast <ProjectItem*>(parent->takeChild(parent->indexOfChild(it)));
+                    if (clone) {
+                        addTopLevelItem(clone);
+                        clone->clearProperty("groupname");
+                        clone->clearProperty("groupid");
+                    }
                 }
             }
         }
@@ -189,6 +197,8 @@ void ProjectListView::mousePressEvent(QMouseEvent *event) {
     if (event->button() == Qt::LeftButton) {
         this->m_DragStartPosition = event->pos();
         m_dragStarted = true;
+        QTreeWidgetItem *underMouse = itemAt(event->pos());
+        if (underMouse && underMouse->isSelected()) emit focusMonitor();
     }
     QTreeWidget::mousePressEvent(event);
 }
@@ -204,18 +214,24 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) {
         return;
 
     {
-        ProjectItem *clickItem = (ProjectItem *) itemAt(event->pos());
+        ProjectItem *clickItem = (ProjectItem *) itemAt(m_DragStartPosition); //event->pos());
         if (clickItem) {
             QDrag *drag = new QDrag(this);
             QMimeData *mimeData = new QMimeData;
             QDomDocument doc;
-            QList <QTreeWidgetItem *> list;
-            list = selectedItems();
+            const QList <QTreeWidgetItem *> list = selectedItems();
             QStringList ids;
-            foreach(QTreeWidgetItem *item, list) {
-                // TODO allow dragging of folders
-                ids.append(QString::number(((ProjectItem *) item)->clipId()));
+            foreach(const QTreeWidgetItem *item, list) {
+                const ProjectItem *clip = static_cast <const ProjectItem *>(item);
+                if (!clip->isGroup()) ids.append(clip->clipId());
+                else {
+                    const int children = item->childCount();
+                    for (int i = 0; i < children; i++) {
+                        ids.append(static_cast <ProjectItem *>(item->child(i))->clipId());
+                    }
+                }
             }
+            if (ids.isEmpty()) return;
             QByteArray data;
             data.append(ids.join(";").toUtf8()); //doc.toString().toUtf8());
             mimeData->setData("kdenlive/producerslist", data);
@@ -236,6 +252,7 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) {
     }
 }
 
+// virtual
 void ProjectListView::dragMoveEvent(QDragMoveEvent * event) {
     QTreeWidgetItem * item = itemAt(event->pos());
     event->setDropAction(Qt::IgnoreAction);