]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Ask to change profile if first clip does not match project profile:
[kdenlive] / src / projectlist.cpp
index 52e4287113b88ce571d6eeb87d17693543c68600..f2b8e9af7061181012928efe292bf4394af57897 100644 (file)
 #include "renderer.h"
 #include "kthumb.h"
 #include "projectlistview.h"
+#include "timecodedisplay.h"
+#include "profilesdialog.h"
 #include "editclipcommand.h"
+#include "editclipcutcommand.h"
 #include "editfoldercommand.h"
+#include "addclipcutcommand.h"
+
 #include "ui_templateclip_ui.h"
 
 #include <KDebug>
 #include <KFileDialog>
 #include <KInputDialog>
 #include <KMessageBox>
-
+#include <KIO/NetAccess>
+#include <KFileItem>
+#ifdef NEPOMUK
 #include <nepomuk/global.h>
 #include <nepomuk/resourcemanager.h>
 //#include <nepomuk/tag.h>
+#endif
 
 #include <QMouseEvent>
 #include <QStylePainter>
 #include <QMenu>
 #include <QProcess>
 #include <QHeaderView>
+#include <QInputDialog>
 
 ProjectList::ProjectList(QWidget *parent) :
-        QWidget(parent),
-        m_render(NULL),
-        m_fps(-1),
-        m_commandStack(NULL),
-        m_editAction(NULL),
-        m_deleteAction(NULL),
-        m_openAction(NULL),
-        m_reloadAction(NULL),
-        m_transcodeAction(NULL),
-        m_selectedItem(NULL),
-        m_refreshed(false),
-        m_infoQueue(),
-        m_thumbnailQueue()
+    QWidget(parent),
+    m_render(NULL),
+    m_fps(-1),
+    m_commandStack(NULL),
+    m_editAction(NULL),
+    m_deleteAction(NULL),
+    m_openAction(NULL),
+    m_reloadAction(NULL),
+    m_transcodeAction(NULL),
+    m_doc(NULL),
+    m_refreshed(false),
+    m_infoQueue(),
+    m_thumbnailQueue()
 {
 
     m_listView = new ProjectListView(this);;
     QVBoxLayout *layout = new QVBoxLayout;
     layout->setContentsMargins(0, 0, 0, 0);
+    layout->setSpacing(0);
 
     // setup toolbar
     KTreeWidgetSearchLine *searchView = new KTreeWidgetSearchLine(this);
     m_toolbar = new QToolBar("projectToolBar", this);
     m_toolbar->addWidget(searchView);
+    int s = style()->pixelMetric(QStyle::PM_SmallIconSize);
+    m_toolbar->setIconSize(QSize(s, s));
     searchView->setTreeWidget(m_listView);
 
     m_addButton = new QToolButton(m_toolbar);
@@ -93,26 +105,28 @@ ProjectList::ProjectList(QWidget *parent) :
     m_queueTimer.setSingleShot(true);
 
 
-
+    connect(m_listView, SIGNAL(projectModified()), this, SIGNAL(projectModified()));
     connect(m_listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
     connect(m_listView, SIGNAL(focusMonitor()), this, SLOT(slotClipSelected()));
     connect(m_listView, SIGNAL(pauseMonitor()), this, SLOT(slotPauseMonitor()));
     connect(m_listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
     connect(m_listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
     connect(m_listView, SIGNAL(addClip(const QList <QUrl>, const QString &, const QString &)), this, SLOT(slotAddClip(const QList <QUrl>, const QString &, const QString &)));
+    connect(m_listView, SIGNAL(addClipCut(const QString &, int, int)), this, SLOT(slotAddClipCut(const QString &, int, int)));
     connect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));
     connect(m_listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
 
     m_listViewDelegate = new ItemDelegate(m_listView);
     m_listView->setItemDelegate(m_listViewDelegate);
-
-    if (KdenliveSettings::activate_nepomuk()) {
+#ifdef NEPOMUK
+    if(KdenliveSettings::activate_nepomuk()) {
         Nepomuk::ResourceManager::instance()->init();
-        if (!Nepomuk::ResourceManager::instance()->initialized()) {
+        if(!Nepomuk::ResourceManager::instance()->initialized()) {
             kDebug() << "Cannot communicate with Nepomuk, DISABLING it";
             KdenliveSettings::setActivate_nepomuk(false);
         }
     }
+#endif
 }
 
 ProjectList::~ProjectList()
@@ -124,25 +138,30 @@ ProjectList::~ProjectList()
     delete m_listViewDelegate;
 }
 
+void ProjectList::focusTree() const
+{
+    m_listView->setFocus();
+}
+
 void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
 {
     QList <QAction *> actions = addMenu->actions();
-    for (int i = 0; i < actions.count(); i++) {
-        if (actions.at(i)->data().toString() == "clip_properties") {
+    for(int i = 0; i < actions.count(); i++) {
+        if(actions.at(i)->data().toString() == "clip_properties") {
             m_editAction = actions.at(i);
             m_toolbar->addAction(m_editAction);
             actions.removeAt(i);
             i--;
-        } else if (actions.at(i)->data().toString() == "delete_clip") {
+        } else if(actions.at(i)->data().toString() == "delete_clip") {
             m_deleteAction = actions.at(i);
             m_toolbar->addAction(m_deleteAction);
             actions.removeAt(i);
             i--;
-        } else if (actions.at(i)->data().toString() == "edit_clip") {
+        } else if(actions.at(i)->data().toString() == "edit_clip") {
             m_openAction = actions.at(i);
             actions.removeAt(i);
             i--;
-        } else if (actions.at(i)->data().toString() == "reload_clip") {
+        } else if(actions.at(i)->data().toString() == "reload_clip") {
             m_reloadAction = actions.at(i);
             actions.removeAt(i);
             i--;
@@ -157,19 +176,24 @@ void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
     m_menu->addActions(addMenu->actions());
 }
 
-void ProjectList::setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu)
+void ProjectList::setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu, QMenu *inTimelineMenu)
 {
-    if (!addMenu) return;
+    if(!addMenu)
+        return;
     QMenu *menu = m_addButton->menu();
     menu->addMenu(addMenu);
     m_addButton->setMenu(menu);
 
     m_menu->addMenu(addMenu);
-    if (addMenu->isEmpty()) addMenu->setEnabled(false);
+    if(addMenu->isEmpty())
+        addMenu->setEnabled(false);
     m_menu->addMenu(transcodeMenu);
-    if (transcodeMenu->isEmpty()) transcodeMenu->setEnabled(false);
+    if(transcodeMenu->isEmpty())
+        transcodeMenu->setEnabled(false);
     m_transcodeAction = transcodeMenu;
     m_menu->addAction(m_reloadAction);
+    m_menu->addMenu(inTimelineMenu);
+    inTimelineMenu->setEnabled(false);
     m_menu->addAction(m_editAction);
     m_menu->addAction(m_openAction);
     m_menu->addAction(m_deleteAction);
@@ -187,77 +211,330 @@ void ProjectList::setHeaderInfo(const QByteArray &state)
     m_listView->header()->restoreState(state);
 }
 
+void ProjectList::updateProjectFormat(Timecode t)
+{
+    m_timecode = t;
+}
+
 void ProjectList::slotEditClip()
 {
-    ProjectItem *item = static_cast <ProjectItem*>(m_listView->currentItem());
-    if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
-    if (item && !item->isGroup()) {
+    QList<QTreeWidgetItem *> list = m_listView->selectedItems();
+    if(list.count() > 1) {
+        editClipSelection(list);
+        return;
+    }
+    ProjectItem *item;
+    if(!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE)
+        return;
+    if(m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE)
+        item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
+    else
+        item = static_cast <ProjectItem*>(m_listView->currentItem());
+    if(item && (item->flags() & Qt::ItemIsDragEnabled)) {
         emit clipSelected(item->referencedClip());
         emit showClipProperties(item->referencedClip());
     }
 }
 
+void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
+{
+    // Gather all common properties
+    QMap <QString, QString> commonproperties;
+    QList <DocClipBase *> clipList;
+    commonproperties.insert("force_aspect_ratio", "-");
+    commonproperties.insert("force_fps", "-");
+    commonproperties.insert("force_progressive", "-");
+    commonproperties.insert("threads", "-");
+    commonproperties.insert("video_index", "-");
+    commonproperties.insert("audio_index", "-");
+
+    bool allowDurationChange = true;
+    int commonDuration = -1;
+    ProjectItem *item;
+    for(int i = 0; i < list.count(); i++) {
+        item = NULL;
+        if(list.at(i)->type() == PROJECTFOLDERTYPE)
+            continue;
+        if(list.at(i)->type() == PROJECTSUBCLIPTYPE)
+            item = static_cast <ProjectItem*>(list.at(i)->parent());
+        else
+            item = static_cast <ProjectItem*>(list.at(i));
+        if(!(item->flags() & Qt::ItemIsDragEnabled))
+            continue;
+        if(item) {
+            // check properties
+            DocClipBase *clip = item->referencedClip();
+            if(clipList.contains(clip)) continue;
+            if(clip->clipType() != COLOR && clip->clipType() != IMAGE && clip->clipType() != TEXT)
+                allowDurationChange = false;
+            if(allowDurationChange && commonDuration != 0) {
+                if(commonDuration == -1)
+                    commonDuration = clip->duration().frames(m_fps);
+                else if(commonDuration != clip->duration().frames(m_fps))
+                    commonDuration = 0;
+            }
+            clipList.append(clip);
+            QMap <QString, QString> clipprops = clip->properties();
+            QMapIterator<QString, QString> p(commonproperties);
+            while(p.hasNext()) {
+                p.next();
+                if(p.value().isEmpty()) continue;
+                if(clipprops.contains(p.key())) {
+                    if(p.value() == "-")
+                        commonproperties.insert(p.key(), clipprops.value(p.key()));
+                    else if(p.value() != clipprops.value(p.key()))
+                        commonproperties.insert(p.key(), QString());
+                } else {
+                    commonproperties.insert(p.key(), QString());
+                }
+            }
+        }
+    }
+    if(allowDurationChange)
+        commonproperties.insert("out", QString::number(commonDuration));
+    QMapIterator<QString, QString> p(commonproperties);
+    while(p.hasNext()) {
+        p.next();
+        kDebug() << "Result: " << p.key() << " = " << p.value();
+    }
+    emit showClipProperties(clipList, commonproperties);
+}
+
 void ProjectList::slotOpenClip()
 {
-    ProjectItem *item = static_cast <ProjectItem*>(m_listView->currentItem());
-    if (item && !item->isGroup()) {
-        if (item->clipType() == IMAGE) {
-            if (KdenliveSettings::defaultimageapp().isEmpty()) KMessageBox::sorry(this, i18n("Please set a default application to open images in the Settings dialog"));
-            else QProcess::startDetached(KdenliveSettings::defaultimageapp(), QStringList() << item->clipUrl().path());
+    ProjectItem *item;
+    if(!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE)
+        return;
+    if(m_listView->currentItem()->type() == QTreeWidgetItem::UserType + 1)
+        item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
+    else
+        item = static_cast <ProjectItem*>(m_listView->currentItem());
+    if(item) {
+        if(item->clipType() == IMAGE) {
+            if(KdenliveSettings::defaultimageapp().isEmpty())
+                KMessageBox::sorry(this, i18n("Please set a default application to open images in the Settings dialog"));
+            else
+                QProcess::startDetached(KdenliveSettings::defaultimageapp(), QStringList() << item->clipUrl().path());
         }
-        if (item->clipType() == AUDIO) {
-            if (KdenliveSettings::defaultaudioapp().isEmpty()) KMessageBox::sorry(this, i18n("Please set a default application to open audio files in the Settings dialog"));
-            else QProcess::startDetached(KdenliveSettings::defaultaudioapp(), QStringList() << item->clipUrl().path());
+        if(item->clipType() == AUDIO) {
+            if(KdenliveSettings::defaultaudioapp().isEmpty())
+                KMessageBox::sorry(this, i18n("Please set a default application to open audio files in the Settings dialog"));
+            else
+                QProcess::startDetached(KdenliveSettings::defaultaudioapp(), QStringList() << item->clipUrl().path());
         }
     }
 }
 
+void ProjectList::cleanup()
+{
+    m_listView->clearSelection();
+    QTreeWidgetItemIterator it(m_listView);
+    ProjectItem *item;
+    while(*it) {
+        if((*it)->type() != PROJECTCLIPTYPE) {
+            it++;
+            continue;
+        }
+        item = static_cast <ProjectItem *>(*it);
+        if(item->numReferences() == 0)
+            item->setSelected(true);
+        it++;
+    }
+    slotRemoveClip();
+}
+
+void ProjectList::trashUnusedClips()
+{
+    QTreeWidgetItemIterator it(m_listView);
+    ProjectItem *item;
+    QStringList ids;
+    QStringList urls;
+    while(*it) {
+        if((*it)->type() != PROJECTCLIPTYPE) {
+            it++;
+            continue;
+        }
+        item = static_cast <ProjectItem *>(*it);
+        if(item->numReferences() == 0) {
+            ids << item->clipId();
+            KUrl url = item->clipUrl();
+            if(!url.isEmpty() && !urls.contains(url.path()))
+                urls << url.path();
+        }
+        it++;
+    }
+
+    // Check that we don't use the URL in another clip
+    QTreeWidgetItemIterator it2(m_listView);
+    while(*it2) {
+        if((*it2)->type() != PROJECTCLIPTYPE) {
+            it2++;
+            continue;
+        }
+        item = static_cast <ProjectItem *>(*it2);
+        if(item->numReferences() > 0) {
+            KUrl url = item->clipUrl();
+            if(!url.isEmpty() && urls.contains(url.path())) urls.removeAll(url.path());
+        }
+        it2++;
+    }
+
+    emit deleteProjectClips(ids, QMap <QString, QString>());
+    for(int i = 0; i < urls.count(); i++)
+        KIO::NetAccess::del(KUrl(urls.at(i)), this);
+}
+
 void ProjectList::slotReloadClip(const QString &id)
 {
     QList<QTreeWidgetItem *> selected;
-    if (id.isEmpty()) selected = m_listView->selectedItems();
-    else selected.append(getItemById(id));
+    if(id.isEmpty())
+        selected = m_listView->selectedItems();
+    else
+        selected.append(getItemById(id));
     ProjectItem *item;
-    for (int i = 0; i < selected.count(); i++) {
+    for(int i = 0; i < selected.count(); i++) {
+        if(selected.at(i)->type() != PROJECTCLIPTYPE) {
+            if(selected.at(i)->type() == PROJECTFOLDERTYPE) {
+                for(int j = 0; j < selected.at(i)->childCount(); j++)
+                    selected.append(selected.at(i)->child(j));
+            }
+            continue;
+        }
         item = static_cast <ProjectItem *>(selected.at(i));
-        if (item && !item->isGroup()) {
-            if (item->clipType() == IMAGE) {
+        if(item) {
+            if(item->clipType() == TEXT) {
+                if(!item->referencedClip()->getProperty("xmltemplate").isEmpty())
+                    regenerateTemplate(item);
+            } else if(item->clipType() != COLOR && item->clipType() != SLIDESHOW && item->referencedClip() &&  item->referencedClip()->checkHash() == false) {
+                item->referencedClip()->setPlaceHolder(true);
+                item->setProperty("file_hash", QString());
+            } else if(item->clipType() == IMAGE) {
                 item->referencedClip()->producer()->set("force_reload", 1);
-            } else if (item->clipType() == TEXT) {
-                if (!item->referencedClip()->getProperty("xmltemplate").isEmpty()) regenerateTemplate(item);
             }
             //requestClipInfo(item->toXml(), item->clipId(), true);
             // Clear the file_hash value, which will cause a complete reload of the clip
-            emit getFileProperties(item->toXml(), item->clipId(), true);
+            emit getFileProperties(item->toXml(), item->clipId(), m_listView->iconSize().height(), true);
         }
     }
 }
 
+void ProjectList::slotModifiedClip(const QString &id)
+{
+    ProjectItem *item = getItemById(id);
+    if(item) {
+        QPixmap pixmap = qVariantValue<QPixmap>(item->data(0, Qt::DecorationRole));
+        if(!pixmap.isNull()) {
+            QPainter p(&pixmap);
+            p.fillRect(0, 0, pixmap.width(), pixmap.height(), QColor(255, 255, 255, 200));
+            p.drawPixmap(0, 0, KIcon("view-refresh").pixmap(m_listView->iconSize()));
+            p.end();
+        } else {
+            pixmap = KIcon("view-refresh").pixmap(m_listView->iconSize());
+        }
+        item->setData(0, Qt::DecorationRole, pixmap);
+    }
+}
+
+void ProjectList::slotMissingClip(const QString &id)
+{
+    ProjectItem *item = getItemById(id);
+    if(item) {
+        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+        if(item->referencedClip()) {
+            item->referencedClip()->setPlaceHolder(true);
+            if(m_render == NULL) kDebug() << "*********  ERROR, NULL RENDR";
+            item->referencedClip()->setProducer(m_render->invalidProducer(id), true);
+            item->slotSetToolTip();
+            emit clipNeedsReload(id, true);
+        }
+    }
+    update();
+    emit displayMessage(i18n("Check missing clips"), -2);
+    emit updateRenderStatus();
+}
+
+void ProjectList::slotAvailableClip(const QString &id)
+{
+    ProjectItem *item = getItemById(id);
+    if(item == NULL)
+        return;
+    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);
+    }
+    /*else {
+    item->referencedClip()->setValid();
+    item->slotSetToolTip();
+    }
+    update();*/
+    emit updateRenderStatus();
+}
+
+bool ProjectList::hasMissingClips()
+{
+    bool missing = false;
+    QTreeWidgetItemIterator it(m_listView);
+    while(*it) {
+        if((*it)->type() == PROJECTCLIPTYPE && !((*it)->flags() & Qt::ItemIsDragEnabled)) {
+            missing = true;
+            break;
+        }
+        it++;
+    }
+    return missing;
+}
+
 void ProjectList::setRenderer(Render *projectRender)
 {
     m_render = projectRender;
-    m_listView->setIconSize(QSize(40 * m_render->dar(), 40));
+    m_listView->setIconSize(QSize((ProjectItem::itemDefaultHeight() - 2) * m_render->dar(), ProjectItem::itemDefaultHeight() - 2));
 }
 
 void ProjectList::slotClipSelected()
 {
-    if (m_listView->currentItem()) {
-        ProjectItem *clip = static_cast <ProjectItem*>(m_listView->currentItem());
-        if (!clip->isGroup()) {
-            m_selectedItem = clip;
-            emit clipSelected(clip->referencedClip());
+    if(!m_listView->isEnabled()) return;
+    if(m_listView->currentItem()) {
+        if(m_listView->currentItem()->type() == PROJECTFOLDERTYPE) {
+            emit clipSelected(NULL);
+            m_editAction->setEnabled(false);
+            m_deleteAction->setEnabled(true);
+            m_openAction->setEnabled(false);
+            m_reloadAction->setEnabled(false);
+            m_transcodeAction->setEnabled(false);
+        } else {
+            ProjectItem *clip;
+            if(m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
+                // this is a sub item, use base clip
+                m_deleteAction->setEnabled(true);
+                clip = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
+                if(clip == NULL) kDebug() << "-----------ERROR";
+                SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
+                emit clipSelected(clip->referencedClip(), sub->zone());
+                m_transcodeAction->setEnabled(false);
+                return;
+            }
+            clip = static_cast <ProjectItem*>(m_listView->currentItem());
+            if(clip)
+                emit clipSelected(clip->referencedClip());
+            m_editAction->setEnabled(true);
+            m_deleteAction->setEnabled(true);
+            m_reloadAction->setEnabled(true);
+            m_transcodeAction->setEnabled(true);
+            if(clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
+                m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
+                m_openAction->setEnabled(true);
+            } else if(clip && clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
+                m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
+                m_openAction->setEnabled(true);
+            } else {
+                m_openAction->setEnabled(false);
+            }
+            // Display relevant transcoding actions only
+            adjustTranscodeActions(clip);
+            // Display uses in timeline
+            emit findInTimeline(clip->clipId());
         }
-        m_editAction->setEnabled(true);
-        m_deleteAction->setEnabled(true);
-        m_reloadAction->setEnabled(true);
-        m_transcodeAction->setEnabled(true);
-        if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
-            m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
-            m_openAction->setEnabled(true);
-        } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
-            m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
-            m_openAction->setEnabled(true);
-        } else m_openAction->setEnabled(false);
     } else {
         emit clipSelected(NULL);
         m_editAction->setEnabled(false);
@@ -268,171 +545,271 @@ void ProjectList::slotClipSelected()
     }
 }
 
+void ProjectList::adjustTranscodeActions(ProjectItem *clip) const
+{
+    if(clip == NULL || clip->type() != PROJECTCLIPTYPE || clip->clipType() == COLOR || clip->clipType() == TEXT || clip->clipType() == PLAYLIST || clip->clipType() == SLIDESHOW) {
+        m_transcodeAction->setEnabled(false);
+        return;
+    }
+    m_transcodeAction->setEnabled(true);
+    QList<QAction *> transcodeActions = m_transcodeAction->actions();
+    QStringList data;
+    QString condition;
+    for(int i = 0; i < transcodeActions.count(); i++) {
+        data = transcodeActions.at(i)->data().toStringList();
+        if(data.count() > 2) {
+            condition = data.at(2);
+            if(condition.startsWith("vcodec"))
+                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section('=', 1, 1)));
+            else if(condition.startsWith("acodec"))
+                transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section('=', 1, 1)));
+        }
+    }
+
+}
+
 void ProjectList::slotPauseMonitor()
 {
-    if (m_render) m_render->pause();
+    if(m_render)
+        m_render->pause();
 }
 
 void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QString> properties)
 {
     ProjectItem *item = getItemById(id);
-    if (item) {
+    if(item) {
         slotUpdateClipProperties(item, properties);
-        if (properties.contains("colour") || properties.contains("resource") || properties.contains("xmldata") || properties.contains("force_aspect_ratio") || properties.contains("templatetext")) {
+        if(properties.contains("out") || properties.contains("force_fps")) {
+            slotReloadClip(id);
+        } else if(properties.contains("colour") || properties.contains("resource") || properties.contains("xmldata") || properties.contains("force_aspect_ratio") || properties.contains("templatetext")) {
             slotRefreshClipThumbnail(item);
             emit refreshClip();
         }
-        if (properties.contains("out")) item->changeDuration(properties.value("out").toInt());
     }
 }
 
 void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QString> properties)
 {
-    if (!clip) return;
-    if (!clip->isGroup()) clip->setProperties(properties);
-    //if (properties.contains("xmldata")) regenerateTemplateImage(clip);
-    if (properties.contains("name")) {
+    if(!clip)
+        return;
+    clip->setProperties(properties);
+    if(properties.contains("name")) {
         m_listView->blockSignals(true);
-        clip->setText(1, properties.value("name"));
+        clip->setText(0, properties.value("name"));
         m_listView->blockSignals(false);
         emit clipNameChanged(clip->clipId(), properties.value("name"));
     }
-    if (properties.contains("description")) {
+    if(properties.contains("description")) {
         CLIPTYPE type = clip->clipType();
         m_listView->blockSignals(true);
-        clip->setText(2, properties.value("description"));
+        clip->setText(1, properties.value("description"));
         m_listView->blockSignals(false);
-        if (KdenliveSettings::activate_nepomuk() && (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST)) {
+#ifdef NEPOMUK
+        if(KdenliveSettings::activate_nepomuk() && (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST)) {
             // Use Nepomuk system to store clip description
             Nepomuk::Resource f(clip->clipUrl().path());
             f.setDescription(properties.value("description"));
         }
+#endif
         emit projectModified();
     }
 }
 
 void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column)
 {
+    if(item->type() == PROJECTSUBCLIPTYPE) {
+        // this is a sub-item
+        if(column == 1) {
+            // user edited description
+            SubProjectItem *sub = static_cast <SubProjectItem*>(item);
+            ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
+            EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), sub->zone(), sub->description(), sub->text(1), true);
+            m_commandStack->push(command);
+            //slotUpdateCutClipProperties(sub->clipId(), sub->zone(), sub->text(1), sub->text(1));
+        }
+        return;
+    }
+    if(item->type() == PROJECTFOLDERTYPE) {
+        if(column == 0) {
+            FolderProjectItem *folder = static_cast <FolderProjectItem*>(item);
+            editFolder(item->text(0), folder->groupName(), folder->clipId());
+            folder->setGroupName(item->text(0));
+            m_doc->clipManager()->addFolder(folder->clipId(), item->text(0));
+            const int children = item->childCount();
+            for(int i = 0; i < children; i++) {
+                ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
+                child->setProperty("groupname", item->text(0));
+            }
+        }
+        return;
+    }
+
     ProjectItem *clip = static_cast <ProjectItem*>(item);
-    if (column == 2) {
-        if (clip->referencedClip()) {
+    if(column == 1) {
+        if(clip->referencedClip()) {
             QMap <QString, QString> oldprops;
             QMap <QString, QString> newprops;
             oldprops["description"] = clip->referencedClip()->getProperty("description");
-            newprops["description"] = item->text(2);
+            newprops["description"] = item->text(1);
 
-            if (clip->clipType() == TEXT && !clip->referencedClip()->getProperty("xmldata").isEmpty()) {
+            if(clip->clipType() == TEXT) {
                 // This is a text template clip, update the image
                 /*oldprops.insert("xmldata", clip->referencedClip()->getProperty("xmldata"));
                 newprops.insert("xmldata", generateTemplateXml(clip->referencedClip()->getProperty("xmltemplate"), item->text(2)).toString());*/
                 oldprops.insert("templatetext", clip->referencedClip()->getProperty("templatetext"));
-                newprops.insert("templatetext", item->text(2));
+                newprops.insert("templatetext", item->text(1));
             }
-
             slotUpdateClipProperties(clip->clipId(), newprops);
             EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
             m_commandStack->push(command);
         }
-    } else if (column == 1) {
-        if (clip->isGroup()) {
-            editFolder(item->text(1), clip->groupName(), clip->clipId());
-            clip->setGroupName(item->text(1));
-            m_doc->clipManager()->addFolder(clip->clipId(), item->text(1));
-            const int children = item->childCount();
-            for (int i = 0; i < children; i++) {
-                ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
-                child->setProperty("groupname", item->text(1));
-            }
-        } else {
-            if (clip->referencedClip()) {
-                QMap <QString, QString> oldprops;
-                QMap <QString, QString> newprops;
-                oldprops["name"] = clip->referencedClip()->getProperty("name");
-                newprops["name"] = item->text(1);
-                slotUpdateClipProperties(clip, newprops);
-                emit projectModified();
-                EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
-                m_commandStack->push(command);
-            }
+    } else if(column == 0) {
+        if(clip->referencedClip()) {
+            QMap <QString, QString> oldprops;
+            QMap <QString, QString> newprops;
+            oldprops["name"] = clip->referencedClip()->getProperty("name");
+            newprops["name"] = item->text(0);
+            slotUpdateClipProperties(clip, newprops);
+            emit projectModified();
+            EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
+            m_commandStack->push(command);
         }
     }
 }
 
 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item)
 {
-    bool enable = false;
-    if (item) {
-        enable = true;
-    }
+    bool enable = item ? true : false;
     m_editAction->setEnabled(enable);
     m_deleteAction->setEnabled(enable);
     m_reloadAction->setEnabled(enable);
     m_transcodeAction->setEnabled(enable);
-    if (enable) {
-        ProjectItem *clip = static_cast <ProjectItem*>(item);
-        if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
+    if(enable) {
+        ProjectItem *clip = NULL;
+        if(m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
+            clip = static_cast <ProjectItem*>(item->parent());
+            m_transcodeAction->setEnabled(false);
+        } else if(m_listView->currentItem()->type() == PROJECTCLIPTYPE) {
+            clip = static_cast <ProjectItem*>(item);
+            // Display relevant transcoding actions only
+            adjustTranscodeActions(clip);
+            // Display uses in timeline
+            emit findInTimeline(clip->clipId());
+        } else {
+            m_transcodeAction->setEnabled(false);
+        }
+        if(clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
             m_openAction->setEnabled(true);
-        } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
+        } else if(clip && clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
             m_openAction->setEnabled(true);
-        } else m_openAction->setEnabled(false);
-    } else m_openAction->setEnabled(false);
+        } else {
+            m_openAction->setEnabled(false);
+        }
+
+    } else {
+        m_openAction->setEnabled(false);
+    }
     m_menu->popup(pos);
 }
 
 void ProjectList::slotRemoveClip()
 {
-    if (!m_listView->currentItem()) return;
-    QList <QString> ids;
+    if(!m_listView->currentItem())
+        return;
+    QStringList ids;
     QMap <QString, QString> folderids;
     QList<QTreeWidgetItem *> selected = m_listView->selectedItems();
-    ProjectItem *item;
-    for (int i = 0; i < selected.count(); i++) {
-        item = static_cast <ProjectItem *>(selected.at(i));
-        if (item->isGroup()) folderids[item->groupName()] = item->clipId();
-        else ids << item->clipId();
-        if (item->numReferences() > 0) {
-            if (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;
-        } else if (item->isGroup() && item->childCount() > 0) {
-            int children = item->childCount();
-            if (KMessageBox::questionYesNo(this, i18n("Delete folder <b>%2</b>?<br>This will also remove the %1 clips in that folder", children, item->names().at(1)), i18n("Delete Folder")) != KMessageBox::Yes) return;
-            for (int i = 0; i < children; ++i) {
-                ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
+
+    QUndoCommand *delCommand = new QUndoCommand();
+    delCommand->setText(i18n("Delete Clip Zone"));
+
+    for(int i = 0; i < selected.count(); i++) {
+        if(selected.at(i)->type() == PROJECTSUBCLIPTYPE) {
+            // subitem
+            SubProjectItem *sub = static_cast <SubProjectItem *>(selected.at(i));
+            ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
+            new AddClipCutCommand(this, item->clipId(), sub->zone().x(), sub->zone().y(), sub->description(), false, true, delCommand);
+        } else if(selected.at(i)->type() == PROJECTFOLDERTYPE) {
+            // folder
+            FolderProjectItem *folder = static_cast <FolderProjectItem *>(selected.at(i));
+            folderids[folder->groupName()] = folder->clipId();
+            int children = folder->childCount();
+
+            if(children > 0 && KMessageBox::questionYesNo(this, i18np("Delete folder <b>%2</b>?<br />This will also remove the clip in that folder", "Delete folder <b>%2</b>?<br />This will also remove the %1 clips in that folder",  children, folder->text(1)), i18n("Delete Folder")) != KMessageBox::Yes)
+                return;
+            for(int i = 0; i < children; ++i) {
+                ProjectItem *child = static_cast <ProjectItem *>(folder->child(i));
                 ids << child->clipId();
             }
+        } 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)
+                return;
         }
     }
-    if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
-    if (!folderids.isEmpty()) deleteProjectFolder(folderids);
-    if (m_listView->topLevelItemCount() == 0) {
-        m_editAction->setEnabled(false);
+
+    if(delCommand->childCount() == 0)
+        delete delCommand;
+    else
+        m_commandStack->push(delCommand);
+    emit deleteProjectClips(ids, folderids);
+}
+
+void ProjectList::updateButtons() const
+{
+    if(m_listView->topLevelItemCount() == 0) {
         m_deleteAction->setEnabled(false);
-        m_openAction->setEnabled(false);
-        m_reloadAction->setEnabled(false);
-        m_transcodeAction->setEnabled(false);
+    } else {
+        m_deleteAction->setEnabled(true);
+        if(!m_listView->currentItem())
+            m_listView->setCurrentItem(m_listView->topLevelItem(0));
+        QTreeWidgetItem *item = m_listView->currentItem();
+        if(item && item->type() == PROJECTCLIPTYPE) {
+            m_editAction->setEnabled(true);
+            m_openAction->setEnabled(true);
+            m_reloadAction->setEnabled(true);
+            m_transcodeAction->setEnabled(true);
+            return;
+        }
     }
+
+    m_editAction->setEnabled(false);
+    m_openAction->setEnabled(false);
+    m_reloadAction->setEnabled(false);
+    m_transcodeAction->setEnabled(false);
 }
 
 void ProjectList::selectItemById(const QString &clipId)
 {
     ProjectItem *item = getItemById(clipId);
-    if (item) m_listView->setCurrentItem(item);
+    if(item)
+        m_listView->setCurrentItem(item);
 }
 
 
 void ProjectList::slotDeleteClip(const QString &clipId)
 {
     ProjectItem *item = getItemById(clipId);
-    if (!item) {
+    if(!item) {
         kDebug() << "/// Cannot find clip to delete";
         return;
     }
     m_listView->blockSignals(true);
+    QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
+    if(!newSelectedItem)
+        newSelectedItem = m_listView->itemBelow(item);
     delete item;
     m_doc->clipManager()->deleteClip(clipId);
     m_listView->blockSignals(false);
-    slotClipSelected();
+    if(newSelectedItem) {
+        m_listView->setCurrentItem(newSelectedItem);
+    } else {
+        updateButtons();
+        emit clipSelected(NULL);
+    }
 }
 
 
@@ -451,35 +828,43 @@ void ProjectList::slotAddFolder()
 
 void ProjectList::slotAddFolder(const QString foldername, const QString &clipId, bool remove, bool edit)
 {
-    if (remove) {
-        ProjectItem *item = getFolderItemById(clipId);
-        if (item) {
+    if(remove) {
+        FolderProjectItem *item = getFolderItemById(clipId);
+        if(item) {
             m_doc->clipManager()->deleteFolder(clipId);
+            QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
+            if(!newSelectedItem)
+                newSelectedItem = m_listView->itemBelow(item);
             delete item;
+            if(newSelectedItem)
+                m_listView->setCurrentItem(newSelectedItem);
+            else
+                updateButtons();
         }
     } else {
-        if (edit) {
-            ProjectItem *item = getFolderItemById(clipId);
-            if (item) {
+        if(edit) {
+            FolderProjectItem *item = getFolderItemById(clipId);
+            if(item) {
                 m_listView->blockSignals(true);
                 item->setGroupName(foldername);
                 m_listView->blockSignals(false);
                 m_doc->clipManager()->addFolder(clipId, foldername);
                 const int children = item->childCount();
-                for (int i = 0; i < children; i++) {
+                for(int i = 0; i < children; i++) {
                     ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
                     child->setProperty("groupname", foldername);
                 }
             }
         } else {
-            QStringList text;
-            text << QString() << foldername;
             m_listView->blockSignals(true);
-            m_listView->setCurrentItem(new ProjectItem(m_listView, text, clipId));
+            m_listView->setCurrentItem(new FolderProjectItem(m_listView, QStringList() << foldername, clipId));
             m_doc->clipManager()->addFolder(clipId, foldername);
             m_listView->blockSignals(false);
+            m_listView->editItem(m_listView->currentItem(), 0);
         }
+        updateButtons();
     }
+    m_doc->setModified(true);
 }
 
 
@@ -489,55 +874,87 @@ void ProjectList::deleteProjectFolder(QMap <QString, QString> map)
     QMapIterator<QString, QString> i(map);
     QUndoCommand *delCommand = new QUndoCommand();
     delCommand->setText(i18n("Delete Folder"));
-    while (i.hasNext()) {
+    while(i.hasNext()) {
         i.next();
         new AddFolderCommand(this, i.key(), i.value(), false, delCommand);
     }
     m_commandStack->push(delCommand);
-    m_doc->setModified(true);
 }
 
 void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
 {
-    if (getProperties) {
-        m_listView->setEnabled(false);
+    m_listView->setEnabled(false);
+    if(getProperties) {
         m_listView->blockSignals(true);
+        m_refreshed = false;
+        // remove file_hash so that we load all properties for the clip
+        QDomElement e = clip->toXML().cloneNode().toElement();
+        e.removeAttribute("file_hash");
+        m_infoQueue.insert(clip->getId(), e);
+        //m_render->getFileProperties(clip->toXML(), clip->getId(), true);
     }
+    clip->askForAudioThumbs();
     const QString parent = clip->getProperty("groupid");
-    kDebug() << "Adding clip with groupid: " << parent;
     ProjectItem *item = NULL;
-    if (!parent.isEmpty()) {
-        ProjectItem *parentitem = getFolderItemById(parent);
-        if (!parentitem) {
+    if(!parent.isEmpty()) {
+        FolderProjectItem *parentitem = getFolderItemById(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;
-            parentitem = new ProjectItem(m_listView, text, parent);
-        } else {
-            //kDebug() << "Adding clip to existing group: " << parentitem->groupName();
+            if(groupName.isEmpty()) groupName = i18n("Folder");
+            text << groupName;
+            parentitem = new FolderProjectItem(m_listView, text, parent);
         }
-        if (parentitem) item = new ProjectItem(parentitem, clip);
+
+        if(parentitem)
+            item = new ProjectItem(parentitem, clip);
     }
-    if (item == NULL) item = new ProjectItem(m_listView, clip);
+    if(item == NULL)
+        item = new ProjectItem(m_listView, clip);
     KUrl url = clip->fileURL();
 
-    if (getProperties == false && !clip->getClipHash().isEmpty()) {
+    if(getProperties == false && !clip->getClipHash().isEmpty()) {
         QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png";
-        if (QFile::exists(cachedPixmap)) {
-            item->setIcon(0, QPixmap(cachedPixmap));
+        if(QFile::exists(cachedPixmap)) {
+            QPixmap pix(cachedPixmap);
+            if(pix.isNull())
+                KIO::NetAccess::del(KUrl(cachedPixmap), this);
+            item->setData(0, Qt::DecorationRole, pix);
         }
     }
-
-    if (!url.isEmpty() && KdenliveSettings::activate_nepomuk()) {
+#ifdef NEPOMUK
+    if(!url.isEmpty() && KdenliveSettings::activate_nepomuk()) {
         // if file has Nepomuk comment, use it
         Nepomuk::Resource f(url.path());
         QString annotation = f.description();
-        if (!annotation.isEmpty()) item->setText(2, annotation);
-        item->setText(3, QString::number(f.rating()));
+        if(!annotation.isEmpty()) item->setText(1, annotation);
+        item->setText(2, QString::number(f.rating()));
+    }
+#endif
+    // Add cut zones
+    QList <CutZoneInfo> cuts = clip->cutZones();
+    if(!cuts.isEmpty()) {
+        for(int i = 0; i < cuts.count(); i++) {
+            SubProjectItem *sub = new SubProjectItem(item, cuts.at(i).zone.x(), cuts.at(i).zone.y(), cuts.at(i).description);
+            if(!clip->getClipHash().isEmpty()) {
+                QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + '#' + QString::number(cuts.at(i).zone.x()) + ".png";
+                if(QFile::exists(cachedPixmap)) {
+                    QPixmap pix(cachedPixmap);
+                    if(pix.isNull())
+                        KIO::NetAccess::del(KUrl(cachedPixmap), this);
+                    sub->setData(0, Qt::DecorationRole, pix);
+                }
+            }
+        }
     }
-    if (getProperties) m_listView->blockSignals(false);
+    if(m_listView->isEnabled()) {
+        updateButtons();
+        if(getProperties)
+            m_listView->blockSignals(false);
+    }
+    if(getProperties && !m_queueTimer.isActive())
+        slotProcessNextClipInQueue();
 }
 
 void ProjectList::slotResetProjectList()
@@ -551,163 +968,237 @@ void ProjectList::slotResetProjectList()
 
 void ProjectList::requestClipInfo(const QDomElement xml, const QString id)
 {
+    m_refreshed = false;
     m_infoQueue.insert(id, xml);
-    m_listView->setEnabled(false);
-    if (!m_queueTimer.isActive()) m_queueTimer.start();
     //if (m_infoQueue.count() == 1 || ) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
 }
 
 void ProjectList::slotProcessNextClipInQueue()
 {
-    if (m_infoQueue.isEmpty()) {
+    if(m_infoQueue.isEmpty()) {
         slotProcessNextThumbnail();
         return;
     }
 
     QMap<QString, QDomElement>::const_iterator j = m_infoQueue.constBegin();
-    if (j != m_infoQueue.constEnd()) {
+    if(j != m_infoQueue.constEnd()) {
         const QDomElement dom = j.value();
         const QString id = j.key();
         m_infoQueue.remove(j.key());
-        emit getFileProperties(dom, id, false);
+        emit getFileProperties(dom, id, m_listView->iconSize().height(), false);
     }
-    if (!m_infoQueue.isEmpty()) m_queueTimer.start();
+    if(!m_infoQueue.isEmpty()) m_queueTimer.start();
 }
 
 void ProjectList::slotUpdateClip(const QString &id)
 {
     ProjectItem *item = getItemById(id);
     m_listView->blockSignals(true);
-    if (item) item->setData(1, UsageRole, QString::number(item->numReferences()));
+    if(item) item->setData(0, UsageRole, QString::number(item->numReferences()));
     m_listView->blockSignals(false);
 }
 
 void ProjectList::updateAllClips()
 {
     m_listView->setSortingEnabled(false);
+    kDebug() << "// UPDATE ALL CLPY";
 
     QTreeWidgetItemIterator it(m_listView);
     DocClipBase *clip;
     ProjectItem *item;
     m_listView->blockSignals(true);
-    while (*it) {
-        item = static_cast <ProjectItem *>(*it);
-        if (!item->isGroup()) {
+    while(*it) {
+        if((*it)->type() == PROJECTSUBCLIPTYPE) {
+            // subitem
+            SubProjectItem *sub = static_cast <SubProjectItem *>(*it);
+            if(sub->data(0, Qt::DecorationRole).isNull()) {
+                item = static_cast <ProjectItem *>((*it)->parent());
+                requestClipThumbnail(item->clipId() + '#' + QString::number(sub->zone().x()));
+            }
+            ++it;
+            continue;
+        } else if((*it)->type() == PROJECTFOLDERTYPE) {
+            // folder
+            ++it;
+            continue;
+        } else {
+            item = static_cast <ProjectItem *>(*it);
             clip = item->referencedClip();
-            /*if (clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) {
-                // regenerate text clip image if required
-                TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this);
-                QDomDocument doc;
-                doc.setContent(clip->getProperty("xmldata"));
-                dia_ui->setXml(doc);
-                QImage pix = dia_ui->renderedPixmap();
-                pix.save(clip->fileURL().path());
-                delete dia_ui;
-            }*/
-            if (item->referencedClip()->producer() == NULL) {
-                if (clip->isPlaceHolder() == false) {
+            if(item->referencedClip()->producer() == NULL) {
+                if(clip->isPlaceHolder() == false)
                     requestClipInfo(clip->toXML(), clip->getId());
-                } else item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+                else if(!clip->isPlaceHolder())
+                    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
             } else {
-                if (item->icon(0).isNull()) {
+                if(item->data(0, Qt::DecorationRole).isNull())
                     requestClipThumbnail(clip->getId());
-                }
-                if (item->data(1, DurationRole).toString().isEmpty()) {
+                if(item->data(0, DurationRole).toString().isEmpty())
                     item->changeDuration(item->referencedClip()->producer()->get_playtime());
-                }
             }
-            item->setData(1, UsageRole, QString::number(item->numReferences()));
-            qApp->processEvents();
+            item->setData(0, UsageRole, QString::number(item->numReferences()));
         }
+        //qApp->processEvents();
         ++it;
     }
-
-    m_listView->blockSignals(false);
+    if(!m_queueTimer.isActive())
+        m_queueTimer.start();
+    if(m_listView->isEnabled())
+        m_listView->blockSignals(false);
     m_listView->setSortingEnabled(true);
-    if (m_infoQueue.isEmpty()) slotProcessNextThumbnail();
+    if(m_infoQueue.isEmpty())
+        slotProcessNextThumbnail();
+}
+
+// static
+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" << "application/mxf"
+                            << "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) {
+        KMimeType::Ptr mime(KMimeType::mimeType(mimeType));
+        if(mime) {
+            allExtensions.append(mime->patterns().join(" "));
+            allExtensions.append(' ');
+        }
+    }
+    return allExtensions.simplified();
 }
 
 void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &groupName, const QString &groupId)
 {
-    if (!m_commandStack) {
+    if(!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
     KUrl::List list;
-    if (givenList.isEmpty()) {
-        // Build list of mime types
-        QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mlt-playlist" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg" << "video/mp4" << "video/quicktime" << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
-
-        QString allExtensions;
-        foreach(const QString& mimeType, mimeTypes) {
-            KMimeType::Ptr mime(KMimeType::mimeType(mimeType));
-            if (mime) {
-                allExtensions.append(mime->patterns().join(" "));
-                allExtensions.append(' ');
+    if(givenList.isEmpty()) {
+        QString allExtensions = getExtensions();
+        const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
+        QCheckBox *b = new QCheckBox(i18n("Import image sequence"));
+        b->setChecked(KdenliveSettings::autoimagesequence());
+        KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, this, b);
+        d->setOperationMode(KFileDialog::Opening);
+        d->setMode(KFile::Files);
+        d->exec();
+        list = d->selectedUrls();
+        if(b->isChecked() && list.count() == 1) {
+            // Check for image sequence
+            KUrl url = list.at(0);
+            QString fileName = url.fileName().section('.', 0, -2);
+            if(fileName.at(fileName.size() - 1).isDigit()) {
+                KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
+                if(item.mimetype().startsWith("image")) {
+                    int count = 0;
+                    // import as sequence if we found more than one image in the sequence
+                    QString pattern = SlideshowClip::selectedPath(url.path(), false, QString(), &count);
+                    if(count > 1) {
+                        delete d;
+                        QStringList groupInfo = getGroup();
+
+                        // get image sequence base name
+                        while(fileName.at(fileName.size() - 1).isDigit()) {
+                            fileName.chop(1);
+                        }
+
+                        m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()),
+                                                           false, false, false,
+                                                           m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0,
+                                                           QString(), groupInfo.at(0), groupInfo.at(1));
+                        return;
+                    }
+                }
             }
         }
-        const QString dialogFilter = allExtensions.simplified() + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
-        list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), dialogFilter, this);
-
+        delete d;
     } else {
-        for (int i = 0; i < givenList.count(); i++)
+        for(int i = 0; i < givenList.count(); i++)
             list << givenList.at(i);
     }
-    if (list.isEmpty()) return;
 
-    if (givenList.isEmpty()) {
+    foreach(const KUrl & file, list) {
+        // Check there is no folder here
+        KMimeType::Ptr type = KMimeType::findByUrl(file);
+        if(type->is("inode/directory")) {
+            // user dropped a folder
+            list.removeAll(file);
+        }
+    }
+
+    if(list.isEmpty())
+        return;
+
+    if(givenList.isEmpty()) {
         QStringList groupInfo = getGroup();
         m_doc->slotAddClipList(list, groupInfo.at(0), groupInfo.at(1));
-    } else m_doc->slotAddClipList(list, groupName, groupId);
+    } else {
+        m_doc->slotAddClipList(list, groupName, groupId);
+    }
 }
 
 void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
 {
     ProjectItem *item = getItemById(id);
     QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
-    if (item) {
+    if(item) {
         const QString path = item->referencedClip()->fileURL().path();
-        if (!path.isEmpty()) {
-            if (replace) KMessageBox::sorry(this, i18n("Clip <b>%1</b><br>is invalid, will be removed from project.", path));
-            else {
-                if (KMessageBox::questionYesNo(this, i18n("Clip <b>%1</b><br>is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes) replace = true;
-            }
+        if(item->referencedClip()->isPlaceHolder()) replace = false;
+        if(!path.isEmpty()) {
+            if(replace)
+                KMessageBox::sorry(this, i18n("Clip <b>%1</b><br />is invalid, will be removed from project.", path));
+            else if(KMessageBox::questionYesNo(this, i18n("Clip <b>%1</b><br />is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes)
+                replace = true;
         }
-        QList <QString> ids;
-        ids << id;
-        if (replace) m_doc->deleteProjectClip(ids);
+        if(replace)
+            emit deleteProjectClips(QStringList() << id, QMap <QString, QString>());
     }
 }
 
 void ProjectList::slotAddColorClip()
 {
-    if (!m_commandStack) {
+    if(!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
     QDialog *dia = new QDialog(this);
     Ui::ColorClip_UI dia_ui;
     dia_ui.setupUi(dia);
+    dia->setWindowTitle(i18n("Color Clip"));
     dia_ui.clip_name->setText(i18n("Color Clip"));
-    dia_ui.clip_duration->setText(KdenliveSettings::color_duration());
-    if (dia->exec() == QDialog::Accepted) {
+
+    TimecodeDisplay *t = new TimecodeDisplay(m_timecode);
+    t->setValue(KdenliveSettings::color_duration());
+    t->setTimeCodeFormat(false);
+    dia_ui.clip_durationBox->addWidget(t);
+    dia_ui.clip_color->setColor(KdenliveSettings::colorclipcolor());
+
+    if(dia->exec() == QDialog::Accepted) {
         QString color = dia_ui.clip_color->color().name();
+        KdenliveSettings::setColorclipcolor(color);
         color = color.replace(0, 1, "0x") + "ff";
         QStringList groupInfo = getGroup();
-        m_doc->slotCreateColorClip(dia_ui.clip_name->text(), color, dia_ui.clip_duration->text(), groupInfo.at(0), groupInfo.at(1));
+        m_doc->slotCreateColorClip(dia_ui.clip_name->text(), color, m_timecode.getTimecode(t->gentime()), groupInfo.at(0), groupInfo.at(1));
     }
+    delete t;
     delete dia;
 }
 
 
 void ProjectList::slotAddSlideshowClip()
 {
-    if (!m_commandStack) {
+    if(!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
     SlideshowClip *dia = new SlideshowClip(m_timecode, this);
 
-    if (dia->exec() == QDialog::Accepted) {
+    if(dia->exec() == QDialog::Accepted) {
         QStringList groupInfo = getGroup();
-        m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), groupInfo.at(0), groupInfo.at(1));
+        m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(),
+                                           dia->loop(), dia->crop(), dia->fade(),
+                                           dia->lumaDuration(), dia->lumaFile(), dia->softness(),
+                                           dia->animation(), groupInfo.at(0), groupInfo.at(1));
     }
     delete dia;
 }
@@ -720,10 +1211,10 @@ void ProjectList::slotAddTitleClip()
 
 void ProjectList::slotAddTitleTemplateClip()
 {
-    QStringList groupInfo = getGroup();
-    if (!m_commandStack) {
+    if(!m_commandStack)
         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-    }
+
+    QStringList groupInfo = getGroup();
 
     // Get the list of existing templates
     QStringList filter;
@@ -734,24 +1225,21 @@ void ProjectList::slotAddTitleTemplateClip()
     QDialog *dia = new QDialog(this);
     Ui::TemplateClip_UI dia_ui;
     dia_ui.setupUi(dia);
-    for (int i = 0; i < templateFiles.size(); ++i) {
+    for(int i = 0; i < templateFiles.size(); ++i)
         dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), path + templateFiles.at(i));
-    }
+
+    if(!templateFiles.isEmpty())
+        dia_ui.buttonBox->button(QDialogButtonBox::Ok)->setFocus();
     dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
     //warning: setting base directory doesn't work??
     KUrl startDir(path);
     dia_ui.template_list->fileDialog()->setUrl(startDir);
-    dia_ui.description->setHidden(true);
-    if (dia->exec() == QDialog::Accepted) {
+    dia_ui.text_box->setHidden(true);
+    if(dia->exec() == QDialog::Accepted) {
         QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
-        if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
-        if (dia_ui.normal_clip->isChecked()) {
-            // Create a normal title clip
-            m_doc->slotCreateTextClip(groupInfo.at(0), groupInfo.at(1), textTemplate);
-        } else {
-            // Create a cloned template clip
-            m_doc->slotCreateTextTemplateClip(groupInfo.at(0), groupInfo.at(1), KUrl(textTemplate));
-        }
+        if(textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
+        // Create a cloned template clip
+        m_doc->slotCreateTextTemplateClip(groupInfo.at(0), groupInfo.at(1), KUrl(textTemplate));
     }
     delete dia;
 }
@@ -759,17 +1247,16 @@ void ProjectList::slotAddTitleTemplateClip()
 QStringList ProjectList::getGroup() const
 {
     QStringList result;
-    ProjectItem *item = static_cast <ProjectItem*>(m_listView->currentItem());
-    if (item && !item->isGroup()) {
-        while (item->parent()) {
-            item = static_cast <ProjectItem*>(item->parent());
-            if (item->isGroup()) break;
-        }
+    QTreeWidgetItem *item = m_listView->currentItem();
+    while(item && item->type() != PROJECTFOLDERTYPE)
+        item = item->parent();
+
+    if(item) {
+        FolderProjectItem *folder = static_cast <FolderProjectItem *>(item);
+        result << folder->groupName() << folder->clipId();
+    } else {
+        result << QString() << QString();
     }
-    if (item && item->isGroup()) {
-        result << item->groupName();
-        result << item->clipId();
-    } else result << QString() << QString();
     return result;
 }
 
@@ -789,32 +1276,46 @@ void ProjectList::setDocument(KdenliveDoc *doc)
 
     QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
     QMapIterator<QString, QString> f(flist);
-    while (f.hasNext()) {
+    while(f.hasNext()) {
         f.next();
-        (void) new ProjectItem(m_listView, QStringList() << QString() << f.value(), f.key());
+        (void) new FolderProjectItem(m_listView, QStringList() << f.value(), f.key());
     }
 
     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
-    for (int i = 0; i < list.count(); i++) {
+    for(int i = 0; i < list.count(); i++)
         slotAddClip(list.at(i), false);
-    }
 
     m_listView->blockSignals(false);
     m_toolbar->setEnabled(true);
     connect(m_doc->clipManager(), SIGNAL(reloadClip(const QString &)), this, SLOT(slotReloadClip(const QString &)));
+    connect(m_doc->clipManager(), SIGNAL(modifiedClip(const QString &)), this, SLOT(slotModifiedClip(const QString &)));
+    connect(m_doc->clipManager(), SIGNAL(missingClip(const QString &)), this, SLOT(slotMissingClip(const QString &)));
+    connect(m_doc->clipManager(), SIGNAL(availableClip(const QString &)), this, SLOT(slotAvailableClip(const QString &)));
     connect(m_doc->clipManager(), SIGNAL(checkAllClips()), this, SLOT(updateAllClips()));
 }
 
+QList <DocClipBase*> ProjectList::documentClipList() const
+{
+    if(m_doc == NULL)
+        return QList <DocClipBase*> ();
+
+    return m_doc->clipManager()->documentClipList();
+}
+
 QDomElement ProjectList::producersList()
 {
     QDomDocument doc;
     QDomElement prods = doc.createElement("producerlist");
     doc.appendChild(prods);
-    kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
+    kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
     QTreeWidgetItemIterator it(m_listView);
-    while (*it) {
-        if (!((ProjectItem *)(*it))->isGroup())
-            prods.appendChild(doc.importNode(((ProjectItem *)(*it))->toXml(), true));
+    while(*it) {
+        if((*it)->type() != PROJECTCLIPTYPE) {
+            // subitem
+            ++it;
+            continue;
+        }
+        prods.appendChild(doc.importNode(((ProjectItem *)(*it))->toXml(), true));
         ++it;
     }
     return prods;
@@ -822,19 +1323,30 @@ QDomElement ProjectList::producersList()
 
 void ProjectList::slotCheckForEmptyQueue()
 {
-    if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
+    if(!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
         m_refreshed = true;
         emit loadingIsOver();
-    } else QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
+        emit displayMessage(QString(), -1);
+        m_listView->blockSignals(false);
+        m_listView->setEnabled(true);
+        updateButtons();
+    } else if(!m_refreshed) {
+        QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
+    }
 }
 
 void ProjectList::reloadClipThumbnails()
 {
+    kDebug() << "//////////////  RELOAD CLIPS THUMBNAILS!!!";
     m_thumbnailQueue.clear();
     QTreeWidgetItemIterator it(m_listView);
-    while (*it) {
-        if (!((ProjectItem *)(*it))->isGroup())
-            m_thumbnailQueue << ((ProjectItem *)(*it))->clipId();
+    while(*it) {
+        if((*it)->type() != PROJECTCLIPTYPE) {
+            // subitem
+            ++it;
+            continue;
+        }
+        m_thumbnailQueue << ((ProjectItem *)(*it))->clipId();
         ++it;
     }
     QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
@@ -842,115 +1354,229 @@ void ProjectList::reloadClipThumbnails()
 
 void ProjectList::requestClipThumbnail(const QString id)
 {
-    m_thumbnailQueue.append(id);
+    if(!m_thumbnailQueue.contains(id)) m_thumbnailQueue.append(id);
 }
 
 void ProjectList::slotProcessNextThumbnail()
 {
-    if (m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
-        m_listView->setEnabled(true);
+    if(m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
         slotCheckForEmptyQueue();
         return;
     }
-    if (!m_infoQueue.isEmpty()) {
+    if(!m_infoQueue.isEmpty()) {
         //QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
         return;
     }
+    if(m_thumbnailQueue.count() > 1) {
+        int max = m_doc->clipManager()->clipsCount();
+        emit displayMessage(i18n("Loading thumbnails"), (int)(100 *(max - m_thumbnailQueue.count()) / max));
+    }
     slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
 }
 
 void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update)
 {
-    ProjectItem *item = getItemById(clipId);
-    if (item) slotRefreshClipThumbnail(item, update);
-    else slotProcessNextThumbnail();
+    QTreeWidgetItem *item = getAnyItemById(clipId);
+    if(item)
+        slotRefreshClipThumbnail(item, update);
+    else
+        slotProcessNextThumbnail();
 }
 
-void ProjectList::slotRefreshClipThumbnail(ProjectItem *item, bool update)
+void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
 {
-    if (item) {
+    if(it == NULL) return;
+    ProjectItem *item = NULL;
+    bool isSubItem = false;
+    int frame;
+    if(it->type() == PROJECTFOLDERTYPE) return;
+    if(it->type() == PROJECTSUBCLIPTYPE) {
+        item = static_cast <ProjectItem *>(it->parent());
+        frame = static_cast <SubProjectItem *>(it)->zone().x();
+        isSubItem = true;
+    } else {
+        item = static_cast <ProjectItem *>(it);
+        frame = item->referencedClip()->getClipThumbFrame();
+    }
+
+    if(item) {
         DocClipBase *clip = item->referencedClip();
-        if (!clip) {
+        if(!clip) {
             slotProcessNextThumbnail();
             return;
         }
         QPixmap pix;
-        int height = 50;
+        int height = m_listView->iconSize().height();
         int width = (int)(height  * m_render->dar());
-        if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
-        else if (clip->clipType() == IMAGE) pix = KThumb::getFrame(item->referencedClip()->producer(), 0, width, height);
-        else pix = item->referencedClip()->thumbProducer()->extractImage(item->referencedClip()->getClipThumbFrame(), width, height);
-        if (!pix.isNull()) {
+        if(clip->clipType() == AUDIO)
+            pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
+        else if(clip->clipType() == IMAGE)
+            pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, width, height));
+        else
+            pix = item->referencedClip()->thumbProducer()->extractImage(frame, width, height);
+
+        if(!pix.isNull()) {
             m_listView->blockSignals(true);
-            item->setIcon(0, pix);
-            m_listView->blockSignals(false);
-            m_doc->cachePixmap(item->getClipHash(), pix);
+            it->setData(0, Qt::DecorationRole, pix);
+            if(m_listView->isEnabled())
+                m_listView->blockSignals(false);
+            if(!isSubItem)
+                m_doc->cachePixmap(item->getClipHash(), pix);
+            else
+                m_doc->cachePixmap(item->getClipHash() + '#' + QString::number(frame), pix);
         }
-        if (update) emit projectModified();
-        QTimer::singleShot(100, this, SLOT(slotProcessNextThumbnail()));
+        if(update)
+            emit projectModified();
+        QTimer::singleShot(30, this, SLOT(slotProcessNextThumbnail()));
     }
 }
 
 void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace)
 {
+    QString toReload;
     ProjectItem *item = getItemById(clipId);
-    if (item && producer) {
+    if(item && producer) {
         m_listView->blockSignals(true);
         item->setProperties(properties, metadata);
-        Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
+        if(item->referencedClip()->isPlaceHolder() && producer->is_valid()) {
+            item->referencedClip()->setValid();
+            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());
         item->referencedClip()->setProducer(producer, replace);
-        emit receivedClipDuration(clipId);
-        if (replace) {
+        item->referencedClip()->askForAudioThumbs();
+        if(!replace && item->data(0, Qt::DecorationRole).isNull())
+            requestClipThumbnail(clipId);
+        if(!toReload.isEmpty())
+            item->slotSetToolTip();
+
+        //emit receivedClipDuration(clipId);
+        if(m_listView->isEnabled() && replace) {
             // update clip in clip monitor
             emit clipSelected(NULL);
             emit clipSelected(item->referencedClip());
+            //TODO: Make sure the line below has no side effect
+            toReload = clipId;
         }
         /*else {
             // Check if duration changed.
             emit receivedClipDuration(clipId);
             delete producer;
         }*/
-        m_listView->blockSignals(false);
-        if (item->icon(0).isNull()) {
+        if(m_listView->isEnabled())
+            m_listView->blockSignals(false);
+        /*if (item->icon(0).isNull()) {
             requestClipThumbnail(clipId);
-        }
+        }*/
     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
-
-    slotProcessNextClipInQueue();
+    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();
+        } else if(KdenliveSettings::checkfirstprojectclip() &&  m_listView->topLevelItemCount() == 1) {
+            // this is the first clip loaded in project, check if we want to adjust project settings to the clip
+            int width = properties.value("frame_size").section('x', 0, 0).toInt();
+            int height = properties.value("frame_size").section('x', -1).toInt();
+            double fps = properties.value("fps").toDouble();
+            if(width != m_doc->width() || height != m_doc->width() || qAbs(fps - m_doc->fps()) > 0.5) {
+                QString suggestedProfile = ProfilesDialog::getPathFromProperties(width, height, fps);
+                if(!suggestedProfile.isEmpty()) {
+                    QString description = ProfilesDialog::getSettingsFromFile(suggestedProfile).value("description");
+                    if(KMessageBox::questionYesNo(this, i18n("Your clip does not match current project's profile.\nDo you want to adjust the profile (clip size: %1, fps: %2)?\nSuggested profile is %3", properties.value("frame_size"), fps, description)) == KMessageBox::Yes) {
+                        //Change project profile
+                        emit updateProfile(suggestedProfile);
+                    }
+                } else KMessageBox::information(this, i18n("Your clip does not match current project's profile.\nNo existing profile found to match the clip's properties.\nClip size: %1\nFps: %2)?\n", properties.value("frame_size"), fps));
+            }
+        }
+        emit clipSelected(item->referencedClip());
+    } else {
+        emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
+    }
+    if(!toReload.isEmpty())
+        emit clipNeedsReload(toReload, true);
+    // small delay so that the app can display the progress info
+    QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
 }
 
 void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)
 {
     ProjectItem *item = getItemById(clipId);
-    if (item && !pix.isNull()) {
+    if(item && !pix.isNull()) {
         m_listView->blockSignals(true);
-        item->setIcon(0, pix);
+        item->setData(0, Qt::DecorationRole, pix);
         m_doc->cachePixmap(item->getClipHash(), pix);
-        m_listView->blockSignals(false);
+        if(m_listView->isEnabled())
+            m_listView->blockSignals(false);
     }
 }
 
+QTreeWidgetItem *ProjectList::getAnyItemById(const QString &id)
+{
+    QTreeWidgetItemIterator it(m_listView);
+    QString lookId = id;
+    if(id.contains('#'))
+        lookId = id.section('#', 0, 0);
+
+    ProjectItem *result = NULL;
+    while(*it) {
+        if((*it)->type() != PROJECTCLIPTYPE) {
+            // subitem
+            ++it;
+            continue;
+        }
+        ProjectItem *item = static_cast<ProjectItem *>(*it);
+        if(item->clipId() == lookId) {
+            result = item;
+            break;
+        }
+        ++it;
+    }
+    if(result == NULL || !id.contains('#')) {
+        return result;
+    } else {
+        for(int i = 0; i < result->childCount(); i++) {
+            SubProjectItem *sub = static_cast <SubProjectItem *>(result->child(i));
+            if(sub && sub->zone().x() == id.section('#', 1, 1).toInt())
+                return sub;
+        }
+    }
+
+    return NULL;
+}
+
+
 ProjectItem *ProjectList::getItemById(const QString &id)
 {
     ProjectItem *item;
     QTreeWidgetItemIterator it(m_listView);
-    while (*it) {
+    while(*it) {
+        if((*it)->type() != PROJECTCLIPTYPE) {
+            // subitem
+            ++it;
+            continue;
+        }
         item = static_cast<ProjectItem *>(*it);
-        if (item->clipId() == id && item->clipType() != FOLDER)
+        if(item->clipId() == id)
             return item;
         ++it;
     }
     return NULL;
 }
 
-ProjectItem *ProjectList::getFolderItemById(const QString &id)
+FolderProjectItem *ProjectList::getFolderItemById(const QString &id)
 {
-    ProjectItem *item;
+    FolderProjectItem *item;
     QTreeWidgetItemIterator it(m_listView);
-    while (*it) {
-        item = static_cast<ProjectItem *>(*it);
-        if (item->clipId() == id && item->clipType() == FOLDER)
-            return item;
+    while(*it) {
+        if((*it)->type() == PROJECTFOLDERTYPE) {
+            item = static_cast<FolderProjectItem *>(*it);
+            if(item->clipId() == id)
+                return item;
+        }
         ++it;
     }
     return NULL;
@@ -959,80 +1585,97 @@ ProjectItem *ProjectList::getFolderItemById(const QString &id)
 void ProjectList::slotSelectClip(const QString &ix)
 {
     ProjectItem *clip = getItemById(ix);
-    if (clip) {
+    if(clip) {
         m_listView->setCurrentItem(clip);
         m_listView->scrollToItem(clip);
         m_editAction->setEnabled(true);
         m_deleteAction->setEnabled(true);
         m_reloadAction->setEnabled(true);
         m_transcodeAction->setEnabled(true);
-        if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
+        if(clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
             m_openAction->setEnabled(true);
-        } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
+        } else if(clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
             m_openAction->setEnabled(true);
-        } else m_openAction->setEnabled(false);
+        } else {
+            m_openAction->setEnabled(false);
+        }
     }
 }
 
 QString ProjectList::currentClipUrl() const
 {
-    ProjectItem *item = static_cast <ProjectItem*>(m_listView->currentItem());
-    if (item == NULL) return QString();
+    ProjectItem *item;
+    if(!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE) return QString();
+    if(m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
+        // subitem
+        item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
+    } else {
+        item = static_cast <ProjectItem*>(m_listView->currentItem());
+    }
+    if(item == NULL)
+        return QString();
     return item->clipUrl().path();
 }
 
+KUrl::List ProjectList::getConditionalUrls(const QString &condition) const
+{
+    KUrl::List result;
+    ProjectItem *item;
+    QList<QTreeWidgetItem *> list = m_listView->selectedItems();
+    for(int i = 0; i < list.count(); i++) {
+        if(list.at(i)->type() == PROJECTFOLDERTYPE)
+            continue;
+        if(list.at(i)->type() == PROJECTSUBCLIPTYPE) {
+            // subitem
+            item = static_cast <ProjectItem*>(list.at(i)->parent());
+        } else {
+            item = static_cast <ProjectItem*>(list.at(i));
+        }
+        if(item == NULL || item->type() == COLOR || item->type() == SLIDESHOW || item->type() == TEXT)
+            continue;
+        DocClipBase *clip = item->referencedClip();
+        if(!condition.isEmpty()) {
+            if(condition.startsWith("vcodec") && !clip->hasVideoCodec(condition.section('=', 1, 1)))
+                continue;
+            else if(condition.startsWith("acodec") && !clip->hasAudioCodec(condition.section('=', 1, 1)))
+                continue;
+        }
+        result.append(item->clipUrl());
+    }
+    return result;
+}
+
 void ProjectList::regenerateTemplate(const QString &id)
 {
     ProjectItem *clip = getItemById(id);
-    if (clip) regenerateTemplate(clip);
+    if(clip)
+        regenerateTemplate(clip);
 }
 
 void ProjectList::regenerateTemplate(ProjectItem *clip)
 {
     //TODO: remove this unused method, only force_reload is necessary
-    // Generate image for template clip
-    /*const QString comment = clip->referencedClip()->getProperty("description");
-    const QString path = clip->referencedClip()->getProperty("resource");
-    QDomDocument doc = generateTemplateXml(path, comment);
-    TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this);
-    dia_ui->setXml(doc);
-    QImage pix = dia_ui->renderedPixmap();
-    pix.save(clip->clipUrl().path());
-    delete dia_ui;*/
     clip->referencedClip()->producer()->set("force_reload", 1);
 }
 
-void ProjectList::regenerateTemplateImage(ProjectItem *clip)
-{
-    //TODO: remove this unused method
-    // Generate image for template clip
-    /*TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this);
-    QDomDocument doc;
-    doc.setContent(clip->referencedClip()->getProperty("xmldata"));
-    dia_ui->setXml(doc);
-    QImage pix = dia_ui->renderedPixmap();
-    pix.save(clip->clipUrl().path());
-    delete dia_ui;*/
-}
-
 QDomDocument ProjectList::generateTemplateXml(QString path, const QString &replaceString)
 {
     QDomDocument doc;
     QFile file(path);
-    if (!file.open(QIODevice::ReadOnly)) {
+    if(!file.open(QIODevice::ReadOnly)) {
         kWarning() << "ERROR, CANNOT READ: " << path;
         return doc;
     }
-    if (!doc.setContent(&file)) {
+    if(!doc.setContent(&file)) {
         kWarning() << "ERROR, CANNOT READ: " << path;
         file.close();
         return doc;
     }
     file.close();
     QDomNodeList texts = doc.elementsByTagName("content");
-    for (int i = 0; i < texts.count(); i++) {
+    for(int i = 0; i < texts.count(); i++) {
         QString data = texts.item(i).firstChild().nodeValue();
         data.replace("%s", replaceString);
         texts.item(i).firstChild().setNodeValue(data);
@@ -1040,4 +1683,102 @@ QDomDocument ProjectList::generateTemplateXml(QString path, const QString &repla
     return doc;
 }
 
+
+void ProjectList::slotAddClipCut(const QString &id, int in, int out)
+{
+    ProjectItem *clip = getItemById(id);
+    if(clip == NULL || clip->referencedClip()->hasCutZone(QPoint(in, out)))
+        return;
+    AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, QString(), true, false);
+    m_commandStack->push(command);
+}
+
+void ProjectList::addClipCut(const QString &id, int in, int out, const QString desc, bool newItem)
+{
+    ProjectItem *clip = getItemById(id);
+    if(clip) {
+        DocClipBase *base = clip->referencedClip();
+        base->addCutZone(in, out);
+        m_listView->blockSignals(true);
+        SubProjectItem *sub = new SubProjectItem(clip, in, out, desc);
+        if(newItem && desc.isEmpty() && !m_listView->isColumnHidden(1)) {
+            if(!clip->isExpanded())
+                clip->setExpanded(true);
+            m_listView->scrollToItem(sub);
+            m_listView->editItem(sub, 1);
+        }
+        QPixmap p = clip->referencedClip()->thumbProducer()->extractImage(in, (int)(sub->sizeHint(0).height()  * m_render->dar()), sub->sizeHint(0).height() - 2);
+        sub->setData(0, Qt::DecorationRole, p);
+        m_doc->cachePixmap(clip->getClipHash() + '#' + QString::number(in), p);
+        m_listView->blockSignals(false);
+    }
+    emit projectModified();
+}
+
+void ProjectList::removeClipCut(const QString &id, int in, int out)
+{
+    ProjectItem *clip = getItemById(id);
+    if(clip) {
+        DocClipBase *base = clip->referencedClip();
+        base->removeCutZone(in, out);
+        SubProjectItem *sub = getSubItem(clip, QPoint(in, out));
+        if(sub) {
+            m_listView->blockSignals(true);
+            delete sub;
+            m_listView->blockSignals(false);
+        }
+    }
+    emit projectModified();
+}
+
+SubProjectItem *ProjectList::getSubItem(ProjectItem *clip, QPoint zone)
+{
+    SubProjectItem *sub = NULL;
+    if(clip) {
+        for(int i = 0; i < clip->childCount(); i++) {
+            QTreeWidgetItem *it = clip->child(i);
+            if(it->type() == PROJECTSUBCLIPTYPE) {
+                sub = static_cast <SubProjectItem*>(it);
+                if(sub->zone() == zone)
+                    break;
+                else
+                    sub = NULL;
+            }
+        }
+    }
+    return sub;
+}
+
+void ProjectList::slotUpdateClipCut(QPoint p)
+{
+    if(!m_listView->currentItem() || m_listView->currentItem()->type() != PROJECTSUBCLIPTYPE)
+        return;
+    SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
+    ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
+    EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), p, sub->text(1), sub->text(1), true);
+    m_commandStack->push(command);
+}
+
+void ProjectList::doUpdateClipCut(const QString &id, const QPoint oldzone, const QPoint zone, const QString &comment)
+{
+    ProjectItem *clip = getItemById(id);
+    SubProjectItem *sub = getSubItem(clip, oldzone);
+    if(sub == NULL || clip == NULL)
+        return;
+    DocClipBase *base = clip->referencedClip();
+    base->updateCutZone(oldzone.x(), oldzone.y(), zone.x(), zone.y(), comment);
+    m_listView->blockSignals(true);
+    sub->setZone(zone);
+    sub->setDescription(comment);
+    m_listView->blockSignals(false);
+    emit projectModified();
+}
+
+void ProjectList::slotForceProcessing(const QString &id)
+{
+    while(m_infoQueue.contains(id)) {
+        slotProcessNextClipInQueue();
+    }
+}
+
 #include "projectlist.moc"