X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fabstractgroupitem.cpp;h=15770b8d20cfe62e5a9fefd8be0217c7733e0685;hb=c24658bd34221d735f0641c924b890e1a6be7101;hp=ba40dd719cacc4995089387688dc0f860ab5f86f;hpb=817cce999d550f2ad3b6bef882810a67915f2ed5;p=kdenlive diff --git a/src/abstractgroupitem.cpp b/src/abstractgroupitem.cpp index ba40dd71..15770b8d 100644 --- a/src/abstractgroupitem.cpp +++ b/src/abstractgroupitem.cpp @@ -34,8 +34,8 @@ AbstractGroupItem::AbstractGroupItem(double /* fps */) : - QObject(), - QGraphicsItemGroup() + QObject(), + QGraphicsItemGroup() { setZValue(1); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); @@ -48,7 +48,7 @@ AbstractGroupItem::AbstractGroupItem(double /* fps */) : int AbstractGroupItem::type() const { - return GROUPWIDGET; + return GroupWidget; } int AbstractGroupItem::track() const @@ -57,14 +57,14 @@ int AbstractGroupItem::track() const int topTrack = -1; QList children = childItems(); for (int i = 0; i < children.count(); ++i) { - if (children.at(i)->type() == GROUPWIDGET) { - children.append(children.at(i)->childItems()); - continue; - } + if (children.at(i)->type() == GroupWidget) { + children.append(children.at(i)->childItems()); + continue; + } AbstractClipItem *item = static_cast (children.at(i)); if (item && (topTrack == -1 || topTrack > item->track())) { - topTrack = item->track(); - } + topTrack = item->track(); + } } return topTrack; } @@ -94,20 +94,20 @@ CustomTrackScene* AbstractGroupItem::projectScene() QPainterPath AbstractGroupItem::clipGroupSpacerShape(const QPointF &offset) const { - return spacerGroupShape(AVWIDGET, offset); + return spacerGroupShape(AVWidget, offset); } QPainterPath AbstractGroupItem::clipGroupShape(const QPointF &offset) const { - return groupShape(AVWIDGET, offset); + return groupShape(AVWidget, offset); } QPainterPath AbstractGroupItem::transitionGroupShape(const QPointF &offset) const { - return groupShape(TRANSITIONWIDGET, offset); + return groupShape(TransitionWidget, offset); } -QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, const QPointF &offset) const +QPainterPath AbstractGroupItem::groupShape(GraphicsRectItem type, const QPointF &offset) const { QPainterPath path; QList children = childItems(); @@ -116,7 +116,7 @@ QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, const QPointF QRectF r(children.at(i)->sceneBoundingRect()); r.translate(offset); path.addRect(r); - } else if (children.at(i)->type() == GROUPWIDGET) { + } else if (children.at(i)->type() == GroupWidget) { QList subchildren = children.at(i)->childItems(); for (int j = 0; j < subchildren.count(); j++) { if (subchildren.at(j)->type() == (int)type) { @@ -130,7 +130,7 @@ QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, const QPointF return path; } -QPainterPath AbstractGroupItem::spacerGroupShape(GRAPHICSRECTITEM type, const QPointF &offset) const +QPainterPath AbstractGroupItem::spacerGroupShape(GraphicsRectItem type, const QPointF &offset) const { QPainterPath path; QList children = childItems(); @@ -138,15 +138,15 @@ QPainterPath AbstractGroupItem::spacerGroupShape(GRAPHICSRECTITEM type, const QP if (children.at(i)->type() == (int)type) { QRectF r(children.at(i)->sceneBoundingRect()); r.translate(offset); - r.setRight(scene()->width()); + r.setRight(scene()->width()); path.addRect(r); - } else if (children.at(i)->type() == GROUPWIDGET) { + } else if (children.at(i)->type() == GroupWidget) { QList 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()); + r.setRight(scene()->width()); path.addRect(r); } } @@ -214,40 +214,40 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant xpos = qMax(xpos, 0); //kDebug()<<"GRP XPOS:"< groupTracks; + QList groupTracks; QList children = childItems(); 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 (children.at(i))->track(); - if (!groupTracks.contains(currentTrack)) groupTracks.append(currentTrack); - } - else if (children.at(i)->type() == GROUPWIDGET) { - currentTrack = static_cast (children.at(i))->track(); - } - else continue; - if (children.at(i)->type() == AVWIDGET) { + if (children.at(i)->type() == AVWidget || children.at(i)->type() == TransitionWidget) { + currentTrack = static_cast (children.at(i))->track(); + if (!groupTracks.contains(currentTrack)) groupTracks.append(currentTrack); + } + 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; topTrack = currentTrack; } - } else if (children.at(i)->type() == TRANSITIONWIDGET) { + } else if (children.at(i)->type() == TransitionWidget) { if (topTrack == -1 || currentTrack < topTrack) { offset = (int)(trackHeight / 3 * 2 - 1); topTrack = currentTrack; } - } else if (children.at(i)->type() == GROUPWIDGET) { + } else if (children.at(i)->type() == GroupWidget) { QList subchildren = children.at(i)->childItems(); bool clipGroup = false; for (int j = 0; j < subchildren.count(); j++) { - if (subchildren.at(j)->type() == AVWIDGET || subchildren.at(j)->type() == TRANSITIONWIDGET) { - int subTrack = static_cast (subchildren.at(j))->track(); - if (!groupTracks.contains(subTrack)) groupTracks.append(subTrack); + if (subchildren.at(j)->type() == AVWidget || subchildren.at(j)->type() == TransitionWidget) { + int subTrack = static_cast (subchildren.at(j))->track(); + if (!groupTracks.contains(subTrack)) groupTracks.append(subTrack); clipGroup = true; } } @@ -266,22 +266,22 @@ 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) { - int offset = groupTracks.at(i) - topTrack; - if (offset > groupHeight) groupHeight = offset; - } - maximumTrack -= groupHeight; + int groupHeight = 0; + for (int i = 0; i < groupTracks.count(); ++i) { + int offset = groupTracks.at(i) - topTrack; + if (offset > groupHeight) groupHeight = offset; + } + maximumTrack -= groupHeight; proposedTrack = qMin(proposedTrack, maximumTrack); proposedTrack = qMax(proposedTrack, 0); - int groupOffset = proposedTrack - topTrack; - if (!lockedTracks.isEmpty()) { - for (int i = 0; i < groupTracks.count(); ++i) { - if (lockedTracks.contains(QString::number(groupTracks.at(i) + groupOffset))) { - return pos(); - } - } - } + int groupOffset = proposedTrack - topTrack; + if (!lockedTracks.isEmpty()) { + for (int i = 0; i < groupTracks.count(); ++i) { + if (lockedTracks.contains(QString::number(groupTracks.at(i) + groupOffset))) { + return pos(); + } + } + } newPos.setY((int)((proposedTrack) * trackHeight) + offset); //if (newPos == start) return start; @@ -297,7 +297,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant collidingItems = scene()->items(shape, Qt::IntersectsItemShape); collidingItems.removeAll(this); for (int i = 0; i < children.count(); ++i) { - if (children.at(i)->type() == GROUPWIDGET) { + if (children.at(i)->type() == GroupWidget) { QList subchildren = children.at(i)->childItems(); for (int j = 0; j < subchildren.count(); j++) { collidingItems.removeAll(subchildren.at(j)); @@ -311,7 +311,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant int offset = 0; for (int i = 0; i < collidingItems.count(); ++i) { QGraphicsItem *collision = collidingItems.at(i); - if (collision->type() == AVWIDGET) { + if (collision->type() == AVWidget) { // Collision if (newPos.y() != pos().y()) { // Track change results in collision, restore original position @@ -343,7 +343,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant collidingItems = scene()->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape); collidingItems.removeAll(this); for (int i = 0; i < children.count(); ++i) { - if (children.at(i)->type() == GROUPWIDGET) { + if (children.at(i)->type() == GroupWidget) { QList subchildren = children.at(i)->childItems(); for (int j = 0; j < subchildren.count(); j++) { collidingItems.removeAll(subchildren.at(j)); @@ -352,7 +352,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant collidingItems.removeAll(children.at(i)); } for (int i = 0; i < collidingItems.count(); ++i) - if (collidingItems.at(i)->type() == AVWIDGET) return pos(); + if (collidingItems.at(i)->type() == AVWidget) return pos(); } } @@ -361,7 +361,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant collidingItems = scene()->items(shape, Qt::IntersectsItemShape); collidingItems.removeAll(this); for (int i = 0; i < children.count(); ++i) { - if (children.at(i)->type() == GROUPWIDGET) { + if (children.at(i)->type() == GroupWidget) { QList subchildren = children.at(i)->childItems(); for (int j = 0; j < subchildren.count(); j++) { collidingItems.removeAll(subchildren.at(j)); @@ -376,7 +376,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant int offset = 0; for (int i = 0; i < collidingItems.count(); ++i) { QGraphicsItem *collision = collidingItems.at(i); - if (collision->type() == TRANSITIONWIDGET) { + if (collision->type() == TransitionWidget) { // Collision if (newPos.y() != pos().y()) { // Track change results in collision, restore original position @@ -410,7 +410,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant collidingItems.removeAll(children.at(i)); } for (int i = 0; i < collidingItems.count(); ++i) - if (collidingItems.at(i)->type() == TRANSITIONWIDGET) return pos(); + if (collidingItems.at(i)->type() == TransitionWidget) return pos(); } } return newPos; @@ -431,11 +431,11 @@ void AbstractGroupItem::dropEvent(QGraphicsSceneDragDropEvent * event) QList selection = scene()->items(dropPos); AbstractClipItem *dropChild = NULL; for (int i = 0; i < selection.count(); ++i) { - if (selection.at(i)->type() == AVWIDGET) { + if (selection.at(i)->type() == AVWidget) { dropChild = (AbstractClipItem *) selection.at(i); - break; + break; } - } + } if (view) view->slotAddGroupEffect(e, this, dropChild); } @@ -457,15 +457,15 @@ void AbstractGroupItem::mousePressEvent(QGraphicsSceneMouseEvent * event) // User want to do a rectangle selection, so ignore the event to pass it to the view event->ignore(); } 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(); + 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(); } } @@ -480,7 +480,7 @@ void AbstractGroupItem::resizeStart(int diff) int itemcount = 0; for (int i = 0; i < children.count(); ++i) { AbstractClipItem *item = static_cast (children.at(i)); - if (item && item->type() == AVWIDGET) { + if (item && item->type() == AVWidget) { items << item; if (info) m_resizeInfos << item->info(); @@ -507,7 +507,7 @@ void AbstractGroupItem::resizeEnd(int diff) int itemcount = 0; for (int i = 0; i < children.count(); ++i) { AbstractClipItem *item = static_cast (children.at(i)); - if (item && item->type() == AVWIDGET) { + if (item && item->type() == AVWidget) { items << item; if (info) m_resizeInfos << item->info(); @@ -540,7 +540,7 @@ GenTime AbstractGroupItem::duration() GenTime start = GenTime(-1.0); GenTime end = GenTime(); for (int i = 0; i < children.count(); ++i) { - if (children.at(i)->type() != GROUPWIDGET) { + if (children.at(i)->type() != GroupWidget) { AbstractClipItem *item = static_cast (children.at(i)); if (item) { if (start < GenTime() || item->startPos() < start)