src/eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py

branch
eric7
changeset 10490
527d47826e97
parent 10475
ee41fab001f2
child 11090
f5f5f5803935
diff -r 1800956305ca -r 527d47826e97 src/eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py
--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py	Sun Jan 07 19:54:03 2024 +0100
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py	Mon Jan 08 11:14:48 2024 +0100
@@ -7,27 +7,34 @@
 Module implementing the bookmark dialog.
 """
 
+import enum
+
 from PyQt6.QtCore import pyqtSlot
 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
 
 from .Ui_HgBookmarkDialog import Ui_HgBookmarkDialog
 
 
+class HgBookmarkAction(enum.Enum):
+    """
+    Class defining the supported bookmark actions.
+    """
+
+    DEFINE = 0
+    MOVE = 1
+
+
 class HgBookmarkDialog(QDialog, Ui_HgBookmarkDialog):
     """
     Class mplementing the bookmark dialog.
     """
 
-    # TODO: change this to an enum
-    DEFINE_MODE = 0
-    MOVE_MODE = 1
-
-    def __init__(self, mode, tagsList, branchesList, bookmarksList, parent=None):
+    def __init__(self, action, tagsList, branchesList, bookmarksList, parent=None):
         """
         Constructor
 
-        @param mode of the dialog
-        @type int
+        @param action bookmark action to be performed
+        @type HgBookmarkAction
         @param tagsList list of tags
         @type list of str
         @param branchesList list of branches
@@ -42,8 +49,8 @@
 
         self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
 
-        self.__mode = mode
-        if mode == self.MOVE_MODE:
+        self.__action = action
+        if action == HgBookmarkAction.MOVE:
             self.nameEdit.hide()
             self.nameCombo.addItems([""] + sorted(bookmarksList))
             self.setWindowTitle(self.tr("Move Bookmark"))
@@ -85,7 +92,7 @@
         """
         enabled = (
             bool(self.nameCombo.currentText())
-            if self.__mode == self.MOVE_MODE
+            if self.__action == HgBookmarkAction.MOVE
             else bool(self.nameEdit.text())
         )
 
@@ -106,7 +113,7 @@
         """
         Private slot to update the bookmarks combo.
         """
-        if self.__mode == self.MOVE_MODE:
+        if self.__action == HgBookmarkAction.MOVE:
             bookmark = self.nameCombo.currentText()
             selectedBookmark = self.bookmarkCombo.currentText()
             self.bookmarkCombo.clearEditText()
@@ -144,7 +151,7 @@
 
         name = (
             self.nameCombo.currentText().replace(" ", "_")
-            if self.__mode == self.MOVE_MODE
+            if self.__action == HgBookmarkAction.MOVE
             else self.nameEdit.text().replace(" ", "_")
         )
 

eric ide

mercurial