]> git.sesse.net Git - kdenlive/commitdiff
Fix scrolling while dragging clips in project tree:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 19 Jul 2010 23:26:01 +0000 (23:26 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 19 Jul 2010 23:26:01 +0000 (23:26 +0000)
http://www.kdenlive.org/mantis/view.php?id=1700

svn path=/trunk/kdenlive/; revision=4606

src/folderprojectitem.cpp
src/folderprojectitem.h
src/projectitem.cpp
src/projectlist.cpp
src/projectlistview.cpp
src/projectlistview.h
src/subprojectitem.cpp

index b9b33b11d0a32e4dcc4b88db27a07610f5c87af3..6f814b54fdb670db3533c71271e5e2b94946d5a8 100644 (file)
@@ -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)));
+}
 
index 5f936b3d7af8e79ae249c9b9e2162c98a637d85c..9d277a2f4a4cc39cd25c32723e413c7aecd8e086 100644 (file)
@@ -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 {
index 12b46be2bff0dde6d12d8a3b5fe4dcc3a74f9139..1f26d0f7ceb88ef2c9b68d05e1f57b7dac4908eb 100644 (file)
@@ -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");
index dec82cc2acd44f81ccfd2a14ba278a4d828e92c0..2850075dfa94fa499ab6590d8098de3cab9e2d4d 100644 (file)
@@ -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));
index 02e00f68dde0a9348f30bc85240f5466da004247..f906fb4601329bff23d3ab93eb1a1123bef67566 100644 (file)
@@ -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"
index 906c0a0c140d81dfa7ee30124b4e0f8d8111f3c4..b09bb3870579594597fe7e4cb7f45497ae9710cd 100644 (file)
@@ -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:
index 1e296354c164ca87d1f5e47a5deb59f48809ea79..9c8ad1ef21303ad3f684689cca6c7c840d964f52 100644 (file)
@@ -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);