X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlistview.cpp;h=8b0182021b74fbf7c284db087bc891e51d3db789;hb=e19f8a27245266dcc6c76ecdcea6c1c827f04399;hp=d7de11cce011aa95489109d525a23744ae22554f;hpb=56f69242fee94baa6a0ed504b9cc51e0b5eb04ae;p=kdenlive diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index d7de11cc..8b018202 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -17,21 +17,23 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include -#include -#include + +#include "projectlistview.h" +#include "projectitem.h" +#include "kdenlivesettings.h" #include #include #include -#include "projectitem.h" -#include "projectlistview.h" -#include "kdenlivesettings.h" - +#include +#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); @@ -55,25 +57,25 @@ ProjectListView::ProjectListView(QWidget *parent) if (!KdenliveSettings::showdescriptioncolumn()) hideColumn(2); if (!KdenliveSettings::showratingcolumn()) hideColumn(3); - setIconSize(QSize(60, 40)); 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")); QHeaderView* headerView = header(); for (int i = 2; i < headerView->count(); ++i) { - const int logicalIndex = headerView->logicalIndex(i); const QString text = model()->headerData(i, Qt::Horizontal).toString(); QAction* action = popup.addAction(text); action->setCheckable(true); - action->setChecked(!headerView->isSectionHidden(logicalIndex)); + action->setChecked(!headerView->isSectionHidden(i)); action->setData(i); } @@ -104,24 +106,32 @@ 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()) == 2)) QTreeWidget::mouseDoubleClickEvent(event); + if ((columnAt(event->pos().x()) == 1) && (item->clipType() == SLIDESHOW || item->clipType() == TEXT || item->clipType() == COLOR)) QTreeWidget::mouseDoubleClickEvent(event); + else if ((columnAt(event->pos().x()) == 2)) QTreeWidget::mouseDoubleClickEvent(event); else emit showProperties(item->referencedClip()); } } // virtual -void ProjectListView::dragEnterEvent(QDragEnterEvent *event) { +void ProjectListView::dragEnterEvent(QDragEnterEvent *event) +{ if (event->mimeData()->hasUrls() || event->mimeData()->hasText()) { kDebug() << "//////////////// DRAG ENTR OK"; } @@ -129,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()); @@ -139,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(url, groupName); - } + emit addClip(event->mimeData()->urls(), groupName); } else if (event->mimeData()->hasFormat("kdenlive/producerslist")) { ProjectItem *item = static_cast (itemAt(event->pos())); @@ -193,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(); @@ -205,8 +214,9 @@ void ProjectListView::mousePressEvent(QMouseEvent *event) { // virtual -void ProjectListView::mouseMoveEvent(QMouseEvent *event) { - kDebug() << "// DRAG STARTED, MOUSE MOVED: "; +void ProjectListView::mouseMoveEvent(QMouseEvent *event) +{ + //kDebug() << "// DRAG STARTED, MOUSE MOVED: "; if (!m_dragStarted) return; if ((event->pos() - m_DragStartPosition).manhattanLength() @@ -214,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) { @@ -238,33 +247,28 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) { //mimeData->setText(ids.join(";")); //doc.toString()); //mimeData->setImageData(image); drag->setMimeData(mimeData); - drag->setPixmap(clickItem->icon(0).pixmap((int)(50 *16 / 9.0), 50)); + drag->setPixmap(clickItem->icon(0).pixmap(iconSize())); drag->setHotSpot(QPoint(0, 50)); - drag->start(Qt::MoveAction); - - //Qt::DropAction dropAction; - //dropAction = drag->start(Qt::CopyAction | Qt::MoveAction); - - //Qt::DropAction dropAction = drag->exec(); - + drag->exec(Qt::MoveAction); } //event->accept(); } } // virtual -void ProjectListView::dragMoveEvent(QDragMoveEvent * event) { - QTreeWidgetItem * item = itemAt(event->pos()); +void ProjectListView::dragMoveEvent(QDragMoveEvent * event) +{ event->setDropAction(Qt::IgnoreAction); - //if (item) { event->setDropAction(Qt::MoveAction); if (event->mimeData()->hasText()) { event->acceptProposedAction(); } - //} + // stop playing because we get a crash otherwise when fetching the thumbnails + emit pauseMonitor(); } -QStringList ProjectListView::mimeTypes() const { +QStringList ProjectListView::mimeTypes() const +{ QStringList qstrList; qstrList << QTreeWidget::mimeTypes(); // list of accepted mime types for drop @@ -275,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; }