eric6/Graphics/UMLGraphicsView.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8176
31965986ecd1
parent 8222
5994b80b8760
child 8400
b3eefd7e58d1
equal deleted inserted replaced
8190:fb0ef164f536 8273:698ae46f40a4
329 Public method to adjust the scene size to the diagram size. 329 Public method to adjust the scene size to the diagram size.
330 330
331 @param limit flag indicating to limit the scene to the 331 @param limit flag indicating to limit the scene to the
332 initial size (boolean) 332 initial size (boolean)
333 """ 333 """
334 super(UMLGraphicsView, self).autoAdjustSceneSize(limit=limit) 334 super().autoAdjustSceneSize(limit=limit)
335 self.__checkSizeActions() 335 self.__checkSizeActions()
336 336
337 def saveImage(self): 337 def saveImage(self):
338 """ 338 """
339 Public method to handle the save context menu entry. 339 Public method to handle the save context menu entry.
360 " Overwrite it?</p>").format(fname), 360 " Overwrite it?</p>").format(fname),
361 icon=E5MessageBox.Warning) 361 icon=E5MessageBox.Warning)
362 if not res: 362 if not res:
363 return 363 return
364 364
365 success = super(UMLGraphicsView, self).saveImage( 365 success = super().saveImage(
366 fname, QFileInfo(fname).suffix().upper()) 366 fname, QFileInfo(fname).suffix().upper())
367 if not success: 367 if not success:
368 E5MessageBox.critical( 368 E5MessageBox.critical(
369 self, 369 self,
370 self.tr("Save Diagram"), 370 self.tr("Save Diagram"),
432 if printerName: 432 if printerName:
433 printer.setPrinterName(printerName) 433 printer.setPrinterName(printerName)
434 434
435 printDialog = QPrintDialog(printer, self) 435 printDialog = QPrintDialog(printer, self)
436 if printDialog.exec(): 436 if printDialog.exec():
437 super(UMLGraphicsView, self).printDiagram( 437 super().printDiagram(
438 printer, self.diagramName) 438 printer, self.diagramName)
439 439
440 def printPreviewDiagram(self): 440 def printPreviewDiagram(self):
441 """ 441 """
442 Public slot called to show a print preview of the diagram. 442 Public slot called to show a print preview of the diagram.
472 """ 472 """
473 Private slot to generate a print preview. 473 Private slot to generate a print preview.
474 474
475 @param printer reference to the printer object (QPrinter) 475 @param printer reference to the printer object (QPrinter)
476 """ 476 """
477 super(UMLGraphicsView, self).printDiagram(printer, self.diagramName) 477 super().printDiagram(printer, self.diagramName)
478 478
479 def setDiagramName(self, name): 479 def setDiagramName(self, name):
480 """ 480 """
481 Public slot to set the diagram name. 481 Public slot to set the diagram name.
482 482
518 elif alignment == Qt.AlignmentFlag.AlignBottom: 518 elif alignment == Qt.AlignmentFlag.AlignBottom:
519 if amount is None or rect.y() + rect.height() > amount: 519 if amount is None or rect.y() + rect.height() > amount:
520 amount = rect.y() + rect.height() 520 amount = rect.y() + rect.height()
521 index = i 521 index = i
522 elif alignment == Qt.AlignmentFlag.AlignVCenter: 522 elif alignment == Qt.AlignmentFlag.AlignVCenter:
523 # __IGNORE_WARNING_Y102__
523 if amount is None or rect.height() > amount: 524 if amount is None or rect.height() > amount:
524 amount = rect.height() 525 amount = rect.height()
525 index = i 526 index = i
526 rect = items[index].sceneBoundingRect() 527 rect = items[index].sceneBoundingRect()
527 528
609 for item in items: 610 for item in items:
610 item.moveBy(dx, dy) 611 item.moveBy(dx, dy)
611 evt.accept() 612 evt.accept()
612 return 613 return
613 614
614 super(UMLGraphicsView, self).keyPressEvent(evt) 615 super().keyPressEvent(evt)
615 616
616 def wheelEvent(self, evt): 617 def wheelEvent(self, evt):
617 """ 618 """
618 Protected method to handle wheel events. 619 Protected method to handle wheel events.
619 620
626 elif delta > 0: 627 elif delta > 0:
627 self.zoomIn() 628 self.zoomIn()
628 evt.accept() 629 evt.accept()
629 return 630 return
630 631
631 super(UMLGraphicsView, self).wheelEvent(evt) 632 super().wheelEvent(evt)
632 633
633 def event(self, evt): 634 def event(self, evt):
634 """ 635 """
635 Public method handling events. 636 Public method handling events.
636 637
639 """ 640 """
640 if evt.type() == QEvent.Type.Gesture: 641 if evt.type() == QEvent.Type.Gesture:
641 self.gestureEvent(evt) 642 self.gestureEvent(evt)
642 return True 643 return True
643 644
644 return super(UMLGraphicsView, self).event(evt) 645 return super().event(evt)
645 646
646 def gestureEvent(self, evt): 647 def gestureEvent(self, evt):
647 """ 648 """
648 Protected method handling gesture events. 649 Protected method handling gesture events.
649 650
738 from .ClassItem import ClassItem 739 from .ClassItem import ClassItem
739 from .ModuleItem import ModuleItem 740 from .ModuleItem import ModuleItem
740 from .PackageItem import PackageItem 741 from .PackageItem import PackageItem
741 from .AssociationItem import AssociationItem 742 from .AssociationItem import AssociationItem
742 743
743 linenum = 0 744 for linenum, line in enumerate(data[1:], start=1):
744 for line in data[1:]:
745 linenum += 1
746 if not line.startswith(("item:", "association:")): 745 if not line.startswith(("item:", "association:")):
747 return False, linenum 746 return False, linenum
748 747
749 key, value = line.split(": ", 1) 748 key, value = line.split(": ", 1)
750 if key == "item": 749 if key == "item":

eric ide

mercurial