customruler.cpp
customtrackscene.cpp
customtrackview.cpp
+ definitions.cpp
docclipbase.cpp
documentchecker.cpp
documentvalidator.cpp
/***************************************************************************
* Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * 2012 Simon A. Eugster <simon.eu@gmail.com> *
* *
* 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 *
#include <KLocale>
MoveClipCommand::MoveClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt, QUndoCommand * parent) :
- QUndoCommand(parent),
- m_view(view),
- m_startPos(start),
- m_endPos(end),
- m_doIt(doIt)
+ QUndoCommand(parent),
+ m_view(view),
+ m_startPos(start),
+ m_endPos(end),
+ m_doIt(doIt),
+ m_success(true)
{
setText(i18n("Move clip"));
if (parent) {
}
-// virtual
void MoveClipCommand::undo()
{
-// kDebug()<<"---- undoing action";
m_doIt = true;
- m_view->moveClip(m_endPos, m_startPos, m_refresh);
+ // We can only undo what was done;
+ // if moveClip() failed in redo() the document does (or should) not change.
+ if (m_success) {
+ m_view->moveClip(m_endPos, m_startPos, m_refresh);
+ }
}
-// virtual
void MoveClipCommand::redo()
{
- //kDebug() << "---- redoing action";
- if (m_doIt)
- m_view->moveClip(m_startPos, m_endPos, m_refresh);
+ if (m_doIt) {
+ qDebug() << "Executing move clip command. End now:" << m_endPos;
+ m_success = m_view->moveClip(m_startPos, m_endPos, m_refresh, &m_endPos);
+ qDebug() << "Move clip command executed. End now: " << m_endPos;
+ }
m_doIt = true;
}
/***************************************************************************
* Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * 2012 Simon A. Eugster <simon.eu@gmail.com> *
* *
* 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 *
private:
CustomTrackView *m_view;
const ItemInfo m_startPos;
- const ItemInfo m_endPos;
+ ItemInfo m_endPos;
bool m_doIt;
bool m_refresh;
+ bool m_success;
};
#endif
return clip;
}
-void CustomTrackView::moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh)
+bool CustomTrackView::moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh, ItemInfo *out_actualEnd)
{
if (m_selectionGroup) resetSelectionGroup(false);
ClipItem *item = getClipItemAt((int) start.startPos.frames(m_document->fps()), start.track);
if (!item) {
emit displayMessage(i18n("Cannot move clip at time: %1 on track %2", m_document->timecode().getTimecodeFromFrames(start.startPos.frames(m_document->fps())), start.track), ErrorMessage);
kDebug() << "---------------- ERROR, CANNOT find clip to move at.. ";
- return;
+ return false;
}
Mlt::Producer *prod = item->getProducer(end.track);
- bool success = m_document->renderer()->mltMoveClip((int)(m_document->tracksCount() - start.track), (int)(m_document->tracksCount() - end.track), (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps()), prod);
+ qDebug() << "Moving item " << (long)item << " from .. to:";
+ qDebug().maybeSpace() << item->info();
+ qDebug() << start;
+ qDebug() << end;
+ bool success = m_document->renderer()->mltMoveClip((int)(m_document->tracksCount() - start.track), (int)(m_document->tracksCount() - end.track),
+ (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps()),
+ prod);
if (success) {
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(end.startPos.frames(m_document->fps()))), ErrorMessage);
}
if (refresh) m_document->renderer()->doRefresh();
+ if (out_actualEnd != NULL) {
+ *out_actualEnd = item->info();
+ qDebug() << "Actual end position updated:" << *out_actualEnd;
+ }
+ qDebug() << item->info();
+ return success;
}
void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime &offset, const int trackOffset, bool reverseMove)
QUndoCommand *moveCommand = new QUndoCommand();
moveCommand->setText(i18n("Auto-align clip"));
new MoveClipCommand(this, start, end, true, moveCommand);
- moveClip(start, end, true);
+// moveClip(start, end, true);
updateTrackDuration(clip->track(), moveCommand);
m_commandStack->push(moveCommand);
void configTracks(QList <TrackInfo> trackInfos);
int cursorPos();
void checkAutoScroll();
- void moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh);
+ /**
+ Move the clip at \c start to \c end.
+
+ If \c out_actualEnd is not NULL, it will be set to the position the clip really ended up at.
+ For example, attempting to move a clip to t = -1 s will actually move it to t = 0 s.
+ */
+ bool moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh, ItemInfo *out_actualEnd = NULL);
void moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime &offset, const int trackOffset, bool reverseMove = false);
/** move transition, startPos = (old start, old end), endPos = (new start, new end) */
void moveTransition(const ItemInfo &start, const ItemInfo &end, bool refresh);
--- /dev/null
+#include "definitions.h"
+
+QDebug operator << (QDebug qd, const ItemInfo &info)
+{
+ qd << "ItemInfo " << &info;
+ qd << "\tTrack" << info.track;
+ qd << "\tStart pos: " << info.startPos.toString();
+ qd << "\tEnd pos: " << info.endPos.toString();
+ qd << "\tCrop start: " << info.cropStart.toString();
+ qd << "\tCrop duration: " << info.cropDuration.toString();
+ return qd.maybeSpace();
+}
#include <QTreeWidgetItem>
#include <KLocale>
+#include <QDebug>
const int MAXCLIPDURATION = 15000;
};
+QDebug operator << (QDebug qd, const ItemInfo &info);
+
#endif
m_time = floor((m_time * framesPerSecond) + 0.5) / framesPerSecond;
return *this;
}
+
+QString GenTime::toString() const
+{
+ return QString("%1 s").arg(m_time, 0, 'f', 2);
+}
#ifndef GENTIME_H
#define GENTIME_H
+#include <QString>
#include <cmath>
/**
* @param framesPerSecond Number of frames per second */
GenTime & roundNearestFrame(double framesPerSecond);
+ QString toString() const;
+
/*
* Operators.
Mlt::Playlist destTrackPlaylist((mlt_playlist) destTrackProducer.get_service());
if (!overwrite && !destTrackPlaylist.is_blank_at(moveEnd)) {
// error, destination is not empty
+ kDebug() << "Cannot move: Destination is not empty";
service.unlock();
return false;
} else {