X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fabstractgroupitem.cpp;h=4ea3e8783134c6a489897ce0c2b0613561618949;hb=27ac7e68c934a04d2922986b07ea8e5dde2cad50;hp=79364deb60109700e0b875eacbbcf532c33f4fbd;hpb=5f58037fe6286c608fc74bf3b08dd467b5630954;p=kdenlive diff --git a/src/abstractgroupitem.cpp b/src/abstractgroupitem.cpp index 79364deb..4ea3e878 100644 --- a/src/abstractgroupitem.cpp +++ b/src/abstractgroupitem.cpp @@ -32,6 +32,7 @@ #include #include + AbstractGroupItem::AbstractGroupItem(double /* fps */) : QObject(), QGraphicsItemGroup() @@ -114,7 +115,12 @@ QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, QPointF offset void AbstractGroupItem::addItem(QGraphicsItem * item) { addToGroup(item); - //fixItemRect(); + item->setFlag(QGraphicsItem::ItemIsMovable, false); +} + +void AbstractGroupItem::removeItem(QGraphicsItem * item) +{ + removeFromGroup(item); } void AbstractGroupItem::fixItemRect() @@ -136,18 +142,18 @@ void AbstractGroupItem::fixItemRect() // virtual void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *) { - const double scale = option->matrix.m11(); QColor bgcolor(100, 100, 200, 100); QRectF bound = option->exposedRect.adjusted(0, 0, 1, 1); p->setClipRect(bound); - p->fillRect(option->exposedRect, bgcolor); + 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); - //pen.setCosmetic(true); p->setPen(pen); - p->drawRect(boundingRect().adjusted(0, 0, - 1 / scale, 0)); + p->drawRoundedRect(mapped, 3, 3); } //virtual @@ -168,22 +174,18 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant //kDebug()<<"GRP XPOS:"<tracksCount() - (int)(boundingRect().height() + 5) / trackHeight); - correctedTrack = qMax(correctedTrack, 0); - - proposedTrack += (correctedTrack - realTrack); + int yOffset = property("y_absolute").toInt() + newPos.y(); + int proposedTrack = yOffset / trackHeight; // Check if top item is a clip or a transition int offset = 0; int topTrack = -1; QList children = childItems(); for (int i = 0; i < children.count(); i++) { - int currentTrack = (int)(children.at(i)->scenePos().y() / trackHeight); + int currentTrack = 0; + if (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET) currentTrack = static_cast (children.at(i))->track(); + else if (children.at(i)->type() == GROUPWIDGET) currentTrack = static_cast (children.at(i))->track(); + else continue; if (children.at(i)->type() == AVWIDGET) { if (topTrack == -1 || currentTrack <= topTrack) { offset = 0; @@ -359,8 +361,18 @@ void AbstractGroupItem::dropEvent(QGraphicsSceneDragDropEvent * event) QDomDocument doc; doc.setContent(effects, true); QDomElement e = doc.documentElement(); + e.setAttribute("kdenlive_ix", 0); CustomTrackView *view = (CustomTrackView *) scene()->views()[0]; - if (view) view->slotAddGroupEffect(e, this); + QPointF dropPos = event->scenePos(); + QList selection = scene()->items(dropPos); + AbstractClipItem *dropChild = NULL; + for (int i = 0; i < selection.count(); i++) { + if (selection.at(i)->type() == AVWIDGET) { + dropChild = (AbstractClipItem *) selection.at(i); + break; + } + } + if (view) view->slotAddGroupEffect(e, this, dropChild); } //virtual @@ -380,7 +392,17 @@ void AbstractGroupItem::mousePressEvent(QGraphicsSceneMouseEvent * event) if (event->modifiers() & Qt::ShiftModifier) { // User want to do a rectangle selection, so ignore the event to pass it to the view event->ignore(); - } else QGraphicsItem::mousePressEvent(event); + } else { + QList list = scene()->items(event->scenePos()); + // only allow group move if we click over an item in the group + foreach(const QGraphicsItem *item, list) { + if (item->type() == TRANSITIONWIDGET || item->type() == AVWIDGET) { + QGraphicsItem::mousePressEvent(event); + return; + } + } + event->ignore(); + } } void AbstractGroupItem::resizeStart(int diff)