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 ***************************************************************************/
24 #include <QStyleOptionGraphicsItem>
25 #include <QGraphicsScene>
26 #include <QGraphicsView>
29 #include <QApplication>
33 #include <mlt++/Mlt.h>
36 #include "customtrackview.h"
39 #include "kdenlivesettings.h"
41 ClipItem::ClipItem(DocClipBase *clip, int track, GenTime startpos, const QRectF & rect, GenTime duration, double fps)
42 : AbstractClipItem(rect), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_effectsCounter(1), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_thumbsRequested(0), m_hover(false) {
44 // kDebug() << "******* CREATING NEW TML CLIP, DUR: " << duration;
46 m_startPos = startpos;
48 m_xml = clip->toXML();
49 m_clipName = clip->name();
50 m_producer = clip->getId();
51 m_clipType = clip->clipType();
52 m_cropStart = GenTime();
53 m_maxDuration = duration;
54 if (duration != GenTime()) m_cropDuration = duration;
55 else m_cropDuration = m_maxDuration;
57 audioThumbReady = clip->audioThumbCreated();
59 m_cropStart = xml.attribute("in", 0).toInt();
60 m_maxDuration = xml.attribute("duration", 0).toInt();
61 if (m_maxDuration == 0) m_maxDuration = xml.attribute("out", 0).toInt() - m_cropStart;
63 if (duration != -1) m_cropDuration = duration;
64 else m_cropDuration = m_maxDuration;*/
67 setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
68 setAcceptsHoverEvents(true);
69 connect(this , SIGNAL(prepareAudioThumb(double, QPainterPath, int, int)) , this, SLOT(slotPrepareAudioThumb(double, QPainterPath, int, int)));
71 setBrush(QColor(141, 166, 215));
72 if (m_clipType == VIDEO || m_clipType == AV) {
74 connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
75 connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
76 connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
77 QTimer::singleShot(300, this, SLOT(slotFetchThumbs()));
79 startThumbTimer = new QTimer(this);
80 startThumbTimer->setSingleShot(true);
81 connect(startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
82 endThumbTimer = new QTimer(this);
83 endThumbTimer->setSingleShot(true);
84 connect(endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
86 } else if (m_clipType == COLOR) {
87 m_maxDuration = GenTime(10000, m_fps);
88 QString colour = m_xml.attribute("colour");
89 colour = colour.replace(0, 2, "#");
90 setBrush(QColor(colour.left(7)));
91 } else if (m_clipType == IMAGE) {
92 m_maxDuration = GenTime(10000, m_fps);
93 m_startPix = KThumb::getImage(KUrl(m_xml.attribute("resource")), (int)(50 * KdenliveSettings::project_display_ratio()), 50);
94 } else if (m_clipType == AUDIO) {
95 connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
100 ClipItem::~ClipItem() {
101 if (startThumbTimer) delete startThumbTimer;
102 if (endThumbTimer) delete endThumbTimer;
105 void ClipItem::resetThumbs() {
107 audioThumbCachePic.clear();
110 void ClipItem::slotFetchThumbs() {
111 m_thumbsRequested += 2;
112 emit getThumb((int)m_cropStart.frames(m_fps), (int)(m_cropStart + m_cropDuration).frames(m_fps));
115 void ClipItem::slotGetStartThumb() {
117 emit getThumb((int)m_cropStart.frames(m_fps), -1);
120 void ClipItem::slotGetEndThumb() {
122 emit getThumb(-1, (int)(m_cropStart + m_cropDuration).frames(m_fps));
125 void ClipItem::slotThumbReady(int frame, QPixmap pix) {
126 if (m_thumbsRequested == 0) return;
127 if (frame == m_cropStart.frames(m_fps)) m_startPix = pix;
133 void ClipItem::slotGotAudioData() {
134 audioThumbReady = true;
138 int ClipItem::type() const {
142 DocClipBase *ClipItem::baseClip() {
146 QDomElement ClipItem::xml() const {
150 int ClipItem::clipType() {
154 QString ClipItem::clipName() {
158 int ClipItem::clipProducer() {
162 void ClipItem::flashClip() {
163 if (m_timeLine == 0) {
164 m_timeLine = new QTimeLine(750, this);
165 connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animate(qreal)));
170 void ClipItem::animate(qreal value) {
176 void ClipItem::paint(QPainter *painter,
177 const QStyleOptionGraphicsItem *option,
179 painter->setOpacity(m_opacity);
180 QBrush paintColor = brush();
182 if (isSelected()) paintColor = QBrush(QColor(79, 93, 121));
184 double scale = br.width() / m_cropDuration.frames(m_fps);
185 QRect rectInView = visibleRect();//this is the rect that is visible by the user
187 if (rectInView.isNull())
189 QPainterPath clippath;
190 clippath.addRect(rectInView);
192 int startpixel = (int)(rectInView.x() - rect().x()); //start and endpixel that is viewable from rect()
196 int endpixel = rectInView.width() + rectInView.x();
200 //painter->setRenderHints(QPainter::Antialiasing);
202 QPainterPath roundRectPathUpper = upperRectPart(br), roundRectPathLower = lowerRectPart(br);
204 painter->setClipRect(option->exposedRect);
206 // build path around clip
208 QPainterPath resultClipPath = roundRectPathUpper.united(roundRectPathLower);
210 painter->setClipPath(resultClipPath.intersected(clippath), Qt::IntersectClip);
211 //painter->fillPath(roundRectPath, brush()); //, QBrush(QColor(Qt::red)));
212 painter->fillRect(br.intersected(rectInView), paintColor);
213 //painter->fillRect(QRectF(br.x() + br.width() - m_endPix.width(), br.y(), m_endPix.width(), br.height()), QBrush(QColor(Qt::black)));
216 if (!m_startPix.isNull() && KdenliveSettings::videothumbnails()) {
217 if (m_clipType == IMAGE) {
218 painter->drawPixmap(QPointF(br.x() + br.width() - m_startPix.width(), br.y()), m_startPix);
219 QLineF l(br.x() + br.width() - m_startPix.width(), br.y(), br.x() + br.width() - m_startPix.width(), br.y() + br.height());
220 painter->drawLine(l);
222 painter->drawPixmap(QPointF(br.x() + br.width() - m_endPix.width(), br.y()), m_endPix);
223 QLineF l(br.x() + br.width() - m_endPix.width(), br.y(), br.x() + br.width() - m_endPix.width(), br.y() + br.height());
224 painter->drawLine(l);
227 painter->drawPixmap(QPointF(br.x(), br.y()), m_startPix);
228 QLineF l2(br.x() + m_startPix.width(), br.y(), br.x() + m_startPix.width(), br.y() + br.height());
229 painter->drawLine(l2);
232 // draw audio thumbnails
233 if ((m_clipType == AV || m_clipType == AUDIO) && audioThumbReady && KdenliveSettings::audiothumbnails()) {
235 QPainterPath path = m_clipType == AV ? roundRectPathLower : roundRectPathUpper.united(roundRectPathLower);
236 if (m_clipType == AV) painter->fillPath(path, QBrush(QColor(200, 200, 200, 140)));
239 if (scale != framePixelWidth)
240 audioThumbCachePic.clear();
241 emit prepareAudioThumb(scale, path, startpixel, endpixel + 200);//200 more for less missing parts before repaint after scrolling
242 int cropLeft = (m_cropStart).frames(m_fps) * scale;
243 for (int startCache = startpixel - startpixel % 100; startCache < endpixel + 300;startCache += 100) {
244 if (audioThumbCachePic.contains(startCache) && !audioThumbCachePic[startCache].isNull())
245 painter->drawPixmap((int)(roundRectPathUpper.united(roundRectPathLower).boundingRect().x() + startCache - cropLeft), (int)(path.boundingRect().y()), audioThumbCachePic[startCache]);
250 // draw start / end fades
253 fades = QBrush(QColor(200, 50, 50, 150));
254 } else fades = QBrush(QColor(200, 200, 200, 200));
256 if (m_startFade != 0) {
257 QPainterPath fadeInPath;
258 fadeInPath.moveTo(br.x() , br.y());
259 fadeInPath.lineTo(br.x() , br.y() + br.height());
260 fadeInPath.lineTo(br.x() + m_startFade * scale, br.y());
261 fadeInPath.closeSubpath();
262 painter->fillPath(fadeInPath, fades);
264 QLineF l(br.x() + m_startFade * scale, br.y(), br.x(), br.y() + br.height());
265 painter->drawLine(l);
268 if (m_endFade != 0) {
269 QPainterPath fadeOutPath;
270 fadeOutPath.moveTo(br.x() + br.width(), br.y());
271 fadeOutPath.lineTo(br.x() + br.width(), br.y() + br.height());
272 fadeOutPath.lineTo(br.x() + br.width() - m_endFade * scale, br.y());
273 fadeOutPath.closeSubpath();
274 painter->fillPath(fadeOutPath, fades);
276 QLineF l(br.x() + br.width() - m_endFade * scale, br.y(), br.x() + br.width(), br.y() + br.height());
277 painter->drawLine(l);
281 QPen pen = painter->pen();
282 pen.setColor(Qt::white);
283 //pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
285 // Draw effects names
286 QString effects = effectNames().join(" / ");
287 if (!effects.isEmpty()) {
288 painter->setPen(pen);
289 QFont font = painter->font();
290 QFont smallFont = font;
291 smallFont.setPointSize(8);
292 painter->setFont(smallFont);
293 QRectF txtBounding = painter->boundingRect(br, Qt::AlignLeft | Qt::AlignTop, " " + effects + " ");
294 painter->fillRect(txtBounding, QBrush(QColor(0, 0, 0, 150)));
295 painter->drawText(txtBounding, Qt::AlignCenter, effects);
296 pen.setColor(Qt::black);
297 painter->setPen(pen);
298 painter->setFont(font);
301 // For testing puspose only: draw transitions count
303 painter->setPen(pen);
304 QFont font = painter->font();
305 QFont smallFont = font;
306 smallFont.setPointSize(8);
307 painter->setFont(smallFont);
308 QString txt = " Transitions: " + QString::number(m_transitionsList.count()) + " ";
309 QRectF txtBoundin = painter->boundingRect(br, Qt::AlignRight | Qt::AlignTop, txt);
310 painter->fillRect(txtBoundin, QBrush(QColor(0, 0, 0, 150)));
311 painter->drawText(txtBoundin, Qt::AlignCenter, txt);
312 pen.setColor(Qt::black);
313 painter->setPen(pen);
314 painter->setFont(font);
318 QRectF txtBounding = painter->boundingRect(br, Qt::AlignHCenter | Qt::AlignTop, " " + m_clipName + " ");
319 painter->fillRect(txtBounding, QBrush(QColor(255, 255, 255, 150)));
320 painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
322 // draw frame around clip
324 pen.setColor(Qt::red);
327 pen.setColor(Qt::black);
330 painter->setPen(pen);
331 painter->setClipRect(option->exposedRect);
332 painter->drawPath(resultClipPath.intersected(clippath));
334 //painter->fillRect(startpixel,0,startpixel+endpixel,(int)br.height(), QBrush(QColor(255,255,255,150)));
335 //painter->fillRect(QRect(br.x(), br.y(), roundingX, roundingY), QBrush(QColor(Qt::green)));
337 /*QRectF recta(rect().x(), rect().y(), scale,rect().height());
338 painter->drawRect(recta);
339 painter->drawLine(rect().x() + 1, rect().y(), rect().x() + 1, rect().y() + rect().height());
340 painter->drawLine(rect().x() + rect().width(), rect().y(), rect().x() + rect().width(), rect().y() + rect().height());
341 painter->setPen(QPen(Qt::black, 1.0));
342 painter->drawLine(rect().x(), rect().y(), rect().x() + rect().width(), rect().y());
343 painter->drawLine(rect().x(), rect().y() + rect().height(), rect().x() + rect().width(), rect().y() + rect().height());*/
345 //QGraphicsRectItem::paint(painter, option, widget);
346 //QPen pen(Qt::green, 1.0 / size.x() + 0.5);
347 //painter->setPen(pen);
348 //painter->drawLine(rect().x(), rect().y(), rect().x() + rect().width(), rect().y());
349 //kDebug()<<"ITEM REPAINT RECT: "<<boundingRect().width();
350 //painter->drawText(rect(), Qt::AlignCenter, m_name);
351 // painter->drawRect(boundingRect());
352 //painter->drawRoundRect(-10, -10, 20, 20);
354 painter->setPen(QPen(Qt::black));
355 painter->setBrush(QBrush(Qt::yellow));
356 painter->drawEllipse((int)(br.x() + 10), (int)(br.y() + br.height() / 2 - 5) , 10, 10);
357 painter->drawEllipse((int)(br.x() + br.width() - 20), (int)(br.y() + br.height() / 2 - 5), 10, 10);
362 OPERATIONTYPE ClipItem::operationMode(QPointF pos, double scale) {
363 if (abs((int)(pos.x() - (rect().x() + scale * m_startFade))) < 6 && abs((int)(pos.y() - rect().y())) < 6) return FADEIN;
364 else if (abs((int)(pos.x() - rect().x())) < 6) return RESIZESTART;
365 else if (abs((int)(pos.x() - (rect().x() + rect().width() - scale * m_endFade))) < 6 && abs((int)(pos.y() - rect().y())) < 6) return FADEOUT;
366 else if (abs((int)(pos.x() - (rect().x() + rect().width()))) < 6) return RESIZEEND;
367 else if (abs((int)(pos.x() - (rect().x() + 10))) < 6 && abs((int)(pos.y() - (rect().y() + rect().height() / 2 - 5))) < 6) return TRANSITIONSTART;
368 else if (abs((int)(pos.x() - (rect().x() + rect().width() - 20))) < 6 && abs((int)(pos.y() - (rect().y() + rect().height() / 2 - 5))) < 6) return TRANSITIONEND;
373 void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, QPainterPath path, int startpixel, int endpixel) {
376 QRectF re = path.boundingRect();
378 //if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
380 for (int startCache = startpixel - startpixel % 100;startCache + 100 < endpixel ;startCache += 100) {
381 //kDebug() << "creating " << startCache;
382 //if (framePixelWidth!=pixelForOneFrame ||
383 if (framePixelWidth == pixelForOneFrame && audioThumbCachePic.contains(startCache))
385 if (audioThumbCachePic[startCache].isNull() || framePixelWidth != pixelForOneFrame) {
386 audioThumbCachePic[startCache] = QPixmap(100, (int)(re.height()));
387 audioThumbCachePic[startCache].fill(QColor(200, 200, 200, 0));
389 bool fullAreaDraw = pixelForOneFrame < 10;
390 QMap<int, QPainterPath > positiveChannelPaths;
391 QMap<int, QPainterPath > negativeChannelPaths;
392 QPainter pixpainter(&audioThumbCachePic[startCache]);
394 audiopen.setWidth(0);
395 pixpainter.setPen(audiopen);
396 //pixpainter.setRenderHint(QPainter::Antialiasing,true);
397 //pixpainter.drawLine(0,0,100,re.height());
398 int channelHeight = audioThumbCachePic[startCache].height() / channels;
400 for (int i = 0;i < channels;i++) {
402 positiveChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
403 negativeChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
406 for (int samples = 0;samples <= 100;samples++) {
407 double frame = (double)(samples + startCache - 0) / pixelForOneFrame;
408 int sample = (int)((frame - (int)(frame)) * 20); // AUDIO_FRAME_SIZE
409 if (frame < 0 || sample < 0 || sample > 19)
411 QMap<int, QByteArray> frame_channel_data = baseClip()->audioFrameChache[(int)frame];
413 for (int channel = 0;channel < channels && frame_channel_data[channel].size() > 0;channel++) {
415 int y = channelHeight * channel + channelHeight / 2;
416 int delta = (int)(frame_channel_data[channel][sample] - 127 / 2) * channelHeight / 64;
418 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + qAbs(delta));
419 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - qAbs(delta));
421 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + delta);
422 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - delta);
425 for (int channel = 0;channel < channels ;channel++)
426 if (fullAreaDraw && samples == 100) {
427 positiveChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
428 negativeChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
429 positiveChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
430 negativeChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
434 if (m_clipType != AV) pixpainter.setBrush(QBrush(QColor(200, 200, 100)));
436 pixpainter.setPen(QPen(QColor(0, 0, 0)));
437 pixpainter.setBrush(QBrush(QColor(60, 60, 60)));
439 for (int i = 0;i < channels;i++) {
441 //pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
442 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
444 pixpainter.drawPath(positiveChannelPaths[i]);
447 //audioThumbWasDrawn=true;
448 framePixelWidth = pixelForOneFrame;
455 void ClipItem::setFadeIn(int pos, double scale) {
456 int oldIn = m_startFade;
457 if (pos < 0) pos = 0;
458 if (pos > m_cropDuration.frames(m_fps)) pos = (int)(m_cropDuration.frames(m_fps) / 2);
460 if (oldIn > pos) update(rect().x(), rect().y(), oldIn * scale, rect().height());
461 else update(rect().x(), rect().y(), pos * scale, rect().height());
464 void ClipItem::setFadeOut(int pos, double scale) {
465 int oldOut = m_endFade;
466 if (pos < 0) pos = 0;
467 if (pos > m_cropDuration.frames(m_fps)) pos = (int)(m_cropDuration.frames(m_fps) / 2);
469 if (oldOut > pos) update(rect().x() + rect().width() - pos * scale, rect().y(), pos * scale, rect().height());
470 else update(rect().x() + rect().width() - oldOut * scale, rect().y(), oldOut * scale, rect().height());
476 void ClipItem::mousePressEvent(QGraphicsSceneMouseEvent * event) {
477 /*m_resizeMode = operationMode(event->pos());
478 if (m_resizeMode == MOVE) {
479 m_maxTrack = scene()->sceneRect().height();
480 m_grabPoint = (int) (event->pos().x() - rect().x());
482 QGraphicsRectItem::mousePressEvent(event);
486 void ClipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) {
488 QGraphicsRectItem::mouseReleaseEvent(event);
492 void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *) {
498 void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
503 void ClipItem::resizeStart(int posx, double scale) {
504 AbstractClipItem::resizeStart(posx, scale);
505 if (m_hasThumbs) startThumbTimer->start(100);
508 void ClipItem::resizeEnd(int posx, double scale) {
509 AbstractClipItem::resizeEnd(posx, scale);
510 if (m_hasThumbs) endThumbTimer->start(100);
514 void ClipItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
517 int ClipItem::effectsCounter() {
518 return m_effectsCounter++;
521 int ClipItem::effectsCount() {
522 return m_effectList.size();
525 QStringList ClipItem::effectNames() {
526 return m_effectList.effectNames();
529 QDomElement ClipItem::effectAt(int ix) {
530 return m_effectList.at(ix);
533 void ClipItem::setEffectAt(int ix, QDomElement effect) {
534 kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
535 m_effectList.insert(ix, effect);
536 m_effectList.removeAt(ix + 1);
537 update(boundingRect());
540 QMap <QString, QString> ClipItem::addEffect(QDomElement effect) {
541 QMap <QString, QString> effectParams;
542 m_effectList.append(effect);
543 effectParams["tag"] = effect.attribute("tag");
544 effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
545 QString state = effect.attribute("disabled");
546 if (!state.isEmpty()) effectParams["disabled"] = state;
547 QDomNodeList params = effect.elementsByTagName("parameter");
548 for (int i = 0; i < params.count(); i++) {
549 QDomElement e = params.item(i).toElement();
551 effectParams[e.attribute("name")] = e.attribute("value");
553 if (!e.attribute("factor").isEmpty()) {
554 effectParams[e.attribute("name")] = QString::number(effectParams[e.attribute("name")].toDouble() / e.attribute("factor").toDouble());
558 update(boundingRect());
562 QMap <QString, QString> ClipItem::getEffectArgs(QDomElement effect) {
563 QMap <QString, QString> effectParams;
564 effectParams["tag"] = effect.attribute("tag");
565 effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
566 QString state = effect.attribute("disabled");
567 if (!state.isEmpty()) effectParams["disabled"] = state;
568 QDomNodeList params = effect.elementsByTagName("parameter");
569 for (int i = 0; i < params.count(); i++) {
570 QDomElement e = params.item(i).toElement();
571 if (e.attribute("name").contains(";")) {
572 QString format = e.attribute("format");
573 QStringList separators = format.split("%d", QString::SkipEmptyParts);
574 QStringList values = e.attribute("value").split(QRegExp("[,:;x]"));
576 QTextStream txtNeu(&neu);
577 if (values.size() > 0)
578 txtNeu << (int)values[0].toDouble();
579 for (int i = 0;i < separators.size() && i + 1 < values.size();i++) {
580 txtNeu << separators[i];
581 txtNeu << (int)(values[i+1].toDouble());
583 effectParams["start"] = neu;
586 effectParams[e.attribute("name")] = e.attribute("value");
588 if (!e.attribute("factor").isEmpty()) {
589 effectParams[e.attribute("name")] = QString::number(effectParams[e.attribute("name")].toDouble() / e.attribute("factor").toDouble());
595 void ClipItem::deleteEffect(QString index) {
596 for (int i = 0; i < m_effectList.size(); ++i) {
597 if (m_effectList.at(i).attribute("kdenlive_ix") == index) {
598 m_effectList.removeAt(i);
603 update(boundingRect());
607 void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event) {
608 QString effects = QString(event->mimeData()->data("kdenlive/effectslist"));
610 doc.setContent(effects, true);
611 QDomElement e = doc.documentElement();
612 CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
613 if (view) view->slotAddEffect(e, m_startPos, m_track);
617 void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
618 event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
621 void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) {
624 void ClipItem::addTransition(Transition* t) {
625 m_transitionsList.append(t);
626 CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
628 QDomElement e = doc.documentElement();
629 if (view) view->slotAddTransition(this, t->toXML() , t->startPos(), track());
633 void CustomTrackView::mousePressEvent ( QMouseEvent * event )
635 int pos = event->x();
636 if (event->modifiers() == Qt::ControlModifier)
637 setDragMode(QGraphicsView::ScrollHandDrag);
638 else if (event->modifiers() == Qt::ShiftModifier)
639 setDragMode(QGraphicsView::RubberBandDrag);
641 QGraphicsItem * item = itemAt(event->pos());
644 else emit cursorMoved((int) mapToScene(event->x(), 0).x());
647 QGraphicsView::mousePressEvent(event);
650 void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
652 QGraphicsView::mouseReleaseEvent(event);
653 setDragMode(QGraphicsView::NoDrag);
657 #include "clipitem.moc"