setDragEnabled(true);
setAcceptDrops(true);
setFrameShape(QFrame::NoFrame);
- setRootIsDecorated(false);
+ setRootIsDecorated(true);
- setColumnCount(3);
+ updateStyleSheet();
+
+ setColumnCount(4);
QStringList headers;
- headers << i18n("Clip") << i18n("Description") << i18n("Rating");
+ headers << i18n("Clip") << i18n("Description") << i18n("Rating") << i18n("Date");
setHeaderLabels(headers);
-
+ setIndentation(12);
+
QHeaderView* headerView = header();
headerView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(configureColumns(const QPoint&)));
+ connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(slotCollapsed(QTreeWidgetItem *)));
+ connect(this, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(slotExpanded(QTreeWidgetItem *)));
headerView->setClickable(true);
headerView->setSortIndicatorShown(true);
headerView->setMovable(false);
sortByColumn(0, Qt::AscendingOrder);
setSortingEnabled(true);
-
+ installEventFilter(this);
if (!KdenliveSettings::showdescriptioncolumn()) hideColumn(1);
if (!KdenliveSettings::showratingcolumn()) hideColumn(2);
+ if (!KdenliveSettings::showdatecolumn()) hideColumn(3);
}
ProjectListView::~ProjectListView()
{
}
+void ProjectListView::updateStyleSheet()
+{
+ QString style = "QTreeView::branch:has-siblings:!adjoins-item{border-image: none;border:0px} \
+ QTreeView::branch:has-siblings:adjoins-item {border-image: none;border:0px} \
+ QTreeView::branch:!has-children:!has-siblings:adjoins-item {border-image: none;border:0px} \
+ QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings { \
+ border-image: none;image: url(:/images/stylesheet-branch-closed.png);} \
+ QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings { \
+ border-image: none;image: url(:/images/stylesheet-branch-open.png);}";
+ setStyleSheet(style);
+}
+
+void ProjectListView::processLayout()
+{
+ executeDelayedItemsLayout();
+}
+
void ProjectListView::configureColumns(const QPoint& pos)
{
KMenu popup(this);
case 2:
KdenliveSettings::setShowratingcolumn(show);
break;
+ case 3:
+ KdenliveSettings::setShowdatecolumn(show);
+ break;
default:
break;
}
emit requestMenu(event->globalPos(), itemAt(event->pos()));
}
-// virtual
-void ProjectListView::keyPressEvent(QKeyEvent * event)
+void ProjectListView::slotCollapsed(QTreeWidgetItem *item)
+{
+ if (item->type() == PROJECTFOLDERTYPE) {
+ blockSignals(true);
+ static_cast <FolderProjectItem *>(item)->switchIcon();
+ blockSignals(false);
+ }
+}
+
+void ProjectListView::slotExpanded(QTreeWidgetItem *item)
+{
+ if (item->type() == PROJECTFOLDERTYPE) {
+ blockSignals(true);
+ static_cast <FolderProjectItem *>(item)->switchIcon();
+ blockSignals(false);
+ }
+}
+
+bool ProjectListView::eventFilter(QObject *obj, QEvent *event)
{
- if (event->key() == Qt::Key_Return) {
- QTreeWidgetItem *it = currentItem();
- if (it) it->setExpanded(!it->isExpanded());
- } else QTreeWidget::keyPressEvent(event);
+ if (event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride) {
+ QKeyEvent* ke = (QKeyEvent*) event;
+ if (ke->key() == Qt::Key_Plus) {
+ if (currentItem()) currentItem()->setExpanded(true);
+ event->accept();
+ return true;
+ } else if (ke->key() == Qt::Key_Minus) {
+ if (currentItem()) currentItem()->setExpanded(false);
+ event->accept();
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ // pass the event on to the parent class
+ return QTreeWidget::eventFilter(obj, event);
+ }
}
// virtual
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) {
if (it->type() == PROJECTCLIPTYPE) {
if (it->parent()) clone = (ProjectItem*) it->parent()->takeChild(it->parent()->indexOfChild(it));
else clone = (ProjectItem*) takeTopLevelItem(indexOfTopLevelItem(it));
- if (clone) {
+ if (clone && item) {
item->addChild(clone);
QMap <QString, QString> props;
props.insert("groupname", item->groupName());
const QList <QTreeWidgetItem *> list = selectedItems();
ProjectItem *clone;
foreach(QTreeWidgetItem *it, list) {
+ if (it->type() != PROJECTCLIPTYPE) continue;
QTreeWidgetItem *parent = it->parent();
if (parent/* && ((ProjectItem *) it)->clipId() < 10000*/) {
kDebug() << "++ item parent: " << parent->text(1);
QStringList list = QString(event->mimeData()->data("kdenlive/clip")).split(';');
emit addClipCut(list.at(0), list.at(1).toInt(), list.at(2).toInt());
}
- event->acceptProposedAction();
+ if (event->source() == this) {
+ event->setDropAction(Qt::MoveAction);
+ event->accept();
+ } else {
+ event->acceptProposedAction();
+ }
+ QTreeWidget::dropEvent(event);
}
// virtual
m_DragStartPosition = event->pos();
m_dragStarted = true;
/*QTreeWidgetItem *underMouse = itemAt(event->pos());
- if (underMouse && underMouse->isSelected()) emit focusMonitor();*/
+ ProjectItem *item = static_cast<ProjectItem *>(underMouse);
+ if (item) {
+ QRect itemRect = visualItemRect(item);
+ if (item->underJobMenu(itemRect, event->pos())) {
+ emit display
+ }
+
+ && underMouse->isSelected()) emit focusMonitor()
+ }*/
}
QTreeWidget::mousePressEvent(event);
}
drag->setMimeData(mimeData);
drag->setPixmap(clickItem->data(0, Qt::DecorationRole).value<QPixmap>());
drag->setHotSpot(QPoint(0, 50));
- drag->exec();
+ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}
} else {
if (it && (it->flags() & Qt::ItemIsDragEnabled)) {
drag->setMimeData(mimeData);
drag->setPixmap(it->data(0, Qt::DecorationRole).value<QPixmap>());
drag->setHotSpot(QPoint(0, 50));
- drag->exec();
+ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}
//event->accept();
}
}
// 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"