return NULL;
}
-QPainterPath AbstractGroupItem::clipGroupShape(QPointF offset) const
+QPainterPath AbstractGroupItem::clipGroupSpacerShape(const QPointF &offset) const
+{
+ return spacerGroupShape(AVWIDGET, offset);
+}
+
+QPainterPath AbstractGroupItem::clipGroupShape(const QPointF &offset) const
{
return groupShape(AVWIDGET, offset);
}
-QPainterPath AbstractGroupItem::transitionGroupShape(QPointF offset) const
+QPainterPath AbstractGroupItem::transitionGroupShape(const 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);
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);
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
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;
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();
// 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;
}
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();
}
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++) {
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
// 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++) {
}
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();
}
}
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++) {
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
}
// 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();
}
}
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;
}
return end - start;
}
+
+#include "abstractgroupitem.moc"