1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include "customtrackview.h"
23 #include "customtrackscene.h"
25 #include "docclipbase.h"
26 #include "transition.h"
27 #include "kdenlivesettings.h"
29 #include "profilesdialog.h"
31 #include "rotoscoping/rotowidget.h"
39 #include <QStyleOptionGraphicsItem>
40 #include <QGraphicsScene>
43 ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, int strobe, bool generateThumbs) :
44 AbstractClipItem(info, QRectF(), fps),
50 m_startPix(QPixmap()),
55 m_startThumbRequested(false),
56 m_endThumbRequested(false),
63 setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double) itemHeight());
64 setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1 + itemOffset());
66 // set speed independant info
67 if (m_speed <= 0 && m_speed > -1)
69 m_speedIndependantInfo = m_info;
70 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
71 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
73 m_videoPix = KIcon("kdenlive-show-video").pixmap(QSize(16, 16));
74 m_audioPix = KIcon("kdenlive-show-audio").pixmap(QSize(16, 16));
77 m_clipName = m_clip->name();
79 m_clipName = m_clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
81 m_producer = m_clip->getId();
82 m_clipType = m_clip->clipType();
83 //m_cropStart = info.cropStart;
84 m_maxDuration = m_clip->maxDuration();
86 m_audioThumbReady = m_clip->audioThumbCreated();
87 //setAcceptsHoverEvents(true);
88 connect(this , SIGNAL(prepareAudioThumb(double, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, int, int, int)));
90 if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
91 m_baseColor = QColor(141, 166, 215);
92 if (!m_clip->isPlaceHolder()) {
94 m_startThumbTimer.setSingleShot(true);
95 connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
96 m_endThumbTimer.setSingleShot(true);
97 connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
99 connect(this, SIGNAL(getThumb(int, int)), m_clip, SLOT(slotExtractImage(int, int)));
101 connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
102 connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
103 if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
106 } else if (m_clipType == COLOR) {
107 QString colour = m_clip->getProperty("colour");
108 colour = colour.replace(0, 2, "#");
109 m_baseColor = QColor(colour.left(7));
110 } else if (m_clipType == IMAGE || m_clipType == TEXT) {
111 m_baseColor = QColor(141, 166, 215);
112 if (m_clipType == TEXT) {
113 connect(this, SIGNAL(getThumb(int, int)), m_clip, SLOT(slotExtractImage(int, int)));
114 connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
116 //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
117 } else if (m_clipType == AUDIO) {
118 m_baseColor = QColor(141, 215, 166);
119 connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
124 ClipItem::~ClipItem()
127 if (scene()) scene()->removeItem(this);
128 if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
129 //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
130 //disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
135 ClipItem *ClipItem::clone(ItemInfo info) const
137 ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed, m_strobe);
138 if (m_clipType == IMAGE || m_clipType == TEXT) duplicate->slotSetStartThumb(m_startPix);
139 else if (m_clipType != COLOR) {
140 if (info.cropStart == m_info.cropStart) duplicate->slotSetStartThumb(m_startPix);
141 if (info.cropStart + (info.endPos - info.startPos) == m_info.cropStart + (m_info.endPos - m_info.startPos)) duplicate->slotSetEndThumb(m_endPix);
143 //kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
144 duplicate->setEffectList(m_effectList);
145 duplicate->setVideoOnly(m_videoOnly);
146 duplicate->setAudioOnly(m_audioOnly);
147 duplicate->setFades(fadeIn(), fadeOut());
148 //duplicate->setSpeed(m_speed);
152 void ClipItem::setEffectList(const EffectsList effectList)
154 m_effectList.clone(effectList);
155 m_effectNames = m_effectList.effectNames().join(" / ");
156 if (!m_effectList.isEmpty()) {
157 for (int i = 0; i < m_effectList.count(); i++) {
158 QString effectId = m_effectList.item(i).attribute("id");
159 // check if it is a fade effect
160 QDomNodeList params = m_effectList.item(i).elementsByTagName("parameter");
162 for (int j = 0; j < params.count(); j++) {
163 QDomElement e = params.item(j).toElement();
165 if (effectId == "fadein") {
166 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
167 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
168 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
170 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
171 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
172 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
174 } else if (effectId == "fade_from_black") {
175 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
176 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
177 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
179 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
180 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
181 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
183 } else if (effectId == "fadeout") {
184 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
185 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
186 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
188 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
189 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
190 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
192 } else if (effectId == "fade_to_black") {
193 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
194 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
195 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
197 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
198 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
199 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
209 setSelectedEffect(0);
213 const EffectsList ClipItem::effectList() const
218 int ClipItem::selectedEffectIndex() const
220 return m_selectedEffect;
223 void ClipItem::initEffect(QDomElement effect, int diff)
225 // the kdenlive_ix int is used to identify an effect in mlt's playlist, should
227 if (effect.attribute("kdenlive_ix").toInt() == 0)
228 effect.setAttribute("kdenlive_ix", QString::number(effectsCounter()));
230 if (effect.attribute("id") == "freeze" && diff > 0) {
231 EffectsList::setParameter(effect, "frame", QString::number(diff));
234 // Init parameter value & keyframes if required
235 QDomNodeList params = effect.elementsByTagName("parameter");
236 for (int i = 0; i < params.count(); i++) {
237 QDomElement e = params.item(i).toElement();
242 // Check if this effect has a variable parameter
243 if (e.attribute("default").startsWith('%')) {
244 double evaluatedValue = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("default"));
245 e.setAttribute("default", evaluatedValue);
246 if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
247 e.setAttribute("value", evaluatedValue);
251 if (effect.attribute("id") == "crop") {
252 // default use_profile to 1 for clips with proxies to avoid problems when rendering
253 if (e.attribute("name") == "use_profile" && !(m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-"))
254 e.setAttribute("value", "1");
257 if ((e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("keyframes").isEmpty()) {
258 // Effect has a keyframe type parameter, we need to set the values
259 e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + e.attribute("default"));
262 if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
263 if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
264 int end = (cropDuration() + cropStart()).frames(m_fps) - 1;
266 if (effect.attribute("id") == "fadeout") {
267 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
268 int effectDuration = EffectsList::parameter(effect, "in").toInt();
269 if (effectDuration > cropDuration().frames(m_fps)) {
270 effectDuration = cropDuration().frames(m_fps) / 2;
272 start -= effectDuration;
274 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
275 start -= EffectsList::parameter(fadeout, "out").toInt() - EffectsList::parameter(fadeout, "in").toInt();
277 } else if (effect.attribute("id") == "fade_to_black") {
278 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
279 int effectDuration = EffectsList::parameter(effect, "in").toInt();
280 if (effectDuration > cropDuration().frames(m_fps)) {
281 effectDuration = cropDuration().frames(m_fps) / 2;
283 start -= effectDuration;
285 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
286 start -= EffectsList::parameter(fadeout, "out").toInt() - EffectsList::parameter(fadeout, "in").toInt();
289 EffectsList::setParameter(effect, "in", QString::number(start));
290 EffectsList::setParameter(effect, "out", QString::number(end));
291 } else if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
292 int start = cropStart().frames(m_fps);
294 if (effect.attribute("id") == "fadein") {
295 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
296 int effectDuration = EffectsList::parameter(effect, "out").toInt();
297 if (effectDuration > cropDuration().frames(m_fps)) {
298 effectDuration = cropDuration().frames(m_fps) / 2;
300 end += effectDuration;
302 end += EffectsList::parameter(m_effectList.getEffectByTag(QString(), "fade_from_black"), "out").toInt();
303 } else if (effect.attribute("id") == "fade_from_black") {
304 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
305 int effectDuration = EffectsList::parameter(effect, "out").toInt();
306 if (effectDuration > cropDuration().frames(m_fps)) {
307 effectDuration = cropDuration().frames(m_fps) / 2;
309 end += effectDuration;
311 end += EffectsList::parameter(m_effectList.getEffectByTag(QString(), "fadein"), "out").toInt();
313 EffectsList::setParameter(effect, "in", QString::number(start));
314 EffectsList::setParameter(effect, "out", QString::number(end));
319 bool ClipItem::checkKeyFrames()
321 bool clipEffectsModified = false;
322 // go through all effects this clip has
323 for (int ix = 0; ix < m_effectList.count(); ++ix) {
324 QStringList keyframeParams = keyframes(ix);
325 QStringList newKeyFrameParams;
326 bool effModified = false;
328 // go through all params which have keyframes
329 foreach(const QString &kfr, keyframeParams) {
330 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
331 QStringList newKeyFrames;
332 bool cutKeyFrame = false;
333 bool modified = false;
335 double lastValue = -1;
336 int start = cropStart().frames(m_fps);
337 int end = (cropStart() + cropDuration()).frames(m_fps);
339 // go through all keyframes for one param
340 foreach(const QString &str, keyframes) {
341 int pos = str.section(':', 0, 0).toInt();
342 double val = str.section(':', 1, 1).toDouble();
343 if (pos - start < 0) {
344 // a keyframe is defined before the start of the clip
346 } else if (cutKeyFrame) {
347 // create new keyframe at clip start, calculate interpolated value
349 int diff = pos - lastPos;
350 double ratio = (double)(start - lastPos) / diff;
351 double newValue = lastValue + (val - lastValue) * ratio;
352 newKeyFrames.append(QString::number(start) + ':' + QString::number(newValue));
359 // create new keyframe at clip end, calculate interpolated value
360 int diff = pos - lastPos;
362 double ratio = (double)(end - lastPos) / diff;
363 double newValue = lastValue + (val - lastValue) * ratio;
364 newKeyFrames.append(QString::number(end) + ':' + QString::number(newValue));
369 newKeyFrames.append(QString::number(pos) + ':' + QString::number(val));
376 newKeyFrameParams.append(newKeyFrames.join(";"));
383 setKeyframes(ix, newKeyFrameParams);
384 clipEffectsModified = true;
387 return clipEffectsModified;
390 void ClipItem::setKeyframes(const int ix, const QStringList keyframes)
392 QDomElement effect = getEffectAt(ix);
393 if (effect.attribute("disable") == "1") return;
394 QDomNodeList params = effect.elementsByTagName("parameter");
395 int keyframeParams = 0;
396 for (int i = 0; i < params.count(); i++) {
397 QDomElement e = params.item(i).toElement();
398 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
399 e.setAttribute("keyframes", keyframes.at(keyframeParams));
400 if (ix == m_selectedEffect && keyframeParams == 0) {
403 double max = e.attribute("max").toDouble();
404 double min = e.attribute("min").toDouble();
405 m_keyframeFactor = 100.0 / (max - min);
406 m_keyframeOffset = min;
407 m_keyframeDefault = e.attribute("default").toDouble();
408 m_selectedKeyframe = 0;
410 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
411 foreach(const QString &str, keyframes) {
412 int pos = str.section(':', 0, 0).toInt();
413 double val = str.section(':', 1, 1).toDouble();
414 m_keyframes[pos] = val;
416 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
417 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
426 void ClipItem::setSelectedEffect(const int ix)
428 m_selectedEffect = ix;
429 QDomElement effect = effectAt(m_selectedEffect);
430 if (!effect.isNull() && effect.attribute("disable") != "1") {
431 QDomNodeList params = effect.elementsByTagName("parameter");
432 for (int i = 0; i < params.count(); i++) {
433 QDomElement e = params.item(i).toElement();
434 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
437 double max = e.attribute("max").toDouble();
438 double min = e.attribute("min").toDouble();
439 m_keyframeFactor = 100.0 / (max - min);
440 m_keyframeOffset = min;
441 m_keyframeDefault = e.attribute("default").toDouble();
442 m_selectedKeyframe = 0;
445 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
446 foreach(const QString &str, keyframes) {
447 int pos = str.section(':', 0, 0).toInt();
448 double val = str.section(':', 1, 1).toDouble();
449 m_keyframes[pos] = val;
451 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end())
452 m_editedKeyframe = -1;
459 if (!m_keyframes.isEmpty()) {
465 QStringList ClipItem::keyframes(const int index)
468 QDomElement effect = effectAt(index);
469 QDomNodeList params = effect.elementsByTagName("parameter");
471 for (int i = 0; i < params.count(); i++) {
472 QDomElement e = params.item(i).toElement();
473 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe"))
474 result.append(e.attribute("keyframes"));
479 void ClipItem::updateKeyframeEffect()
481 // regenerate xml parameter from the clip keyframes
482 QDomElement effect = getEffectAt(m_selectedEffect);
483 if (effect.attribute("disable") == "1") return;
484 QDomNodeList params = effect.elementsByTagName("parameter");
485 QDomElement e = params.item(m_visibleParam).toElement();
489 if (m_keyframes.count() > 0) {
490 QMap<int, int>::const_iterator i = m_keyframes.constBegin();
491 while (i != m_keyframes.constEnd()) {
492 keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';');
496 // Effect has a keyframe type parameter, we need to set the values
497 e.setAttribute("keyframes", keyframes);
501 QDomElement ClipItem::selectedEffect()
503 if (m_selectedEffect == -1 || m_effectList.isEmpty()) return QDomElement();
504 return effectAt(m_selectedEffect);
507 void ClipItem::resetThumbs(bool clearExistingThumbs)
509 if (clearExistingThumbs) {
510 m_startPix = QPixmap();
511 m_endPix = QPixmap();
512 m_audioThumbCachePic.clear();
518 void ClipItem::refreshClip(bool checkDuration, bool forceResetThumbs)
520 if (checkDuration && (m_maxDuration != m_clip->maxDuration())) {
521 m_maxDuration = m_clip->maxDuration();
522 if (m_clipType != IMAGE && m_clipType != TEXT && m_clipType != COLOR) {
523 if (m_maxDuration != GenTime() && m_info.cropStart + m_info.cropDuration > m_maxDuration) {
524 // Clip duration changed, make sure to stay in correct range
525 if (m_info.cropStart > m_maxDuration) {
526 m_info.cropStart = GenTime();
527 m_info.cropDuration = qMin(m_info.cropDuration, m_maxDuration);
529 m_info.cropDuration = m_maxDuration;
531 updateRectGeometry();
535 if (m_clipType == COLOR) {
536 QString colour = m_clip->getProperty("colour");
537 colour = colour.replace(0, 2, "#");
538 m_baseColor = QColor(colour.left(7));
540 } else resetThumbs(forceResetThumbs);
543 void ClipItem::slotFetchThumbs()
545 if (scene() == NULL || m_clipType == AUDIO || m_clipType == COLOR) return;
546 if (m_clipType == IMAGE) {
547 if (m_startPix.isNull()) {
548 m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
554 if (m_clipType == TEXT) {
555 if (m_startPix.isNull()) slotGetStartThumb();
559 if (m_endPix.isNull() && m_startPix.isNull()) {
560 m_startThumbRequested = true;
561 m_endThumbRequested = true;
562 emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
564 if (m_endPix.isNull()) {
567 if (m_startPix.isNull()) {
573 void ClipItem::slotGetStartThumb()
575 m_startThumbRequested = true;
576 emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), -1);
579 void ClipItem::slotGetEndThumb()
581 m_endThumbRequested = true;
582 emit getThumb(-1, (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
586 void ClipItem::slotSetStartThumb(QImage img)
588 if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
589 QPixmap pix = QPixmap::fromImage(img);
591 QRectF r = sceneBoundingRect();
592 r.setRight(pix.width() + 2);
597 void ClipItem::slotSetEndThumb(QImage img)
599 if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
600 QPixmap pix = QPixmap::fromImage(img);
602 QRectF r = sceneBoundingRect();
603 r.setLeft(r.right() - pix.width() - 2);
608 void ClipItem::slotThumbReady(int frame, QImage img)
610 if (scene() == NULL) return;
611 QRectF r = boundingRect();
612 QPixmap pix = QPixmap::fromImage(img);
613 double width = pix.width() / projectScene()->scale().x();
614 if (m_startThumbRequested && frame == m_speedIndependantInfo.cropStart.frames(m_fps)) {
616 m_startThumbRequested = false;
617 update(r.left(), r.top(), width, pix.height());
618 if (m_clipType == IMAGE || m_clipType == TEXT) {
619 update(r.right() - width, r.top(), width, pix.height());
621 } else if (m_endThumbRequested && frame == (m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1) {
623 m_endThumbRequested = false;
624 update(r.right() - width, r.top(), width, pix.height());
628 void ClipItem::slotSetStartThumb(const QPixmap pix)
633 void ClipItem::slotSetEndThumb(const QPixmap pix)
638 QPixmap ClipItem::startThumb() const
643 QPixmap ClipItem::endThumb() const
648 void ClipItem::slotGotAudioData()
650 m_audioThumbReady = true;
651 if (m_clipType == AV && !isAudioOnly()) {
652 QRectF r = boundingRect();
653 r.setTop(r.top() + r.height() / 2 - 1);
658 int ClipItem::type() const
663 DocClipBase *ClipItem::baseClip() const
668 QDomElement ClipItem::xml() const
673 QDomElement ClipItem::itemXml() const
675 QDomElement xml = m_clip->toXML();
676 if (m_speed != 1.0) xml.setAttribute("speed", m_speed);
677 if (m_strobe > 1) xml.setAttribute("strobe", m_strobe);
678 if (m_audioOnly) xml.setAttribute("audio_only", 1);
679 else if (m_videoOnly) xml.setAttribute("video_only", 1);
683 int ClipItem::clipType() const
688 QString ClipItem::clipName() const
693 void ClipItem::setClipName(const QString &name)
698 const QString ClipItem::clipProducer() const
703 void ClipItem::flashClip()
705 if (m_timeLine == 0) {
706 m_timeLine = new QTimeLine(750, this);
707 m_timeLine->setUpdateInterval(80);
708 m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve);
709 m_timeLine->setFrameRange(0, 100);
710 connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animate(qreal)));
712 //m_timeLine->start();
715 void ClipItem::animate(qreal /*value*/)
717 QRectF r = boundingRect();
723 void ClipItem::paint(QPainter *painter,
724 const QStyleOptionGraphicsItem *option,
728 if (parentItem()) paintColor = QColor(255, 248, 149);
729 else paintColor = m_baseColor;
730 if (isSelected() || (parentItem() && parentItem()->isSelected())) paintColor = paintColor.darker();
732 painter->setMatrixEnabled(false);
733 const QRectF mapped = painter->matrix().mapRect(rect()).adjusted(0.5, 0, 0.5, 0);
734 const QRectF exposed = option->exposedRect;
735 painter->setClipRect(mapped);
736 painter->fillRect(mapped, paintColor);
739 if (KdenliveSettings::videothumbnails() && !isAudioOnly()) {
740 QPen pen = painter->pen();
741 pen.setColor(QColor(255, 255, 255, 150));
742 painter->setPen(pen);
743 if ((m_clipType == IMAGE || m_clipType == TEXT) && !m_startPix.isNull()) {
744 const QPointF top = mapped.topRight() - QPointF(m_startPix.width() - 1, 0);
745 painter->drawPixmap(top, m_startPix);
746 QLineF l2(top.x(), mapped.top(), top.x(), mapped.bottom());
747 painter->drawLine(l2);
748 } else if (!m_endPix.isNull()) {
749 const QPointF top = mapped.topRight() - QPointF(m_endPix.width() - 1, 0);
750 painter->drawPixmap(top, m_endPix);
751 QLineF l2(top.x(), mapped.top(), top.x(), mapped.bottom());
752 painter->drawLine(l2);
754 if (!m_startPix.isNull()) {
755 painter->drawPixmap(mapped.topLeft(), m_startPix);
756 QLineF l2(mapped.left() + m_startPix.width(), mapped.top(), mapped.left() + m_startPix.width(), mapped.bottom());
757 painter->drawLine(l2);
759 if (painter->matrix().m11() == FRAME_SIZE && m_clip->thumbProducer() && clipType() != COLOR && clipType() != AUDIO && !m_audioOnly) {
760 int offset = (m_info.startPos - m_info.cropStart).frames(m_fps);
761 int left = qMax((int) m_info.startPos.frames(m_fps) + 1, (int) mapToScene(exposed.left(), 0).x()) - offset;
762 int right = qMin((int)(m_info.startPos + m_info.cropDuration).frames(m_fps) - 1, (int) mapToScene(exposed.right(), 0).x()) - offset;
763 QPointF startPos = mapped.topLeft();
764 int twidth = FRAME_SIZE;
765 int startOffset = m_info.cropStart.frames(m_fps);
766 if (clipType() == IMAGE || clipType() == TEXT) {
767 for (int i = left; i <= right; i++) {
768 painter->drawPixmap(startPos + QPointF(twidth *(i - startOffset), 0), m_startPix);
772 #if KDE_IS_VERSION(4,5,0)
773 m_clip->thumbProducer()->queryIntraThumbs(left, right);
774 connect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache()));
775 QString path = m_clip->fileURL().path() + "%";
776 for (int i = left; i <= right; i++) {
777 painter->drawImage(startPos + QPointF(twidth *(i - startOffset), 0), m_clip->thumbProducer()->findCachedThumb(path + QString::number(i)));
782 painter->setPen(Qt::black);
785 // draw audio thumbnails
786 if (KdenliveSettings::audiothumbnails() && m_speed == 1.0 && !isVideoOnly() && ((m_clipType == AV && (exposed.bottom() > (rect().height() / 2) || isAudioOnly())) || m_clipType == AUDIO) && m_audioThumbReady) {
788 double startpixel = exposed.left();
791 double endpixel = exposed.right();
794 //kDebug()<<"/// REPAINTING AUDIO THMBS ZONE: "<<startpixel<<"x"<<endpixel;
796 /*QPainterPath path = m_clipType == AV ? roundRectPathLower : resultClipPath;*/
798 if (m_clipType == AV && !isAudioOnly()) {
800 mappedRect.setTop(mappedRect.bottom() - mapped.height() / 2);
801 } else mappedRect = mapped;
803 double scale = painter->matrix().m11();
805 if (isEnabled() && m_clip) channels = m_clip->getProperty("channels").toInt();
806 if (scale != m_framePixelWidth)
807 m_audioThumbCachePic.clear();
808 double cropLeft = m_info.cropStart.frames(m_fps);
809 const int clipStart = mappedRect.x();
810 const int mappedStartPixel = painter->matrix().map(QPointF(startpixel + cropLeft, 0)).x() - clipStart;
811 const int mappedEndPixel = painter->matrix().map(QPointF(endpixel + cropLeft, 0)).x() - clipStart;
812 cropLeft = cropLeft * scale;
816 emit prepareAudioThumb(scale, mappedStartPixel, mappedEndPixel, channels);
819 for (int startCache = mappedStartPixel - (mappedStartPixel) % 100; startCache < mappedEndPixel; startCache += 100) {
820 if (m_audioThumbCachePic.contains(startCache) && !m_audioThumbCachePic[startCache].isNull())
821 painter->drawPixmap(clipStart + startCache - cropLeft, mappedRect.y(), m_audioThumbCachePic[startCache]);
825 // Draw effects names
826 if (!m_effectNames.isEmpty() && mapped.width() > 40) {
827 QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignLeft | Qt::AlignTop, m_effectNames);
829 if (m_timeLine && m_timeLine->state() == QTimeLine::Running) {
830 qreal value = m_timeLine->currentValue();
831 txtBounding.setWidth(txtBounding.width() * value);
832 bgColor.setRgb(50 + 200 *(1.0 - value), 50, 50, 100 + 50 * value);
833 } else bgColor.setRgb(50, 50, 90, 180);
835 QPainterPath rounded;
836 rounded.moveTo(txtBounding.bottomRight());
837 rounded.arcTo(txtBounding.right() - txtBounding.height() - 2, txtBounding.top() - txtBounding.height(), txtBounding.height() * 2, txtBounding.height() * 2, 270, 90);
838 rounded.lineTo(txtBounding.topLeft());
839 rounded.lineTo(txtBounding.bottomLeft());
840 painter->fillPath(rounded, bgColor);
841 painter->setPen(Qt::lightGray);
842 painter->drawText(txtBounding.adjusted(1, 0, 1, 0), Qt::AlignCenter, m_effectNames);
846 QColor frameColor(paintColor.darker());
847 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
848 frameColor = QColor(Qt::red);
850 frameColor.setAlpha(160);
852 const QRectF txtBounding2 = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + m_clipName + ' ');
853 //painter->fillRect(txtBounding2, frameColor);
854 painter->setBrush(frameColor);
855 painter->setPen(Qt::NoPen);
856 painter->drawRoundedRect(txtBounding2, 3, 3);
857 painter->setBrush(QBrush(Qt::NoBrush));
859 //painter->setPen(QColor(0, 0, 0, 180));
860 //painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
862 painter->drawPixmap(txtBounding2.topLeft() - QPointF(17, -1), m_videoPix);
863 } else if (m_audioOnly) {
864 painter->drawPixmap(txtBounding2.topLeft() - QPointF(17, -1), m_audioPix);
866 painter->setPen(Qt::white);
867 painter->drawText(txtBounding2, Qt::AlignCenter, m_clipName);
871 if (isEnabled() && m_clip) {
872 QList < CommentedTime > markers = m_clip->commentedSnapMarkers();
873 QList < CommentedTime >::Iterator it = markers.begin();
876 QBrush markerBrush(QColor(120, 120, 0, 140));
877 QPen pen = painter->pen();
878 pen.setColor(QColor(255, 255, 255, 200));
879 pen.setStyle(Qt::DotLine);
881 for (; it != markers.end(); ++it) {
882 pos = GenTime((int)((*it).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
883 if (pos > GenTime()) {
884 if (pos > cropDuration()) break;
885 QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
886 QLineF l2 = painter->matrix().map(l);
887 painter->setPen(pen);
888 painter->drawLine(l2);
889 if (KdenliveSettings::showmarkers()) {
890 framepos = rect().x() + pos.frames(m_fps);
891 const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
892 const QRectF r2 = painter->matrix().mapRect(r1);
893 const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
894 painter->setBrush(markerBrush);
895 painter->setPen(Qt::NoPen);
896 painter->drawRoundedRect(txtBounding3, 3, 3);
897 painter->setBrush(QBrush(Qt::NoBrush));
898 painter->setPen(Qt::white);
899 painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
901 //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
906 // draw start / end fades
909 fades = QBrush(QColor(200, 50, 50, 150));
910 } else fades = QBrush(QColor(200, 200, 200, 200));
912 if (m_startFade != 0) {
913 QPainterPath fadeInPath;
914 fadeInPath.moveTo(0, 0);
915 fadeInPath.lineTo(0, rect().height());
916 fadeInPath.lineTo(m_startFade, 0);
917 fadeInPath.closeSubpath();
918 QPainterPath f1 = painter->matrix().map(fadeInPath);
919 painter->fillPath(f1/*.intersected(resultClipPath)*/, fades);
920 /*if (isSelected()) {
921 QLineF l(m_startFade * scale, 0, 0, itemHeight);
922 painter->drawLine(l);
925 if (m_endFade != 0) {
926 QPainterPath fadeOutPath;
927 fadeOutPath.moveTo(rect().width(), 0);
928 fadeOutPath.lineTo(rect().width(), rect().height());
929 fadeOutPath.lineTo(rect().width() - m_endFade, 0);
930 fadeOutPath.closeSubpath();
931 QPainterPath f1 = painter->matrix().map(fadeOutPath);
932 painter->fillPath(f1/*.intersected(resultClipPath)*/, fades);
933 /*if (isSelected()) {
934 QLineF l(itemWidth - m_endFade * scale, 0, itemWidth, itemHeight);
935 painter->drawLine(l);
940 painter->setPen(QPen(Qt::lightGray));
941 // draw effect or transition keyframes
942 if (mapped.width() > 20) drawKeyFrames(painter, exposed);
944 //painter->setMatrixEnabled(true);
947 // expand clip rect to allow correct painting of clip border
948 QPen pen1(frameColor);
949 painter->setPen(pen1);
950 painter->setClipping(false);
951 painter->drawRect(painter->matrix().mapRect(rect()));
955 OPERATIONTYPE ClipItem::operationMode(QPointF pos)
957 if (isItemLocked()) return NONE;
958 const double scale = projectScene()->scale().x();
959 double maximumOffset = 6 / scale;
960 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
961 int kf = mouseOverKeyFrames(pos, maximumOffset);
963 m_editedKeyframe = kf;
967 QRectF rect = sceneBoundingRect();
968 int addtransitionOffset = 10;
969 // Don't allow add transition if track height is very small
970 if (rect.height() < 30) addtransitionOffset = 0;
972 if (qAbs((int)(pos.x() - (rect.x() + m_startFade))) < maximumOffset && qAbs((int)(pos.y() - rect.y())) < 6) {
974 } else if (pos.x() - rect.x() < maximumOffset && (rect.bottom() - pos.y() > addtransitionOffset)) {
976 } else if (qAbs((int)(pos.x() - (rect.x() + rect.width() - m_endFade))) < maximumOffset && qAbs((int)(pos.y() - rect.y())) < 6) {
978 } else if ((rect.right() - pos.x() < maximumOffset) && (rect.bottom() - pos.y() > addtransitionOffset)) {
980 } else if ((pos.x() - rect.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
981 return TRANSITIONSTART;
982 } else if ((rect.right() - pos.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
983 return TRANSITIONEND;
989 int ClipItem::itemHeight()
991 return KdenliveSettings::trackheight() - 2;
994 QList <GenTime> ClipItem::snapMarkers() const
996 QList < GenTime > snaps;
997 QList < GenTime > markers = baseClip()->snapMarkers();
1000 for (int i = 0; i < markers.size(); i++) {
1001 pos = GenTime((int)(markers.at(i).frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
1002 if (pos > GenTime()) {
1003 if (pos > cropDuration()) break;
1004 else snaps.append(pos + startPos());
1010 QList <CommentedTime> ClipItem::commentedSnapMarkers() const
1012 QList < CommentedTime > snaps;
1013 QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
1016 for (int i = 0; i < markers.size(); i++) {
1017 pos = GenTime((int)(markers.at(i).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
1018 if (pos > GenTime()) {
1019 if (pos > cropDuration()) break;
1020 else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment()));
1026 void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, int endpixel, int channels)
1028 QRectF re = sceneBoundingRect();
1029 if (m_clipType == AV && !isAudioOnly()) re.setTop(re.y() + re.height() / 2);
1031 //kDebug() << "// PREP AUDIO THMB FRMO : scale:" << pixelForOneFrame<< ", from: " << startpixel << ", to: " << endpixel;
1032 //if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
1034 for (int startCache = startpixel - startpixel % 100; startCache < endpixel; startCache += 100) {
1035 //kDebug() << "creating " << startCache;
1036 //if (framePixelWidth!=pixelForOneFrame ||
1037 if (m_framePixelWidth == pixelForOneFrame && m_audioThumbCachePic.contains(startCache))
1039 if (m_audioThumbCachePic[startCache].isNull() || m_framePixelWidth != pixelForOneFrame) {
1040 m_audioThumbCachePic[startCache] = QPixmap(100, (int)(re.height()));
1041 m_audioThumbCachePic[startCache].fill(QColor(180, 180, 200, 140));
1043 bool fullAreaDraw = pixelForOneFrame < 10;
1044 QMap<int, QPainterPath > positiveChannelPaths;
1045 QMap<int, QPainterPath > negativeChannelPaths;
1046 QPainter pixpainter(&m_audioThumbCachePic[startCache]);
1048 audiopen.setWidth(0);
1049 pixpainter.setPen(audiopen);
1050 //pixpainter.setRenderHint(QPainter::Antialiasing,true);
1051 //pixpainter.drawLine(0,0,100,re.height());
1052 // Bail out, if caller provided invalid data
1053 if (channels <= 0) {
1054 kWarning() << "Unable to draw image with " << channels << "number of channels";
1058 int channelHeight = m_audioThumbCachePic[startCache].height() / channels;
1060 for (int i = 0; i < channels; i++) {
1062 positiveChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
1063 negativeChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
1066 for (int samples = 0; samples <= 100; samples++) {
1067 double frame = (double)(samples + startCache - 0) / pixelForOneFrame;
1068 int sample = (int)((frame - (int)(frame)) * 20); // AUDIO_FRAME_SIZE
1069 if (frame < 0 || sample < 0 || sample > 19)
1071 QMap<int, QByteArray> frame_channel_data = baseClip()->m_audioFrameCache[(int)frame];
1073 for (int channel = 0; channel < channels && frame_channel_data[channel].size() > 0; channel++) {
1075 int y = channelHeight * channel + channelHeight / 2;
1076 int delta = (int)(frame_channel_data[channel][sample] - 127 / 2) * channelHeight / 64;
1078 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + qAbs(delta));
1079 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - qAbs(delta));
1081 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + delta);
1082 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - delta);
1085 for (int channel = 0; channel < channels ; channel++)
1086 if (fullAreaDraw && samples == 100) {
1087 positiveChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
1088 negativeChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
1089 positiveChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
1090 negativeChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
1094 pixpainter.setPen(QPen(QColor(0, 0, 0)));
1095 pixpainter.setBrush(QBrush(QColor(60, 60, 60)));
1097 for (int i = 0; i < channels; i++) {
1099 //pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
1100 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
1102 pixpainter.drawPath(positiveChannelPaths[i]);
1105 //audioThumbWasDrawn=true;
1106 m_framePixelWidth = pixelForOneFrame;
1111 int ClipItem::fadeIn() const
1116 int ClipItem::fadeOut() const
1122 void ClipItem::setFadeIn(int pos)
1124 if (pos == m_startFade) return;
1125 int oldIn = m_startFade;
1126 m_startFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
1127 QRectF rect = boundingRect();
1128 update(rect.x(), rect.y(), qMax(oldIn, m_startFade), rect.height());
1131 void ClipItem::setFadeOut(int pos)
1133 if (pos == m_endFade) return;
1134 int oldOut = m_endFade;
1135 m_endFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
1136 QRectF rect = boundingRect();
1137 update(rect.x() + rect.width() - qMax(oldOut, m_endFade), rect.y(), qMax(oldOut, m_endFade), rect.height());
1141 void ClipItem::setFades(int in, int out)
1149 void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
1151 //if (e->pos().x() < 20) m_hover = true;
1153 if (isItemLocked()) return;
1155 QRectF r = boundingRect();
1156 double width = 35 / projectScene()->scale().x();
1157 double height = r.height() / 2;
1158 //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
1159 update(r.x(), r.y() + height, width, height);
1160 update(r.right() - width, r.y() + height, width, height);
1164 void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
1166 if (isItemLocked()) return;
1168 QRectF r = boundingRect();
1169 double width = 35 / projectScene()->scale().x();
1170 double height = r.height() / 2;
1171 //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
1172 update(r.x(), r.y() + height, width, height);
1173 update(r.right() - width, r.y() + height, width, height);
1177 void ClipItem::resizeStart(int posx, bool /*size*/)
1179 bool sizeLimit = false;
1180 if (clipType() != IMAGE && clipType() != COLOR && clipType() != TEXT) {
1181 const int min = (startPos() - cropStart()).frames(m_fps);
1182 if (posx < min) posx = min;
1186 if (posx == startPos().frames(m_fps)) return;
1187 const int previous = cropStart().frames(m_fps);
1188 AbstractClipItem::resizeStart(posx, sizeLimit);
1190 // set speed independant info
1191 m_speedIndependantInfo = m_info;
1192 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
1193 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
1195 if ((int) cropStart().frames(m_fps) != previous) {
1196 if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
1197 m_startThumbTimer.start(150);
1202 void ClipItem::resizeEnd(int posx)
1204 const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps);
1205 if (posx > max && maxDuration() != GenTime()) posx = max;
1206 if (posx == endPos().frames(m_fps)) return;
1207 //kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
1208 const int previous = cropDuration().frames(m_fps);
1209 AbstractClipItem::resizeEnd(posx);
1211 // set speed independant info
1212 m_speedIndependantInfo = m_info;
1213 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
1214 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
1216 if ((int) cropDuration().frames(m_fps) != previous) {
1217 if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
1218 m_endThumbTimer.start(150);
1224 QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
1226 if (change == QGraphicsItem::ItemSelectedChange) {
1227 if (value.toBool()) setZValue(10);
1230 if (change == ItemPositionChange && scene()) {
1231 // calculate new position.
1232 //if (parentItem()) return pos();
1233 QPointF newPos = value.toPointF();
1234 //kDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++";
1235 int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
1236 xpos = qMax(xpos, 0);
1238 int newTrack = newPos.y() / KdenliveSettings::trackheight();
1239 newTrack = qMin(newTrack, projectScene()->tracksCount() - 1);
1240 newTrack = qMax(newTrack, 0);
1241 newPos.setY((int)(newTrack * KdenliveSettings::trackheight() + 1));
1242 // Only one clip is moving
1243 QRectF sceneShape = rect();
1244 sceneShape.translate(newPos);
1245 QList<QGraphicsItem*> items;
1246 if (projectScene()->editMode() == NORMALEDIT)
1247 items = scene()->items(sceneShape, Qt::IntersectsItemShape);
1248 items.removeAll(this);
1249 bool forwardMove = newPos.x() > pos().x();
1251 if (!items.isEmpty()) {
1252 for (int i = 0; i < items.count(); i++) {
1253 if (!items.at(i)->isEnabled()) continue;
1254 if (items.at(i)->type() == type()) {
1256 QPointF otherPos = items.at(i)->pos();
1257 if ((int) otherPos.y() != (int) pos().y()) {
1261 offset = qMax(offset, (int)(newPos.x() - (static_cast < AbstractClipItem* >(items.at(i))->startPos() - cropDuration()).frames(m_fps)));
1263 offset = qMax(offset, (int)((static_cast < AbstractClipItem* >(items.at(i))->endPos().frames(m_fps)) - newPos.x()));
1268 sceneShape.translate(QPointF(-offset, 0));
1269 newPos.setX(newPos.x() - offset);
1271 sceneShape.translate(QPointF(offset, 0));
1272 newPos.setX(newPos.x() + offset);
1274 QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
1275 subitems.removeAll(this);
1276 for (int j = 0; j < subitems.count(); j++) {
1277 if (!subitems.at(j)->isEnabled()) continue;
1278 if (subitems.at(j)->type() == type()) {
1279 // move was not successful, revert to previous pos
1280 m_info.startPos = GenTime((int) pos().x(), m_fps);
1286 m_info.track = newTrack;
1287 m_info.startPos = GenTime((int) newPos.x(), m_fps);
1293 m_info.track = newTrack;
1294 m_info.startPos = GenTime((int) newPos.x(), m_fps);
1295 //kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
1298 return QGraphicsItem::itemChange(change, value);
1302 /*void ClipItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
1305 int ClipItem::effectsCounter()
1307 return effectsCount() + 1;
1310 int ClipItem::effectsCount()
1312 return m_effectList.count();
1315 int ClipItem::hasEffect(const QString &tag, const QString &id) const
1317 return m_effectList.hasEffect(tag, id);
1320 QStringList ClipItem::effectNames()
1322 return m_effectList.effectNames();
1325 QDomElement ClipItem::effectAt(int ix) const
1327 if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
1328 return m_effectList.at(ix).cloneNode().toElement();
1331 QDomElement ClipItem::getEffectAt(int ix) const
1333 if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
1334 return m_effectList.at(ix);
1337 void ClipItem::setEffectAt(int ix, QDomElement effect)
1339 if (ix < 0 || ix > (m_effectList.count() - 1) || effect.isNull()) {
1340 kDebug() << "Invalid effect index: " << ix;
1343 //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
1344 effect.setAttribute("kdenlive_ix", ix + 1);
1345 m_effectList.replace(ix, effect);
1346 m_effectNames = m_effectList.effectNames().join(" / ");
1347 QString id = effect.attribute("id");
1348 if (id == "fadein" || id == "fadeout" || id == "fade_from_black" || id == "fade_to_black")
1351 QRectF r = boundingRect();
1357 EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animate*/)
1359 bool needRepaint = false;
1361 if (!effect.hasAttribute("kdenlive_ix")) {
1362 ix = effectsCounter();
1363 } else ix = effect.attribute("kdenlive_ix").toInt();
1364 if (!m_effectList.isEmpty() && ix <= m_effectList.count()) {
1366 m_effectList.insert(ix - 1, effect);
1367 for (int i = ix; i < m_effectList.count(); i++) {
1368 int index = m_effectList.item(i).attribute("kdenlive_ix").toInt();
1369 if (index >= ix) m_effectList.item(i).setAttribute("kdenlive_ix", index + 1);
1371 } else m_effectList.append(effect);
1372 EffectsParameterList parameters;
1373 parameters.addParam("tag", effect.attribute("tag"));
1374 parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
1375 if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
1376 if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
1378 QString effectId = effect.attribute("id");
1379 if (effectId.isEmpty()) effectId = effect.attribute("tag");
1380 parameters.addParam("id", effectId);
1382 // special case: the affine effect needs in / out points
1383 if (effectId == "pan_zoom") {
1384 parameters.addParam("in", QString::number(cropStart().frames(m_fps)));
1385 parameters.addParam("out", QString::number((cropStart() + cropDuration()).frames(m_fps)));
1388 QDomNodeList params = effect.elementsByTagName("parameter");
1390 for (int i = 0; i < params.count(); i++) {
1391 QDomElement e = params.item(i).toElement();
1393 if (e.attribute("type") == "simplekeyframe") {
1394 QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
1395 double factor = e.attribute("factor", "1").toDouble();
1397 for (int j = 0; j < values.count(); j++) {
1398 QString pos = values.at(j).section(':', 0, 0);
1399 double val = values.at(j).section(':', 1, 1).toDouble() / factor;
1400 values[j] = pos + "=" + QString::number(val);
1403 parameters.addParam(e.attribute("name"), values.join(";"));
1404 /*parameters.addParam("max", e.attribute("max"));
1405 parameters.addParam("min", e.attribute("min"));
1406 parameters.addParam("factor", );*/
1407 } else if (e.attribute("type") == "keyframe") {
1408 parameters.addParam("keyframes", e.attribute("keyframes"));
1409 parameters.addParam("max", e.attribute("max"));
1410 parameters.addParam("min", e.attribute("min"));
1411 parameters.addParam("factor", e.attribute("factor", "1"));
1412 parameters.addParam("starttag", e.attribute("starttag", "start"));
1413 parameters.addParam("endtag", e.attribute("endtag", "end"));
1414 } else if (e.attribute("factor", "1") == "1") {
1415 parameters.addParam(e.attribute("name"), e.attribute("value"));
1417 // check if it is a fade effect
1418 if (effectId == "fadein") {
1420 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
1421 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
1422 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
1424 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
1425 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
1426 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
1428 } else if (effectId == "fade_from_black") {
1430 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
1431 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
1432 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
1434 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
1435 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
1436 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
1438 } else if (effectId == "fadeout") {
1440 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
1441 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
1442 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
1444 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
1445 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
1446 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
1448 } else if (effectId == "fade_to_black") {
1450 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
1451 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
1452 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
1454 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
1455 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
1456 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
1461 if (e.attribute("factor").startsWith('%')) {
1462 fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
1463 } else fact = e.attribute("factor", "1").toDouble();
1464 parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
1468 m_effectNames = m_effectList.effectNames().join(" / ");
1469 if (fade > 0) m_startFade = fade;
1470 else if (fade < 0) m_endFade = -fade;
1472 if (m_selectedEffect == -1) {
1473 setSelectedEffect(0);
1474 } else if (m_selectedEffect == ix - 1) setSelectedEffect(m_selectedEffect);
1475 if (needRepaint) update(boundingRect());
1479 else { /*if (!needRepaint) */
1480 QRectF r = boundingRect();
1487 void ClipItem::deleteEffect(QString index)
1489 bool needRepaint = false;
1492 for (int i = 0; i < m_effectList.count(); ++i) {
1493 ix = m_effectList.at(i).attribute("kdenlive_ix");
1495 QString effectId = m_effectList.at(i).attribute("id");
1496 if ((effectId == "fadein" && hasEffect(QString(), "fade_from_black") == -1) ||
1497 (effectId == "fade_from_black" && hasEffect(QString(), "fadein") == -1)) {
1500 } else if ((effectId == "fadeout" && hasEffect(QString(), "fade_to_black") == -1) ||
1501 (effectId == "fade_to_black" && hasEffect(QString(), "fadeout") == -1)) {
1504 } else if (EffectsList::hasKeyFrames(m_effectList.at(i))) needRepaint = true;
1505 m_effectList.removeAt(i);
1507 } else if (ix.toInt() > index.toInt()) {
1508 m_effectList.item(i).setAttribute("kdenlive_ix", ix.toInt() - 1);
1511 m_effectNames = m_effectList.effectNames().join(" / ");
1513 if (m_effectList.isEmpty() || m_selectedEffect + 1 == index.toInt()) {
1514 // Current effect was removed
1515 if (index.toInt() > m_effectList.count() - 1) {
1516 setSelectedEffect(m_effectList.count() - 1);
1517 } else setSelectedEffect(index.toInt());
1519 if (needRepaint) update(boundingRect());
1521 QRectF r = boundingRect();
1525 //if (!m_effectList.isEmpty()) flashClip();
1528 double ClipItem::speed() const
1533 int ClipItem::strobe() const
1538 void ClipItem::setSpeed(const double speed, const int strobe)
1541 if (m_speed <= 0 && m_speed > -1)
1544 if (m_speed == 1.0) m_clipName = baseClip()->name();
1545 else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + '%';
1546 m_info.cropStart = GenTime((int)(m_speedIndependantInfo.cropStart.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1547 m_info.cropDuration = GenTime((int)(m_speedIndependantInfo.cropDuration.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1551 GenTime ClipItem::maxDuration() const
1553 return GenTime((int)(m_maxDuration.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1556 GenTime ClipItem::speedIndependantCropStart() const
1558 return m_speedIndependantInfo.cropStart;
1561 GenTime ClipItem::speedIndependantCropDuration() const
1563 return m_speedIndependantInfo.cropDuration;
1567 const ItemInfo ClipItem::speedIndependantInfo() const
1569 return m_speedIndependantInfo;
1573 void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event)
1575 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
1577 doc.setContent(effects, true);
1578 const QDomElement e = doc.documentElement();
1579 if (scene() && !scene()->views().isEmpty()) {
1581 CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1582 if (view) view->slotAddEffect(e, m_info.startPos, track());
1587 void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
1589 if (isItemLocked()) event->setAccepted(false);
1590 else event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
1593 void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
1598 void ClipItem::addTransition(Transition* t)
1600 m_transitionsList.append(t);
1601 //CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1603 QDomElement e = doc.documentElement();
1604 //if (view) view->slotAddTransition(this, t->toXML() , t->startPos(), track());
1607 void ClipItem::setVideoOnly(bool force)
1609 m_videoOnly = force;
1612 void ClipItem::setAudioOnly(bool force)
1614 m_audioOnly = force;
1615 if (m_audioOnly) m_baseColor = QColor(141, 215, 166);
1617 if (m_clipType == COLOR) {
1618 QString colour = m_clip->getProperty("colour");
1619 colour = colour.replace(0, 2, "#");
1620 m_baseColor = QColor(colour.left(7));
1621 } else if (m_clipType == AUDIO) m_baseColor = QColor(141, 215, 166);
1622 else m_baseColor = QColor(141, 166, 215);
1624 m_audioThumbCachePic.clear();
1627 bool ClipItem::isAudioOnly() const
1632 bool ClipItem::isVideoOnly() const
1637 void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
1639 if (effect.attribute("disable") == "1") return;
1640 effect.setAttribute("active_keyframe", pos);
1641 m_editedKeyframe = pos;
1642 QDomNodeList params = effect.elementsByTagName("parameter");
1643 for (int i = 0; i < params.count(); i++) {
1644 QDomElement e = params.item(i).toElement();
1645 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
1646 QString kfr = e.attribute("keyframes");
1647 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
1650 foreach(const QString &str, keyframes) {
1651 int kpos = str.section(':', 0, 0).toInt();
1652 double newval = str.section(':', 1, 1).toDouble();
1655 } else if (!added) {
1656 if (i == m_visibleParam)
1657 newkfr.append(QString::number(pos) + ":" + QString::number(val));
1659 newkfr.append(QString::number(pos) + ":" + QString::number(newval));
1660 if (kpos > pos) newkfr.append(str);
1662 } else newkfr.append(str);
1665 if (i == m_visibleParam)
1666 newkfr.append(QString::number(pos) + ":" + QString::number(val));
1668 newkfr.append(QString::number(pos) + ":" + e.attribute("default"));
1670 e.setAttribute("keyframes", newkfr.join(";"));
1675 void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double value)
1677 if (effect.attribute("disable") == "1") return;
1678 effect.setAttribute("active_keyframe", newpos);
1679 QDomNodeList params = effect.elementsByTagName("parameter");
1680 int start = cropStart().frames(m_fps);
1681 int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
1682 for (int i = 0; i < params.count(); i++) {
1683 QDomElement e = params.item(i).toElement();
1684 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
1685 QString kfr = e.attribute("keyframes");
1686 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
1688 foreach(const QString &str, keyframes) {
1689 if (str.section(':', 0, 0).toInt() != oldpos) {
1691 } else if (newpos != -1) {
1692 newpos = qMax(newpos, start);
1693 newpos = qMin(newpos, end);
1694 if (i == m_visibleParam)
1695 newkfr.append(QString::number(newpos) + ":" + QString::number(value));
1697 newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1));
1700 e.setAttribute("keyframes", newkfr.join(";"));
1704 updateKeyframes(effect);
1708 void ClipItem::updateKeyframes(QDomElement effect)
1710 m_keyframes.clear();
1712 QDomNodeList params = effect.elementsByTagName("parameter");
1713 QDomElement e = params.item(m_visibleParam).toElement();
1714 if (e.attribute("intimeline") != "1") {
1715 setSelectedEffect(m_selectedEffect);
1718 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
1719 foreach(const QString &str, keyframes) {
1720 int pos = str.section(':', 0, 0).toInt();
1721 double val = str.section(':', 1, 1).toDouble();
1722 m_keyframes[pos] = val;
1724 if (!m_keyframes.contains(m_selectedKeyframe)) m_selectedKeyframe = -1;
1727 /*void ClipItem::slotGetIntraThumbs(CustomTrackView *view, int start, int end)
1729 const int theight = KdenliveSettings::trackheight();
1730 const int twidth = FRAME_SIZE;
1731 QString path = m_clip->fileURL().path() + "%";
1733 for (int i = start; i <= end; i++) {
1734 #if KDE_IS_VERSION(4,5,0)
1735 if (!view->m_pixmapCache->contains(path + QString::number(i))) {
1736 p = m_clip->extractImage(i, twidth, theight);
1737 view->m_pixmapCache->insertPixmap(path + QString::number(i), p);
1740 if (!view->m_pixmapCache->find(path + QString::number(i), p)) {
1741 p = m_clip->extractImage(i, twidth, theight);
1742 view->m_pixmapCache->insert(path + QString::number(i), p);
1749 QList <int> ClipItem::updatePanZoom(int width, int height, int cut)
1751 QList <int> effectPositions;
1752 for (int i = 0; i < m_effectList.count(); i++) {
1753 QDomElement effect = m_effectList.at(i);
1754 QDomNodeList params = effect.elementsByTagName("parameter");
1755 for (int j = 0; j < params.count(); j++) {
1756 QDomElement e = params.item(j).toElement();
1759 if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
1760 effectPositions << i;
1761 // updateGeometryKeyframes(effect, j, width, height, cut);
1766 return effectPositions;
1769 Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
1772 return m_clip->audioProducer(track);
1773 else if (isVideoOnly())
1774 return m_clip->videoProducer();
1776 return m_clip->producer(trackSpecific ? track : -1);
1779 QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo)
1781 QMap<int, QDomElement> effects;
1782 for (int i = 0; i < m_effectList.count(); i++) {
1783 QDomElement effect = m_effectList.at(i);
1785 if (effect.attribute("id").startsWith("fade")) {
1786 QString id = effect.attribute("id");
1787 int in = EffectsList::parameter(effect, "in").toInt();
1788 int out = EffectsList::parameter(effect, "out").toInt();
1789 int clipEnd = (cropStart() + cropDuration()).frames(m_fps);
1790 if (id == "fade_from_black" || id == "fadein") {
1791 if (in != cropStart().frames(m_fps)) {
1792 effects[i] = effect.cloneNode().toElement();
1793 int diff = in - cropStart().frames(m_fps);
1796 EffectsList::setParameter(effect, "in", QString::number(in));
1797 EffectsList::setParameter(effect, "out", QString::number(out));
1799 if (out > clipEnd) {
1800 if (!effects.contains(i))
1801 effects[i] = effect.cloneNode().toElement();
1802 EffectsList::setParameter(effect, "out", QString::number(clipEnd));
1804 if (effects.contains(i))
1805 setFadeIn(out - in);
1807 if (out != clipEnd) {
1808 effects[i] = effect.cloneNode().toElement();
1809 int diff = out - clipEnd;
1812 EffectsList::setParameter(effect, "in", QString::number(in));
1813 EffectsList::setParameter(effect, "out", QString::number(out));
1815 if (in < cropStart().frames(m_fps)) {
1816 if (!effects.contains(i))
1817 effects[i] = effect.cloneNode().toElement();
1818 EffectsList::setParameter(effect, "in", QString::number(cropStart().frames(m_fps)));
1820 if (effects.contains(i))
1821 setFadeOut(out - in);
1824 } else if (effect.attribute("id") == "freeze" && cropStart() != oldInfo.cropStart) {
1825 effects[i] = effect.cloneNode().toElement();
1826 int diff = (oldInfo.cropStart - cropStart()).frames(m_fps);
1827 int frame = EffectsList::parameter(effect, "frame").toInt();
1828 EffectsList::setParameter(effect, "frame", QString::number(frame - diff));
1832 QDomNodeList params = effect.elementsByTagName("parameter");
1833 for (int j = 0; j < params.count(); j++) {
1834 QDomElement param = params.item(j).toElement();
1836 QString type = param.attribute("type");
1837 if (type == "geometry" && !param.hasAttribute("fixed")) {
1838 if (!effects.contains(i))
1839 effects[i] = effect.cloneNode().toElement();
1840 updateGeometryKeyframes(effect, j, width, height, oldInfo);
1841 } else if (type == "simplekeyframe" || type == "keyframe") {
1842 if (!effects.contains(i))
1843 effects[i] = effect.cloneNode().toElement();
1844 updateNormalKeyframes(param);
1846 } else if (type == "roto-spline") {
1847 if (!effects.contains(i))
1848 effects[i] = effect.cloneNode().toElement();
1849 QString value = param.attribute("value");
1850 if (adjustRotoDuration(&value, cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1))
1851 param.setAttribute("value", value);
1859 bool ClipItem::updateNormalKeyframes(QDomElement parameter)
1861 int in = cropStart().frames(m_fps);
1862 int out = (cropStart() + cropDuration()).frames(m_fps) - 1;
1864 const QStringList data = parameter.attribute("keyframes").split(';', QString::SkipEmptyParts);
1865 QMap <int, double> keyframes;
1866 foreach (QString keyframe, data)
1867 keyframes[keyframe.section(':', 0, 0).toInt()] = keyframe.section(':', 1, 1).toDouble();
1870 QMap<int, double>::iterator i = keyframes.end();
1872 double lastValue = 0;
1876 * Take care of resize from start
1878 bool startFound = false;
1879 while (i-- != keyframes.begin()) {
1880 if (i.key() < in && !startFound) {
1883 keyframes[in] = i.value();
1885 relPos = (in - i.key()) / (qreal)(lastPos - i.key() + 1);
1886 keyframes[in] = i.value() + (lastValue - i.value()) * relPos;
1890 lastValue = i.value();
1892 i = keyframes.erase(i);
1896 * Take care of resize from end
1898 i = keyframes.begin();
1900 bool endFound = false;
1901 while (i != keyframes.end()) {
1902 if (i.key() > out && !endFound) {
1905 keyframes[out] = i.value();
1907 relPos = (out - lastPos) / (qreal)(i.key() - lastPos + 1);
1908 keyframes[out] = lastValue + (i.value() - lastValue) * relPos;
1912 lastValue = i.value();
1914 i = keyframes.erase(i);
1919 if (startFound || endFound) {
1921 QMap<int, double>::const_iterator k = keyframes.constBegin();
1922 while (k != keyframes.constEnd()) {
1923 newkfr.append(QString::number(k.key()) + ':' + QString::number(qRound(k.value())) + ';');
1926 parameter.setAttribute("keyframes", newkfr);
1933 void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, ItemInfo oldInfo)
1935 QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
1937 Mlt::Geometry geometry(param.attribute("value").toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
1939 param.setAttribute("value", geometry.serialise(cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1));
1942 void ClipItem::slotGotThumbsCache()
1944 disconnect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache()));
1948 #include "clipitem.moc"