-AbstractClipItem::AbstractClipItem(const ItemInfo info, const QRectF& rect, double fps): QGraphicsRectItem(rect), m_track(0), m_fps(fps), m_editedKeyframe(-1), m_selectedKeyframe(0) {
- setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
- setTrack(info.track);
- m_startPos = info.startPos;
- m_cropDuration = info.endPos - info.startPos;
-}
-
-void AbstractClipItem::moveTo(int x, double scale, int offset, int newTrack) {
- double origX = rect().x();
- double origY = rect().y();
- bool success = true;
- if (x < 0) return;
- setRect(x * scale, origY + offset, rect().width(), rect().height());
- QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
- if (collisionList.size() == 0) m_track = newTrack;
- for (int i = 0; i < collisionList.size(); ++i) {
- QGraphicsItem *item = collisionList.at(i);
- if (item->type() == type()) {
- if (offset == 0) {
- QRectF other = ((QGraphicsRectItem *)item)->rect();
- if (x < m_startPos.frames(m_fps)) {
- kDebug() << "COLLISION, MOVING TO------";
- m_startPos = ((AbstractClipItem *)item)->endPos();
- origX = m_startPos.frames(m_fps) * scale;
- } else if (x > m_startPos.frames(m_fps)) {
- //kDebug() << "COLLISION, MOVING TO+++: "<<x<<", CLIP CURR POS: "<<m_startPos.frames(m_fps)<<", COLLIDING START: "<<((AbstractClipItem *)item)->startPos().frames(m_fps);
- m_startPos = ((AbstractClipItem *)item)->startPos() - m_cropDuration;
- origX = m_startPos.frames(m_fps) * scale;
- }
- }
- setRect(origX, origY, rect().width(), rect().height());
- offset = 0;
- origX = rect().x();
- success = false;
- break;
- }
- }
- if (success) {
- m_track = newTrack;
- m_startPos = GenTime(x, m_fps);
- }
- /* QList <QGraphicsItem *> childrenList = QGraphicsItem::children();
- for (int i = 0; i < childrenList.size(); ++i) {
- childrenList.at(i)->moveBy(rect().x() - origX , offset);
- }*/
+void AbstractClipItem::closeAnimation()
+{
+#if QT_VERSION >= 0x040600
+ if (m_closeAnimation) return;
+ setEnabled(false);
+ m_closeAnimation = new QPropertyAnimation(this, "rect");
+ connect(m_closeAnimation, SIGNAL(finished()), this, SLOT(deleteLater()));
+ m_closeAnimation->setDuration(200);
+ QRectF r = rect();
+ QRectF r2 = r;
+ r2.setLeft(r.left() + r.width() / 2);
+ r2.setTop(r.top() + r.height() / 2);
+ r2.setWidth(1);
+ r2.setHeight(1);
+ m_closeAnimation->setStartValue(r);
+ m_closeAnimation->setEndValue(r2);
+ m_closeAnimation->setEasingCurve(QEasingCurve::InQuad);
+ m_closeAnimation->start();
+#endif