forked from M-Labs/artiq
dndwidgets: improvements
This commit is contained in:
parent
19bcc2357b
commit
780e0bada8
@ -23,6 +23,7 @@ class DragDropSplitter(QtWidgets.QSplitter):
|
|||||||
pos = e.pos()
|
pos = e.pos()
|
||||||
src = e.source()
|
src = e.source()
|
||||||
src_i = self.indexOf(src)
|
src_i = self.indexOf(src)
|
||||||
|
self.setRubberBand(self.height())
|
||||||
# case 0: smaller than source widget
|
# case 0: smaller than source widget
|
||||||
if pos.y() < src.y():
|
if pos.y() < src.y():
|
||||||
for n in range(src_i):
|
for n in range(src_i):
|
||||||
@ -34,8 +35,8 @@ class DragDropSplitter(QtWidgets.QSplitter):
|
|||||||
elif pos.y() > src.y() + src.size().height():
|
elif pos.y() > src.y() + src.size().height():
|
||||||
for n in range(src_i + 1, self.count()):
|
for n in range(src_i + 1, self.count()):
|
||||||
w = self.widget(n)
|
w = self.widget(n)
|
||||||
if pos.y() < w.y() + w.size().height():
|
if pos.y() < w.y():
|
||||||
self.setRubberBand(w.y() + w.size().height())
|
self.setRubberBand(w.y())
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.setRubberBand(-1)
|
self.setRubberBand(-1)
|
||||||
@ -46,20 +47,11 @@ class DragDropSplitter(QtWidgets.QSplitter):
|
|||||||
pos = e.pos()
|
pos = e.pos()
|
||||||
src = e.source()
|
src = e.source()
|
||||||
src_i = self.indexOf(src)
|
src_i = self.indexOf(src)
|
||||||
# case 0: smaller than source widget
|
for n in range(self.count()):
|
||||||
if pos.y() < src.y():
|
w = self.widget(n)
|
||||||
for n in range(src_i):
|
if pos.y() < w.y() + w.size().height():
|
||||||
w = self.widget(n)
|
self.insertWidget(n, src)
|
||||||
if pos.y() < w.y() + w.size().height():
|
break
|
||||||
self.insertWidget(n, src)
|
|
||||||
break
|
|
||||||
# case 2: greater than source widget
|
|
||||||
elif pos.y() > src.y() + src.size().height():
|
|
||||||
for n in range(src_i + 1, self.count()):
|
|
||||||
w = self.widget(n)
|
|
||||||
if pos.y() < w.y() + w.size().height():
|
|
||||||
self.insertWidget(n, src)
|
|
||||||
break
|
|
||||||
e.accept()
|
e.accept()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user