Просмотр исходного кода

Qt5->Qt6: Rectify constant locations: UserRole, CppOwnership

part of CURA-8591
Remco Burema 3 лет назад
Родитель
Сommit
32b52c6166

+ 1 - 1
cura/Machines/MachineNode.py

@@ -129,7 +129,7 @@ class MachineNode(ContainerNode):
             if name not in groups_by_name:
             if name not in groups_by_name:
                 # CURA-6599
                 # CURA-6599
                 # For some reason, QML will get null or fail to convert type for MachineManager.activeQualityChangesGroup() to
                 # For some reason, QML will get null or fail to convert type for MachineManager.activeQualityChangesGroup() to
-                # a QObject. Setting the object ownership to QQmlEngine.CppOwnership doesn't work, but setting the object
+                # a QObject. Setting the object ownership to QQmlEngine.ObjectOwnership.CppOwnership doesn't work, but setting the object
                 # parent to application seems to work.
                 # parent to application seems to work.
                 from cura.CuraApplication import CuraApplication
                 from cura.CuraApplication import CuraApplication
                 groups_by_name[name] = QualityChangesGroup(name, quality_type = quality_changes["quality_type"],
                 groups_by_name[name] = QualityChangesGroup(name, quality_type = quality_changes["quality_type"],

+ 16 - 16
cura/Machines/Models/BaseMaterialsModel.py

@@ -61,22 +61,22 @@ class BaseMaterialsModel(ListModel):
         ContainerTree.getInstance().materialsChanged.connect(self._materialsListChanged)
         ContainerTree.getInstance().materialsChanged.connect(self._materialsListChanged)
         self._application.getMaterialManagementModel().favoritesChanged.connect(self._onChanged)
         self._application.getMaterialManagementModel().favoritesChanged.connect(self._onChanged)
 
 
-        self.addRoleName(Qt.UserRole + 1, "root_material_id")
-        self.addRoleName(Qt.UserRole + 2, "id")
-        self.addRoleName(Qt.UserRole + 3, "GUID")
-        self.addRoleName(Qt.UserRole + 4, "name")
-        self.addRoleName(Qt.UserRole + 5, "brand")
-        self.addRoleName(Qt.UserRole + 6, "description")
-        self.addRoleName(Qt.UserRole + 7, "material")
-        self.addRoleName(Qt.UserRole + 8, "color_name")
-        self.addRoleName(Qt.UserRole + 9, "color_code")
-        self.addRoleName(Qt.UserRole + 10, "density")
-        self.addRoleName(Qt.UserRole + 11, "diameter")
-        self.addRoleName(Qt.UserRole + 12, "approximate_diameter")
-        self.addRoleName(Qt.UserRole + 13, "adhesion_info")
-        self.addRoleName(Qt.UserRole + 14, "is_read_only")
-        self.addRoleName(Qt.UserRole + 15, "container_node")
-        self.addRoleName(Qt.UserRole + 16, "is_favorite")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 1, "root_material_id")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 2, "id")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 3, "GUID")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 4, "name")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 5, "brand")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 6, "description")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 7, "material")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 8, "color_name")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 9, "color_code")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 10, "density")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 11, "diameter")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 12, "approximate_diameter")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 13, "adhesion_info")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 14, "is_read_only")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 15, "container_node")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 16, "is_favorite")
 
 
     def _onChanged(self) -> None:
     def _onChanged(self) -> None:
         self._update_timer.start()
         self._update_timer.start()

+ 2 - 2
cura/Machines/Models/BuildPlateModel.py

@@ -7,8 +7,8 @@ from UM.Qt.ListModel import ListModel
 
 
 
 
 class BuildPlateModel(ListModel):
 class BuildPlateModel(ListModel):
-    NameRole = Qt.UserRole + 1
-    ContainerNodeRole = Qt.UserRole + 2
+    NameRole = Qt.ItemDataRole.UserRole + 1
+    ContainerNodeRole = Qt.ItemDataRole.UserRole + 2
 
 
     def __init__(self, parent = None):
     def __init__(self, parent = None):
         super().__init__(parent)
         super().__init__(parent)

+ 4 - 4
cura/Machines/Models/DiscoveredCloudPrintersModel.py

@@ -12,10 +12,10 @@ class DiscoveredCloudPrintersModel(ListModel):
     """Model used to inform the application about newly added cloud printers, which are discovered from the user's
     """Model used to inform the application about newly added cloud printers, which are discovered from the user's
      account """
      account """
 
 
-    DeviceKeyRole = Qt.UserRole + 1
-    DeviceNameRole = Qt.UserRole + 2
-    DeviceTypeRole = Qt.UserRole + 3
-    DeviceFirmwareVersionRole = Qt.UserRole + 4
+    DeviceKeyRole = Qt.ItemDataRole.UserRole + 1
+    DeviceNameRole = Qt.ItemDataRole.UserRole + 2
+    DeviceTypeRole = Qt.ItemDataRole.UserRole + 3
+    DeviceFirmwareVersionRole = Qt.ItemDataRole.UserRole + 4
 
 
     cloudPrintersDetectedChanged = pyqtSignal(bool)
     cloudPrintersDetectedChanged = pyqtSignal(bool)
 
 

+ 13 - 13
cura/Machines/Models/ExtrudersModel.py

@@ -23,43 +23,43 @@ class ExtrudersModel(ListModel):
     """
     """
 
 
     # The ID of the container stack for the extruder.
     # The ID of the container stack for the extruder.
-    IdRole = Qt.UserRole + 1
+    IdRole = Qt.ItemDataRole.UserRole + 1
 
 
-    NameRole = Qt.UserRole + 2
+    NameRole = Qt.ItemDataRole.UserRole + 2
     """Human-readable name of the extruder."""
     """Human-readable name of the extruder."""
 
 
-    ColorRole = Qt.UserRole + 3
+    ColorRole = Qt.ItemDataRole.UserRole + 3
     """Colour of the material loaded in the extruder."""
     """Colour of the material loaded in the extruder."""
 
 
-    IndexRole = Qt.UserRole + 4
+    IndexRole = Qt.ItemDataRole.UserRole + 4
     """Index of the extruder, which is also the value of the setting itself.
     """Index of the extruder, which is also the value of the setting itself.
 
 
     An index of 0 indicates the first extruder, an index of 1 the second one, and so on. This is the value that will 
     An index of 0 indicates the first extruder, an index of 1 the second one, and so on. This is the value that will 
     be saved in instance containers. """
     be saved in instance containers. """
 
 
     # The ID of the definition of the extruder.
     # The ID of the definition of the extruder.
-    DefinitionRole = Qt.UserRole + 5
+    DefinitionRole = Qt.ItemDataRole.UserRole + 5
 
 
     # The material of the extruder.
     # The material of the extruder.
-    MaterialRole = Qt.UserRole + 6
+    MaterialRole = Qt.ItemDataRole.UserRole + 6
 
 
     # The variant of the extruder.
     # The variant of the extruder.
-    VariantRole = Qt.UserRole + 7
-    StackRole = Qt.UserRole + 8
+    VariantRole = Qt.ItemDataRole.UserRole + 7
+    StackRole = Qt.ItemDataRole.UserRole + 8
 
 
-    MaterialBrandRole = Qt.UserRole + 9
-    ColorNameRole = Qt.UserRole + 10
+    MaterialBrandRole = Qt.ItemDataRole.UserRole + 9
+    ColorNameRole = Qt.ItemDataRole.UserRole + 10
 
 
-    EnabledRole = Qt.UserRole + 11
+    EnabledRole = Qt.ItemDataRole.UserRole + 11
     """Is the extruder enabled?"""
     """Is the extruder enabled?"""
 
 
-    MaterialTypeRole = Qt.UserRole + 12
+    MaterialTypeRole = Qt.ItemDataRole.UserRole + 12
     """The type of the material (e.g. PLA, ABS, PETG, etc.)."""
     """The type of the material (e.g. PLA, ABS, PETG, etc.)."""
 
 
     defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"]
     defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"]
     """List of colours to display if there is no material or the material has no known colour. """
     """List of colours to display if there is no material or the material has no known colour. """
 
 
-    MaterialNameRole = Qt.UserRole + 13
+    MaterialNameRole = Qt.ItemDataRole.UserRole + 13
 
 
     def __init__(self, parent = None):
     def __init__(self, parent = None):
         """Initialises the extruders model, defining the roles and listening for changes in the data.
         """Initialises the extruders model, defining the roles and listening for changes in the data.

+ 3 - 3
cura/Machines/Models/FirstStartMachineActionsModel.py

@@ -19,9 +19,9 @@ class FirstStartMachineActionsModel(ListModel):
         - action  : the MachineAction object itself
         - action  : the MachineAction object itself
     """
     """
 
 
-    TitleRole = Qt.UserRole + 1
-    ContentRole = Qt.UserRole + 2
-    ActionRole = Qt.UserRole + 3
+    TitleRole = Qt.ItemDataRole.UserRole + 1
+    ContentRole = Qt.ItemDataRole.UserRole + 2
+    ActionRole = Qt.ItemDataRole.UserRole + 3
 
 
     def __init__(self, application: "CuraApplication", parent: Optional[QObject] = None) -> None:
     def __init__(self, application: "CuraApplication", parent: Optional[QObject] = None) -> None:
         super().__init__(parent)
         super().__init__(parent)

+ 8 - 8
cura/Machines/Models/GlobalStacksModel.py

@@ -15,14 +15,14 @@ from cura.UltimakerCloud.UltimakerCloudConstants import META_CAPABILITIES  # To
 
 
 
 
 class GlobalStacksModel(ListModel):
 class GlobalStacksModel(ListModel):
-    NameRole = Qt.UserRole + 1
-    IdRole = Qt.UserRole + 2
-    HasRemoteConnectionRole = Qt.UserRole + 3
-    ConnectionTypeRole = Qt.UserRole + 4
-    MetaDataRole = Qt.UserRole + 5
-    DiscoverySourceRole = Qt.UserRole + 6  # For separating local and remote printers in the machine management page
-    RemovalWarningRole = Qt.UserRole + 7
-    IsOnlineRole = Qt.UserRole + 8
+    NameRole = Qt.ItemDataRole.UserRole + 1
+    IdRole = Qt.ItemDataRole.UserRole + 2
+    HasRemoteConnectionRole = Qt.ItemDataRole.UserRole + 3
+    ConnectionTypeRole = Qt.ItemDataRole.UserRole + 4
+    MetaDataRole = Qt.ItemDataRole.UserRole + 5
+    DiscoverySourceRole = Qt.ItemDataRole.UserRole + 6  # For separating local and remote printers in the machine management page
+    RemovalWarningRole = Qt.ItemDataRole.UserRole + 7
+    IsOnlineRole = Qt.ItemDataRole.UserRole + 8
 
 
     def __init__(self, parent = None) -> None:
     def __init__(self, parent = None) -> None:
         super().__init__(parent)
         super().__init__(parent)

+ 5 - 5
cura/Machines/Models/IntentCategoryModel.py

@@ -21,11 +21,11 @@ catalog = i18nCatalog("cura")
 class IntentCategoryModel(ListModel):
 class IntentCategoryModel(ListModel):
     """Lists the intent categories that are available for the current printer configuration. """
     """Lists the intent categories that are available for the current printer configuration. """
 
 
-    NameRole = Qt.UserRole + 1
-    IntentCategoryRole = Qt.UserRole + 2
-    WeightRole = Qt.UserRole + 3
-    QualitiesRole = Qt.UserRole + 4
-    DescriptionRole = Qt.UserRole + 5
+    NameRole = Qt.ItemDataRole.UserRole + 1
+    IntentCategoryRole = Qt.ItemDataRole.UserRole + 2
+    WeightRole = Qt.ItemDataRole.UserRole + 3
+    QualitiesRole = Qt.ItemDataRole.UserRole + 4
+    DescriptionRole = Qt.ItemDataRole.UserRole + 5
 
 
     modelUpdated = pyqtSignal()
     modelUpdated = pyqtSignal()
 
 

+ 5 - 5
cura/Machines/Models/IntentModel.py

@@ -15,11 +15,11 @@ from cura.Machines.QualityGroup import QualityGroup
 
 
 
 
 class IntentModel(ListModel):
 class IntentModel(ListModel):
-    NameRole = Qt.UserRole + 1
-    QualityTypeRole = Qt.UserRole + 2
-    LayerHeightRole = Qt.UserRole + 3
-    AvailableRole = Qt.UserRole + 4
-    IntentRole = Qt.UserRole + 5
+    NameRole = Qt.ItemDataRole.UserRole + 1
+    QualityTypeRole = Qt.ItemDataRole.UserRole + 2
+    LayerHeightRole = Qt.ItemDataRole.UserRole + 3
+    AvailableRole = Qt.ItemDataRole.UserRole + 4
+    IntentRole = Qt.ItemDataRole.UserRole + 5
 
 
     def __init__(self, parent: Optional[QObject] = None) -> None:
     def __init__(self, parent: Optional[QObject] = None) -> None:
         super().__init__(parent)
         super().__init__(parent)

+ 5 - 5
cura/Machines/Models/MaterialBrandsModel.py

@@ -10,9 +10,9 @@ class MaterialTypesModel(ListModel):
     def __init__(self, parent = None):
     def __init__(self, parent = None):
         super().__init__(parent)
         super().__init__(parent)
 
 
-        self.addRoleName(Qt.UserRole + 1, "name")
-        self.addRoleName(Qt.UserRole + 2, "brand")
-        self.addRoleName(Qt.UserRole + 3, "colors")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 1, "name")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 2, "brand")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 3, "colors")
 
 
 class MaterialBrandsModel(BaseMaterialsModel):
 class MaterialBrandsModel(BaseMaterialsModel):
 
 
@@ -21,8 +21,8 @@ class MaterialBrandsModel(BaseMaterialsModel):
     def __init__(self, parent = None):
     def __init__(self, parent = None):
         super().__init__(parent)
         super().__init__(parent)
 
 
-        self.addRoleName(Qt.UserRole + 1, "name")
-        self.addRoleName(Qt.UserRole + 2, "material_types")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 1, "name")
+        self.addRoleName(Qt.ItemDataRole.UserRole + 2, "material_types")
 
 
         self._update()
         self._update()
 
 

Некоторые файлы не были показаны из-за большого количества измененных файлов