Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLMC
Commits
f5a42a36
Commit
f5a42a36
authored
Aug 20, 2009
by
Ludovic Fauvet
Browse files
Improve the horizontal placement of the contiguous items
parent
654e0288
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/gui/TracksView.cpp
View file @
f5a42a36
...
...
@@ -247,18 +247,23 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, qint
// Check for horizontal collisions
qint64
mappedXPos
=
qMax
(
time
,
(
qint64
)
0
);
item
->
setPos
(
mappedXPos
,
0
);
QList
<
QGraphicsItem
*>
colliding
=
item
->
collidingItems
(
Qt
::
IntersectsItemShape
);
for
(
int
i
=
0
;
i
<
colliding
.
size
();
++
i
)
while
(
item
->
pos
().
x
()
!=
oldPos
.
x
()
)
{
AbstractGraphicsMediaItem
*
currentItem
=
dynamic_cast
<
AbstractGraphicsMediaItem
*>
(
colliding
.
at
(
i
)
);
if
(
currentItem
)
bool
emptyPlace
=
true
;
QList
<
QGraphicsItem
*>
colliding
=
item
->
collidingItems
(
Qt
::
IntersectsItemShape
);
for
(
int
i
=
0
;
i
<
colliding
.
size
();
++
i
)
{
// Collision with an item of the same type
// Restoring original position (horizontal)
if
(
oldPos
.
isNull
()
==
false
)
item
->
setPos
(
oldPos
);
break
;
AbstractGraphicsMediaItem
*
currentItem
=
dynamic_cast
<
AbstractGraphicsMediaItem
*>
(
colliding
.
at
(
i
)
);
if
(
currentItem
)
emptyPlace
=
false
;
}
if
(
emptyPlace
)
break
;
if
(
item
->
pos
().
x
()
>
oldPos
.
x
()
)
item
->
setPos
(
item
->
pos
().
x
()
-
1
,
0
);
else
item
->
setPos
(
item
->
pos
().
x
()
+
1
,
0
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment