X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlistview.cpp;h=b424ebef1de1f43fb72e41ca7887e77479620c53;hb=5fdf3dfaacd0d5144b1fc2c3949e2cb774e50d25;hp=022ea16238e80883877b829876f44fd531f6c286;hpb=cdddde0d37cc1c73d5823afe19e72f922f8159ef;p=kdenlive diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index 022ea162..b424ebef 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -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,9 @@ void ProjectListView::contextMenuEvent(QContextMenuEvent * event) { void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event) { ProjectItem *item = static_cast (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 emit showProperties(item->referencedClip()); } // virtual @@ -135,8 +136,7 @@ void ProjectListView::dropEvent(QDropEvent *event) { else if (item->parent() && ((ProjectItem *) item->parent())->isGroup()) groupName = item->parent()->text(1); } - QList list; - list = event->mimeData()->urls(); + const QList list = event->mimeData()->urls(); foreach(const QUrl &url, list) { emit addClip(url, groupName); } @@ -148,20 +148,19 @@ void ProjectListView::dropEvent(QDropEvent *event) { if (item->isGroup()) { //emit addClip(event->mimeData->text()); kDebug() << "//////////////// DROPPED RIGHT 1 "; - QList list; - list = selectedItems(); + const QList 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); QMap props; props.insert("groupname", item->groupName()); - props.insert("groupid", QString::number(parentId)); + props.insert("groupid", parentId); clone->setProperties(props); } } @@ -171,15 +170,18 @@ void ProjectListView::dropEvent(QDropEvent *event) { if (!item) { kDebug() << "//////////////// DROPPED ON EMPTY ZONE"; // item dropped in empty zone, move it to top level - QList list; - list = selectedItems(); + const QList 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 (parent->takeChild(parent->indexOfChild(it))); + if (clone) { + addTopLevelItem(clone); + clone->clearProperty("groupname"); + clone->clearProperty("groupid"); + } } } } @@ -192,6 +194,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); } @@ -207,18 +211,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 list; - list = selectedItems(); + const QList list = selectedItems(); QStringList ids; foreach(const QTreeWidgetItem *item, list) { - // TODO allow dragging of folders - ids.append(QString::number(((ProjectItem *) item)->clipId())); + const ProjectItem *clip = static_cast (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 (item->child(i))->clipId()); + } + } } + if (ids.isEmpty()) return; QByteArray data; data.append(ids.join(";").toUtf8()); //doc.toString().toUtf8()); mimeData->setData("kdenlive/producerslist", data); @@ -239,6 +249,7 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) { } } +// virtual void ProjectListView::dragMoveEvent(QDragMoveEvent * event) { QTreeWidgetItem * item = itemAt(event->pos()); event->setDropAction(Qt::IgnoreAction);