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

Mon, 22 Apr 2024 18:23:20 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 22 Apr 2024 18:23:20 +0200
branch
eric7
changeset 10690
fab36645aa7d
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
permissions
-rw-r--r--

Changed the source code and the source code documentation to improve the indication of unused method/function arguments.

# -*- coding: utf-8 -*-

# Copyright (c) 2011 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to get the data to rename a bookmark.
"""

from PyQt6.QtCore import pyqtSlot
from PyQt6.QtWidgets import QDialog, QDialogButtonBox

from .Ui_HgBookmarkRenameDialog import Ui_HgBookmarkRenameDialog


class HgBookmarkRenameDialog(QDialog, Ui_HgBookmarkRenameDialog):
    """
    Class implementing a dialog to get the data to rename a bookmark.
    """

    def __init__(self, bookmarksList, parent=None):
        """
        Constructor

        @param bookmarksList list of bookmarks
        @type list of str
        @param parent reference to the parent widget
        @type QWidget
        """
        super().__init__(parent)
        self.setupUi(self)

        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)

        self.bookmarkCombo.addItems(sorted(bookmarksList))

        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())

    def __updateUI(self):
        """
        Private slot to update the UI.
        """
        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
            self.nameEdit.text() != "" and self.bookmarkCombo.currentText() != ""
        )

    @pyqtSlot(str)
    def on_nameEdit_textChanged(self, _txt):
        """
        Private slot to handle changes of the bookmark name.

        @param _txt text of the edit (unused)
        @type str
        """
        self.__updateUI()

    @pyqtSlot(str)
    def on_bookmarkCombo_editTextChanged(self, _txt):
        """
        Private slot to handle changes of the selected bookmark.

        @param _txt name of the selected bookmark (unused)
        @type str
        """
        self.__updateUI()

    def getData(self):
        """
        Public method to retrieve the entered data.

        @return tuple naming the old and new bookmark names
        @rtype tuple of (str, str)
        """
        return (
            self.bookmarkCombo.currentText().replace(" ", "_"),
            self.nameEdit.text().replace(" ", "_"),
        )

eric ide

mercurial