X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlistview.cpp;h=8b0182021b74fbf7c284db087bc891e51d3db789;hb=2bc1e097b59002f245b0378d99b7dbfa4fcb0713;hp=e2cb395749f7ad5ecd7b310a7e2383858d27ade9;hpb=59e776c1eff0753fe4b62d9f4c31beaac1724b7f;p=kdenlive diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index e2cb3957..8b018202 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -30,8 +30,10 @@ #include #include -ProjectListView::ProjectListView(QWidget *parent) - : QTreeWidget(parent), m_dragStarted(false) { +ProjectListView::ProjectListView(QWidget *parent) : + QTreeWidget(parent), + m_dragStarted(false) +{ setSelectionMode(QAbstractItemView::ExtendedSelection); setDragDropMode(QAbstractItemView::DragDrop); setDropIndicatorShown(true); @@ -58,11 +60,13 @@ ProjectListView::ProjectListView(QWidget *parent) setSortingEnabled(true); } -ProjectListView::~ProjectListView() { +ProjectListView::~ProjectListView() +{ } -void ProjectListView::configureColumns(const QPoint& pos) { +void ProjectListView::configureColumns(const QPoint& pos) +{ KMenu popup(this); popup.addTitle(i18nc("@title:menu", "Columns")); @@ -102,15 +106,21 @@ void ProjectListView::configureColumns(const QPoint& pos) { } // virtual -void ProjectListView::contextMenuEvent(QContextMenuEvent * event) { +void ProjectListView::contextMenuEvent(QContextMenuEvent * event) +{ emit requestMenu(event->globalPos(), itemAt(event->pos())); } // virtual -void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event) { +void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event) +{ ProjectItem *item = static_cast (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); @@ -120,7 +130,8 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event) { } // virtual -void ProjectListView::dragEnterEvent(QDragEnterEvent *event) { +void ProjectListView::dragEnterEvent(QDragEnterEvent *event) +{ if (event->mimeData()->hasUrls() || event->mimeData()->hasText()) { kDebug() << "//////////////// DRAG ENTR OK"; } @@ -128,7 +139,8 @@ void ProjectListView::dragEnterEvent(QDragEnterEvent *event) { } // virtual -void ProjectListView::dropEvent(QDropEvent *event) { +void ProjectListView::dropEvent(QDropEvent *event) +{ kDebug() << "//////////////// DROPPED EVENT"; if (event->mimeData()->hasUrls()) { QTreeWidgetItem *item = itemAt(event->pos()); @@ -138,10 +150,7 @@ void ProjectListView::dropEvent(QDropEvent *event) { else if (item->parent() && ((ProjectItem *) item->parent())->isGroup()) groupName = item->parent()->text(1); } - const QList list = event->mimeData()->urls(); - foreach(const QUrl &url, list) { - emit addClip(KUrl(url), groupName); - } + emit addClip(event->mimeData()->urls(), groupName); } else if (event->mimeData()->hasFormat("kdenlive/producerslist")) { ProjectItem *item = static_cast (itemAt(event->pos())); @@ -192,9 +201,10 @@ void ProjectListView::dropEvent(QDropEvent *event) { } // virtual -void ProjectListView::mousePressEvent(QMouseEvent *event) { +void ProjectListView::mousePressEvent(QMouseEvent *event) +{ if (event->button() == Qt::LeftButton) { - this->m_DragStartPosition = event->pos(); + m_DragStartPosition = event->pos(); m_dragStarted = true; QTreeWidgetItem *underMouse = itemAt(event->pos()); if (underMouse && underMouse->isSelected()) emit focusMonitor(); @@ -204,7 +214,8 @@ void ProjectListView::mousePressEvent(QMouseEvent *event) { // virtual -void ProjectListView::mouseMoveEvent(QMouseEvent *event) { +void ProjectListView::mouseMoveEvent(QMouseEvent *event) +{ //kDebug() << "// DRAG STARTED, MOUSE MOVED: "; if (!m_dragStarted) return; @@ -213,11 +224,10 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) { return; { - ProjectItem *clickItem = (ProjectItem *) itemAt(m_DragStartPosition); //event->pos()); - if (clickItem) { + ProjectItem *clickItem = static_cast (itemAt(m_DragStartPosition)); + if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) { QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; - QDomDocument doc; const QList list = selectedItems(); QStringList ids; foreach(const QTreeWidgetItem *item, list) { @@ -246,7 +256,8 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) { } // virtual -void ProjectListView::dragMoveEvent(QDragMoveEvent * event) { +void ProjectListView::dragMoveEvent(QDragMoveEvent * event) +{ event->setDropAction(Qt::IgnoreAction); event->setDropAction(Qt::MoveAction); if (event->mimeData()->hasText()) { @@ -256,7 +267,8 @@ void ProjectListView::dragMoveEvent(QDragMoveEvent * event) { emit pauseMonitor(); } -QStringList ProjectListView::mimeTypes() const { +QStringList ProjectListView::mimeTypes() const +{ QStringList qstrList; qstrList << QTreeWidget::mimeTypes(); // list of accepted mime types for drop @@ -267,7 +279,8 @@ QStringList ProjectListView::mimeTypes() const { } -Qt::DropActions ProjectListView::supportedDropActions() const { +Qt::DropActions ProjectListView::supportedDropActions() const +{ // returns what actions are supported when dropping return Qt::MoveAction; }