#include "projectlistview.h"
#include "projectitem.h"
+#include "subprojectitem.h"
#include "kdenlivesettings.h"
#include <KDebug>
// virtual
void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
{
- ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
- if (!item) emit addClip();
- else if (item->isGroup()) {
+ QTreeWidgetItem *it = itemAt(event->pos());
+ if (!it) return;
+ ProjectItem *item;
+ if (it->type() == QTreeWidgetItem::UserType + 1) {
+ // subitem
+ item = static_cast <ProjectItem *>(it->parent());
+ } else item = static_cast <ProjectItem *>(it);
+ 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);
// virtual
void ProjectListView::dropEvent(QDropEvent *event)
{
- kDebug() << "//////////////// DROPPED EVENT";
+ ProjectItem *item = NULL;
+ QTreeWidgetItem *it = itemAt(event->pos());
+ if (it) {
+ if (it->type() == QTreeWidgetItem::UserType + 1) {
+ // subitem
+ item = static_cast <ProjectItem *>(it->parent());
+ } else item = static_cast <ProjectItem *>(it);
+ }
+
if (event->mimeData()->hasUrls()) {
- QTreeWidgetItem *item = 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);
+ event->setDropAction(Qt::CopyAction);
+ event->accept();
+ return;
} else if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
- ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
if (item) {
if (item->parent()) item = static_cast <ProjectItem *>(item->parent());
if (item->isGroup()) {
//emit addClip(event->mimeData->text());
- kDebug() << "//////////////// DROPPED RIGHT 1 ";
const QList <QTreeWidgetItem *> list = selectedItems();
ProjectItem *clone;
QString parentId = item->clipId();
} else item = NULL;
}
if (!item) {
- kDebug() << "//////////////// DROPPED ONÂ EMPTY ZONE";
// item dropped in empty zone, move it to top level
const QList <QTreeWidgetItem *> list = selectedItems();
ProjectItem *clone;
}
}
}
+ } else if (event->mimeData()->hasFormat("kdenlive/clip")) {
+ QStringList list = QString(event->mimeData()->data("kdenlive/clip")).split(';');
+ emit addClipCut(list.at(0), list.at(1).toInt(), list.at(2).toInt());
}
event->acceptProposedAction();
}
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);
+ QTreeWidgetItem *underMouse = itemAt(event->pos());
+ if (underMouse) emit focusMonitor();
+}
// virtual
void ProjectListView::mouseMoveEvent(QMouseEvent *event)
< QApplication::startDragDistance())
return;
- {
- ProjectItem *clickItem = (ProjectItem *) itemAt(m_DragStartPosition); //event->pos());
- if (clickItem) {
+ QTreeWidgetItem *it = itemAt(m_DragStartPosition);
+ if (!it) return;
+ if (it->type() == QTreeWidgetItem::UserType + 1) {
+ // subitem
+ SubProjectItem *clickItem = static_cast <SubProjectItem *>(it);
+ if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) {
+ ProjectItem *clip = static_cast <ProjectItem *>(it->parent());
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ QStringList list;
+ list.append(clip->clipId());
+ QPoint p = clickItem->zone();
+ list.append(QString::number(p.x()));
+ list.append(QString::number(p.y()));
+ QByteArray data;
+ data.append(list.join(";").toUtf8());
+ mimeData->setData("kdenlive/clip", data);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(clickItem->icon(0).pixmap(iconSize()));
+ drag->setHotSpot(QPoint(0, 50));
+ drag->exec();
+ }
+ } else {
+ ProjectItem *clickItem = static_cast <ProjectItem *>(it);
+ if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) {
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
const QList <QTreeWidgetItem *> list = selectedItems();
drag->setMimeData(mimeData);
drag->setPixmap(clickItem->icon(0).pixmap(iconSize()));
drag->setHotSpot(QPoint(0, 50));
- drag->exec(Qt::MoveAction);
+ drag->exec();
}
//event->accept();
}
// virtual
void ProjectListView::dragMoveEvent(QDragMoveEvent * event)
{
- event->setDropAction(Qt::IgnoreAction);
- event->setDropAction(Qt::MoveAction);
+ //event->setDropAction(Qt::MoveAction);
if (event->mimeData()->hasText()) {
event->acceptProposedAction();
}
qstrList.append("text/uri-list");
qstrList.append("text/plain");
qstrList.append("kdenlive/producerslist");
+ qstrList.append("kdenlive/clip");
return qstrList;
}