]> git.sesse.net Git - kdenlive/blobdiff - src/abstractgroupitem.cpp
Remove some not necessary endline
[kdenlive] / src / abstractgroupitem.cpp
index abf061c7a4382a80655c755721dc7dc088af2352..e52a8a336f3736ca40600cbf422c77129c86aa45 100644 (file)
@@ -92,6 +92,11 @@ CustomTrackScene* AbstractGroupItem::projectScene()
     return NULL;
 }
 
+QPainterPath AbstractGroupItem::clipGroupSpacerShape(QPointF offset) const
+{
+    return spacerGroupShape(AVWIDGET, offset);
+}
+
 QPainterPath AbstractGroupItem::clipGroupShape(QPointF offset) const
 {
     return groupShape(AVWIDGET, offset);
@@ -102,11 +107,11 @@ QPainterPath AbstractGroupItem::transitionGroupShape(QPointF offset) const
     return groupShape(TRANSITIONWIDGET, offset);
 }
 
-QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, QPointF offset) const
+QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, const QPointF &offset) const
 {
     QPainterPath path;
     QList<QGraphicsItem *> children = childItems();
-    for (int i = 0; i < children.count(); i++) {
+    for (int i = 0; i < children.count(); ++i) {
         if (children.at(i)->type() == (int)type) {
             QRectF r(children.at(i)->sceneBoundingRect());
             r.translate(offset);
@@ -125,6 +130,31 @@ QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, QPointF offset
     return path;
 }
 
+QPainterPath AbstractGroupItem::spacerGroupShape(GRAPHICSRECTITEM type, const QPointF &offset) const
+{
+    QPainterPath path;
+    QList<QGraphicsItem *> children = childItems();
+    for (int i = 0; i < children.count(); ++i) {
+        if (children.at(i)->type() == (int)type) {
+            QRectF r(children.at(i)->sceneBoundingRect());
+            r.translate(offset);
+           r.setRight(scene()->width());
+            path.addRect(r);
+        } else if (children.at(i)->type() == GROUPWIDGET) {
+            QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+            for (int j = 0; j < subchildren.count(); j++) {
+                if (subchildren.at(j)->type() == (int)type) {
+                    QRectF r(subchildren.at(j)->sceneBoundingRect());
+                    r.translate(offset);
+                   r.setRight(scene()->width());
+                    path.addRect(r);
+                }
+            }
+        }
+    }
+    return path;
+}
+
 void AbstractGroupItem::addItem(QGraphicsItem * item)
 {
     addToGroup(item);
@@ -158,15 +188,13 @@ void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *optio
     QColor bgcolor(100, 100, 200, 100);
     QRectF bound = option->exposedRect.adjusted(0, 0, 1, 1);
     p->setClipRect(bound);
-    const QRectF mapped = p->worldTransform().mapRect(option->exposedRect);
-    p->setWorldMatrixEnabled(false);
     p->setBrush(bgcolor);
     QPen pen = p->pen();
     pen.setColor(QColor(200, 90, 90));
     pen.setStyle(Qt::DashLine);
     pen.setWidthF(0.0);
     p->setPen(pen);
-    p->drawRoundedRect(mapped, 3, 3);
+    p->drawRoundedRect(boundingRect().adjusted(0, 0, -1, 0), 3, 3);
 }
 
 //virtual
@@ -184,7 +212,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         int xpos = projectScene()->getSnapPointForPos((int)(start.x() + newPos.x() - pos().x()), KdenliveSettings::snaptopoints());
 
         xpos = qMax(xpos, 0);
-        //kDebug()<<"GRP XPOS:"<<xpos<<", START:"<<start.x()<<",NEW:"<<newPos.x()<<"; SCENE:"<<scenePos().x()<<",POS:"<<pos().x();
+        //kDebug()<<"GRP XPOS:"<<xpos<<", START:"<<start.x()<<",NEW:"<<newPos.x()<<"; SCENE:"<<scenePos().x()<<",POS:"<<pos().x();
         newPos.setX((int)(pos().x() + xpos - (int) start.x()));
        QStringList lockedTracks = property("locked_tracks").toStringList();
         int proposedTrack = (property("y_absolute").toInt() + newPos.y()) / trackHeight;
@@ -193,7 +221,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         int topTrack = -1;
        QList<int> groupTracks;
         QList<QGraphicsItem *> children = childItems();
-        for (int i = 0; i < children.count(); i++) {
+        for (int i = 0; i < children.count(); ++i) {
             int currentTrack = 0;
            if (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET) {
                currentTrack = static_cast <AbstractClipItem*> (children.at(i))->track();
@@ -239,7 +267,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         // Check no clip in the group goes outside of existing tracks
         int maximumTrack = projectScene()->tracksCount() - 1;
        int groupHeight = 0;
-       for (int i = 0; i < groupTracks.count(); i++) {
+       for (int i = 0; i < groupTracks.count(); ++i) {
            int offset = groupTracks.at(i) - topTrack;
            if (offset > groupHeight) groupHeight = offset; 
        }
@@ -248,7 +276,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         proposedTrack = qMax(proposedTrack, 0);
        int groupOffset = proposedTrack - topTrack;
        if (!lockedTracks.isEmpty()) {
-           for (int i = 0; i < groupTracks.count(); i++) {
+           for (int i = 0; i < groupTracks.count(); ++i) {
                if (lockedTracks.contains(QString::number(groupTracks.at(i) + groupOffset))) {
                    return pos();
                }
@@ -268,7 +296,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
             shape = clipGroupShape(newPos - pos());
             collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
             collidingItems.removeAll(this);
-            for (int i = 0; i < children.count(); i++) {
+            for (int i = 0; i < children.count(); ++i) {
                 if (children.at(i)->type() == GROUPWIDGET) {
                     QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
                     for (int j = 0; j < subchildren.count(); j++) {
@@ -281,7 +309,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         if (!collidingItems.isEmpty()) {
             bool forwardMove = xpos > start.x();
             int offset = 0;
-            for (int i = 0; i < collidingItems.count(); i++) {
+            for (int i = 0; i < collidingItems.count(); ++i) {
                 QGraphicsItem *collision = collidingItems.at(i);
                 if (collision->type() == AVWIDGET) {
                     // Collision
@@ -314,7 +342,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
                 // If there is still a collision after our position adjust, restore original pos
                 collidingItems = scene()->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape);
                 collidingItems.removeAll(this);
-                for (int i = 0; i < children.count(); i++) {
+                for (int i = 0; i < children.count(); ++i) {
                     if (children.at(i)->type() == GROUPWIDGET) {
                         QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
                         for (int j = 0; j < subchildren.count(); j++) {
@@ -323,7 +351,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
                     }
                     collidingItems.removeAll(children.at(i));
                 }
-                for (int i = 0; i < collidingItems.count(); i++)
+                for (int i = 0; i < collidingItems.count(); ++i)
                     if (collidingItems.at(i)->type() == AVWIDGET) return pos();
             }
         }
@@ -332,7 +360,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
             shape = transitionGroupShape(newPos - pos());
             collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
             collidingItems.removeAll(this);
-            for (int i = 0; i < children.count(); i++) {
+            for (int i = 0; i < children.count(); ++i) {
                 if (children.at(i)->type() == GROUPWIDGET) {
                     QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
                     for (int j = 0; j < subchildren.count(); j++) {
@@ -346,7 +374,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         else {
             bool forwardMove = xpos > start.x();
             int offset = 0;
-            for (int i = 0; i < collidingItems.count(); i++) {
+            for (int i = 0; i < collidingItems.count(); ++i) {
                 QGraphicsItem *collision = collidingItems.at(i);
                 if (collision->type() == TRANSITIONWIDGET) {
                     // Collision
@@ -378,10 +406,10 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
                 }
                 // If there is still a collision after our position adjust, restore original pos
                 collidingItems = scene()->items(transitionGroupShape(newPos - pos()), Qt::IntersectsItemShape);
-                for (int i = 0; i < children.count(); i++) {
+                for (int i = 0; i < children.count(); ++i) {
                     collidingItems.removeAll(children.at(i));
                 }
-                for (int i = 0; i < collidingItems.count(); i++)
+                for (int i = 0; i < collidingItems.count(); ++i)
                     if (collidingItems.at(i)->type() == TRANSITIONWIDGET) return pos();
             }
         }
@@ -402,7 +430,7 @@ void AbstractGroupItem::dropEvent(QGraphicsSceneDragDropEvent * event)
     QPointF dropPos = event->scenePos();
     QList<QGraphicsItem *> selection = scene()->items(dropPos);
     AbstractClipItem *dropChild = NULL;
-    for (int i = 0; i < selection.count(); i++) {
+    for (int i = 0; i < selection.count(); ++i) {
        if (selection.at(i)->type() == AVWIDGET) {
             dropChild = (AbstractClipItem *) selection.at(i);
            break;
@@ -526,3 +554,5 @@ GenTime AbstractGroupItem::duration()
     }
     return end - start;
 }
+
+#include "abstractgroupitem.moc"