]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Fix group move, should solve:
[kdenlive] / src / projectlist.cpp
index d8d30f911f25632df6a555379a7ea0447562f1bf..17b247dae712ad9e0e05af37e2153f144670a1f6 100644 (file)
@@ -58,6 +58,7 @@ ProjectList::ProjectList(QWidget *parent)
     QWidget *vbox = new QWidget;
     listView = new ProjectListView(this);;
     QVBoxLayout *layout = new QVBoxLayout;
+    layout->setContentsMargins(0, 0, 0, 0);
     m_clipIdCounter = 0;
     // setup toolbar
     searchView = new KTreeWidgetSearchLine(this);
@@ -112,6 +113,7 @@ ProjectList::ProjectList(QWidget *parent)
 
     connect(listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
     connect(listView, SIGNAL(focusMonitor()), this, SLOT(slotClipSelected()));
+    connect(listView, SIGNAL(pauseMonitor()), this, SLOT(slotPauseMonitor()));
     connect(listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
     connect(listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
     connect(listView, SIGNAL(addClip(QUrl, const QString &)), this, SLOT(slotAddClip(QUrl, const QString &)));
@@ -127,6 +129,14 @@ ProjectList::~ProjectList() {
     delete m_toolbar;
 }
 
+QByteArray ProjectList::headerInfo() {
+    return listView->header()->saveState();
+}
+
+void ProjectList::setHeaderInfo(const QByteArray &state) {
+    listView->header()->restoreState(state);
+}
+
 void ProjectList::slotEditClip() {
     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
     if (item && !item->isGroup()) {
@@ -156,6 +166,10 @@ void ProjectList::slotClipSelected() {
     }
 }
 
+void ProjectList::slotPauseMonitor() {
+    if (m_render) m_render->pause();
+}
+
 void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QString> properties) {
     ProjectItem *item = getItemById(id);
     if (item) {
@@ -251,7 +265,7 @@ void ProjectList::slotDeleteClip(const QString &clipId) {
     ProjectItem *item = getItemById(clipId);
     QTreeWidgetItem *p = item->parent();
     if (p) {
-        kDebug() << "///////  DELETEED CLIP HAS A PARENT... " << p->indexOfChild(item);
+        kDebug() << "///////  DELETED CLIP HAS A PARENT... " << p->indexOfChild(item);
         QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
     } else if (item) {
         delete item;
@@ -306,17 +320,21 @@ void ProjectList::slotAddFolder(const QString foldername, const QString &clipId,
 
 void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) {
     const QString parent = clip->getProperty("groupid");
+    //kDebug() << "Adding clip with groupid: " << parent;
     ProjectItem *item = NULL;
     if (!parent.isEmpty()) {
         ProjectItem *parentitem = getItemById(parent);
         if (!parentitem) {
             QStringList text;
             QString groupName = clip->getProperty("groupname");
+            //kDebug() << "Adding clip to new group: " << groupName;
             if (groupName.isEmpty()) groupName = i18n("Folder");
             text << QString() << groupName;
             listView->blockSignals(true);
             parentitem = new ProjectItem(listView, text, parent);
             listView->blockSignals(false);
+        } else {
+            //kDebug() << "Adding clip to existing group: " << parentitem->groupName();
         }
         if (parentitem) item = new ProjectItem(parentitem, clip);
     }
@@ -398,10 +416,10 @@ void ProjectList::updateAllClips() {
 }
 
 void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
-    if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
+    if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
     KUrl::List list;
     if (givenUrl.isEmpty()) {
-        list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/x-kdenlive application/x-flash-video application/vnd.rn-realmedia video/x-dv video/dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr video/mlt-playlist audio/x-flac audio/mp4", this);
+        list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/x-kdenlive video/x-flv application/vnd.rn-realmedia video/x-dv video/dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr video/mlt-playlist audio/x-flac audio/mp4", this);
     } else list.append(givenUrl);
     if (list.isEmpty()) return;
 
@@ -425,18 +443,17 @@ void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
 void ProjectList::slotRemoveInvalidClip(const QString &id) {
     ProjectItem *item = getItemById(id);
     if (item) {
-        QString path = item->referencedClip()->fileURL().path();
+        const QString path = item->referencedClip()->fileURL().path();
         if (!path.isEmpty()) KMessageBox::sorry(this, i18n("<qt>Clip <b>%1</b><br>is invalid, will be removed from project.", path));
-
+        QList <QString> ids;
+        ids << id;
+        m_doc->deleteProjectClip(ids);
     }
-    QList <QString> ids;
-    ids << id;
-    m_doc->deleteProjectClip(ids);
     if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
 }
 
 void ProjectList::slotAddColorClip() {
-    if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
+    if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
     QDialog *dia = new QDialog(this);
     Ui::ColorClip_UI *dia_ui = new Ui::ColorClip_UI();
     dia_ui->setupUi(dia);
@@ -468,7 +485,7 @@ void ProjectList::slotAddColorClip() {
 
 
 void ProjectList::slotAddSlideshowClip() {
-    if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
+    if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
     SlideshowClip *dia = new SlideshowClip(this);
 
     if (dia->exec() == QDialog::Accepted) {
@@ -511,12 +528,12 @@ void ProjectList::slotAddTitleClip() {
 }
 
 void ProjectList::setDocument(KdenliveDoc *doc) {
+    listView->blockSignals(true);
     listView->clear();
     m_thumbnailQueue.clear();
     m_infoQueue.clear();
     m_refreshed = false;
     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
-    listView->blockSignals(true);
     for (int i = 0; i < list.count(); i++) {
         slotAddClip(list.at(i), false);
     }
@@ -575,7 +592,11 @@ void ProjectList::slotRefreshClipThumbnail(ProjectItem *item, bool update) {
         if (!item->referencedClip()) return;
         int height = 50;
         int width = (int)(height  * m_render->dar());
-        QPixmap pix = item->referencedClip()->thumbProducer()->extractImage(item->referencedClip()->getClipThumbFrame(), width, height);
+        DocClipBase *clip = item->referencedClip();
+        if (!clip) slotProcessNextThumbnail();
+        QPixmap pix;
+        if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
+        else pix = item->referencedClip()->thumbProducer()->extractImage(item->referencedClip()->getClipThumbFrame(), width, height);
         item->setIcon(0, pix);
         if (update) emit projectModified();
         if (!m_thumbnailQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
@@ -599,6 +620,13 @@ void ProjectList::slotReplyGetImage(const QString &clipId, int pos, const QPixma
 
 ProjectItem *ProjectList::getItemById(const QString &id) {
     QTreeWidgetItemIterator it(listView);
+    while (*it) {
+        if (((ProjectItem *)(*it))->clipId() == id)
+            return static_cast<ProjectItem *>(*it);
+        ++it;
+    }
+    return NULL;
+#ifdef USED_TO_BE_THIS
     while (*it) {
         if (((ProjectItem *)(*it))->clipId() == id)
             break;
@@ -606,6 +634,7 @@ ProjectItem *ProjectList::getItemById(const QString &id) {
     }
     if (*it) return ((ProjectItem *)(*it));
     return NULL;
+#endif
 }
 
 void ProjectList::slotSelectClip(const QString &ix) {