Commit d6d2992f authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix scrolling while dragging clips in project tree:

http://www.kdenlive.org/mantis/view.php?id=1700

svn path=/trunk/kdenlive/; revision=4606
parent 1a7c5f0e
......@@ -31,7 +31,7 @@ FolderProjectItem::FolderProjectItem(QTreeWidget * parent, const QStringList & s
m_clipId(clipId)
{
setSizeHint(0, QSize(65, QFontInfo(font(1)).pixelSize() * 2));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
setData(0, Qt::DecorationRole, KIcon("folder").pixmap(sizeHint(0)));
//setIcon(0, KIcon("folder").pixmap(sizeHint(0)));
setToolTip(0, "<b>" + i18n("Folder"));
......@@ -60,5 +60,8 @@ void FolderProjectItem::setGroupName(const QString name)
setText(0, name);
}
void FolderProjectItem::switchIcon()
{
setData(0, Qt::DecorationRole, isExpanded() ? KIcon("folder-open").pixmap(sizeHint(0)) : KIcon("folder").pixmap(sizeHint(0)));
}
......@@ -39,6 +39,7 @@ public:
QString clipId() const;
const QString groupName() const;
void setGroupName(const QString name);
void switchIcon();
/** Make sure folders appear on top of the tree widget */
virtual bool operator<(const QTreeWidgetItem &other)const {
......
......@@ -34,8 +34,8 @@ ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
QTreeWidgetItem(parent, PROJECTCLIPTYPE)
{
setSizeHint(0, QSize(itemHeight * 3, itemHeight));
if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
m_clip = clip;
m_clipId = clip->getId();
QString name = m_clip->getProperty("name");
......@@ -54,8 +54,8 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip) :
QTreeWidgetItem(parent, PROJECTCLIPTYPE)
{
setSizeHint(0, QSize(itemHeight * 3, itemHeight));
if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
m_clip = clip;
m_clipId = clip->getId();
QString name = m_clip->getProperty("name");
......
......@@ -60,6 +60,7 @@
#include <QMenu>
#include <QProcess>
#include <QHeaderView>
#include <QInputDialog>
ProjectList::ProjectList(QWidget *parent) :
QWidget(parent),
......@@ -437,7 +438,7 @@ void ProjectList::slotMissingClip(const QString &id)
{
ProjectItem *item = getItemById(id);
if (item) {
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
if (item->referencedClip()) {
item->referencedClip()->setPlaceHolder(true);
if (m_render == NULL) kDebug() << "********* ERROR, NULL RENDR";
......@@ -456,7 +457,7 @@ void ProjectList::slotAvailableClip(const QString &id)
ProjectItem *item = getItemById(id);
if (item == NULL)
return;
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
if (item->referencedClip()) { // && item->referencedClip()->checkHash() == false) {
item->setProperty("file_hash", QString());
slotReloadClip(id);
......@@ -744,7 +745,7 @@ void ProjectList::slotRemoveClip()
} else {
ProjectItem *item = static_cast <ProjectItem *>(selected.at(i));
ids << item->clipId();
if (item->numReferences() > 0 &&KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b>?<br />This will also remove the clip in timeline", "Delete clip <b>%2</b>?<br />This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes)
if (item->numReferences() > 0 && KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b>?<br />This will also remove the clip in timeline", "Delete clip <b>%2</b>?<br />This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes)
return;
}
}
......@@ -1025,7 +1026,7 @@ void ProjectList::updateAllClips()
if (clip->isPlaceHolder() == false)
requestClipInfo(clip->toXML(), clip->getId());
else if (!clip->isPlaceHolder())
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
} else {
if (item->data(0, Qt::DecorationRole).isNull())
requestClipThumbnail(clip->getId());
......@@ -1051,9 +1052,9 @@ QString ProjectList::getExtensions()
{
// Build list of mime types
QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain"
<< "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime"
<< "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg"
<< "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
<< "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime"
<< "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg"
<< "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
QString allExtensions;
foreach(const QString& mimeType, mimeTypes) {
......@@ -1401,7 +1402,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
item->setProperties(properties, metadata);
if (item->referencedClip()->isPlaceHolder() && producer->is_valid()) {
item->referencedClip()->setValid();
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
toReload = clipId;
}
//Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
......@@ -1434,6 +1435,10 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
int max = m_doc->clipManager()->clipsCount();
if (item && m_infoQueue.isEmpty() && m_thumbnailQueue.isEmpty()) {
m_listView->setCurrentItem(item);
if (item->parent()) {
if (item->parent()->type() == PROJECTFOLDERTYPE)
static_cast <FolderProjectItem *>(item->parent())->switchIcon();
}
emit clipSelected(item->referencedClip());
} else {
emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
......
......@@ -119,7 +119,12 @@ void ProjectListView::keyPressEvent(QKeyEvent * event)
{
if (event->key() == Qt::Key_Return) {
QTreeWidgetItem *it = currentItem();
if (it) it->setExpanded(!it->isExpanded());
if (it) {
it->setExpanded(!it->isExpanded());
if (it->type() == PROJECTFOLDERTYPE) {
static_cast <FolderProjectItem *>(it)->switchIcon();
}
}
} else QTreeWidget::keyPressEvent(event);
}
......@@ -138,6 +143,7 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
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);
}
......@@ -337,12 +343,8 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
}
// virtual
void ProjectListView::dragMoveEvent(QDragMoveEvent * event)
void ProjectListView::dragLeaveEvent(QDragLeaveEvent *)
{
//event->setDropAction(Qt::MoveAction);
if (event->mimeData()->hasText()) {
event->acceptProposedAction();
}
// stop playing because we get a crash otherwise when fetching the thumbnails
emit pauseMonitor();
}
......@@ -363,7 +365,7 @@ 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"
......@@ -47,7 +47,7 @@ protected:
virtual void dropEvent(QDropEvent *event);
virtual QStringList mimeTypes() const;
virtual Qt::DropActions supportedDropActions() const;
virtual void dragMoveEvent(QDragMoveEvent * event);
virtual void dragLeaveEvent(QDragLeaveEvent *);
virtual void keyPressEvent(QKeyEvent * event);
public slots:
......
......@@ -34,7 +34,7 @@ SubProjectItem::SubProjectItem(QTreeWidgetItem * parent, int in, int out, QStrin
QTreeWidgetItem(parent, PROJECTSUBCLIPTYPE), m_in(in), m_out(out), m_description(description)
{
setSizeHint(0, QSize(65, 30));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
QString name = Timecode::getStringTimecode(in, KdenliveSettings::project_fps());
setText(0, name);
setText(1, description);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment