subprojectitem.cpp
folderprojectitem.cpp
addclipcutcommand.cpp
+ editclipcutcommand.cpp
)
add_definitions( ${KDE4_DEFINITIONS} )
#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"));
// 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);
}
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();
QString m_id;
int m_in;
int m_out;
+ QString m_desc;
bool m_remove;
};
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());
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(";"));
}
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;
}
{
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--;
+ }
}
}
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;
}
--- /dev/null
+/***************************************************************************
+ * 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;
+}
+
--- /dev/null
+/***************************************************************************
+ * 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
+
m_in(0),
m_out(0),
m_frameSize(QPoint()),
- m_keyframeEditor(NULL)
+ m_keyframeEditor(NULL)
{
m_baseWidget = new QWidget(this);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
} 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);
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"));
//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());
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);
}
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);
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()));
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();
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()));
#include "projectlist.h"
#include "projectitem.h"
-#include "subprojectitem.h"
#include "addfoldercommand.h"
#include "kdenlivesettings.h"
#include "slideshowclip.h"
#include "kthumb.h"
#include "projectlistview.h"
#include "editclipcommand.h"
+#include "editclipcutcommand.h"
#include "editfoldercommand.h"
#include "addclipcutcommand.h"
{
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) {
// 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();
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);
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
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));
}
}
}
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()) {
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);
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);
}
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)
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"
#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
{
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 {
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);
void slotReloadClip(const QString &id = QString());
void slotAddColorClip();
void regenerateTemplate(const QString &id);
+ void slotUpdateClipCut(QPoint p);
private:
ProjectListView *m_listView;
}
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);
//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();
}
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);
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);
+}
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 {
private:
int m_in;
int m_out;
+ QString m_description;
};
#endif