-void ProjectListView::dropEvent(QDropEvent *event)
-{
- kDebug()<<"//////////////// DROPPED EVENT";
- if (event->mimeData()->hasUrls()) {
- QTreeWidgetItem *item = itemAt(event->pos());
- QString groupName;
- if (item) {
- if (((ProjectItem *) item)->isGroup()) groupName = item->text(1);
- else if (item->parent() && ((ProjectItem *) item->parent())->isGroup())
- groupName = item->parent()->text(1);
- }
- QList <QUrl> list;
- list = event->mimeData()->urls();
- foreach (QUrl url, list) {
- emit addClip(url, groupName);
- }
-
- }
- else if (event->mimeData()->hasText())
- {
- QTreeWidgetItem *item = itemAt(event->pos());
- if (item) {
- if (item->parent()) item = item->parent();
- if (((ProjectItem *) item)->isGroup()) {
- //emit addClip(event->mimeData->text());
- kDebug()<<"//////////////// DROPPED RIGHT 1 ";
- QList <QTreeWidgetItem *> list;
- list = selectedItems ();
- ProjectItem *clone;
- foreach (QTreeWidgetItem *it, list) {
- // TODO allow dragging of folders ?
- 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);
- }
- }
- }
- else item = NULL;
+void ProjectListView::dropEvent(QDropEvent *event) {
+ kDebug() << "//////////////// DROPPED EVENT";
+ if (event->mimeData()->hasUrls()) {
+ QTreeWidgetItem *item = itemAt(event->pos());
+ QString groupName;
+ if (item) {
+ if (((ProjectItem *) item)->isGroup()) groupName = item->text(1);
+ else if (item->parent() && ((ProjectItem *) item->parent())->isGroup())
+ groupName = item->parent()->text(1);
+ }
+ QList <QUrl> list;
+ list = event->mimeData()->urls();
+ foreach(QUrl url, list) {
+ emit addClip(url, groupName);
+ }
+
+ } else if (event->mimeData()->hasText()) {
+ QTreeWidgetItem *item = itemAt(event->pos());
+ if (item) {
+ if (item->parent()) item = item->parent();
+ if (((ProjectItem *) item)->isGroup()) {
+ //emit addClip(event->mimeData->text());
+ kDebug() << "//////////////// DROPPED RIGHT 1 ";
+ QList <QTreeWidgetItem *> list;
+ list = selectedItems();
+ ProjectItem *clone;
+ foreach(QTreeWidgetItem *it, list) {
+ // TODO allow dragging of folders ?
+ 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);
+ }
+ }
+ } else item = NULL;
+ }
+ if (!item) {
+ kDebug() << "//////////////// DROPPED ON EMPTY ZONE";
+ // item dropped in empty zone, move it to top level
+ QList <QTreeWidgetItem *> list;
+ list = selectedItems();
+ ProjectItem *clone;
+ foreach(QTreeWidgetItem *it, list) {
+ QTreeWidgetItem *parent = it->parent();
+ if (parent && ((ProjectItem *) it)->clipId() < 10000) {
+ kDebug() << "++ item parent: " << parent->text(1);
+ clone = (ProjectItem*) parent->takeChild(parent->indexOfChild(it));
+ if (clone) addTopLevelItem(clone);
+ }
+ }
+ }