setAlternatingRowColors(true);
setDragEnabled(true);
setAcceptDrops(true);
-
+ setFrameShape(QFrame::NoFrame);
+ setRootIsDecorated(false);
setColumnCount(3);
QStringList headers;
emit requestMenu(event->globalPos(), itemAt(event->pos()));
}
+// virtual
+void ProjectListView::keyPressEvent(QKeyEvent * event)
+{
+ if (event->key() == Qt::Key_Return) {
+ QTreeWidgetItem *it = currentItem();
+ if (it) {
+ it->setExpanded(!it->isExpanded());
+ if (it->type() == PROJECTFOLDERTYPE) {
+ static_cast <FolderProjectItem *>(it)->switchIcon();
+ }
+ }
+ } else QTreeWidget::keyPressEvent(event);
+}
+
// virtual
void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
{
}
ProjectItem *item;
if (it->type() == PROJECTFOLDERTYPE) {
- if ((columnAt(event->pos().x()) == 0)) QTreeWidget::mouseDoubleClickEvent(event);
+ if ((columnAt(event->pos().x()) == 0)) {
+ QPixmap pix = qVariantValue<QPixmap>(it->data(0, Qt::DecorationRole));
+ int offset = pix.width() + indentation();
+ if (event->pos().x() < offset) {
+ it->setExpanded(!it->isExpanded());
+ static_cast <FolderProjectItem *>(it)->switchIcon();
+ event->accept();
+ } else QTreeWidget::mouseDoubleClickEvent(event);
+ }
return;
}
if (it->type() == PROJECTSUBCLIPTYPE) {
if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
int column = columnAt(event->pos().x());
- if (column == 0 && (item->clipType() == SLIDESHOW || item->clipType() == TEXT || item->clipType() == COLOR)) {
+ if (column == 0 && (item->clipType() == SLIDESHOW || item->clipType() == TEXT || item->clipType() == COLOR || it->childCount() > 0)) {
QPixmap pix = qVariantValue<QPixmap>(it->data(0, Qt::DecorationRole));
int offset = pix.width() + indentation();
if (item->parent()) offset += indentation();
- if ((pix.isNull() || offset < event->pos().x())) {
+ if (it->childCount() > 0) {
+ if (offset > event->pos().x()) {
+ it->setExpanded(!it->isExpanded());
+ event->accept();
+ return;
+ }
+ } else if (pix.isNull() || offset < event->pos().x()) {
QTreeWidget::mouseDoubleClickEvent(event);
return;
}
emit showProperties(item->referencedClip());
}
-// virtual
-void ProjectListView::dragEnterEvent(QDragEnterEvent *event)
-{
- if (event->mimeData()->hasUrls() || event->mimeData()->hasText()) {
- kDebug() << "//////////////// DRAG ENTR OK";
- }
- event->acceptProposedAction();
-}
// virtual
void ProjectListView::dropEvent(QDropEvent *event)
emit addClip(event->mimeData()->urls(), groupName, groupId);
event->setDropAction(Qt::CopyAction);
event->accept();
+ QTreeWidget::dropEvent(event);
return;
} else if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
if (item) {
emit addClipCut(list.at(0), list.at(1).toInt(), list.at(2).toInt());
}
event->acceptProposedAction();
+ QTreeWidget::dropEvent(event);
}
// virtual
}
// virtual
-void ProjectListView::dragMoveEvent(QDragMoveEvent * event)
+void ProjectListView::dragLeaveEvent(QDragLeaveEvent *event)
{
- //event->setDropAction(Qt::MoveAction);
- if (event->mimeData()->hasText()) {
- event->acceptProposedAction();
- }
// stop playing because we get a crash otherwise when fetching the thumbnails
emit pauseMonitor();
+ QTreeWidget::dragLeaveEvent(event);
}
QStringList ProjectListView::mimeTypes() const
Qt::DropActions ProjectListView::supportedDropActions() const
{
// returns what actions are supported when dropping
- return Qt::MoveAction;
+ return Qt::MoveAction | Qt::CopyAction;
}
#include "projectlistview.moc"