def doDrag(self, o, e): if self._dragType == self.DRAG_HORIZONTAL: delta = e.pos().x() - self._lastPos.x() else: delta = self._lastPos.y() - e.pos().y() self._leftover += delta self._lastPos = e.pos() count = int(self._leftover / self.dragSensitivity) if count: mul = 1.0 if e.modifiers() & self.fastModifier: mul = self.fastMultiplier elif e.modifiers() & self.slowModifier: mul = 1.0 / self.slowDivisor self.dragTick.emit(count, mul) self._leftover %= self.dragSensitivity if self.cursorLock: QCursor.setPos(self.mapToGlobal(self._dragStart)) self._lastPos = self._dragStart else: r = self._screen b = self.wrapBoundary p = o.mapToGlobal(e.pos()) # when wrapping move to the other side in by 2*boundary # so we don't loop the wrapping if p.x() > r.right() - b: p.setX(r.left() + 2 * b) if p.x() < r.left() + b: p.setX(r.right() - 2 * b) if p.y() > r.bottom() - b: p.setY(r.top() + 2 * b) if p.y() < r.top() + b: p.setY(r.bottom() - 2 * b) if p != e.globalPos(): QCursor.setPos(p) self._lastPos = self.parent().mapFromGlobal(p) self._leftover = 0