#include "kthumb.h"
-ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, bool generateThumbs)
- : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_startThumbRequested(false), m_endThumbRequested(false), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1), m_speed(1.0), framePixelWidth(0), m_startPix(QPixmap()), m_endPix(QPixmap()) {
+ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, bool generateThumbs)
+ : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_startThumbRequested(false), m_endThumbRequested(false), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1), m_speed(speed), framePixelWidth(0), m_startPix(QPixmap()), m_endPix(QPixmap()) {
setZValue(1);
setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double)(KdenliveSettings::trackheight() - 2));
setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1);
- m_clipName = clip->name();
+ if (m_speed == 1.0) m_clipName = clip->name();
+ else {
+ m_clipName = clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + "%";
+ m_cropDuration = m_cropDuration * m_speed;
+ }
m_producer = clip->getId();
m_clipType = clip->clipType();
m_cropStart = info.cropStart;
}
ClipItem *ClipItem::clone(ItemInfo info) const {
- ClipItem *duplicate = new ClipItem(m_clip, info, m_fps);
+ ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed);
if (info.cropStart == cropStart()) duplicate->slotSetStartThumb(m_startPix);
if (info.cropStart + (info.endPos - info.startPos) == m_cropStart + m_cropDuration) duplicate->slotSetEndThumb(m_endPix);
kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
duplicate->setEffectList(m_effectList.clone());
- duplicate->setSpeed(m_speed);
+ //duplicate->setSpeed(m_speed);
return duplicate;
}
}
QDomElement ClipItem::xml() const {
- return m_clip->toXML();
+ QDomElement xml = m_clip->toXML();
+ if (m_speed != 1.0) xml.setAttribute("speed", m_speed);
+ return xml;
}
int ClipItem::clipType() const {
return m_clipName;
}
+void ClipItem::setClipName(const QString &name) {
+ m_clipName = name;
+}
+
const QString &ClipItem::clipProducer() const {
return m_producer;
}
OPERATIONTYPE ClipItem::operationMode(QPointF pos) {
+ if (isItemLocked()) return NONE;
+
if (isSelected()) {
m_editedKeyframe = mouseOverKeyFrames(pos);
if (m_editedKeyframe != -1) return KEYFRAME;
//virtual
void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
//if (e->pos().x() < 20) m_hover = true;
+ if (isItemLocked()) return;
m_hover = true;
QRectF r = boundingRect();
double width = 35 / projectScene()->scale();
//virtual
void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
+ if (isItemLocked()) return;
m_hover = false;
QRectF r = boundingRect();
double width = 35 / projectScene()->scale();
if (posx == startPos().frames(m_fps)) return;
const int previous = cropStart().frames(m_fps);
AbstractClipItem::resizeStart(posx, m_speed);
- checkEffectsKeyframesPos(previous, cropStart().frames(m_fps), true);
- if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
- /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
- startThumbTimer->start(100);
+ if ((int) cropStart().frames(m_fps) != previous) {
+ checkEffectsKeyframesPos(previous, cropStart().frames(m_fps), true);
+ if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
+ /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
+ startThumbTimer->start(150);
+ }
}
}
//kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
const int previous = (cropStart() + duration()).frames(m_fps);
AbstractClipItem::resizeEnd(posx, m_speed);
- if (updateKeyFrames) checkEffectsKeyframesPos(previous, (cropStart() + duration()).frames(m_fps), false);
- if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
- /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
- endThumbTimer->start(100);
+ if ((int)(cropStart() + duration()).frames(m_fps) != previous) {
+ if (updateKeyFrames) checkEffectsKeyframesPos(previous, (cropStart() + duration()).frames(m_fps), false);
+ if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
+ /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
+ endThumbTimer->start(150);
+ }
}
}
return pos();
}
if (forwardMove) {
- offset = qMax(offset, (int)(newPos.x() - (static_cast < AbstractClipItem* >(items.at(i))->startPos() - m_cropDuration).frames(m_fps)));
+ offset = qMax(offset, (int)(newPos.x() - (static_cast < AbstractClipItem* >(items.at(i))->startPos() - cropDuration()).frames(m_fps)));
} else {
offset = qMax(offset, (int)((static_cast < AbstractClipItem* >(items.at(i))->endPos().frames(m_fps)) - newPos.x()));
}
QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
subitems.removeAll(this);
for (int j = 0; j < subitems.count(); j++) {
- if (subitems.at(j)->type() == type()) return pos();
+ if (subitems.at(j)->type() == type()) {
+ m_startPos = GenTime((int) pos().x(), m_fps);
+ return pos();
+ }
}
}
needRepaint = true;
}
m_effectList.removeAt(i);
- } else if (ix.toInt() > index.toInt()) m_effectList[i].setAttribute("kdenlive_ix", ix.toInt() - 1);
+ i--;
+ } else if (ix.toInt() > index.toInt()) {
+ m_effectList[i].setAttribute("kdenlive_ix", ix.toInt() - 1);
+ }
}
m_effectNames = m_effectList.effectNames().join(" / ");
if (needRepaint) update(boundingRect());
//virtual
void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
- event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
+ if (isItemLocked()) event->setAccepted(false);
+ else event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
}
void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) {