]> git.sesse.net Git - kdenlive/commitdiff
Clip cuts in project tree can now have a description
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 24 Nov 2009 08:40:25 +0000 (08:40 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 24 Nov 2009 08:40:25 +0000 (08:40 +0000)
svn path=/trunk/kdenlive/; revision=4143

15 files changed:
src/CMakeLists.txt
src/addclipcutcommand.cpp
src/addclipcutcommand.h
src/clipmanager.cpp
src/docclipbase.cpp
src/editclipcutcommand.cpp [new file with mode: 0644]
src/editclipcutcommand.h [new file with mode: 0644]
src/effectstackedit.cpp
src/keyframeedit.cpp
src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h
src/projectlistview.cpp
src/subprojectitem.cpp
src/subprojectitem.h

index 6294db6d8f43ed8b7a58da59933629e7ee8cbc00..03a591a825c2c8a2aeddc745216ccba2b40d6666 100644 (file)
@@ -183,6 +183,7 @@ set(kdenlive_SRCS
   subprojectitem.cpp
   folderprojectitem.cpp
   addclipcutcommand.cpp
+  editclipcutcommand.cpp
 )
 
 add_definitions( ${KDE4_DEFINITIONS} )
index 717a9c5b0245c17d6169ff785fd3d18dc9809641..0eb5e7e33b932aea82e332097ce489a549272753 100644 (file)
 
 #include <KLocale>
 
-AddClipCutCommand::AddClipCutCommand(ProjectList *list, const QString &id, int in, int out, bool remove, QUndoCommand * parent) :
+AddClipCutCommand::AddClipCutCommand(ProjectList *list, const QString &id, int in, int out, const QString desc, bool remove, QUndoCommand * parent) :
         QUndoCommand(parent),
         m_list(list),
         m_id(id),
         m_in(in),
         m_out(out),
+        m_desc(desc),
         m_remove(remove)
 {
     setText(i18n("Add clip cut"));
@@ -37,13 +38,13 @@ AddClipCutCommand::AddClipCutCommand(ProjectList *list, const QString &id, int i
 // virtual
 void AddClipCutCommand::undo()
 {
-    if (m_remove) m_list->addClipCut(m_id, m_in, m_out);
+    if (m_remove) m_list->addClipCut(m_id, m_in, m_out, m_desc);
     else m_list->removeClipCut(m_id, m_in, m_out);
 }
 // virtual
 void AddClipCutCommand::redo()
 {
     if (m_remove) m_list->removeClipCut(m_id, m_in, m_out);
-    else m_list->addClipCut(m_id, m_in, m_out);
+    else m_list->addClipCut(m_id, m_in, m_out, m_desc);
 }
 
index 7351d0416b3c41316fc61ae75a980492bab66537..7a8f832d2a202442e65494a489d245c7ebaec1a3 100644 (file)
@@ -29,7 +29,7 @@ class ProjectList;
 class AddClipCutCommand : public QUndoCommand
 {
 public:
-    AddClipCutCommand(ProjectList *list, const QString &id, int in, int out, bool remove, QUndoCommand * parent = 0);
+    AddClipCutCommand(ProjectList *list, const QString &id, int in, int out, const QString desc, bool remove, QUndoCommand * parent = 0);
 
     virtual void undo();
     virtual void redo();
@@ -39,6 +39,7 @@ private:
     QString m_id;
     int m_in;
     int m_out;
+    QString m_desc;
     bool m_remove;
 };
 
index cf7a540d2e32a813d12863f043cde07307a3ed51..4f96ba185bcfac2aa78599c662bab0457e1b1a7f 100644 (file)
@@ -274,7 +274,7 @@ void ClipManager::slotAddClipList(const KUrl::List urls, const QString group, co
                 prod.setAttribute("type", (int) IMAGE);
                 prod.setAttribute("in", 0);
                 prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()) - 1);
-            } else if (type->name() == "application/x-kdenlivetitle") {
+            } else if (type->is("application/x-kdenlivetitle")) {
                 // opening a title file
                 QDomDocument txtdoc("titledocument");
                 QFile txtfile(file.path());
index 87b6dfa96327c54dfe1e7591748f31b4ad5afc2d..ae8a07a03f5fd9b58f5cbc8679e29cd1f3ba1ac3 100644 (file)
@@ -273,7 +273,8 @@ QDomElement DocClipBase::toXML() const
     if (!m_cutZones.isEmpty()) {
         QStringList cuts;
         for (int i = 0; i < m_cutZones.size(); i++) {
-            cuts << QString::number(m_cutZones.at(i).zone.x()) + "-" + QString::number(m_cutZones.at(i).zone.y()) + "-" + m_cutZones.at(i).description;
+            CutZoneInfo info = m_cutZones.at(i);
+            cuts << QString::number(info.zone.x()) + "-" + QString::number(info.zone.y()) + "-" + info.description;
         }
         clip.setAttribute("cutzones", cuts.join(";"));
     }
@@ -861,16 +862,16 @@ void DocClipBase::addCutZone(int in, int out, QString desc)
     info.zone = QPoint(in, out);
     info.description = desc;
     for (int i = 0; i < m_cutZones.count(); i++)
-       if (m_cutZones.at(i).zone == info.zone) {
-           return;
-       }
+        if (m_cutZones.at(i).zone == info.zone) {
+            return;
+        }
     m_cutZones.append(info);
 }
 
 bool DocClipBase::hasCutZone(QPoint p) const
 {
     for (int i = 0; i < m_cutZones.count(); i++)
-       if (m_cutZones.at(i).zone == p) return true;
+        if (m_cutZones.at(i).zone == p) return true;
     return false;
 }
 
@@ -879,8 +880,10 @@ void DocClipBase::removeCutZone(int in, int out)
 {
     QPoint p(in, out);
     for (int i = 0; i < m_cutZones.count(); i++) {
-       if (m_cutZones.at(i).zone == p) m_cutZones.removeAt(i);
-       i--;
+        if (m_cutZones.at(i).zone == p) {
+            m_cutZones.removeAt(i);
+            i--;
+        }
     }
 }
 
@@ -889,9 +892,9 @@ void DocClipBase::updateCutZone(int oldin, int oldout, int in, int out, QString
     QPoint old(oldin, oldout);
     for (int i = 0; i < m_cutZones.size(); ++i) {
         if (m_cutZones.at(i).zone == old) {
-           CutZoneInfo info;
-           info.zone = QPoint(in, out);
-           info.description = desc;
+            CutZoneInfo info;
+            info.zone = QPoint(in, out);
+            info.description = desc;
             m_cutZones.replace(i, info);
             break;
         }
diff --git a/src/editclipcutcommand.cpp b/src/editclipcutcommand.cpp
new file mode 100644 (file)
index 0000000..b6708f8
--- /dev/null
@@ -0,0 +1,52 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include "editclipcutcommand.h"
+#include "projectlist.h"
+
+#include <KLocale>
+
+EditClipCutCommand::EditClipCutCommand(ProjectList *list, const QString &id, const QPoint oldZone, const QPoint newZone, const QString &oldComment, const QString &newComment, bool doIt, QUndoCommand * parent) :
+        QUndoCommand(parent),
+        m_list(list),
+        m_id(id),
+        m_oldZone(oldZone),
+        m_newZone(newZone),
+        m_oldComment(oldComment),
+        m_newComment(newComment),
+        m_doIt(doIt)
+{
+    setText(i18n("Edit clip cut"));
+}
+
+
+// virtual
+void EditClipCutCommand::undo()
+{
+    kDebug() << "----  undoing action";
+    m_list->doUpdateClipCut(m_id, m_newZone, m_oldZone, m_oldComment);
+}
+// virtual
+void EditClipCutCommand::redo()
+{
+    kDebug() << "----  redoing action";
+    if (m_doIt) m_list->doUpdateClipCut(m_id, m_oldZone, m_newZone, m_newComment);
+    m_doIt = true;
+}
+
diff --git a/src/editclipcutcommand.h b/src/editclipcutcommand.h
new file mode 100644 (file)
index 0000000..b8090aa
--- /dev/null
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+
+#ifndef EDITCLIPCUTCOMMAND_H
+#define EDITCLIPCUTCOMMAND_H
+
+#include <QUndoCommand>
+#include <QPoint>
+
+#include <KDebug>
+
+class ProjectList;
+
+class EditClipCutCommand : public QUndoCommand
+{
+public:
+    EditClipCutCommand(ProjectList *list, const QString &id, const QPoint oldZone, const QPoint newZone, const QString &oldComment, const QString &newComment, bool doIt, QUndoCommand * parent = 0);
+
+    virtual void undo();
+    virtual void redo();
+
+private:
+    ProjectList *m_list;
+    QString m_id;
+    QPoint m_oldZone;
+    QPoint m_newZone;
+    QString m_oldComment;
+    QString m_newComment;
+    bool m_doIt;
+};
+
+#endif
+
index 27fccfa022884801b1cbb2b1e86f7410c42cb837..8d951902f148363c3b1c8f9f5cd53ffbc5e8ba3c 100644 (file)
@@ -67,7 +67,7 @@ EffectStackEdit::EffectStackEdit(QWidget *parent) :
         m_in(0),
         m_out(0),
         m_frameSize(QPoint()),
-       m_keyframeEditor(NULL)
+        m_keyframeEditor(NULL)
 {
     m_baseWidget = new QWidget(this);
     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -234,17 +234,16 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
         } else if (type == "keyframe" || type == "simplekeyframe") {
             // keyframe editor widget
             kDebug() << "min: " << m_in << ", MAX: " << m_out;
-           if (m_keyframeEditor == NULL) {
-               KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode, paramName);
-               m_vbox->addWidget(geo);
-               m_valueItems[paramName+"keyframe"] = geo;
-               m_keyframeEditor = geo;
-               connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
-           }
-           else {
-               // we already have a keyframe editor, so just add another column for the new param
-               m_keyframeEditor->addParameter(pa);
-           }
+            if (m_keyframeEditor == NULL) {
+                KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode, paramName);
+                m_vbox->addWidget(geo);
+                m_valueItems[paramName+"keyframe"] = geo;
+                m_keyframeEditor = geo;
+                connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
+            } else {
+                // we already have a keyframe editor, so just add another column for the new param
+                m_keyframeEditor->addParameter(pa);
+            }
         } else if (type == "color") {
             Colorval *cval = new Colorval;
             cval->setupUi(toFillin);
index 6f42dd3de9fd0baa9abc979c1b4853df062ae0f3..d2c93623c5d30f5544dec6f23cf530f9fb4b8231 100644 (file)
@@ -36,7 +36,7 @@ KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, int minVal
     setupUi(this);
     m_params.append(e);
     keyframe_list->setFont(KGlobalSettings::generalFont());
-    
+
     //keyframe_list->setHorizontalHeaderLabels(QStringList() << (paramName.isEmpty() ? i18n("Value") : paramName));
     //setResizeMode(1, QHeaderView::Interactive);
     button_add->setIcon(KIcon("list-add"));
@@ -69,7 +69,8 @@ KeyframeEdit::~KeyframeEdit()
     //delete m_delegate;
 }
 
-void KeyframeEdit::addParameter(QDomElement e) {
+void KeyframeEdit::addParameter(QDomElement e)
+{
     keyframe_list->blockSignals(true);
     QDomNode na = e.firstChildElement("name");
     QString paramName = i18n(na.toElement().text().toUtf8().data());
@@ -79,27 +80,26 @@ void KeyframeEdit::addParameter(QDomElement e) {
     m_params.append(e);
     QStringList frames = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
     for (int i = 0; i < frames.count(); i++) {
-       int frame = frames.at(i).section(':', 0, 0).toInt();
-       bool found = false;
-       int j;
-       for (j = 0; j < keyframe_list->rowCount(); j++) {
-           int currentPos = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(j)->text());
-           if (frame == currentPos) {
-               keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
-               found = true;
-               break;
-           }
-           else if (currentPos > frame) {
-               break;
-           }
-       }
+        int frame = frames.at(i).section(':', 0, 0).toInt();
+        bool found = false;
+        int j;
+        for (j = 0; j < keyframe_list->rowCount(); j++) {
+            int currentPos = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(j)->text());
+            if (frame == currentPos) {
+                keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
+                found = true;
+                break;
+            } else if (currentPos > frame) {
+                break;
+            }
+        }
         if (!found) {
-           //int newRow = keyframe_list->rowCount();
-           keyframe_list->insertRow(j);
-           keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(m_timecode.getTimecodeFromFrames(frame)));
-           keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
-           keyframe_list->resizeRowToContents(j);
-       }
+            //int newRow = keyframe_list->rowCount();
+            keyframe_list->insertRow(j);
+            keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(m_timecode.getTimecodeFromFrames(frame)));
+            keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
+            keyframe_list->resizeRowToContents(j);
+        }
     }
     keyframe_list->blockSignals(false);
 }
@@ -111,15 +111,15 @@ void KeyframeEdit::setupParam()
     int col = keyframe_list->columnCount();
     QDomNode na = m_params.at(0).firstChildElement("name");
     QString paramName = i18n(na.toElement().text().toUtf8().data());
-    kDebug()<<" INSERT COL: "<<col<<", "<<paramName;
+    kDebug() << " INSERT COL: " << col << ", " << paramName;
     keyframe_list->insertColumn(col);
     keyframe_list->setHorizontalHeaderItem(col, new QTableWidgetItem(paramName));
     QStringList frames = m_params.at(0).attribute("keyframes").split(";", QString::SkipEmptyParts);
     for (int i = 0; i < frames.count(); i++) {
-       keyframe_list->insertRow(i);
-       QString framePos = m_timecode.getTimecodeFromFrames(frames.at(i).section(':', 0, 0).toInt());
-       keyframe_list->setVerticalHeaderItem(i, new QTableWidgetItem(framePos));
-       keyframe_list->setItem(i, col, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
+        keyframe_list->insertRow(i);
+        QString framePos = m_timecode.getTimecodeFromFrames(frames.at(i).section(':', 0, 0).toInt());
+        keyframe_list->setVerticalHeaderItem(i, new QTableWidgetItem(framePos));
+        keyframe_list->setItem(i, col, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
         //item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
     }
     /*QTreeWidgetItem *first = keyframe_list->topLevelItem(0);
@@ -151,26 +151,23 @@ void KeyframeEdit::slotAddKeyframe()
     int newrow = row;
     int pos1 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row)->text());
     int result;
-    kDebug()<<"// ADD KF: "<<row<<", MAX: "<<keyframe_list->rowCount()<<", POS: "<<pos1;
+    kDebug() << "// ADD KF: " << row << ", MAX: " << keyframe_list->rowCount() << ", POS: " << pos1;
     if (row < (keyframe_list->rowCount() - 1)) {
-       int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row + 1)->text());
-       result = pos1 + (pos2 - pos1) / 2;
-       newrow++;
-    }
-    else if (row == 0) {
-       if (pos1 == m_min) {
-           result = m_max - 1;
-           newrow++;
-       }
-        else {
-           result = m_min;
-       }
+        int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row + 1)->text());
+        result = pos1 + (pos2 - pos1) / 2;
+        newrow++;
+    } else if (row == 0) {
+        if (pos1 == m_min) {
+            result = m_max - 1;
+            newrow++;
+        } else {
+            result = m_min;
+        }
+    } else {
+        int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row - 1)->text());
+        result = pos2 + (pos1 - pos2) / 2;
     }
-    else {
-       int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row - 1)->text());
-       result = pos2 + (pos1 - pos2) / 2;
-    }
-        
+
     keyframe_list->insertRow(newrow);
     keyframe_list->setVerticalHeaderItem(newrow, new QTableWidgetItem(m_timecode.getTimecodeFromFrames(result)));
     keyframe_list->setItem(newrow, keyframe_list->currentColumn(), new QTableWidgetItem(item->text()));
@@ -190,19 +187,19 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
     QString val = keyframe_list->verticalHeaderItem(row)->text();
     int pos = m_timecode.getFrameCount(val);
     if (pos <= m_min) {
-       pos = m_min;
+        pos = m_min;
         val = m_timecode.getTimecodeFromFrames(pos);
     }
     if (pos > m_max) {
-       pos = m_max;
+        pos = m_max;
         val = m_timecode.getTimecodeFromFrames(pos);
     }
-            /*QList<QTreeWidgetItem *> duplicates = keyframe_list->findItems(val, Qt::MatchExactly, 0);
-            duplicates.removeAll(item);
-            if (!duplicates.isEmpty()) {
-                // Trying to insert a keyframe at existing value, revert it
-                val = m_timecode.getTimecodeFromFrames(m_previousPos);
-            }*/
+    /*QList<QTreeWidgetItem *> duplicates = keyframe_list->findItems(val, Qt::MatchExactly, 0);
+    duplicates.removeAll(item);
+    if (!duplicates.isEmpty()) {
+        // Trying to insert a keyframe at existing value, revert it
+        val = m_timecode.getTimecodeFromFrames(m_previousPos);
+    }*/
     if (val != keyframe_list->verticalHeaderItem(row)->text()) keyframe_list->verticalHeaderItem(row)->setText(val);
 
     int v = item->text().toInt();
index c3fb809c66d8f5c37bf368b09037b19ef082acb4..8ad31a6ff782afa489d50b2e48ad1ddf0679eeab 100644 (file)
@@ -1973,6 +1973,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
     connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
+    connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
     connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
     connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
 
index 683ace78c12d8ad4d458d4fee278757714a57b18..10be0cd1b18876cfe88390ac11e063eca09f99be 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "projectlist.h"
 #include "projectitem.h"
-#include "subprojectitem.h"
 #include "addfoldercommand.h"
 #include "kdenlivesettings.h"
 #include "slideshowclip.h"
@@ -33,6 +32,7 @@
 #include "kthumb.h"
 #include "projectlistview.h"
 #include "editclipcommand.h"
+#include "editclipcutcommand.h"
 #include "editfoldercommand.h"
 #include "addclipcutcommand.h"
 
@@ -414,11 +414,14 @@ 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);
-           //slotUpdateCutClipProperties(sub->clipId(), sub->zone(), sub->text(1), sub->text(1));
-       }
+        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) {
@@ -509,11 +512,8 @@ void ProjectList::slotRemoveClip()
             // 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(), true, delCommand);
-            continue;
-        }
-
-        if (selected.at(i)->type() == PROJECTFOLDERTYPE) {
+            new AddClipCutCommand(this, item->clipId(), sub->zone().x(), sub->zone().y(), sub->description(), true, delCommand);
+        } else if (selected.at(i)->type() == PROJECTFOLDERTYPE) {
             // folder
             FolderProjectItem *folder = static_cast <FolderProjectItem *>(selected.at(i));
             folderids[folder->groupName()] = folder->clipId();
@@ -524,15 +524,15 @@ void ProjectList::slotRemoveClip()
                 ProjectItem *child = static_cast <ProjectItem *>(folder->child(i));
                 ids << child->clipId();
             }
-            continue;
-        }
-
-        ProjectItem *item = static_cast <ProjectItem *>(selected.at(i));
-        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 {
+            ProjectItem *item = static_cast <ProjectItem *>(selected.at(i));
+            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;
+            }
         }
     }
+
     if (delCommand->childCount() == 0) delete delCommand;
     else m_commandStack->push(delCommand);
     if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
@@ -663,7 +663,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     if (getProperties == false && !clip->getClipHash().isEmpty()) {
         QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png";
         if (QFile::exists(cachedPixmap)) {
-           item->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap));
+            item->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap));
         }
     }
 #ifdef NEPOMUK
@@ -683,7 +683,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
             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)) {
-                   sub->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap));
+                    sub->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap));
                 }
             }
         }
@@ -807,16 +807,16 @@ void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &group
         for (int i = 0; i < givenList.count(); i++)
             list << givenList.at(i);
     }
-    
+
     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);
-       }
-    }
-    
+        // 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()) {
@@ -1077,7 +1077,7 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
 
         if (!pix.isNull()) {
             m_listView->blockSignals(true);
-           it->setData(0, Qt::DecorationRole, 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);
@@ -1126,7 +1126,7 @@ void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)
     ProjectItem *item = getItemById(clipId);
     if (item && !pix.isNull()) {
         m_listView->blockSignals(true);
-       item->setData(0, Qt::DecorationRole, pix);
+        item->setData(0, Qt::DecorationRole, pix);
         m_doc->cachePixmap(item->getClipHash(), pix);
         if (m_listView->isEnabled()) m_listView->blockSignals(false);
     }
@@ -1271,24 +1271,24 @@ void ProjectList::slotAddClipCut(const QString &id, int in, int out)
     ProjectItem *clip = getItemById(id);
     if (clip == NULL) return;
     if (clip->referencedClip()->hasCutZone(QPoint(in, out))) return;
-    AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, false);
+    AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, QString(), false);
     m_commandStack->push(command);
 }
 
-void ProjectList::addClipCut(const QString &id, int in, int out)
+void ProjectList::addClipCut(const QString &id, int in, int out, const QString desc)
 {
     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);
-
+        SubProjectItem *sub = new SubProjectItem(clip, in, out, desc);
         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);
+        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)
@@ -1297,18 +1297,53 @@ void ProjectList::removeClipCut(const QString &id, int in, int out)
     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) continue;
-            SubProjectItem *sub = static_cast <SubProjectItem*>(it);
-            if (sub->zone() == QPoint(in, out)) {
-                m_listView->blockSignals(true);
-                delete it;
-                m_listView->blockSignals(false);
-                break;
+            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();
 }
 
 #include "projectlist.moc"
index 6e56e115054e117c7fb9e5f31b2d66c7b780cec2..c7ef75d5d5a384c6bc67225ea4c61b56cebf04ba 100644 (file)
 
 #include <KTreeWidgetSearchLine>
 #include <KUrl>
+
 #ifdef NEPOMUK
 #include <nepomuk/kratingpainter.h>
 #include <nepomuk/resource.h>
 #endif
+
 #include "definitions.h"
 #include "timecode.h"
 #include "kdenlivesettings.h"
 #include "folderprojectitem.h"
+#include "subprojectitem.h"
 
 namespace Mlt
 {
@@ -108,7 +111,7 @@ public:
             if (option.state & (QStyle::State_Selected)) {
                 painter->fillRect(r1, option.palette.highlight());
             }
-#ifdef NEPOMUK 
+#ifdef NEPOMUK
             KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt());
 #endif
         } else {
@@ -138,9 +141,11 @@ public:
     void cleanup();
     void trashUnusedClips();
     QList <DocClipBase*> documentClipList() const;
-    void addClipCut(const QString &id, int in, int out);
+    void addClipCut(const QString &id, int in, int out, const QString desc);
     void removeClipCut(const QString &id, int in, int out);
     void focusTree() const;
+    SubProjectItem *getSubItem(ProjectItem *clip, QPoint zone);
+    void doUpdateClipCut(const QString &id, const QPoint oldzone, const QPoint zone, const QString &comment);
 
 public slots:
     void setDocument(KdenliveDoc *doc);
@@ -163,6 +168,7 @@ public slots:
     void slotReloadClip(const QString &id = QString());
     void slotAddColorClip();
     void regenerateTemplate(const QString &id);
+    void slotUpdateClipCut(QPoint p);
 
 private:
     ProjectListView *m_listView;
index ccedd98aff0ddc72cf71201e869cdc1d33d8a3d4..35b2bc89a8070e960b6c18bc781133d0ede46018 100644 (file)
@@ -128,10 +128,10 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
     }
     if (it->type() == PROJECTSUBCLIPTYPE) {
         // subitem
-       if ((columnAt(event->pos().x()) == 1)) {
-           QTreeWidget::mouseDoubleClickEvent(event);
-           return;
-       }
+        if ((columnAt(event->pos().x()) == 1)) {
+            QTreeWidget::mouseDoubleClickEvent(event);
+            return;
+        }
         item = static_cast <ProjectItem *>(it->parent());
     } else item = static_cast <ProjectItem *>(it);
 
@@ -291,7 +291,7 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
             //mimeData->setText(ids.join(";")); //doc.toString());
             //mimeData->setImageData(image);
             drag->setMimeData(mimeData);
-           drag->setPixmap(it->data(0, Qt::DecorationRole).value<QPixmap>());
+            drag->setPixmap(it->data(0, Qt::DecorationRole).value<QPixmap>());
             drag->setHotSpot(QPoint(0, 50));
             drag->exec();
         }
index 081cfeaf948f1d10a02d2cf38eeada7b070f9291..1e296354c164ca87d1f5e47a5deb59f48809ea79 100644 (file)
@@ -31,7 +31,7 @@
 const int DurationRole = Qt::UserRole + 1;
 
 SubProjectItem::SubProjectItem(QTreeWidgetItem * parent, int in, int out, QString description) :
-        QTreeWidgetItem(parent, PROJECTSUBCLIPTYPE), m_in(in), m_out(out)
+        QTreeWidgetItem(parent, PROJECTSUBCLIPTYPE), m_in(in), m_out(out), m_description(description)
 {
     setSizeHint(0, QSize(65, 30));
     setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
@@ -66,9 +66,28 @@ QPoint SubProjectItem::zone() const
     return z;
 }
 
+void SubProjectItem::setZone(QPoint p)
+{
+    m_in = p.x();
+    m_out = p.y();
+    QString name = Timecode::getStringTimecode(m_in, KdenliveSettings::project_fps());
+    setText(0, name);
+    GenTime duration = GenTime(m_out - m_in, KdenliveSettings::project_fps());
+    if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
+}
+
 DocClipBase *SubProjectItem::referencedClip()
 {
     return NULL; //m_clip;
 }
 
+QString SubProjectItem::description() const
+{
+    return m_description;
+}
 
+void SubProjectItem::setDescription(QString desc)
+{
+    m_description = desc;
+    setText(1, m_description);
+}
index 4dcb216de38154fb7b6933f210a7f8c4c081fcd3..9a5a01cf94bada5f162c7ba0d64b51de7c7d24c9 100644 (file)
@@ -44,6 +44,9 @@ public:
     int numReferences() const;
     DocClipBase *referencedClip();
     QPoint zone() const;
+    void setZone(QPoint p);
+    QString description() const;
+    void setDescription(QString desc);
 
     /** Make sure folders appear on top of the tree widget */
     virtual bool operator<(const QTreeWidgetItem &other)const {
@@ -56,6 +59,7 @@ public:
 private:
     int m_in;
     int m_out;
+    QString m_description;
 };
 
 #endif