284 """ |
284 """ |
285 Protected method to handle mouse button presses. |
285 Protected method to handle mouse button presses. |
286 |
286 |
287 @param evt mouse press event (QMouseEvent) |
287 @param evt mouse press event (QMouseEvent) |
288 """ |
288 """ |
289 self.__showHelp = not self.__helpTextRect.contains(evt.position().toPoint()) |
289 self.__showHelp = not self.__helpTextRect.contains( |
|
290 evt.position().toPoint()) |
290 if evt.button() == Qt.MouseButton.LeftButton: |
291 if evt.button() == Qt.MouseButton.LeftButton: |
291 self.__mouseDown = True |
292 self.__mouseDown = True |
292 self.__dragStartPoint = evt.position().toPoint() |
293 self.__dragStartPoint = evt.position().toPoint() |
293 self.__selectionBeforeDrag = QRect(self.__selection) |
294 self.__selectionBeforeDrag = QRect(self.__selection) |
294 if not self.__selection.contains(evt.position().toPoint()): |
295 if not self.__selection.contains(evt.position().toPoint()): |
306 """ |
307 """ |
307 Protected method to handle mouse movements. |
308 Protected method to handle mouse movements. |
308 |
309 |
309 @param evt mouse move event (QMouseEvent) |
310 @param evt mouse move event (QMouseEvent) |
310 """ |
311 """ |
311 shouldShowHelp = not self.__helpTextRect.contains(evt.position().toPoint()) |
312 shouldShowHelp = not self.__helpTextRect.contains( |
|
313 evt.position().toPoint()) |
312 if shouldShowHelp != self.__showHelp: |
314 if shouldShowHelp != self.__showHelp: |
313 self.__showHelp = shouldShowHelp |
315 self.__showHelp = shouldShowHelp |
314 self.update() |
316 self.update() |
315 |
317 |
316 if self.__mouseDown: |
318 if self.__mouseDown: |
322 self.__limitPointToRect(p, r))) |
324 self.__limitPointToRect(p, r))) |
323 elif self.__mouseOverHandle is None: |
325 elif self.__mouseOverHandle is None: |
324 # moving the whole selection |
326 # moving the whole selection |
325 r = self.rect().normalized() |
327 r = self.rect().normalized() |
326 s = self.__selectionBeforeDrag.normalized() |
328 s = self.__selectionBeforeDrag.normalized() |
327 p = s.topLeft() + evt.position().toPoint() - self.__dragStartPoint |
329 p = ( |
|
330 s.topLeft() + evt.position().toPoint() - |
|
331 self.__dragStartPoint |
|
332 ) |
328 r.setBottomRight( |
333 r.setBottomRight( |
329 r.bottomRight() - QPoint(s.width(), s.height()) + |
334 r.bottomRight() - QPoint(s.width(), s.height()) + |
330 QPoint(1, 1)) |
335 QPoint(1, 1)) |
331 if not r.isNull() and r.isValid(): |
336 if not r.isNull() and r.isValid(): |
332 self.__selection.moveTo(self.__limitPointToRect(p, r)) |
337 self.__selection.moveTo(self.__limitPointToRect(p, r)) |