From 8bcc799b522e6e5ae0299973b4d296bef831a17f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 24 Nov 2009 08:40:25 +0000 Subject: [PATCH] Clip cuts in project tree can now have a description svn path=/trunk/kdenlive/; revision=4143 --- src/CMakeLists.txt | 1 + src/addclipcutcommand.cpp | 7 ++- src/addclipcutcommand.h | 3 +- src/clipmanager.cpp | 2 +- src/docclipbase.cpp | 23 ++++--- src/editclipcutcommand.cpp | 52 ++++++++++++++++ src/editclipcutcommand.h | 50 +++++++++++++++ src/effectstackedit.cpp | 23 ++++--- src/keyframeedit.cpp | 103 +++++++++++++++---------------- src/mainwindow.cpp | 1 + src/projectlist.cpp | 121 ++++++++++++++++++++++++------------- src/projectlist.h | 10 ++- src/projectlistview.cpp | 10 +-- src/subprojectitem.cpp | 21 ++++++- src/subprojectitem.h | 4 ++ 15 files changed, 300 insertions(+), 131 deletions(-) create mode 100644 src/editclipcutcommand.cpp create mode 100644 src/editclipcutcommand.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6294db6d..03a591a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -183,6 +183,7 @@ set(kdenlive_SRCS subprojectitem.cpp folderprojectitem.cpp addclipcutcommand.cpp + editclipcutcommand.cpp ) add_definitions( ${KDE4_DEFINITIONS} ) diff --git a/src/addclipcutcommand.cpp b/src/addclipcutcommand.cpp index 717a9c5b..0eb5e7e3 100644 --- a/src/addclipcutcommand.cpp +++ b/src/addclipcutcommand.cpp @@ -22,12 +22,13 @@ #include -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); } diff --git a/src/addclipcutcommand.h b/src/addclipcutcommand.h index 7351d041..7a8f832d 100644 --- a/src/addclipcutcommand.h +++ b/src/addclipcutcommand.h @@ -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; }; diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index cf7a540d..4f96ba18 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -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()); diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 87b6dfa9..ae8a07a0 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -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 index 00000000..b6708f81 --- /dev/null +++ b/src/editclipcutcommand.cpp @@ -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 + +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 index 00000000..b8090aac --- /dev/null +++ b/src/editclipcutcommand.h @@ -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 +#include + +#include + +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 + diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index 27fccfa0..8d951902 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -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); diff --git a/src/keyframeedit.cpp b/src/keyframeedit.cpp index 6f42dd3d..d2c93623 100644 --- a/src/keyframeedit.cpp +++ b/src/keyframeedit.cpp @@ -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: "<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: "<rowCount()<<", POS: "<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 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 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(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c3fb809c..8ad31a6f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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())); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 683ace78..10be0cd1 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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 (item); - //slotUpdateCutClipProperties(sub->clipId(), sub->zone(), sub->text(1), sub->text(1)); - } + if (column == 1) { + // user edited description + SubProjectItem *sub = static_cast (item); + ProjectItem *item = static_cast (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 (selected.at(i)); ProjectItem *item = static_cast (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 (selected.at(i)); folderids[folder->groupName()] = folder->clipId(); @@ -524,15 +524,15 @@ void ProjectList::slotRemoveClip() ProjectItem *child = static_cast (folder->child(i)); ids << child->clipId(); } - continue; - } - - ProjectItem *item = static_cast (selected.at(i)); - ids << item->clipId(); - if (item->numReferences() > 0) { - if (KMessageBox::questionYesNo(this, i18np("Delete clip %2?
This will also remove the clip in timeline", "Delete clip %2?
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 (selected.at(i)); + ids << item->clipId(); + if (item->numReferences() > 0) { + if (KMessageBox::questionYesNo(this, i18np("Delete clip %2?
This will also remove the clip in timeline", "Delete clip %2?
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 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 (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 (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 (m_listView->currentItem()); + ProjectItem *item = static_cast (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" diff --git a/src/projectlist.h b/src/projectlist.h index 6e56e115..c7ef75d5 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -33,14 +33,17 @@ #include #include + #ifdef NEPOMUK #include #include #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 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; diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index ccedd98a..35b2bc89 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -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 (it->parent()); } else item = static_cast (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()); + drag->setPixmap(it->data(0, Qt::DecorationRole).value()); drag->setHotSpot(QPoint(0, 50)); drag->exec(); } diff --git a/src/subprojectitem.cpp b/src/subprojectitem.cpp index 081cfeaf..1e296354 100644 --- a/src/subprojectitem.cpp +++ b/src/subprojectitem.cpp @@ -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); +} diff --git a/src/subprojectitem.h b/src/subprojectitem.h index 4dcb216d..9a5a01cf 100644 --- a/src/subprojectitem.h +++ b/src/subprojectitem.h @@ -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 -- 2.39.2