+ xpos = qMax(xpos, 0);
+ //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;
+ // Check if top item is a clip or a transition
+ int offset = 0;
+ int topTrack = -1;
+ QList<int> groupTracks;
+ QList<QGraphicsItem *> 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 <AbstractClipItem*> (children.at(i))->track();
+ if (!groupTracks.contains(currentTrack)) groupTracks.append(currentTrack);
+ }
+ else if (children.at(i)->type() == GroupWidget) {
+ currentTrack = static_cast <AbstractGroupItem*> (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) {
+ if (topTrack == -1 || currentTrack < topTrack) {
+ offset = (int)(trackHeight / 3 * 2 - 1);
+ topTrack = currentTrack;
+ }
+ } else if (children.at(i)->type() == GroupWidget) {
+ QList<QGraphicsItem *> 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 <AbstractClipItem*> (subchildren.at(j))->track();
+ if (!groupTracks.contains(subTrack)) groupTracks.append(subTrack);
+ clipGroup = true;
+ }
+ }
+ if (clipGroup) {
+ if (topTrack == -1 || currentTrack <= topTrack) {
+ offset = 0;
+ topTrack = currentTrack;
+ }
+ } else {
+ if (topTrack == -1 || currentTrack < topTrack) {
+ offset = (int)(trackHeight / 3 * 2 - 1);
+ topTrack = currentTrack;
+ }
+ }
+ }
+ }
+ // 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;
+ 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();
+ }
+ }
+ }
+ newPos.setY((int)((proposedTrack) * trackHeight) + offset);
+ //if (newPos == start) return start;